From 412e8bdc105595889231417143b411ada3c761bc Mon Sep 17 00:00:00 2001 From: ageer <ageerle@163.com> Date: 星期一, 31 三月 2025 19:13:27 +0800 Subject: [PATCH] feat: 1. 调整项目结构 2.增加插件管理 --- ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/util/VelocityUtils.java | 76 +++++++++++++++++++++++++++++++++++++- 1 files changed, 74 insertions(+), 2 deletions(-) diff --git a/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/util/VelocityUtils.java b/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/util/VelocityUtils.java index 1742348..eb52c85 100644 --- a/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/util/VelocityUtils.java +++ b/ruoyi-modules/ruoyi-generator/src/main/java/org/ruoyi/generator/util/VelocityUtils.java @@ -3,6 +3,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.Dict; +import cn.hutool.core.util.ObjectUtil; import org.ruoyi.generator.constant.GenConstants; import org.ruoyi.generator.domain.GenTable; import org.ruoyi.generator.domain.GenTableColumn; @@ -74,6 +75,27 @@ if (GenConstants.TPL_TREE.equals(tplCategory)) { setTreeVelocityContext(velocityContext, genTable); } + // 鍒ゆ柇鏄痬odal杩樻槸drawer + Dict paramsObj = JsonUtils.parseMap(genTable.getOptions()); + if (ObjectUtil.isNotNull(paramsObj)) { + String popupComponent = Optional + .ofNullable(paramsObj.getStr("popupComponent")) + .orElse("modal"); + velocityContext.put("popupComponent", popupComponent); + velocityContext.put("PopupComponent", StringUtils.capitalize(popupComponent)); + } else { + velocityContext.put("popupComponent", "modal"); + velocityContext.put("PopupComponent", "Modal"); + } + // 鍒ゆ柇鏄師鐢焌ntd琛ㄥ崟杩樻槸useForm琛ㄥ崟 + // native 鍘熺敓antd琛ㄥ崟 + // useForm useVbenForm + if (ObjectUtil.isNotNull(paramsObj)) { + String formComponent = Optional + .ofNullable(paramsObj.getStr("formComponent")) + .orElse("useForm"); + velocityContext.put("formComponent", formComponent); + } return velocityContext; } @@ -109,7 +131,7 @@ * @return 妯℃澘鍒楄〃 */ public static List<String> getTemplateList(String tplCategory) { - List<String> templates = new ArrayList<String>(); + List<String> templates = new ArrayList<>(); templates.add("vm/java/domain.java.vm"); templates.add("vm/java/vo.java.vm"); templates.add("vm/java/bo.java.vm"); @@ -134,6 +156,21 @@ } else if (GenConstants.TPL_TREE.equals(tplCategory)) { templates.add("vm/vue/index-tree.vue.vm"); } + + /** + * 娣诲姞vben5 + */ + templates.add("vm/vben5/api/index.ts.vm"); + templates.add("vm/vben5/api/model.d.ts.vm"); + templates.add("vm/vben5/views/data.ts.vm"); + if (GenConstants.TPL_CRUD.equals(tplCategory)) { + templates.add("vm/vben5/views/index_vben.vue.vm"); + templates.add("vm/vben5/views/popup.vue.vm"); + } else if (GenConstants.TPL_TREE.equals(tplCategory)) { + templates.add("vm/vben5/views/index_vben_tree.vue.vm"); + templates.add("vm/vben5/views/popup_tree.vue.vm"); + } + return templates; } @@ -186,6 +223,38 @@ } else if (template.contains("index-tree.vue.vm")) { fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName); } + + // 鍒ゆ柇鏄痬odal杩樻槸drawer + Dict paramsObj = JsonUtils.parseMap(genTable.getOptions()); + String popupComponent = "modal"; + if (ObjectUtil.isNotNull(paramsObj)) { + popupComponent = Optional + .ofNullable(paramsObj.getStr("popupComponent")) + .orElse("modal"); + } + String vben5Path = "vben5"; + if (template.contains("vm/vben5/api/index.ts.vm")) { + fileName = StringUtils.format("{}/api/{}/{}/index.ts", vben5Path, moduleName, businessName); + } + if (template.contains("vm/vben5/api/model.d.ts.vm")) { + fileName = StringUtils.format("{}/api/{}/{}/model.d.ts", vben5Path, moduleName, businessName); + } + if (template.contains("vm/vben5/views/index_vben.vue.vm")) { + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vben5Path, moduleName, businessName); + } + if (template.contains("vm/vben5/views/index_vben_tree.vue.vm")) { + fileName = StringUtils.format("{}/views/{}/{}/index.vue", vben5Path, moduleName, businessName); + } + if (template.contains("vm/vben5/views/data.ts.vm")) { + fileName = StringUtils.format("{}/views/{}/{}/data.ts", vben5Path, moduleName, businessName); + } + if (template.contains("vm/vben5/views/popup.vue.vm")) { + fileName = StringUtils.format("{}/views/{}/{}/{}-{}.vue", vben5Path, moduleName, businessName, businessName, popupComponent); + } + if (template.contains("vm/vben5/views/popup_tree.vue.vm")) { + fileName = StringUtils.format("{}/views/{}/{}/{}-{}.vue", vben5Path, moduleName, businessName, businessName, popupComponent); + } + return fileName; } @@ -208,13 +277,16 @@ */ public static HashSet<String> getImportList(GenTable genTable) { List<GenTableColumn> columns = genTable.getColumns(); - HashSet<String> importList = new HashSet<String>(); + HashSet<String> importList = new HashSet<>(); for (GenTableColumn column : columns) { if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) { importList.add("java.util.Date"); importList.add("com.fasterxml.jackson.annotation.JsonFormat"); } else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) { importList.add("java.math.BigDecimal"); + } else if (!column.isSuperColumn() && "imageUpload".equals(column.getHtmlType())) { + importList.add("org.dromara.common.translation.annotation.Translation"); + importList.add("org.dromara.common.translation.constant.TransConstant"); } } return importList; -- Gitblit v1.9.3