|
@@ -15,19 +15,15 @@
|
|
|
*/
|
|
|
package org.springblade.develop.support;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.annotation.DbType;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.generator.AutoGenerator;
|
|
|
-import com.baomidou.mybatisplus.generator.InjectionConfig;
|
|
|
-import com.baomidou.mybatisplus.generator.config.*;
|
|
|
-import com.baomidou.mybatisplus.generator.config.converts.MySqlTypeConvert;
|
|
|
-import com.baomidou.mybatisplus.generator.config.converts.OracleTypeConvert;
|
|
|
-import com.baomidou.mybatisplus.generator.config.converts.PostgreSqlTypeConvert;
|
|
|
-import com.baomidou.mybatisplus.generator.config.converts.SqlServerTypeConvert;
|
|
|
+import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
|
|
+import com.baomidou.mybatisplus.generator.config.OutputFile;
|
|
|
+import com.baomidou.mybatisplus.generator.config.TemplateType;
|
|
|
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
|
|
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
|
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
|
|
+import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
@@ -39,7 +35,9 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
-import java.util.*;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Properties;
|
|
|
|
|
|
/**
|
|
|
* 代码生成器配置类
|
|
@@ -52,7 +50,7 @@ public class BladeCodeGenerator {
|
|
|
/**
|
|
|
* 代码所在系统
|
|
|
*/
|
|
|
- private String systemName = DevelopConstant.SWORD_NAME;
|
|
|
+ private String systemName = DevelopConstant.SABER_NAME;
|
|
|
/**
|
|
|
* 代码模块名称
|
|
|
*/
|
|
@@ -88,11 +86,11 @@ public class BladeCodeGenerator {
|
|
|
/**
|
|
|
* 是否包含基础业务字段
|
|
|
*/
|
|
|
- private Boolean hasSuperEntity = Boolean.FALSE;
|
|
|
+ private Boolean hasSuperEntity = Boolean.TRUE;
|
|
|
/**
|
|
|
* 是否包含包装器
|
|
|
*/
|
|
|
- private Boolean hasWrapper = Boolean.FALSE;
|
|
|
+ private Boolean hasWrapper = Boolean.TRUE;
|
|
|
/**
|
|
|
* 基础业务字段
|
|
|
*/
|
|
@@ -101,10 +99,6 @@ public class BladeCodeGenerator {
|
|
|
* 租户字段
|
|
|
*/
|
|
|
private String tenantColumn = "tenant_id";
|
|
|
- /**
|
|
|
- * 是否启用swagger
|
|
|
- */
|
|
|
- private Boolean isSwagger2 = Boolean.TRUE;
|
|
|
/**
|
|
|
* 数据库驱动名
|
|
|
*/
|
|
@@ -122,200 +116,138 @@ public class BladeCodeGenerator {
|
|
|
*/
|
|
|
private String password;
|
|
|
|
|
|
+ /**
|
|
|
+ * 代码生成执行
|
|
|
+ */
|
|
|
public void run() {
|
|
|
Properties props = getProperties();
|
|
|
- AutoGenerator mpg = new AutoGenerator();
|
|
|
- GlobalConfig gc = new GlobalConfig();
|
|
|
- String outputDir = getOutputDir();
|
|
|
- String author = props.getProperty("author");
|
|
|
- gc.setOutputDir(outputDir);
|
|
|
- gc.setAuthor(author);
|
|
|
- gc.setFileOverride(true);
|
|
|
- gc.setOpen(false);
|
|
|
- gc.setActiveRecord(false);
|
|
|
- gc.setEnableCache(false);
|
|
|
- gc.setBaseResultMap(true);
|
|
|
- gc.setBaseColumnList(true);
|
|
|
- gc.setMapperName("%sMapper");
|
|
|
- gc.setXmlName("%sMapper");
|
|
|
- gc.setServiceName("I%sService");
|
|
|
- gc.setServiceImplName("%sServiceImpl");
|
|
|
- gc.setControllerName("%sController");
|
|
|
- gc.setSwagger2(isSwagger2);
|
|
|
- mpg.setGlobalConfig(gc);
|
|
|
- DataSourceConfig dsc = new DataSourceConfig();
|
|
|
- String driverName = Func.toStr(this.driverName, props.getProperty("spring.datasource.driver-class-name"));
|
|
|
- if (StringUtil.containsAny(driverName, DbType.MYSQL.getDb())) {
|
|
|
- dsc.setDbType(DbType.MYSQL);
|
|
|
- dsc.setTypeConvert(new MySqlTypeConvert());
|
|
|
- } else if (StringUtil.containsAny(driverName, DbType.POSTGRE_SQL.getDb())) {
|
|
|
- dsc.setDbType(DbType.POSTGRE_SQL);
|
|
|
- dsc.setTypeConvert(new PostgreSqlTypeConvert());
|
|
|
- } else if (StringUtil.containsAny(driverName, DbType.SQL_SERVER.getDb())) {
|
|
|
- dsc.setDbType(DbType.SQL_SERVER);
|
|
|
- dsc.setTypeConvert(new SqlServerTypeConvert());
|
|
|
- } else {
|
|
|
- dsc.setDbType(DbType.ORACLE);
|
|
|
- dsc.setTypeConvert(new OracleTypeConvert());
|
|
|
- }
|
|
|
- dsc.setDriverName(driverName);
|
|
|
- dsc.setUrl(Func.toStr(this.url, props.getProperty("spring.datasource.url")));
|
|
|
- dsc.setUsername(Func.toStr(this.username, props.getProperty("spring.datasource.username")));
|
|
|
- dsc.setPassword(Func.toStr(this.password, props.getProperty("spring.datasource.password")));
|
|
|
- mpg.setDataSource(dsc);
|
|
|
- // 策略配置
|
|
|
- StrategyConfig strategy = new StrategyConfig();
|
|
|
- // strategy.setCapitalMode(true);// 全局大写命名
|
|
|
- // strategy.setDbColumnUnderline(true);//全局下划线命名
|
|
|
- strategy.setNaming(NamingStrategy.underline_to_camel);
|
|
|
- strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
|
|
- strategy.setTablePrefix(tablePrefix);
|
|
|
- if (includeTables.length > 0) {
|
|
|
- strategy.setInclude(includeTables);
|
|
|
- }
|
|
|
- if (excludeTables.length > 0) {
|
|
|
- strategy.setExclude(excludeTables);
|
|
|
- }
|
|
|
- if (hasSuperEntity) {
|
|
|
- strategy.setSuperEntityClass("org.springblade.core.mp.base.BaseEntity");
|
|
|
- strategy.setSuperEntityColumns(superEntityColumns);
|
|
|
- strategy.setSuperServiceClass("org.springblade.core.mp.base.BaseService");
|
|
|
- strategy.setSuperServiceImplClass("org.springblade.core.mp.base.BaseServiceImpl");
|
|
|
- } else {
|
|
|
- strategy.setSuperServiceClass("com.baomidou.mybatisplus.extension.service.IService");
|
|
|
- strategy.setSuperServiceImplClass("com.baomidou.mybatisplus.extension.service.impl.ServiceImpl");
|
|
|
- }
|
|
|
- // 自定义 controller 父类
|
|
|
- strategy.setSuperControllerClass("org.springblade.core.boot.ctrl.BladeController");
|
|
|
- strategy.setEntityBuilderModel(false);
|
|
|
- strategy.setEntityLombokModel(true);
|
|
|
- strategy.setControllerMappingHyphenStyle(true);
|
|
|
- mpg.setStrategy(strategy);
|
|
|
- // 包配置
|
|
|
- PackageConfig pc = new PackageConfig();
|
|
|
- // 控制台扫描
|
|
|
- pc.setModuleName(null);
|
|
|
- pc.setParent(packageName);
|
|
|
- pc.setController("controller");
|
|
|
- pc.setEntity("entity");
|
|
|
- pc.setXml("mapper");
|
|
|
- mpg.setPackageInfo(pc);
|
|
|
- mpg.setCfg(getInjectionConfig());
|
|
|
- mpg.execute();
|
|
|
- }
|
|
|
-
|
|
|
- private InjectionConfig getInjectionConfig() {
|
|
|
+ String url = Func.toStr(this.url, props.getProperty("spring.datasource.url"));
|
|
|
+ String username = Func.toStr(this.username, props.getProperty("spring.datasource.username"));
|
|
|
+ String password = Func.toStr(this.password, props.getProperty("spring.datasource.password"));
|
|
|
String servicePackage = serviceName.split("-").length > 1 ? serviceName.split("-")[1] : serviceName;
|
|
|
- // 自定义配置
|
|
|
- Map<String, Object> map = new HashMap<>(16);
|
|
|
- InjectionConfig cfg = new InjectionConfig() {
|
|
|
- @Override
|
|
|
- public void initMap() {
|
|
|
- map.put("codeName", codeName);
|
|
|
- map.put("serviceName", serviceName);
|
|
|
- map.put("servicePackage", servicePackage);
|
|
|
- map.put("servicePackageLowerCase", servicePackage.toLowerCase());
|
|
|
- map.put("tenantColumn", tenantColumn);
|
|
|
- map.put("hasWrapper", hasWrapper);
|
|
|
- this.setMap(map);
|
|
|
- }
|
|
|
- };
|
|
|
- List<FileOutConfig> focList = new ArrayList<>();
|
|
|
- focList.add(new FileOutConfig("/templates/sql/menu.sql.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- map.put("entityKey", (tableInfo.getEntityName().toLowerCase()));
|
|
|
- map.put("menuId", IdWorker.getId());
|
|
|
- map.put("addMenuId", IdWorker.getId());
|
|
|
- map.put("editMenuId", IdWorker.getId());
|
|
|
- map.put("removeMenuId", IdWorker.getId());
|
|
|
- map.put("viewMenuId", IdWorker.getId());
|
|
|
- return getOutputDir() + "/" + "/sql/" + tableInfo.getEntityName().toLowerCase() + ".menu.mysql";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/entityVO.java.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputDir() + "/" + packageName.replace(".", "/") + "/" + "vo" + "/" + tableInfo.getEntityName() + "VO" + StringPool.DOT_JAVA;
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/entityDTO.java.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputDir() + "/" + packageName.replace(".", "/") + "/" + "dto" + "/" + tableInfo.getEntityName() + "DTO" + StringPool.DOT_JAVA;
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ Map<String, Object> customMap = new HashMap<>(11);
|
|
|
+ customMap.put("codeName", codeName);
|
|
|
+ customMap.put("serviceName", serviceName);
|
|
|
+ customMap.put("servicePackage", servicePackage);
|
|
|
+ customMap.put("servicePackageLowerCase", servicePackage.toLowerCase());
|
|
|
+ customMap.put("tenantColumn", tenantColumn);
|
|
|
+ customMap.put("hasWrapper", hasWrapper);
|
|
|
+ Map<String, String> customFile = new HashMap<>(15);
|
|
|
+ customFile.put("menu.sql", "/templates/sql/menu.sql.vm");
|
|
|
+ customFile.put("entityVO.java", "/templates/entityVO.java.vm");
|
|
|
+ customFile.put("entityDTO.java", "/templates/entityDTO.java.vm");
|
|
|
if (hasWrapper) {
|
|
|
- focList.add(new FileOutConfig("/templates/wrapper.java.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputDir() + "/" + packageName.replace(".", "/") + "/" + "wrapper" + "/" + tableInfo.getEntityName() + "Wrapper" + StringPool.DOT_JAVA;
|
|
|
- }
|
|
|
- });
|
|
|
+ customFile.put("wrapper.java", "/templates/wrapper.java.vm");
|
|
|
}
|
|
|
if (Func.isNotBlank(packageWebDir)) {
|
|
|
if (Func.equals(systemName, DevelopConstant.SWORD_NAME)) {
|
|
|
- focList.add(new FileOutConfig("/templates/sword/action.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/actions" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/sword/model.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/models" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/sword/service.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/services" + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/sword/list.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + ".js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/sword/add.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Add.js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/sword/edit.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "Edit.js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/sword/view.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/pages" + "/" + StringUtil.upperFirst(servicePackage) + "/" + tableInfo.getEntityName() + "/" + tableInfo.getEntityName() + "View.js";
|
|
|
- }
|
|
|
- });
|
|
|
+ customFile.put("action.js", "/templates/sword/action.js.vm");
|
|
|
+ customFile.put("model.js", "/templates/sword/model.js.vm");
|
|
|
+ customFile.put("service.js", "/templates/sword/service.js.vm");
|
|
|
+ customFile.put("list.js", "/templates/sword/list.js.vm");
|
|
|
+ customFile.put("add.js", "/templates/sword/add.js.vm");
|
|
|
+ customFile.put("edit.js", "/templates/sword/edit.js.vm");
|
|
|
+ customFile.put("view.js", "/templates/sword/view.js.vm");
|
|
|
} else if (Func.equals(systemName, DevelopConstant.SABER_NAME)) {
|
|
|
- focList.add(new FileOutConfig("/templates/saber/api.js.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/api" + "/" + servicePackage.toLowerCase() + "/" + tableInfo.getEntityName().toLowerCase() + ".js";
|
|
|
- }
|
|
|
- });
|
|
|
- focList.add(new FileOutConfig("/templates/saber/crud.vue.vm") {
|
|
|
- @Override
|
|
|
- public String outputFile(TableInfo tableInfo) {
|
|
|
- return getOutputWebDir() + "/views" + "/" + servicePackage.toLowerCase() + "/" + tableInfo.getEntityName().toLowerCase() + ".vue";
|
|
|
- }
|
|
|
- });
|
|
|
+ customFile.put("api.js", "/templates/saber/api.js.vm");
|
|
|
+ customFile.put("crud.vue", "/templates/saber/crud.vue.vm");
|
|
|
}
|
|
|
}
|
|
|
- cfg.setFileOutConfigList(focList);
|
|
|
- return cfg;
|
|
|
+
|
|
|
+ FastAutoGenerator.create(url, username, password)
|
|
|
+ .globalConfig(builder -> builder.author(props.getProperty("author")).dateType(DateType.TIME_PACK).enableSwagger().outputDir(getOutputDir()).disableOpenDir())
|
|
|
+ .packageConfig(builder -> builder.parent(packageName).controller("controller").entity("entity").service("service").serviceImpl("service.impl").mapper("mapper").xml("mapper"))
|
|
|
+ .strategyConfig(builder -> builder.addTablePrefix(tablePrefix).addInclude(includeTables).addExclude(excludeTables)
|
|
|
+ .entityBuilder().naming(NamingStrategy.underline_to_camel).columnNaming(NamingStrategy.underline_to_camel).enableLombok().superClass("org.springblade.core.mp.base.BaseEntity").addSuperEntityColumns(superEntityColumns)
|
|
|
+ .serviceBuilder().superServiceClass("org.springblade.core.mp.base.BaseService").superServiceImplClass("org.springblade.core.mp.base.BaseService").formatServiceFileName("I%sService").formatServiceImplFileName("%sServiceImpl")
|
|
|
+ .mapperBuilder().enableMapperAnnotation().enableBaseResultMap().enableBaseColumnList().formatMapperFileName("%sMapper").formatXmlFileName("%sMapper")
|
|
|
+ .controllerBuilder().superClass("org.springblade.core.boot.ctrl.BladeController").formatFileName("%sController").enableRestStyle().enableHyphenStyle()
|
|
|
+ )
|
|
|
+ .templateConfig(builder -> builder.disable(TemplateType.ENTITY)
|
|
|
+ .entity("/templates/entity.java.vm")
|
|
|
+ .service("/templates/service.java.vm")
|
|
|
+ .serviceImpl("/templates/serviceImpl.java.vm")
|
|
|
+ .mapper("/templates/mapper.java.vm")
|
|
|
+ .mapperXml("/templates/mapper.xml.vm")
|
|
|
+ .controller("/templates/controller.java.vm"))
|
|
|
+ .injectionConfig(builder -> builder.beforeOutputFile(
|
|
|
+ (tableInfo, objectMap) -> System.out.println("tableInfo: " + tableInfo.getEntityName() + " objectMap: " + objectMap.size())
|
|
|
+ ).customMap(customMap).customFile(customFile)
|
|
|
+ )
|
|
|
+ .templateEngine(new VelocityTemplateEngine() {
|
|
|
+ @Override
|
|
|
+ protected void outputCustomFile(Map<String, String> customFile, TableInfo tableInfo, Map<String, Object> objectMap) {
|
|
|
+ String entityName = tableInfo.getEntityName();
|
|
|
+ String entityNameLower = tableInfo.getEntityName().toLowerCase();
|
|
|
+
|
|
|
+ customFile.forEach((key, value) -> {
|
|
|
+ String outputPath = getPathInfo(OutputFile.other);
|
|
|
+ if (StringUtil.equals(key, "menu.sql")) {
|
|
|
+ objectMap.put("entityKey", entityNameLower);
|
|
|
+ objectMap.put("menuId", IdWorker.getId());
|
|
|
+ objectMap.put("addMenuId", IdWorker.getId());
|
|
|
+ objectMap.put("editMenuId", IdWorker.getId());
|
|
|
+ objectMap.put("removeMenuId", IdWorker.getId());
|
|
|
+ objectMap.put("viewMenuId", IdWorker.getId());
|
|
|
+ outputPath = getOutputDir() + StringPool.SLASH + "sql" + StringPool.SLASH + entityNameLower + ".menu.sql";
|
|
|
+ }
|
|
|
+ if (StringUtil.equals(key, "entityVO.java")) {
|
|
|
+ outputPath = getOutputDir() + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "vo" + StringPool.SLASH + entityName + "VO" + StringPool.DOT_JAVA;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "entityDTO.java")) {
|
|
|
+ outputPath = getOutputDir() + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "dto" + StringPool.SLASH + entityName + "DTO" + StringPool.DOT_JAVA;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "wrapper.java")) {
|
|
|
+ outputPath = getOutputDir() + StringPool.SLASH + packageName.replace(StringPool.DOT, StringPool.SLASH) + StringPool.SLASH + "wrapper" + StringPool.SLASH + entityName + "Wrapper" + StringPool.DOT_JAVA;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "action.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "actions" + StringPool.SLASH + entityNameLower + ".js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "model.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "models" + StringPool.SLASH + entityNameLower + ".js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "service.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "services" + StringPool.SLASH + entityNameLower + ".js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "list.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.upperFirst(servicePackage) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + ".js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "add.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.upperFirst(servicePackage) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + "Add.js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "edit.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.upperFirst(servicePackage) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + "Edit.js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "view.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "pages" + StringPool.SLASH + StringUtil.upperFirst(servicePackage) + StringPool.SLASH + entityName + StringPool.SLASH + entityName + "View.js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "api.js")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "api" + StringPool.SLASH + servicePackage.toLowerCase() + StringPool.SLASH + entityNameLower + ".js";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.equals(key, "crud.vue")) {
|
|
|
+ outputPath = getOutputWebDir() + StringPool.SLASH + "views" + StringPool.SLASH + servicePackage.toLowerCase() + StringPool.SLASH + entityNameLower + ".vue";
|
|
|
+ }
|
|
|
+ outputFile(new File(String.valueOf(outputPath)), objectMap, value);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .execute();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 获取配置文件
|
|
|
*
|
|
@@ -351,17 +283,4 @@ public class BladeCodeGenerator {
|
|
|
return (Func.isBlank(packageWebDir) ? System.getProperty("user.dir") : packageWebDir) + "/src";
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 页面生成的文件名
|
|
|
- */
|
|
|
- private String getGeneratorViewPath(String viewOutputDir, TableInfo tableInfo, String suffixPath) {
|
|
|
- String name = StringUtils.firstToLowerCase(tableInfo.getEntityName());
|
|
|
- String path = viewOutputDir + "/" + name + "/" + name + suffixPath;
|
|
|
- File viewDir = new File(path).getParentFile();
|
|
|
- if (!viewDir.exists()) {
|
|
|
- viewDir.mkdirs();
|
|
|
- }
|
|
|
- return path;
|
|
|
- }
|
|
|
-
|
|
|
}
|