Commit 937c51f4ec42f1f9caa9afd0f4e69fd074dbee86

Authored by YunaiV
1 parent b8351f50

完成代码生成器的 sql 生成

ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java renamed to ruoyi-common/src/main/java/com/ruoyi/generator/config/GenConfig.java
1   -package com.ruoyi.generator.config;
2   -
3   -import org.springframework.beans.factory.annotation.Value;
4   -import org.springframework.boot.context.properties.ConfigurationProperties;
5   -import org.springframework.context.annotation.PropertySource;
6   -import org.springframework.stereotype.Component;
7   -
8   -/**
9   - * 读取代码生成相关配置
10   - *
11   - * @author ruoyi
12   - */
13   -@Component
14   -@ConfigurationProperties(prefix = "gen")
15   -@PropertySource(value = { "classpath:generator.yml" })
16   -public class GenConfig {
17   -
18   - /** 作者 */
19   - public static String author;
20   -
21   - /** 生成包路径 */
22   - public static String packageName;
23   -
24   - /** 自动去除表前缀,默认是false */
25   - public static boolean autoRemovePre;
26   -
27   - /** 表前缀(类名不会包含表前缀) */
28   - public static String tablePrefix;
29   -
30   -}
  1 +package com.ruoyi.generator.config;
  2 +
  3 +import org.springframework.beans.factory.annotation.Value;
  4 +import org.springframework.boot.context.properties.ConfigurationProperties;
  5 +import org.springframework.context.annotation.PropertySource;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +/**
  9 + * 读取代码生成相关配置
  10 + *
  11 + * @author ruoyi
  12 + */
  13 +@Component
  14 +@ConfigurationProperties(prefix = "gen")
  15 +@PropertySource(value = { "classpath:generator.yml" })
  16 +public class GenConfig {
  17 +
  18 + /** 作者 */
  19 + public static String author;
  20 +
  21 + /** 生成包路径 */
  22 + public static String packageName;
  23 +
  24 + /** 自动去除表前缀,默认是false */
  25 + public static boolean autoRemovePre;
  26 +
  27 + /** 表前缀(类名不会包含表前缀) */
  28 + public static String tablePrefix;
  29 +
  30 +}
... ...
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java renamed to ruoyi-common/src/main/java/com/ruoyi/generator/domain/GenTable.java
1   -package com.ruoyi.generator.domain;
2   -
3   -import java.util.List;
4   -import javax.validation.Valid;
5   -import javax.validation.constraints.NotBlank;
6   -
7   -import org.apache.commons.lang3.ArrayUtils;
8   -import com.ruoyi.common.constant.GenConstants;
9   -import com.ruoyi.common.core.domain.BaseEntity;
10   -import com.ruoyi.common.utils.StringUtils;
11   -
12   -/**
13   - * 业务表 gen_table
14   - *
15   - * @author ruoyi
16   - */
17   -public class GenTable extends BaseEntity {
18   -
19   - /**
20   - * 生成包路径
21   - */
22   - @NotBlank(message = "生成包路径不能为空")
23   - private String packageName;
24   -
25   - /**
26   - * 其它生成选项
27   - */
28   - private String options;
29   -
30   - /**
31   - * 树编码字段
32   - */
33   - private String treeCode;
34   -
35   - /**
36   - * 树父编码字段
37   - */
38   - private String treeParentCode;
39   -
40   - /**
41   - * 树名称字段
42   - */
43   - private String treeName;
44   -
45   - /**
46   - * 上级菜单ID字段
47   - */
48   - private String parentMenuId;
49   -
50   - /**
51   - * 上级菜单名称字段
52   - */
53   - private String parentMenuName;
54   -
55   -}
  1 +package com.ruoyi.generator.domain;
  2 +
  3 +import java.util.List;
  4 +import javax.validation.Valid;
  5 +import javax.validation.constraints.NotBlank;
  6 +
  7 +import org.apache.commons.lang3.ArrayUtils;
  8 +import com.ruoyi.common.constant.GenConstants;
  9 +import com.ruoyi.common.core.domain.BaseEntity;
  10 +import com.ruoyi.common.utils.StringUtils;
  11 +
  12 +/**
  13 + * 业务表 gen_table
  14 + *
  15 + * @author ruoyi
  16 + */
  17 +public class GenTable extends BaseEntity {
  18 +
  19 + /**
  20 + * 生成包路径
  21 + */
  22 + @NotBlank(message = "生成包路径不能为空")
  23 + private String packageName;
  24 +
  25 + /**
  26 + * 其它生成选项
  27 + */
  28 + private String options;
  29 +
  30 + /**
  31 + * 树编码字段
  32 + */
  33 + private String treeCode;
  34 +
  35 + /**
  36 + * 树父编码字段
  37 + */
  38 + private String treeParentCode;
  39 +
  40 + /**
  41 + * 树名称字段
  42 + */
  43 + private String treeName;
  44 +
  45 +}
