From 6a0e6312c2df0077b6a514b64cfa5606e9774e0d Mon Sep 17 00:00:00 2001 From: "20932067@zju.edu.cn" Date: Tue, 9 Feb 2021 16:48:05 +0800 Subject: [PATCH] 11 --- hchyun-ui/src/views/tool/gen/editTable.vue | 6 +- hchyun-ui/src/views/tool/gen/genInfoForm.vue | 21 ++- hchyun-ui/src/views/tool/gen/index.vue | 4 +- .../src/main/resources/application.yml | 2 +- .../hchyun/common/constant/GenConstants.java | 3 + .../com/hchyun/common/utils/StringUtils.java | 15 ++ .../generator/controller/GenController.java | 15 +- .../com/hchyun/generator/entity/GenTable.java | 15 +- .../generator/service/IGenTableService.java | 4 +- .../service/impl/GenTableServiceImpl.java | 47 +++++-- .../hchyun/generator/util/VelocityUtils.java | 108 +++++++++------ .../src/main/resources/generator.yml | 4 +- .../mapper/generator/AssociateMapper.xml | 6 +- .../mapper/generator/GenTableMapper.xml | 28 +++- .../main/resources/vm/java/ass-entity.java.vm | 55 ++++++++ .../main/resources/vm/java/controller.java.vm | 8 +- .../src/main/resources/vm/java/entity.java.vm | 21 ++- .../main/resources/vm/java/sub-entity.java.vm | 1 - .../main/resources/vm/vue/index-tree.vue.vm | 7 +- .../src/main/resources/vm/vue/index.vue.vm | 129 +++++++++++++++++- .../src/main/resources/vm/xml/mapper.xml.vm | 102 ++++++++++++-- 21 files changed, 496 insertions(+), 105 deletions(-) create mode 100644 hchyun/hchyun-generator/src/main/resources/vm/java/ass-entity.java.vm diff --git a/hchyun-ui/src/views/tool/gen/editTable.vue b/hchyun-ui/src/views/tool/gen/editTable.vue index 9b4ccd7..f9624be 100644 --- a/hchyun-ui/src/views/tool/gen/editTable.vue +++ b/hchyun-ui/src/views/tool/gen/editTable.vue @@ -204,7 +204,11 @@ export default { submitForm() { const basicForm = this.$refs.basicInfo.$refs.basicInfoForm; const genForm = this.$refs.genInfo.$refs.genInfoForm; - const assColumns = this.$refs.genInfo.$refs.assCloumnTable.data; + const assCloumnTable = this.$refs.genInfo.$refs.assCloumnTable + let assColumns = null; + if (assCloumnTable!=undefined){ + assColumns = assCloumnTable.data + } Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => { const validateResult = res.every(item => !!item); if (validateResult) { diff --git a/hchyun-ui/src/views/tool/gen/genInfoForm.vue b/hchyun-ui/src/views/tool/gen/genInfoForm.vue index 52c1ebe..759324c 100644 --- a/hchyun-ui/src/views/tool/gen/genInfoForm.vue +++ b/hchyun-ui/src/views/tool/gen/genInfoForm.vue @@ -216,7 +216,7 @@

关联关系

- + 主表id @@ -233,7 +233,7 @@ - + 关联表表名 @@ -250,7 +250,7 @@ - + 关联表表名 @@ -267,6 +267,21 @@ + + + + 关联查询方式 + + + + + + + + + + +
diff --git a/hchyun-ui/src/views/tool/gen/index.vue b/hchyun-ui/src/views/tool/gen/index.vue index 9a00514..b4f051f 100644 --- a/hchyun-ui/src/views/tool/gen/index.vue +++ b/hchyun-ui/src/views/tool/gen/index.vue @@ -306,7 +306,6 @@ export default { highlightedCode(code, key) { const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm")); var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length); - console.log(language) const result = hljs.highlight(language, code || "", true); return result.value || ' '; }, @@ -325,7 +324,8 @@ export default { /** 删除按钮操作 */ handleDelete(row) { const tableIds = row.tableId || this.ids; - this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", { + const tableName = row.tableName; + this.$confirm('是否确认删除表"' + tableName + '"的数据项?', "警告", { confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" diff --git a/hchyun/hchyun-admin/src/main/resources/application.yml b/hchyun/hchyun-admin/src/main/resources/application.yml index 15ce3df..e9230ab 100644 --- a/hchyun/hchyun-admin/src/main/resources/application.yml +++ b/hchyun/hchyun-admin/src/main/resources/application.yml @@ -82,7 +82,7 @@ token: # 令牌自定义标识 header: Authorization # 令牌密钥 - secret: abcdefghijklmnopqrstuvwxyz + secret: hcy@2020 # 令牌有效期(默认30分钟) expireTime: 30 diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java index 965c5d3..ed3ff41 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/constant/GenConstants.java @@ -16,6 +16,9 @@ public class GenConstants /** 主子表(增删改查) */ public static final String TPL_SUB = "sub"; + /** 关联查询(增删改查) */ + public static final String TPL_ASS = "ass"; + /** 树编码字段 */ public static final String TREE_CODE = "treeCode"; diff --git a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java index 08ba53f..aff43d8 100644 --- a/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java +++ b/hchyun/hchyun-common/src/main/java/com/hchyun/common/utils/StringUtils.java @@ -392,8 +392,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { return sb.toString(); } + /** + * 分割sql字符串 + * @param str + * @return + */ + public static String sqlFormat(String str){ + String[] strList = str.split("_"); + String sqlStr = ""; + for (String s:strList) { + sqlStr +=s.substring(0,1); + } + return sqlStr; + } + @SuppressWarnings("unchecked") public static T cast(Object obj) { return (T) obj; } + } \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java index d64d261..7be6284 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/controller/GenController.java @@ -6,6 +6,8 @@ import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletResponse; +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.utils.ServerResult; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -128,8 +130,17 @@ public class GenController extends BaseController { @Log(title = "代码生成" , businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") public AjaxResult remove(@PathVariable Long[] tableIds) { - genTableService.deleteGenTableByIds(tableIds); - return AjaxResult.success(); + try { + ServerResult serverResult = genTableService.deleteGenTableByIds(tableIds); + if (serverResult.isStart()){ + return AjaxResult.success(); + }else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } } /** diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java index c33adb0..48a1d2d 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/entity/GenTable.java @@ -38,7 +38,7 @@ public class GenTable extends BaseEntity @NotBlank(message = "实体类名称不能为空") private String className; - /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */ + /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作 ass关联表操作) */ private String tplCategory; /** 生成包路径 */ @@ -98,12 +98,25 @@ public class GenTable extends BaseEntity /** 上级菜单名称字段 */ private String parentMenuName; + /** 关联表名 */ private String assTableName; + /** 主表字段 */ private String assTableColumn; + /** 关联表key */ private String assTableFkColumn; + /** 关联查询方式 */ + private String assQueryType; + + public String getAssQueryType() { + return assQueryType; + } + + public void setAssQueryType(String assQueryType) { + this.assQueryType = assQueryType; + } public List getAssColumns() { return assColumns; diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java index 0d6c379..4b6ce79 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/IGenTableService.java @@ -2,6 +2,8 @@ package com.hchyun.generator.service; import java.util.List; import java.util.Map; + +import com.hchyun.common.utils.ServerResult; import com.hchyun.generator.entity.GenTable; /** @@ -64,7 +66,7 @@ public interface IGenTableService * @param tableIds 需要删除的表数据ID * @return 结果 */ - public void deleteGenTableByIds(Long[] tableIds); + public ServerResult deleteGenTableByIds(Long[] tableIds); /** * 导入表结构 diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java index c320be1..7c803d9 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/service/impl/GenTableServiceImpl.java @@ -12,6 +12,7 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.utils.ServerResult; import com.hchyun.generator.dao.AssociatedDao; import com.hchyun.generator.entity.AssColumn; import com.hchyun.generator.service.IGenTableService; @@ -132,12 +133,12 @@ public class GenTableServiceImpl implements IGenTableService { if (row > 0) { genTableColumnDao.updateGenTableColumn(genTable.getColumns()); List assColumns = genTable.getAssColumns(); - if (assColumns.size() > 0){ + if (assColumns != null) { associatedDao.deleteTableColumn(genTable.getTableId()); associatedDao.insertColumns(assColumns); } } - }catch (CustomException e){ + } catch (CustomException e) { log.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); throw new CustomException(ReturnConstants.DB_EX); @@ -152,9 +153,16 @@ public class GenTableServiceImpl implements IGenTableService { */ @Override @Transactional - public void deleteGenTableByIds(Long[] tableIds) { - genTableDao.deleteGenTableByIds(tableIds); - genTableColumnDao.deleteGenTableColumnByIds(tableIds); + public ServerResult deleteGenTableByIds(Long[] tableIds) { + try { + genTableDao.deleteGenTableByIds(tableIds); + genTableColumnDao.deleteGenTableColumnByIds(tableIds); + return new ServerResult<>(true); + }catch (RuntimeException e){ + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + log.error(e.getMessage()); + return new ServerResult<>(false,ReturnConstants.DB_EX); + } } /** @@ -196,8 +204,13 @@ public class GenTableServiceImpl implements IGenTableService { Map dataMap = new LinkedHashMap<>(); // 查询表信息 GenTable table = genTableDao.selectGenTableById(tableId); - // 设置主子表信息 - setSubTable(table); + if (table.getTplCategory().equals(GenConstants.TPL_SUB)) { + // 设置主子表信息 + setSubTable(table); + } + if (table.getTplCategory().equals(GenConstants.TPL_ASS)) { + table.setAssColumns(associatedDao.selectTableColumnByTableId(tableId)); + } // 设置主键列信息 setPkColumn(table); VelocityInitializer.initVelocity(); @@ -260,10 +273,10 @@ public class GenTableServiceImpl implements IGenTableService { tpl.merge(context, sw); if (template.equals("vm/sql/table.sql.vm")) { Boolean start = insertMenuItem(sw); - if (start){ + if (start) { return false; } - }else { + } else { try { String path = getGenPath(table, template); FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); @@ -321,7 +334,7 @@ public class GenTableServiceImpl implements IGenTableService { for (String tableName : tableNames) { zip = generatorCode(tableName, zip); // generatorCode(tableName, zip); - if (zip==null){ + if (zip == null) { return null; } } @@ -330,13 +343,13 @@ public class GenTableServiceImpl implements IGenTableService { } @Transactional - boolean insertMenuItem(StringWriter stringWriter){ + boolean insertMenuItem(StringWriter stringWriter) { try { String sql = stringWriter.toString(); int start = genTableDao.insertMenu(sql); - if (start > 0){ + if (start > 0) { return false; - }else { + } else { return true; } } catch (RuntimeException e) { @@ -345,6 +358,7 @@ public class GenTableServiceImpl implements IGenTableService { return true; } } + /** * todo 查询表信息并生成代码 */ @@ -355,6 +369,9 @@ public class GenTableServiceImpl implements IGenTableService { setSubTable(table); // 设置主键列信息 setPkColumn(table); + if (table.getTplCategory().equals(GenConstants.TPL_ASS)){ + table.setAssColumns(associatedDao.selectTableColumnByTableId(table.getTableId())); + } VelocityInitializer.initVelocity(); @@ -370,7 +387,7 @@ public class GenTableServiceImpl implements IGenTableService { if (template.equals("vm/sql/table.sql.vm")) { Boolean start = insertMenuItem(sw); - if (start){ + if (start) { return null; } } @@ -410,6 +427,8 @@ public class GenTableServiceImpl implements IGenTableService { } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { throw new CustomException("子表关联的外键名不能为空"); } + } else if (GenConstants.TPL_ASS.equals(genTable.getTplCategory())) { +// todo 规则校验 } } } diff --git a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java index cb00559..8d9f830 100644 --- a/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java +++ b/hchyun/hchyun-generator/src/main/java/com/hchyun/generator/util/VelocityUtils.java @@ -47,24 +47,24 @@ public class VelocityUtils { String functionName = genTable.getFunctionName(); VelocityContext velocityContext = new VelocityContext(); - velocityContext.put("tplCategory", genTable.getTplCategory()); - velocityContext.put("tableName", genTable.getTableName()); - velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】"); - velocityContext.put("ClassName", genTable.getClassName()); - velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName())); - velocityContext.put("moduleName", genTable.getModuleName()); - velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName())); - velocityContext.put("businessName", genTable.getBusinessName()); - velocityContext.put("basePackage", getPackagePrefix(packageName)); - velocityContext.put("packageName", packageName); - velocityContext.put("author", genTable.getFunctionAuthor()); - velocityContext.put("datetime", DateUtils.getDate()); - velocityContext.put("createBy", SecurityUtils.getUserId()); - velocityContext.put("pkColumn", genTable.getPkColumn()); - velocityContext.put("importList", getImportList(genTable)); - velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName)); - velocityContext.put("columns", genTable.getColumns()); - velocityContext.put("table", genTable); + velocityContext.put("tplCategory" , genTable.getTplCategory()); + velocityContext.put("tableName" , genTable.getTableName()); + velocityContext.put("functionName" , StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】"); + velocityContext.put("ClassName" , genTable.getClassName()); + velocityContext.put("className" , StringUtils.uncapitalize(genTable.getClassName())); + velocityContext.put("moduleName" , genTable.getModuleName()); + velocityContext.put("BusinessName" , StringUtils.capitalize(genTable.getBusinessName())); + velocityContext.put("businessName" , genTable.getBusinessName()); + velocityContext.put("basePackage" , getPackagePrefix(packageName)); + velocityContext.put("packageName" , packageName); + velocityContext.put("author" , genTable.getFunctionAuthor()); + velocityContext.put("datetime" , DateUtils.getDate()); + velocityContext.put("createBy" , SecurityUtils.getUserId()); + velocityContext.put("pkColumn" , genTable.getPkColumn()); + velocityContext.put("importList" , getImportList(genTable)); + velocityContext.put("permissionPrefix" , getPermissionPrefix(moduleName, businessName)); + velocityContext.put("columns" , genTable.getColumns()); + velocityContext.put("table" , genTable); setMenuVelocityContext(velocityContext, genTable); if (GenConstants.TPL_TREE.equals(tplCategory)) { setTreeVelocityContext(velocityContext, genTable); @@ -72,14 +72,25 @@ public class VelocityUtils { if (GenConstants.TPL_SUB.equals(tplCategory)) { setSubVelocityContext(velocityContext, genTable); } + if (GenConstants.TPL_ASS.equals(tplCategory)) { + setAssVelocityContext(velocityContext, genTable); + } return velocityContext; } + public static void setAssVelocityContext(VelocityContext context, GenTable genTable) { + String assClassName = GenUtils.convertClassName(genTable.getAssTableName()); + context.put("assClassName" , assClassName); + context.put("assclassName" , StringUtils.uncapitalize(assClassName)); + context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName())); + context.put("assMapping" , StringUtils.sqlFormat(genTable.getAssTableName())); + } + public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) { String options = genTable.getOptions(); JSONObject paramsObj = JSONObject.parseObject(options); String parentMenuId = getParentMenuId(paramsObj); - context.put("parentMenuId", parentMenuId); + context.put("parentMenuId" , parentMenuId); } public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) { @@ -89,15 +100,15 @@ public class VelocityUtils { String treeParentCode = getTreeParentCode(paramsObj); String treeName = getTreeName(paramsObj); - context.put("treeCode", treeCode); - context.put("treeParentCode", treeParentCode); - context.put("treeName", treeName); - context.put("expandColumn", getExpandColumn(genTable)); + context.put("treeCode" , treeCode); + context.put("treeParentCode" , treeParentCode); + context.put("treeName" , treeName); + context.put("expandColumn" , getExpandColumn(genTable)); if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) { - context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE)); + context.put("tree_parent_code" , paramsObj.getString(GenConstants.TREE_PARENT_CODE)); } if (paramsObj.containsKey(GenConstants.TREE_NAME)) { - context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME)); + context.put("tree_name" , paramsObj.getString(GenConstants.TREE_NAME)); } } @@ -108,14 +119,16 @@ public class VelocityUtils { String subClassName = genTable.getSubTable().getClassName(); String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName); - context.put("subTable", subTable); - context.put("subTableName", subTableName); - context.put("subTableFkName", subTableFkName); - context.put("subTableFkClassName", subTableFkClassName); - context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName)); - context.put("subClassName", subClassName); - context.put("subclassName", StringUtils.uncapitalize(subClassName)); - context.put("subImportList", getImportList(genTable.getSubTable())); + context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName())); + context.put("subMapping" , StringUtils.sqlFormat(subTable.getTableName())); + context.put("subTable" , subTable); + context.put("subTableName" , subTableName); + context.put("subTableFkName" , subTableFkName); + context.put("subTableFkClassName" , subTableFkClassName); + context.put("subTableFkclassName" , StringUtils.uncapitalize(subTableFkClassName)); + context.put("subClassName" , subClassName); + context.put("subclassName" , StringUtils.uncapitalize(subClassName)); + context.put("subImportList" , getImportList(genTable.getSubTable())); } /** @@ -140,6 +153,9 @@ public class VelocityUtils { } else if (GenConstants.TPL_SUB.equals(tplCategory)) { templates.add("vm/vue/index.vue.vm"); templates.add("vm/java/sub-entity.java.vm"); + } else if (GenConstants.TPL_ASS.equals(tplCategory)) { + templates.add("vm/vue/index.vue.vm"); + templates.add("vm/java/ass-entity.java.vm"); } return templates; } @@ -159,33 +175,35 @@ public class VelocityUtils { // 业务名称 String businessName = genTable.getBusinessName(); - String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/"); + String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, "." , "/"); String mybatisPath = MYBATIS_PATH + "/" + moduleName; String vuePath = "vue"; if (template.contains("entity.java.vm")) { - fileName = StringUtils.format("{}/entity/{}.java", javaPath, className); + fileName = StringUtils.format("{}/entity/{}.java" , javaPath, className); } if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) { - fileName = StringUtils.format("{}/entity/{}.java", javaPath, genTable.getSubTable().getClassName()); + fileName = StringUtils.format("{}/entity/{}.java" , javaPath, genTable.getSubTable().getClassName()); + } else if (template.contains("ass-entity.java.vm")) { + fileName = StringUtils.format("{}/entity/{}.java" , javaPath, GenUtils.convertClassName(genTable.getAssTableName())); } else if (template.contains("dao.java.vm")) { - fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className); + fileName = StringUtils.format("{}/dao/{}Dao.java" , javaPath, className); } else if (template.contains("service.java.vm")) { - fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className); + fileName = StringUtils.format("{}/service/{}Service.java" , javaPath, className); } else if (template.contains("serviceImpl.java.vm")) { - fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className); + fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java" , javaPath, className); } else if (template.contains("controller.java.vm")) { - fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className); + fileName = StringUtils.format("{}/controller/{}Controller.java" , javaPath, className); } else if (template.contains("mapper.xml.vm")) { - fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className); + fileName = StringUtils.format("{}/{}Mapper.xml" , mybatisPath, className); } else if (template.contains("table.sql.vm")) { fileName = businessName + "Menu.sql"; } else if (template.contains("api.js.vm")) { - fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName); + fileName = StringUtils.format("{}/api/{}/{}.js" , vuePath, moduleName, businessName); } else if (template.contains("index.vue.vm")) { - fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); + fileName = StringUtils.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName); } else if (template.contains("index-tree.vue.vm")) { - fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); + fileName = StringUtils.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName); } return fileName; } @@ -234,7 +252,7 @@ public class VelocityUtils { * @return 返回权限前缀 */ public static String getPermissionPrefix(String moduleName, String businessName) { - return StringUtils.format("{}:{}", moduleName, businessName); + return StringUtils.format("{}:{}" , moduleName, businessName); } /** diff --git a/hchyun/hchyun-generator/src/main/resources/generator.yml b/hchyun/hchyun-generator/src/main/resources/generator.yml index dc0a583..7e57e2c 100644 --- a/hchyun/hchyun-generator/src/main/resources/generator.yml +++ b/hchyun/hchyun-generator/src/main/resources/generator.yml @@ -3,8 +3,8 @@ gen: # 作者 author: hchyun # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool - packageName: com.hchyun.system + packageName: com.hchyun.test # 自动去除表前缀,默认是false autoRemovePre: true # 表前缀(生成类名不会包含表前缀,多个用逗号分隔) - tablePrefix: sys_ \ No newline at end of file + tablePrefix: sys_,test_ \ No newline at end of file diff --git a/hchyun/hchyun-generator/src/main/resources/mapper/generator/AssociateMapper.xml b/hchyun/hchyun-generator/src/main/resources/mapper/generator/AssociateMapper.xml index 024030e..35bd514 100644 --- a/hchyun/hchyun-generator/src/main/resources/mapper/generator/AssociateMapper.xml +++ b/hchyun/hchyun-generator/src/main/resources/mapper/generator/AssociateMapper.xml @@ -11,7 +11,7 @@ AND table_name NOT LIKE 'gen_%' @@ -122,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - +