From acf6e8e0815e8902fe77dc7ea98aa5fec0e7478f Mon Sep 17 00:00:00 2001 From: RuoYi Date: Thu, 30 Nov 2023 09:39:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=80=89=E6=8B=A9=E5=89=8D=E7=AB=AF=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/{ry_20230706.sql => ry_20231130.sql} | 2 ++ .../ruoyi/project/tool/gen/domain/GenTable.java | 13 +++++++++++++ .../tool/gen/service/GenTableServiceImpl.java | 6 +++--- .../project/tool/gen/util/VelocityUtils.java | 16 +++++++++++----- .../resources/mybatis/tool/GenTableMapper.xml | 12 ++++++++---- src/main/resources/vm/vue/v3/readme.txt | 1 - 6 files changed, 37 insertions(+), 13 deletions(-) rename sql/{ry_20230706.sql => ry_20231130.sql} (99%) delete mode 100644 src/main/resources/vm/vue/v3/readme.txt diff --git a/sql/ry_20230706.sql b/sql/ry_20231130.sql similarity index 99% rename from sql/ry_20230706.sql rename to sql/ry_20231130.sql index d7dc8da..bcdde65 100644 --- a/sql/ry_20230706.sql +++ b/sql/ry_20231130.sql @@ -954,6 +954,7 @@ create table gen_table ( sub_table_fk_name varchar(64) default null, class_name varchar2(100) default '', tpl_category varchar2(200) default 'crud', + tpl_web_type varchar2(30) default '', package_name varchar2(100), module_name varchar2(30), business_name varchar2(30), @@ -979,6 +980,7 @@ comment on column gen_table.sub_table_name is '关联子表的表名'; comment on column gen_table.sub_table_fk_name is '子表关联的外键名'; comment on column gen_table.class_name is '实体类名称'; comment on column gen_table.tpl_category is '使用的模板(crud单表操作 tree树表操作)'; +comment on column gen_table.tpl_web_type is '前端模板类型(element-ui模版 element-plus模版)'; comment on column gen_table.package_name is '生成包路径'; comment on column gen_table.module_name is '生成模块名'; comment on column gen_table.business_name is '生成业务名'; diff --git a/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java b/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java index 6c72289..c0dfd79 100644 --- a/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java +++ b/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java @@ -41,6 +41,9 @@ public class GenTable extends BaseEntity /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */ private String tplCategory; + /** 前端类型(element-ui模版 element-plus模版) */ + private String tplWebType; + /** 生成包路径 */ @NotBlank(message = "生成包路径不能为空") private String packageName; @@ -168,6 +171,16 @@ public class GenTable extends BaseEntity this.tplCategory = tplCategory; } + public String getTplWebType() + { + return tplWebType; + } + + public void setTplWebType(String tplWebType) + { + this.tplWebType = tplWebType; + } + public String getPackageName() { return packageName; diff --git a/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java b/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java index 83e7a85..e824d6c 100644 --- a/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java +++ b/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java @@ -206,7 +206,7 @@ public class GenTableServiceImpl implements IGenTableService VelocityContext context = VelocityUtils.prepareContext(table); // 获取模板列表 - List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + List templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); for (String template : templates) { // 渲染模板 @@ -257,7 +257,7 @@ public class GenTableServiceImpl implements IGenTableService VelocityContext context = VelocityUtils.prepareContext(table); // 获取模板列表 - List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + List templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); for (String template : templates) { if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) @@ -373,7 +373,7 @@ public class GenTableServiceImpl implements IGenTableService VelocityContext context = VelocityUtils.prepareContext(table); // 获取模板列表 - List templates = VelocityUtils.getTemplateList(table.getTplCategory()); + List templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); for (String template : templates) { // 渲染模板 diff --git a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java index 6c792ea..ba1b06d 100644 --- a/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java +++ b/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java @@ -123,11 +123,17 @@ public class VelocityUtils /** * 获取模板信息 - * + * @param tplCategory 生成的模板 + * @param tplWebType 前端类型 * @return 模板列表 */ - public static List getTemplateList(String tplCategory) + public static List getTemplateList(String tplCategory, String tplWebType) { + String useWebType = "vm/vue"; + if ("element-plus".equals(tplWebType)) + { + useWebType = "vm/vue/v3"; + } List templates = new ArrayList(); templates.add("vm/java/domain.java.vm"); templates.add("vm/java/mapper.java.vm"); @@ -139,15 +145,15 @@ public class VelocityUtils templates.add("vm/js/api.js.vm"); if (GenConstants.TPL_CRUD.equals(tplCategory)) { - templates.add("vm/vue/index.vue.vm"); + templates.add(useWebType + "/index.vue.vm"); } else if (GenConstants.TPL_TREE.equals(tplCategory)) { - templates.add("vm/vue/index-tree.vue.vm"); + templates.add(useWebType + "/index-tree.vue.vm"); } else if (GenConstants.TPL_SUB.equals(tplCategory)) { - templates.add("vm/vue/index.vue.vm"); + templates.add(useWebType + "/index.vue.vm"); templates.add("vm/java/sub-domain.java.vm"); } return templates; diff --git a/src/main/resources/mybatis/tool/GenTableMapper.xml b/src/main/resources/mybatis/tool/GenTableMapper.xml index d7be350..c65bfea 100644 --- a/src/main/resources/mybatis/tool/GenTableMapper.xml +++ b/src/main/resources/mybatis/tool/GenTableMapper.xml @@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -54,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table + select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table