... ...
ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java renamed to ruoyi-common/src/main/java/com/ruoyi/generator/util/VelocityUtils.java
1   -package com.ruoyi.generator.util;
2   -
3   -import java.util.ArrayList;
4   -import java.util.HashSet;
5   -import java.util.List;
6   -
7   -import org.apache.velocity.VelocityContext;
8   -import com.alibaba.fastjson.JSONObject;
9   -import com.ruoyi.common.constant.GenConstants;
10   -import com.ruoyi.common.utils.DateUtils;
11   -import com.ruoyi.common.utils.StringUtils;
12   -import com.ruoyi.generator.domain.GenTable;
13   -import com.ruoyi.generator.domain.GenTableColumn;
14   -
15   -/**
16   - * 模板处理工具类
17   - *
18   - * @author ruoyi
19   - */
20   -public class VelocityUtils {
21   -
22   - /**
23   - * 默认上级菜单,系统工具
24   - */
25   - private static final String DEFAULT_PARENT_MENU_ID = "3";
26   -
27   - /**
28   - * 设置模板变量信息
29   - *
30   - * @return 模板列表
31   - */
32   - public static VelocityContext prepareContext(GenTable genTable) {
33   - String moduleName = genTable.getModuleName();
34   - String businessName = genTable.getBusinessName();
35   - String packageName = genTable.getPackageName();
36   - String tplCategory = genTable.getTplCategory();
37   - String functionName = genTable.getFunctionName();
38   -
39   - VelocityContext velocityContext = new VelocityContext();
40   - velocityContext.put("tplCategory", genTable.getTplCategory());
41   - velocityContext.put("tableName", genTable.getTableName());
42   - velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
43   - velocityContext.put("ClassName", genTable.getClassName());
44   - velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
45   - velocityContext.put("moduleName", genTable.getModuleName());
46   - velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
47   - velocityContext.put("businessName", genTable.getBusinessName());
48   - velocityContext.put("basePackage", getPackagePrefix(packageName));
49   - velocityContext.put("packageName", packageName);
50   - velocityContext.put("author", genTable.getFunctionAuthor());
51   - velocityContext.put("datetime", DateUtils.getDate());
52   - velocityContext.put("pkColumn", genTable.getPkColumn());
53   - velocityContext.put("importList", getImportList(genTable.getColumns()));
54   - velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
55   - velocityContext.put("columns", genTable.getColumns());
56   - velocityContext.put("table", genTable);
57   - setMenuVelocityContext(velocityContext, genTable);
58   - if (GenConstants.TPL_TREE.equals(tplCategory)) {
59   - setTreeVelocityContext(velocityContext, genTable);
60   - }
61   - return velocityContext;
62   - }
63   -
64   - public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
65   - String options = genTable.getOptions();
66   - JSONObject paramsObj = JSONObject.parseObject(options);
67   - String parentMenuId = getParentMenuId(paramsObj);
68   - context.put("parentMenuId", parentMenuId);
69   - }
70   -
71   - public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
72   - String options = genTable.getOptions();
73   - JSONObject paramsObj = JSONObject.parseObject(options);
74   - String treeCode = getTreecode(paramsObj);
75   - String treeParentCode = getTreeParentCode(paramsObj);
76   - String treeName = getTreeName(paramsObj);
77   -
78   - context.put("treeCode", treeCode);
79   - context.put("treeParentCode", treeParentCode);
80   - context.put("treeName", treeName);
81   - context.put("expandColumn", getExpandColumn(genTable));
82   - if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
83   - context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
84   - }
85   - if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
86   - context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
87   - }
88   - }
89   -
90   - /**
91   - * 获取模板信息
92   - *
93   - * @return 模板列表
94   - */
95   - public static List<String> getTemplateList(String tplCategory) {
96   - List<String> templates = new ArrayList<String>();
97   - templates.add("vm/java/domain.java.vm");
98   - templates.add("vm/java/mapper.java.vm");
99   - templates.add("vm/java/service.java.vm");
100   - templates.add("vm/java/serviceImpl.java.vm");
101   - templates.add("vm/java/controller.java.vm");
102   - templates.add("vm/xml/mapper.xml.vm");
103   - templates.add("vm/sql/sql.vm");
104   - templates.add("vm/js/api.js.vm");
105   - if (GenConstants.TPL_CRUD.equals(tplCategory)) {
106   - templates.add("vm/vue/index.vue.vm");
107   - } else if (GenConstants.TPL_TREE.equals(tplCategory)) {
108   - templates.add("vm/vue/index-tree.vue.vm");
109   - }
110   - return templates;
111   - }
112   -
113   - /**
114   - * 获取文件名
115   - */
116   - public static String getFileName(String template, GenTable genTable) {
117   - // 文件名称
118   - String fileName = "";
119   - // 包路径
120   - String packageName = genTable.getPackageName();
121   - // 模块名
122   - String moduleName = genTable.getModuleName();
123   - // 大写类名
124   - String className = genTable.getClassName();
125   - // 业务名称
126   - String businessName = genTable.getBusinessName();
127   -
128   - String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
129   - String mybatisPath = MYBATIS_PATH + "/" + moduleName;
130   - String vuePath = "vue";
131   -
132   - if (template.contains("domain.java.vm")) {
133   - fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
134   - } else if (template.contains("mapper.java.vm")) {
135   - fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
136   - } else if (template.contains("service.java.vm")) {
137   - fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
138   - } else if (template.contains("serviceImpl.java.vm")) {
139   - fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
140   - } else if (template.contains("controller.java.vm")) {
141   - fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
142   - } else if (template.contains("mapper.xml.vm")) {
143   - fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
144   - } else if (template.contains("sql.vm")) {
145   - fileName = businessName + "Menu.sql";
146   - } else if (template.contains("api.js.vm")) {
147   - fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
148   - } else if (template.contains("index.vue.vm")) {
149   - fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
150   - } else if (template.contains("index-tree.vue.vm")) {
151   - fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
152   - }
153   - return fileName;
154   - }
155   -
156   - /**
157   - * 获取包前缀
158   - *
159   - * @param packageName 包名称
160   - * @return 包前缀名称
161   - */
162   - public static String getPackagePrefix(String packageName) {
163   - int lastIndex = packageName.lastIndexOf(".");
164   - String basePackage = StringUtils.substring(packageName, 0, lastIndex);
165   - return basePackage;
166   - }
167   -
168   - /**
169   - * 根据列类型获取导入包
170   - *
171   - * @param columns 列集合
172   - * @return 返回需要导入的包列表
173   - */
174   - public static HashSet<String> getImportList(List<GenTableColumn> columns) {
175   - HashSet<String> importList = new HashSet<String>();
176   - for (GenTableColumn column : columns) {
177   - if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
178   - importList.add("java.util.Date");
179   - importList.add("com.fasterxml.jackson.annotation.JsonFormat");
180   - } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
181   - importList.add("java.math.BigDecimal");
182   - }
183   - }
184   - return importList;
185   - }
186   -
187   - /**
188   - * 获取权限前缀
189   - *
190   - * @param moduleName 模块名称
191   - * @param businessName 业务名称
192   - * @return 返回权限前缀
193   - */
194   - public static String getPermissionPrefix(String moduleName, String businessName) {
195   - return StringUtils.format("{}:{}", moduleName, businessName);
196   - }
197   -
198   - /**
199   - * 获取上级菜单ID字段
200   - *
201   - * @param paramsObj 生成其他选项
202   - * @return 上级菜单ID字段
203   - */
204   - public static String getParentMenuId(JSONObject paramsObj) {
205   - if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) {
206   - return paramsObj.getString(GenConstants.PARENT_MENU_ID);
207   - }
208   - return DEFAULT_PARENT_MENU_ID;
209   - }
210   -
211   - /**
212   - * 获取树编码
213   - *
214   - * @param paramsObj 生成其他选项
215   - * @return 树编码
216   - */
217   - public static String getTreecode(JSONObject paramsObj) {
218   - if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
219   - return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
220   - }
221   - return StringUtils.EMPTY;
222   - }
223   -
224   - /**
225   - * 获取树父编码
226   - *
227   - * @param paramsObj 生成其他选项
228   - * @return 树父编码
229   - */
230   - public static String getTreeParentCode(JSONObject paramsObj) {
231   - if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
232   - return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
233   - }
234   - return StringUtils.EMPTY;
235   - }
236   -
237   - /**
238   - * 获取树名称
239   - *
240   - * @param paramsObj 生成其他选项
241   - * @return 树名称
242   - */
243   - public static String getTreeName(JSONObject paramsObj) {
244   - if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
245   - return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
246   - }
247   - return StringUtils.EMPTY;
248   - }
249   -
250   - /**
251   - * 获取需要在哪一列上面显示展开按钮
252   - *
253   - * @param genTable 业务表对象
254   - * @return 展开按钮列序号
255   - */
256   - public static int getExpandColumn(GenTable genTable) {
257   - String options = genTable.getOptions();
258   - JSONObject paramsObj = JSONObject.parseObject(options);
259   - String treeName = paramsObj.getString(GenConstants.TREE_NAME);
260   - int num = 0;
261   - for (GenTableColumn column : genTable.getColumns()) {
262   - if (column.isList()) {
263   - num++;
264   - String columnName = column.getColumnName();
265   - if (columnName.equals(treeName)) {
266   - break;
267   - }
268   - }
269   - }
270   - return num;
271   - }
272   -}
  1 +package com.ruoyi.generator.util;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.HashSet;
  5 +import java.util.List;
  6 +
  7 +import org.apache.velocity.VelocityContext;
  8 +import com.alibaba.fastjson.JSONObject;
  9 +import com.ruoyi.common.constant.GenConstants;
  10 +import com.ruoyi.common.utils.DateUtils;
  11 +import com.ruoyi.common.utils.StringUtils;
  12 +import com.ruoyi.generator.domain.GenTable;
  13 +import com.ruoyi.generator.domain.GenTableColumn;
  14 +
  15 +/**
  16 + * 模板处理工具类
  17 + *
  18 + * @author ruoyi
  19 + */
  20 +public class VelocityUtils {
  21 +
  22 + /**
  23 + * 默认上级菜单,系统工具
  24 + */
  25 + private static final String DEFAULT_PARENT_MENU_ID = "3";
  26 +
  27 + /**
  28 + * 设置模板变量信息
  29 + *
  30 + * @return 模板列表
  31 + */
  32 + public static VelocityContext prepareContext(GenTable genTable) {
  33 + String moduleName = genTable.getModuleName();
  34 + String businessName = genTable.getBusinessName();
  35 + String packageName = genTable.getPackageName();
  36 + String tplCategory = genTable.getTplCategory();
  37 + String functionName = genTable.getFunctionName();
  38 +
  39 + VelocityContext velocityContext = new VelocityContext();
  40 + velocityContext.put("tplCategory", genTable.getTplCategory());
  41 + velocityContext.put("tableName", genTable.getTableName());
  42 + velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
  43 + velocityContext.put("ClassName", genTable.getClassName());
  44 + velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
  45 + velocityContext.put("moduleName", genTable.getModuleName());
  46 + velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
  47 + velocityContext.put("businessName", genTable.getBusinessName());
  48 + velocityContext.put("basePackage", getPackagePrefix(packageName));
  49 + velocityContext.put("packageName", packageName);
  50 + velocityContext.put("author", genTable.getFunctionAuthor());
  51 + velocityContext.put("datetime", DateUtils.getDate());
  52 + velocityContext.put("pkColumn", genTable.getPkColumn());
  53 + velocityContext.put("importList", getImportList(genTable.getColumns()));
  54 + velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
  55 + velocityContext.put("columns", genTable.getColumns());
  56 + velocityContext.put("table", genTable);
  57 + setMenuVelocityContext(velocityContext, genTable);
  58 + if (GenConstants.TPL_TREE.equals(tplCategory)) {
  59 + setTreeVelocityContext(velocityContext, genTable);
  60 + }
  61 + return velocityContext;
  62 + }
  63 +
  64 + public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
  65 + String options = genTable.getOptions();
  66 + JSONObject paramsObj = JSONObject.parseObject(options);
  67 + String treeCode = getTreecode(paramsObj);
  68 + String treeParentCode = getTreeParentCode(paramsObj);
  69 + String treeName = getTreeName(paramsObj);
  70 +
  71 + context.put("treeCode", treeCode);
  72 + context.put("treeParentCode", treeParentCode);
  73 + context.put("treeName", treeName);
  74 + context.put("expandColumn", getExpandColumn(genTable));
  75 + if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
  76 + context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
  77 + }
  78 + if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
  79 + context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
  80 + }
  81 + }
  82 +
  83 + /**
  84 + * 获取模板信息
  85 + *
  86 + * @return 模板列表
  87 + */
  88 + public static List<String> getTemplateList(String tplCategory) {
  89 + List<String> templates = new ArrayList<String>();
  90 + templates.add("vm/java/domain.java.vm");
  91 + templates.add("vm/java/mapper.java.vm");
  92 + templates.add("vm/java/service.java.vm");
  93 + templates.add("vm/java/serviceImpl.java.vm");
  94 + templates.add("vm/java/controller.java.vm");
  95 + templates.add("vm/xml/mapper.xml.vm");
  96 + templates.add("vm/sql/sql.vm");
  97 + templates.add("vm/js/api.js.vm");
  98 + if (GenConstants.TPL_CRUD.equals(tplCategory)) {
  99 + templates.add("vm/vue/index.vue.vm");
  100 + } else if (GenConstants.TPL_TREE.equals(tplCategory)) {
  101 + templates.add("vm/vue/index-tree.vue.vm");
  102 + }
  103 + return templates;
  104 + }
  105 +
  106 + /**
  107 + * 获取文件名
  108 + */
  109 + public static String getFileName(String template, GenTable genTable) {
  110 + // 文件名称
  111 + String fileName = "";
  112 + // 包路径
  113 + String packageName = genTable.getPackageName();
  114 + // 模块名
  115 + String moduleName = genTable.getModuleName();
  116 + // 大写类名
  117 + String className = genTable.getClassName();
  118 + // 业务名称
  119 + String businessName = genTable.getBusinessName();
  120 +
  121 + String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
  122 + String mybatisPath = MYBATIS_PATH + "/" + moduleName;
  123 + String vuePath = "vue";
  124 +
  125 + if (template.contains("domain.java.vm")) {
  126 + fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
  127 + } else if (template.contains("mapper.java.vm")) {
  128 + fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
  129 + } else if (template.contains("service.java.vm")) {
  130 + fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
  131 + } else if (template.contains("serviceImpl.java.vm")) {
  132 + fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
  133 + } else if (template.contains("controller.java.vm")) {
  134 + fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
  135 + } else if (template.contains("mapper.xml.vm")) {
  136 + fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
  137 + } else if (template.contains("sql.vm")) {
  138 + fileName = businessName + "Menu.sql";
  139 + } else if (template.contains("api.js.vm")) {
  140 + fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
  141 + } else if (template.contains("index.vue.vm")) {
  142 + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
  143 + } else if (template.contains("index-tree.vue.vm")) {
  144 + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
  145 + }
  146 + return fileName;
  147 + }
  148 +
  149 + /**
  150 + * 获取包前缀
  151 + *
  152 + * @param packageName 包名称
  153 + * @return 包前缀名称
  154 + */
  155 + public static String getPackagePrefix(String packageName) {
  156 + int lastIndex = packageName.lastIndexOf(".");
  157 + String basePackage = StringUtils.substring(packageName, 0, lastIndex);
  158 + return basePackage;
  159 + }
  160 +
  161 + /**
  162 + * 根据列类型获取导入包
  163 + *
  164 + * @param columns 列集合
  165 + * @return 返回需要导入的包列表
  166 + */
  167 + public static HashSet<String> getImportList(List<GenTableColumn> columns) {
  168 + HashSet<String> importList = new HashSet<String>();
  169 + for (GenTableColumn column : columns) {
  170 + if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
  171 + importList.add("java.util.Date");
  172 + importList.add("com.fasterxml.jackson.annotation.JsonFormat");
  173 + } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
  174 + importList.add("java.math.BigDecimal");
  175 + }
  176 + }
  177 + return importList;
  178 + }
  179 +
  180 + /**
  181 + * 获取权限前缀
  182 + *
  183 + * @param moduleName 模块名称
  184 + * @param businessName 业务名称
  185 + * @return 返回权限前缀
  186 + */
  187 + public static String getPermissionPrefix(String moduleName, String businessName) {
  188 + return StringUtils.format("{}:{}", moduleName, businessName);
  189 + }
  190 +
  191 + /**
  192 + * 获取上级菜单ID字段
  193 + *
  194 + * @param paramsObj 生成其他选项
  195 + * @return 上级菜单ID字段
  196 + */
  197 + public static String getParentMenuId(JSONObject paramsObj) {
  198 + if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) {
  199 + return paramsObj.getString(GenConstants.PARENT_MENU_ID);
  200 + }
  201 + return DEFAULT_PARENT_MENU_ID;
  202 + }
  203 +
  204 + /**
  205 + * 获取树编码
  206 + *
  207 + * @param paramsObj 生成其他选项
  208 + * @return 树编码
  209 + */
  210 + public static String getTreecode(JSONObject paramsObj) {
  211 + if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
  212 + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
  213 + }
  214 + return StringUtils.EMPTY;
  215 + }
  216 +
  217 + /**
  218 + * 获取树父编码
  219 + *
  220 + * @param paramsObj 生成其他选项
  221 + * @return 树父编码
  222 + */
  223 + public static String getTreeParentCode(JSONObject paramsObj) {
  224 + if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
  225 + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
  226 + }
  227 + return StringUtils.EMPTY;
  228 + }
  229 +
  230 + /**
  231 + * 获取树名称
  232 + *
  233 + * @param paramsObj 生成其他选项
  234 + * @return 树名称
  235 + */
  236 + public static String getTreeName(JSONObject paramsObj) {
  237 + if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
  238 + return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
  239 + }
  240 + return StringUtils.EMPTY;
  241 + }
  242 +
  243 + /**
  244 + * 获取需要在哪一列上面显示展开按钮
  245 + *
  246 + * @param genTable 业务表对象
  247 + * @return 展开按钮列序号
  248 + */
  249 + public static int getExpandColumn(GenTable genTable) {
  250 + String options = genTable.getOptions();
  251 + JSONObject paramsObj = JSONObject.parseObject(options);
  252 + String treeName = paramsObj.getString(GenConstants.TREE_NAME);
  253 + int num = 0;
  254 + for (GenTableColumn column : genTable.getColumns()) {
  255 + if (column.isList()) {
  256 + num++;
  257 + String columnName = column.getColumnName();
  258 + if (columnName.equals(treeName)) {
  259 + break;
  260 + }
  261 + }
  262 + }
  263 + return num;
  264 + }
  265 +}
... ...
ruoyi-generator/src/main/resources/generator.yml renamed to ruoyi-common/src/main/resources/generator.yml
1   -# 代码生成
2   -gen:
3   - # 作者
4   - author: ruoyi
5   - # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
6   - packageName: com.ruoyi.system
7   - # 自动去除表前缀,默认是false
8   - autoRemovePre: false
9   - # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
  1 +# 代码生成
  2 +gen:
  3 + # 作者
  4 + author: ruoyi
  5 + # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
  6 + packageName: com.ruoyi.system
  7 + # 自动去除表前缀,默认是false
  8 + autoRemovePre: false
  9 + # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
10 10 tablePrefix: sys_
11 11 \ No newline at end of file
... ...
ruoyi-generator/src/main/resources/vm/java/controller.java.vm deleted
1   -package ${packageName}.controller;
2   -
3   -import java.util.List;
4   -import org.springframework.security.access.prepost.PreAuthorize;
5   -import org.springframework.beans.factory.annotation.Autowired;
6   -import org.springframework.web.bind.annotation.GetMapping;
7   -import org.springframework.web.bind.annotation.PostMapping;
8   -import org.springframework.web.bind.annotation.PutMapping;
9   -import org.springframework.web.bind.annotation.DeleteMapping;
10   -import org.springframework.web.bind.annotation.PathVariable;
11   -import org.springframework.web.bind.annotation.RequestBody;
12   -import org.springframework.web.bind.annotation.RequestMapping;
13   -import org.springframework.web.bind.annotation.RestController;
14   -import com.ruoyi.common.annotation.Log;
15   -import com.ruoyi.common.core.controller.BaseController;
16   -import com.ruoyi.common.core.domain.AjaxResult;
17   -import com.ruoyi.common.enums.BusinessType;
18   -import ${packageName}.domain.${ClassName};
19   -import ${packageName}.service.I${ClassName}Service;
20   -import com.ruoyi.common.utils.poi.ExcelUtil;
21   -#if($table.crud)
22   -import com.ruoyi.common.core.page.TableDataInfo;
23   -#elseif($table.tree)
24   -#end
25   -
26   -/**
27   - * ${functionName}Controller
28   - *
29   - * @author ${author}
30   - * @date ${datetime}
31   - */
32   -@RestController
33   -@RequestMapping("/${moduleName}/${businessName}")
34   -public class ${ClassName}Controller extends BaseController
35   -{
36   - @Autowired
37   - private I${ClassName}Service ${className}Service;
38   -
39   - /**
40   - * 查询${functionName}列表
41   - */
42   - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
43   - @GetMapping("/list")
44   -#if($table.crud)
45   - public TableDataInfo list(${ClassName} ${className})
46   - {
47   - startPage();
48   - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
49   - return getDataTable(list);
50   - }
51   -#elseif($table.tree)
52   - public AjaxResult list(${ClassName} ${className})
53   - {
54   - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
55   - return AjaxResult.success(list);
56   - }
57   -#end
58   -
59   - /**
60   - * 导出${functionName}列表
61   - */
62   - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
63   - @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
64   - @GetMapping("/export")
65   - public AjaxResult export(${ClassName} ${className})
66   - {
67   - List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
68   - ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
69   - return util.exportExcel(list, "${businessName}");
70   - }
71   -
72   - /**
73   - * 获取${functionName}详细信息
74   - */
75   - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
76   - @GetMapping(value = "/{${pkColumn.javaField}}")
77   - public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
78   - {
79   - return AjaxResult.success(${className}Service.select${ClassName}ById(${pkColumn.javaField}));
80   - }
81   -
82   - /**
83   - * 新增${functionName}
84   - */
85   - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
86   - @Log(title = "${functionName}", businessType = BusinessType.INSERT)
87   - @PostMapping
88   - public AjaxResult add(@RequestBody ${ClassName} ${className})
89   - {
90   - return toAjax(${className}Service.insert${ClassName}(${className}));
91   - }
92   -
93   - /**
94   - * 修改${functionName}
95   - */
96   - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
97   - @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
98   - @PutMapping
99   - public AjaxResult edit(@RequestBody ${ClassName} ${className})
100   - {
101   - return toAjax(${className}Service.update${ClassName}(${className}));
102   - }
103   -
104   - /**
105   - * 删除${functionName}
106   - */
107   - @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
108   - @Log(title = "${functionName}", businessType = BusinessType.DELETE)
109   - @DeleteMapping("/{${pkColumn.javaField}s}")
110   - public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
111   - {
112   - return toAjax(${className}Service.delete${ClassName}ByIds(${pkColumn.javaField}s));
113   - }
114   -}
ruoyi-generator/src/main/resources/vm/sql/sql.vm deleted
1   --- 菜单 SQL
2   -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
3   -values('${functionName}', '${parentMenuId}', '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 'admin', sysdate(), '', null, '${functionName}菜单');
4   -
5   --- 按钮父菜单ID
6   -SELECT @parentId := LAST_INSERT_ID();
7   -
8   --- 按钮 SQL
9   -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
10   -values('${functionName}查询', @parentId, '1', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', sysdate(), '', null, '');
11   -
12   -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
13   -values('${functionName}新增', @parentId, '2', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', sysdate(), '', null, '');
14   -
15   -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
16   -values('${functionName}修改', @parentId, '3', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', sysdate(), '', null, '');
17   -
18   -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
19   -values('${functionName}删除', @parentId, '4', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', sysdate(), '', null, '');
20   -
21   -insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
22   -values('${functionName}导出', @parentId, '5', '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', sysdate(), '', null, '');
23 0 \ No newline at end of file
src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/auth/SysUserSessionDO.java
... ... @@ -33,7 +33,7 @@ public class SysUserSessionDO extends BaseDO {
33 33 /**
34 34 * 用户编号
35 35 *
36   - * 外键 {@link SysUserDO#getId()}
  36 + * 关联 {@link SysUserDO#getId()}
37 37 */
38 38 private Long userId;
39 39 /**
... ...
src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/dept/SysDeptDO.java
... ... @@ -29,7 +29,7 @@ public class SysDeptDO extends BaseDO {
29 29 /**
30 30 * 父部门ID
31 31 *
32   - * 外键 {@link #id}
  32 + * 关联 {@link #id}
33 33 */
34 34 private Long parentId;
35 35 /**
... ...
src/main/java/cn/iocoder/dashboard/modules/tool/dal/dataobject/codegen/ToolCodegenColumnDO.java
... ... @@ -29,7 +29,7 @@ public class ToolCodegenColumnDO extends BaseDO {
29 29 /**
30 30 * 表编号
31 31 *
32   - * 外键 {@link ToolCodegenTableDO#getId()}
  32 + * 关联 {@link ToolCodegenTableDO#getId()}
33 33 */
34 34 private Long tableId;
35 35  
... ...
src/main/java/cn/iocoder/dashboard/modules/tool/dal/dataobject/codegen/ToolCodegenTableDO.java
1 1 package cn.iocoder.dashboard.modules.tool.dal.dataobject.codegen;
2 2  
3 3 import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysMenuDO;
4 5 import cn.iocoder.dashboard.modules.tool.enums.codegen.ToolCodegenTemplateTypeEnum;
5 6 import com.baomidou.mybatisplus.annotation.TableName;
6 7 import lombok.Builder;
... ... @@ -86,4 +87,11 @@ public class ToolCodegenTableDO extends BaseDO {
86 87  
87 88 // ========== 菜单相关字段 ==========
88 89  
  90 + /**
  91 + * 父菜单编号
  92 + *
  93 + * 关联 {@link SysMenuDO#getId()}
  94 + */
  95 + private Long parentMenuId;
  96 +
89 97 }
... ...
src/main/java/cn/iocoder/dashboard/modules/tool/service/codegen/impl/ToolCodegenEngine.java
... ... @@ -12,6 +12,8 @@ import cn.iocoder.dashboard.common.pojo.PageResult;
12 12 import cn.iocoder.dashboard.framework.codegen.config.CodegenProperties;
13 13 import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat;
14 14 import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils;
  15 +import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog;
  16 +import cn.iocoder.dashboard.framework.logger.operatelog.core.enums.OperateTypeEnum;
15 17 import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO;
16 18 import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX;
17 19 import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX;
... ... @@ -84,6 +86,7 @@ public class ToolCodegenEngine {
84 86 .put(vueTemplatePath("api/api.js"),
85 87 vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
86 88 // SQL
  89 + .put("codegen/sql/sql.vm", "sql/sql.sql")
87 90 .build();
88 91  
89 92 @Resource
... ... @@ -124,10 +127,12 @@ public class ToolCodegenEngine {
124 127 globalBindingMap.put("BaseDOClassName", BaseDO.class.getName());
125 128 globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName());
126 129 globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName());
127   - // Util 了诶
  130 + // Util 工具类
128 131 globalBindingMap.put("ServiceExceptionUtilClassName", ServiceExceptionUtil.class.getName());
129 132 globalBindingMap.put("DateUtilsClassName", DateUtils.class.getName());
130 133 globalBindingMap.put("ExcelUtilsClassName", ExcelUtils.class.getName());
  134 + globalBindingMap.put("OperateLogClassName", OperateLog.class.getName());
  135 + globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName());
131 136 }
132 137  
133 138 public Map<String, String> execute(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) {
... ... @@ -146,7 +151,10 @@ public class ToolCodegenEngine {
146 151 bindingMap.put("simpleClassName", simpleClassName);
147 152 bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type
148 153 bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量
149   - bindingMap.put("simpleClassName_strikeCase", toSymbolCase(simpleClassName, '-')); // 将 DictType 转换成 dict-type
  154 + String simpleClassNameStrikeCase = toSymbolCase(simpleClassName, '-'); // 将 DictType 转换成 dict-type
  155 + bindingMap.put("simpleClassName_strikeCase", simpleClassNameStrikeCase);
  156 + // permission 前缀
  157 + bindingMap.put("permissionPrefix", table.getModuleName() + ":" + simpleClassNameStrikeCase);
150 158  
151 159 // 执行生成
152 160 final Map<String, String> result = Maps.newLinkedHashMapWithExpectedSize(TEMPLATES.size()); // 有序
... ...
src/main/resources/codegen/java/controller/controller.vm
... ... @@ -3,6 +3,7 @@ package ${basePackage}.${table.moduleName}.controller.${table.businessName};
3 3 import org.springframework.web.bind.annotation.*;
4 4 import javax.annotation.Resource;
5 5 import org.springframework.validation.annotation.Validated;
  6 +import org.springframework.security.access.prepost.PreAuthorize;
6 7  
7 8 import io.swagger.annotations.*;
8 9  
... ... @@ -18,6 +19,9 @@ import static ${CommonResultClassName}.success;
18 19  
19 20 import ${ExcelUtilsClassName};
20 21  
  22 +import ${OperateLogClassName};
  23 +import static ${OperateTypeEnumClassName}.*;
  24 +
21 25 import ${basePackage}.${table.moduleName}.controller.${table.businessName}.vo.*;
22 26 import ${basePackage}.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
23 27 import ${basePackage}.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
... ... @@ -33,22 +37,25 @@ public class ${table.className}Controller {
33 37 @Resource
34 38 private ${table.className}Service ${classNameVar}Service;
35 39  
36   - @ApiOperation("创建${table.classComment}")
37 40 @PostMapping("/create")
  41 + @ApiOperation("创建${table.classComment}")
  42 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:create')")
38 43 public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid ${table.className}CreateReqVO createReqVO) {
39 44 return success(${classNameVar}Service.create${simpleClassName}(createReqVO));
40 45 }
41 46  
42   - @ApiOperation("更新${table.classComment}")
43 47 @PutMapping("/update")
  48 + @ApiOperation("更新${table.classComment}")
  49 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:update')")
44 50 public CommonResult<Boolean> update${simpleClassName}(@Valid ${table.className}UpdateReqVO updateReqVO) {
45 51 ${classNameVar}Service.update${simpleClassName}(updateReqVO);
46 52 return success(true);
47 53 }
48 54  
  55 + @DeleteMapping("/delete")
49 56 @ApiOperation("删除${table.classComment}")
50   - @DeleteMapping("/delete")
51 57 @ApiImplicitParam(name = "id", value = "编号", required = true)
  58 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:delete')")
52 59 public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
53 60 ${classNameVar}Service.delete${simpleClassName}(id);
54 61 return success(true);
... ... @@ -57,6 +64,7 @@ public class ${table.className}Controller {
57 64 @GetMapping("/get")
58 65 @ApiOperation("获得${table.classComment}")
59 66 @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class)
  67 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
60 68 public CommonResult<${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) {
61 69 ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id);
62 70 return success(${table.className}Convert.INSTANCE.convert(${classNameVar}));
... ... @@ -65,13 +73,15 @@ public class ${table.className}Controller {
65 73 @GetMapping("/list")
66 74 @ApiOperation("获得${table.classComment}列表")
67 75 @ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class)
  76 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
68 77 public CommonResult<List<${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) {
69 78 List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids);
70 79 return success(${table.className}Convert.INSTANCE.convertList(list));
71 80 }
72 81  
73   - @ApiOperation("获得${table.classComment}分页")
74 82 @GetMapping("/page")
  83 + @ApiOperation("获得${table.classComment}分页")
  84 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
75 85 public CommonResult<PageResult<${table.className}RespVO>> get${simpleClassName}Page(@Valid ${table.className}PageReqVO pageVO) {
76 86 PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO);
77 87 return success(${table.className}Convert.INSTANCE.convertPage(pageResult));
... ... @@ -79,6 +89,8 @@ public class ${table.className}Controller {
79 89  
80 90 @GetMapping("/export-excel")
81 91 @ApiOperation("导出${table.classComment} Excel")
  92 + @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
  93 + @OperateLog(type = EXPORT)
82 94 public void export${simpleClassName}Excel(@Valid ${table.className}ExportReqVO exportReqVO,
83 95 HttpServletResponse response) throws IOException {
84 96 List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(exportReqVO);
... ...
src/main/resources/codegen/sql/sql.vm 0 → 100644
  1 +-- 菜单 SQL
  2 +INSERT INTO `sys_menu`(
  3 + `name`, `permission`, `menu_type`, `sort`, `parent_id`,
  4 + `path`, `icon`, `component`, `status`
  5 +)
  6 +VALUES (
  7 + '${table.tableComment}管理', '${permissionPrefix}:query', 2, 0, ${table.parentMenuId},
  8 + '${simpleClassName_strikeCase}', '', '${table.moduleName}/${table.businessName}/index', 1
  9 +);
  10 +
  11 +-- 按钮父菜单ID
  12 +SELECT @parentId := LAST_INSERT_ID();
  13 +
  14 +-- 按钮 SQL
  15 +#set ($functionNames = ['创建', '更新', '删除', '导出'])
  16 +#set ($functionOps = ['create', 'update', 'delete', 'export'])
  17 +#foreach ($functionName in $functionNames)
  18 +INSERT INTO `sys_menu`(
  19 + `name`, `permission`, `menu_type`, `sort`, `parent_id`,
  20 + `path`, `icon`, `component`, `status`
  21 +)
  22 +VALUES (
  23 + '${table.tableComment}${functionName}', '${permissionPrefix}:${functionOps[$velocityCount]}', 3, 0, @parentId,
  24 + '', '', '', 1
  25 +);
  26 +#end
... ...
src/main/resources/codegen/vue/views/index.vue.vm
... ... @@ -48,11 +48,11 @@
48 48 <el-row :gutter="10" class="mb8">
49 49 <el-col :span="1.5">
50 50 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
51   - v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
  51 + v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
52 52 </el-col>
53 53 <el-col :span="1.5">
54 54 <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
55   - v-hasPermi="['${moduleName}:${businessName}:export']">导出</el-button>
  55 + v-hasPermi="['${permissionPrefix}:export']">导出</el-button>
56 56 </el-col>
57 57 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
58 58 </el-row>
... ... @@ -85,9 +85,9 @@
85 85 <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
86 86 <template slot-scope="scope">
87 87 <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
88   - v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
  88 + v-hasPermi="['${permissionPrefix}:update']">修改</el-button>
89 89 <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
90   - v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
  90 + v-hasPermi="['${permissionPrefix}:delete']">删除</el-button>
91 91 </template>
92 92 </el-table-column>
93 93 </el-table>
... ... @@ -211,7 +211,7 @@ export default {
211 211 showSearch: true,
212 212 // 总条数
213 213 total: 0,
214   - // ${table.tableComment}表格数据
  214 + // ${table.classComment}列表
215 215 list: [],
216 216 // 弹出层标题
217 217 title: "",
... ... @@ -305,7 +305,7 @@ export default {
305 305 handleAdd() {
306 306 this.reset();
307 307 this.open = true;
308   - this.title = "添加${table.tableComment}";
  308 + this.title = "添加${table.classComment}";
309 309 },
310 310 /** 修改按钮操作 */
311 311 handleUpdate(row) {
... ... @@ -319,7 +319,7 @@ export default {
319 319 #end
320 320 #end
321 321 this.open = true;
322   - this.title = "修改${table.tableComment}";
  322 + this.title = "修改${table.classComment}";
323 323 });
324 324 },
325 325 /** 提交按钮 */
... ... @@ -353,7 +353,7 @@ export default {
353 353 /** 删除按钮操作 */
354 354 handleDelete(row) {
355 355 const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
356   - this.$confirm('是否确认删除${table.tableComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
  356 + this.$confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?', "警告", {
357 357 confirmButtonText: "确定",
358 358 cancelButtonText: "取消",
359 359 type: "warning"
... ... @@ -366,7 +366,7 @@ export default {
366 366 },
367 367 /** 导出按钮操作 */
368 368 handleExport() {
369   - this.$confirm('是否确认导出所有${table.tableComment}数据项?', "警告", {
  369 + this.$confirm('是否确认导出所有${table.classComment}数据项?', "警告", {
370 370 confirmButtonText: "确定",
371 371 cancelButtonText: "取消",
372 372 type: "warning"
... ...