From b0c25ea9f45149303c11e40dbb610b7f90e5d875 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 2 Feb 2022 13:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=9A=E6=A8=A1=E5=9D=97=E9=87=8D=E6=9E=84?= =?UTF-8?q?=2011=EF=BC=9A=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=99=A8=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdminServerApplication.java | 7 +- .../config/AdminServerConfiguration.java | 2 +- .../framework/monitor/package-info.java | 2 +- ...芋道 Spring Boot 监控工具 Admin 入门》.md | 0 .../framework/package-info.java | 2 +- .../security/SecurityConfiguration.java | 2 +- .../src/main/resources/application-local.yaml | 15 ++--- .../src/main/resources/application.yaml | 7 +- .../BaseDbAndRedisIntegrationTest.java | 2 +- .../adminserver/BaseRedisIntegrationTest.java | 2 +- .../quartz/core/SchedulerManagerTest.java | 4 +- .../redis/core/stream/RedisStreamTest.java | 4 +- .../sms/SysSmsServiceIntegrationTest.java | 2 +- ...ToolInformationSchemaColumnMapperTest.java | 2 +- .../ToolInformationSchemaTableMapperTest.java | 2 +- .../codegen/ToolCodegenEngineTest.java | 2 +- .../codegen/ToolCodegenSQLParserTest.java | 2 +- .../codegen/ToolCodegenServiceImplTest.java | 2 +- yudao-admin-ui/src/utils/dict.js | 1 + .../src/views/tool/codegen/genInfoForm.vue | 22 +++++-- .../config/YudaoMybatisAutoConfiguration.java | 4 +- .../definition/BpmFormServiceTest.java | 2 +- .../definition/BpmUserGroupServiceTest.java | 2 +- .../BaseDbUnitTest.java | 2 +- .../yudao-module-tool-impl/pom.xml | 5 ++ .../admin/codegen/CodegenController.java | 6 +- .../codegen/vo/table/CodegenTableBaseVO.java | 4 ++ .../dataobject/codegen/CodegenTableDO.java | 7 ++ .../tool/enums/codegen/CodegenSceneEnum.java | 31 +++++++++ .../tool/service/codegen/CodegenService.java | 11 ++-- .../service/codegen/CodegenServiceImpl.java | 19 ++++-- .../service/codegen/inner/CodegenBuilder.java | 41 ++---------- .../service/codegen/inner/CodegenEngine.java | 66 +++++++++++-------- .../codegen/java/controller/controller.vm | 10 +-- .../codegen/java/controller/vo/_column.vm | 0 .../codegen/java/controller/vo/baseVO.vm | 2 +- .../codegen/java/controller/vo/createReqVO.vm | 2 +- .../codegen/java/controller/vo/excelVO.vm | 2 +- .../codegen/java/controller/vo/exportReqVO.vm | 2 +- .../codegen/java/controller/vo/pageReqVO.vm | 2 +- .../codegen/java/controller/vo/respVO.vm | 2 +- .../codegen/java/controller/vo/updateReqVO.vm | 2 +- .../resources/codegen/java/convert/convert.vm | 6 +- .../src/main/resources/codegen/java/dal/do.vm | 2 +- .../main/resources/codegen/java/dal/mapper.vm | 6 +- .../resources/codegen/java/enums/errorcode.vm | 0 .../resources/codegen/java/service/service.vm | 6 +- .../codegen/java/service/serviceImpl.vm | 14 ++-- .../codegen/java/test/serviceTest.vm | 12 ++-- .../src/main/resources/codegen/sql/sql.vm | 4 +- .../main/resources/codegen/vue/api/api.js.vm | 0 .../resources/codegen/vue/views/index.vue.vm | 0 52 files changed, 195 insertions(+), 163 deletions(-) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/{adminserver => server}/AdminServerApplication.java (65%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/{adminserver => server}/framework/monitor/config/AdminServerConfiguration.java (76%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/{adminserver => server}/framework/monitor/package-info.java (53%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/{adminserver => server}/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md (100%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/{adminserver => server}/framework/package-info.java (65%) rename yudao-admin-server/src/main/java/cn/iocoder/yudao/{adminserver => server}/framework/security/SecurityConfiguration.java (97%) rename yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/{adminserver => server}/BaseDbUnitTest.java (98%) create mode 100644 yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/controller.vm (90%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/_column.vm (100%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/baseVO.vm (91%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/createReqVO.vm (91%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/excelVO.vm (90%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/exportReqVO.vm (94%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/pageReqVO.vm (94%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/respVO.vm (88%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/controller/vo/updateReqVO.vm (91%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/convert/convert.vm (74%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/dal/do.vm (90%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/dal/mapper.vm (89%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/enums/errorcode.vm (100%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/service/service.vm (85%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/service/serviceImpl.vm (77%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/java/test/serviceTest.vm (90%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/sql/sql.vm (94%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/vue/api/api.js.vm (100%) rename {yudao-admin-server => yudao-module-tool/yudao-module-tool-impl}/src/main/resources/codegen/vue/views/index.vue.vm (100%) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/AdminServerApplication.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/AdminServerApplication.java similarity index 65% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/AdminServerApplication.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/AdminServerApplication.java index 2adf77b80..db8e7fd5d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/AdminServerApplication.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/AdminServerApplication.java @@ -1,11 +1,10 @@ -package cn.iocoder.yudao.adminserver; +package cn.iocoder.yudao.server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} 和 ${yudao.core-service.base-package} -@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}", "${yudao.core-service.base-package}", - "${yudao.info.base-package2}"}) // TODO 芋艿:重构 +@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} +@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}) public class AdminServerApplication { public static void main(String[] args) { diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/config/AdminServerConfiguration.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java similarity index 76% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/config/AdminServerConfiguration.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java index c9614410d..f3784570d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/config/AdminServerConfiguration.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.framework.monitor.config; +package cn.iocoder.yudao.server.framework.monitor.config; import de.codecentric.boot.admin.server.config.EnableAdminServer; import org.springframework.context.annotation.Configuration; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java similarity index 53% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/package-info.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java index 0d380cfaa..99a6c75bd 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/package-info.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java @@ -1,4 +1,4 @@ /** * 使用 Spring Boot Admin 实现简单的监控平台 */ -package cn.iocoder.yudao.adminserver.framework.monitor; +package cn.iocoder.yudao.server.framework.monitor; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md similarity index 100% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/package-info.java similarity index 65% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/package-info.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/package-info.java index fcb2a0936..bca006708 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/package-info.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/package-info.java @@ -3,4 +3,4 @@ * * @author 芋道源码 */ -package cn.iocoder.yudao.adminserver.framework; +package cn.iocoder.yudao.server.framework; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java similarity index 97% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java rename to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java index 2d911a675..0a698bea9 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.framework.security; +package cn.iocoder.yudao.server.framework.security; import cn.iocoder.yudao.framework.web.config.WebProperties; import org.springframework.beans.factory.annotation.Value; diff --git a/yudao-admin-server/src/main/resources/application-local.yaml b/yudao-admin-server/src/main/resources/application-local.yaml index addd7fbfa..8cb2d7a8e 100644 --- a/yudao-admin-server/src/main/resources/application-local.yaml +++ b/yudao-admin-server/src/main/resources/application-local.yaml @@ -163,16 +163,11 @@ logging: name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 level: # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql: debug - cn.iocoder.yudao.adminserver.modules.infra.dal.mysql: debug - cn.iocoder.yudao.adminserver.modules.pay.dal.mysql: debug - cn.iocoder.yudao.adminserver.modules.system.dal.mysql: debug - cn.iocoder.yudao.adminserver.modules.tool.dal.mysql: debug - cn.iocoder.yudao.coreservice.modules.bpm.dal.mysql: debug - cn.iocoder.yudao.coreservice.modules.infra.dal.mysql: debug - cn.iocoder.yudao.coreservice.modules.pay.dal.mysql: debug - cn.iocoder.yudao.coreservice.modules.system.dal.mysql: debug - cn.iocoder.yudao.coreservice.modules.tool.dal.mysql: debug + cn.iocoder.yudao.module.bpm.dal.mysql: debug + cn.iocoder.yudao.module.infra.dal.mysql: debug + cn.iocoder.yudao.module.pay.dal.mysql: debug + cn.iocoder.yudao.module.system.dal.mysql: debug + cn.iocoder.yudao.module.tool.dal.mysql: debug --- #################### 微信公众号相关配置 #################### wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 diff --git a/yudao-admin-server/src/main/resources/application.yaml b/yudao-admin-server/src/main/resources/application.yaml index 14c5025d2..14fd67f31 100644 --- a/yudao-admin-server/src/main/resources/application.yaml +++ b/yudao-admin-server/src/main/resources/application.yaml @@ -40,17 +40,14 @@ mybatis-plus: id-type: AUTO # 自增 ID logic-delete-value: 1 # 逻辑已删除值(默认为 1) logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject, ${yudao.core-service.base-package}.modules.*.dal.dataobject + type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject --- #################### 芋道相关配置 #################### yudao: info: version: 1.0.0 - base-package: cn.iocoder.yudao.adminserver - base-package2: cn.iocoder.yudao.module - core-service: - base-package: cn.iocoder.yudao.coreservice + base-package: cn.iocoder.yudao web: admin-api: prefix: /admin-api diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java index 915715c33..cf7b03f59 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver; +package cn.iocoder.yudao.server; import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java index 78857e01f..d82d0daf5 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver; +package cn.iocoder.yudao.server; import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; import org.redisson.spring.starter.RedissonAutoConfiguration; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java index 72ce3cd77..0fb4cc662 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.framework.quartz.core; +package cn.iocoder.yudao.server.framework.quartz.core; import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob; import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; import org.junit.jupiter.api.Test; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java index a99c65e47..284fb1022 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.framework.redis.core.stream; +package cn.iocoder.yudao.server.framework.redis.core.stream; import cn.hutool.core.thread.ThreadUtil; -import cn.iocoder.yudao.adminserver.BaseRedisIntegrationTest; +import cn.iocoder.yudao.server.BaseRedisIntegrationTest; import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer; import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java index ad63132b9..f3fab8985 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.sms; import cn.hutool.core.map.MapUtil; import cn.hutool.core.thread.ThreadUtil; -import cn.iocoder.yudao.adminserver.BaseDbAndRedisIntegrationTest; +import cn.iocoder.yudao.server.BaseDbAndRedisIntegrationTest; import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; import cn.iocoder.yudao.module.system.mq.producer.sms.SysSmsProducer; import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java index f945ddbe2..c8ef7018e 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.tool.dal.mysql.codegen; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO; import org.junit.jupiter.api.Test; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java index 88b4c58b2..43f8f4cbc 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.tool.dal.mysql.codegen; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import javax.annotation.Resource; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java index 6a461f0c0..6d9fd3d98 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.tool.service.codegen; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO; import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java index e498dc02e..5d7f6365b 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.tool.service.codegen; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser; import org.junit.jupiter.api.Test; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java index cedd3870a..27bf28d06 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.tool.service.codegen; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl; import org.junit.jupiter.api.Test; diff --git a/yudao-admin-ui/src/utils/dict.js b/yudao-admin-ui/src/utils/dict.js index c3813c31a..1c46aebe0 100644 --- a/yudao-admin-ui/src/utils/dict.js +++ b/yudao-admin-ui/src/utils/dict.js @@ -33,6 +33,7 @@ export const DICT_TYPE = { // ========== TOOL 模块 ========== TOOL_CODEGEN_TEMPLATE_TYPE: 'tool_codegen_template_type', + TOOL_CODEGEN_SCENE: 'tool_codegen_scene', // ========== BPM 模块 ========== BPM_MODEL_CATEGORY: 'bpm_model_category', diff --git a/yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue b/yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue index 187baf0d6..e3827eaba 100644 --- a/yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue +++ b/yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue @@ -2,15 +2,20 @@ - + 生成模板 - + + + + + + + 生成模板 + + @@ -249,6 +254,9 @@ export default { templateType: [ { required: true, message: "请选择生成模板", trigger: "blur" } ], + scene: [ + { required: true, message: "请选择生成场景", trigger: "blur" } + ], // packageName: [ // { required: true, message: "请输入生成包路径", trigger: "blur" } // ], diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java index 7e2576137..f8eeeef87 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java @@ -15,9 +15,7 @@ import org.springframework.context.annotation.Configuration; * @author 芋道源码 */ @Configuration -@MapperScan(value = {"${yudao.info.base-package}", "${yudao.core-service.base-package}", - "${yudao.info.base-package2}"}, - annotationClass = Mapper.class, +@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 public class YudaoMybatisAutoConfiguration { diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java index ca9d675fe..75e1727c8 100644 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java +++ b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.bpm.service.definition; import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java index 9c04d644d..494d10442 100644 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java +++ b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.bpm.service.definition; -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; +import cn.iocoder.yudao.server.BaseDbUnitTest; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; diff --git a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java similarity index 98% rename from yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java rename to yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java index 5f7daeded..592545af5 100644 --- a/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java +++ b/yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver; +package cn.iocoder.yudao.server; import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; diff --git a/yudao-module-tool/yudao-module-tool-impl/pom.xml b/yudao-module-tool/yudao-module-tool-impl/pom.xml index 8e998e0e8..2e2c35c7f 100644 --- a/yudao-module-tool/yudao-module-tool-impl/pom.xml +++ b/yudao-module-tool/yudao-module-tool-impl/pom.xml @@ -23,6 +23,11 @@ yudao-module-tool-api ${revision} + + cn.iocoder.boot + yudao-module-system-api + ${revision} + diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java index 4523b1ab4..c7d6e9324 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java @@ -4,6 +4,7 @@ import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ZipUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenDetailRespVO; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenPreviewRespVO; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; @@ -36,6 +37,7 @@ import java.util.Map; import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Api(tags = "管理后台 - 代码生成器") @RestController @@ -88,7 +90,7 @@ public class CodegenController { @PostMapping("/create-list-from-db") @PreAuthorize("@ss.hasPermission('tool:codegen:create')") public CommonResult> createCodegenListFromDB(@RequestParam("tableNames") List tableNames) { - return success(codegenService.createCodegenListFromDB(tableNames)); + return success(codegenService.createCodegenListFromDB(getLoginUserId(), tableNames)); } @ApiOperation("基于 SQL 建表语句,创建代码生成器的表和字段定义") @@ -96,7 +98,7 @@ public class CodegenController { @PostMapping("/create-list-from-sql") @PreAuthorize("@ss.hasPermission('tool:codegen:create')") public CommonResult createCodegenListFromSQL(@RequestParam("sql") String sql) { - return success(codegenService.createCodegenListFromSQL(sql)); + return success(codegenService.createCodegenListFromSQL(getLoginUserId(), sql)); } @ApiOperation("更新数据库的表和字段定义") diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java index 1b57219fa..dbe155c8a 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java @@ -16,6 +16,10 @@ public class CodegenTableBaseVO { @NotNull(message = "导入类型不能为空") private Integer importType; + @ApiModelProperty(value = "生成场景", required = true, example = "1", notes = "参见 CodegenSceneEnum 枚举") + @NotNull(message = "导入类型不能为空") + private Integer scene; + @ApiModelProperty(value = "表名称", required = true, example = "yudao") @NotNull(message = "表名称不能为空") private String tableName; diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java index c299e013b..9585cb388 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.tool.dal.dataobject.codegen; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; import cn.iocoder.yudao.module.tool.enums.codegen.CodegenTemplateTypeEnum; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -29,6 +30,12 @@ public class CodegenTableDO extends BaseDO { * 枚举 {@link CodegenTemplateTypeEnum} */ private Integer importType; + /** + * 生成场景 + * + * 枚举 {@link CodegenSceneEnum} + */ + private Integer scene; // ========== 表相关字段 ========== diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java new file mode 100644 index 000000000..84f309a93 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.tool.enums.codegen; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 代码生成的场景枚举 + * + * @author 芋道源码 + */ +@AllArgsConstructor +@Getter +public enum CodegenSceneEnum { + + ADMIN(1, "管理后台", "admin"), + APP(2, "用户 APP", "app"); + + /** + * 场景 + */ + private final Integer scene; + /** + * 场景名 + */ + private final String name; + /** + * 基础包名 + */ + private final String basePackage; + +} diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java index 7b8f84b2c..75327b331 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java @@ -20,26 +20,29 @@ public interface CodegenService { /** * 基于 SQL 建表语句,创建代码生成器的表定义 * + * @param userId 用户编号 * @param sql SQL 建表语句 * @return 创建的表定义的编号 */ - Long createCodegenListFromSQL(String sql); + Long createCodegenListFromSQL(Long userId, String sql); /** * 基于数据库的表结构,创建代码生成器的表定义 * + * @param userId 用户编号 * @param tableName 表名称 * @return 创建的表定义的编号 */ - Long createCodegen(String tableName); + Long createCodegen(Long userId, String tableName); /** - * 基于 {@link #createCodegen(String)} 的批量创建 + * 基于 {@link #createCodegen(Long, String)} 的批量创建 * + * @param userId 用户编号 * @param tableNames 表名称数组 * @return 创建的表定义的编号数组 */ - List createCodegenListFromDB(List tableNames); + List createCodegenListFromDB(Long userId, List tableNames); /** * 更新数据库的表和字段定义 diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java index f478244d0..93210f26d 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tool.service.codegen; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO; @@ -50,6 +51,9 @@ public class CodegenServiceImpl implements CodegenService { @Resource private CodegenColumnMapper codegenColumnMapper; + @Resource + private AdminUserApi userApi; + @Resource private CodegenBuilder codegenBuilder; @Resource @@ -58,7 +62,7 @@ public class CodegenServiceImpl implements CodegenService { @Resource private CodegenProperties codegenProperties; - private Long createCodegen0(CodegenImportTypeEnum importType, + private Long createCodegen0(Long userId, CodegenImportTypeEnum importType, SchemaTableDO schemaTable, List schemaColumns) { // 校验导入的表和字段非空 if (schemaTable == null) { @@ -75,6 +79,7 @@ public class CodegenServiceImpl implements CodegenService { // 构建 CodegenTableDO 对象,插入到 DB 中 CodegenTableDO table = codegenBuilder.buildTable(schemaTable); table.setImportType(importType.getType()); + table.setAuthor(userApi.getUser(userId).getNickname()); codegenTableMapper.insert(table); // 构建 CodegenColumnDO 数组,插入到 DB 中 List columns = codegenBuilder.buildColumns(schemaColumns); @@ -86,7 +91,7 @@ public class CodegenServiceImpl implements CodegenService { } @Override - public Long createCodegenListFromSQL(String sql) { + public Long createCodegenListFromSQL(Long userId, String sql) { // 从 SQL 中,获得数据库表结构 SchemaTableDO schemaTable; List schemaColumns; @@ -98,26 +103,26 @@ public class CodegenServiceImpl implements CodegenService { throw exception(CODEGEN_PARSE_SQL_ERROR); } // 导入 - return this.createCodegen0(CodegenImportTypeEnum.SQL, schemaTable, schemaColumns); + return this.createCodegen0(userId, CodegenImportTypeEnum.SQL, schemaTable, schemaColumns); } @Override - public Long createCodegen(String tableName) { + public Long createCodegen(Long userId, String tableName) { // 获取当前schema String tableSchema = codegenProperties.getDbSchemas().iterator().next(); // 从数据库中,获得数据库表结构 SchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName); List schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, tableName); // 导入 - return this.createCodegen0(CodegenImportTypeEnum.DB, schemaTable, schemaColumns); + return this.createCodegen0(userId, CodegenImportTypeEnum.DB, schemaTable, schemaColumns); } @Override @Transactional(rollbackFor = Exception.class) - public List createCodegenListFromDB(List tableNames) { + public List createCodegenListFromDB(Long userId, List tableNames) { List ids = new ArrayList<>(tableNames.size()); // 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量 - tableNames.forEach(tableName -> ids.add(createCodegen(tableName))); + tableNames.forEach(tableName -> ids.add(createCodegen(userId, tableName))); return ids; } diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java index cf9b6c35d..774aea208 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java @@ -27,18 +27,6 @@ import static cn.hutool.core.text.CharSequenceUtil.*; @Component public class CodegenBuilder { - /** - * Module 名字的映射 TODO 后续梳理到配置类 - * - * key:模块的完整名 - * value:模块的缩写名 - */ - private static final Map moduleNames = MapUtil.builder() - .put("system", "sys") - .put("infra", "inf") - .put("tool", "tool") - .build(); - /** * 字段名与 {@link CodegenColumnListConditionEnum} 的默认映射 * 注意,字段的匹配以后缀的方式 @@ -125,8 +113,10 @@ public class CodegenBuilder { * @param table 表定义 */ private void initTableDefault(CodegenTableDO table) { - table.setModuleName(getFullModuleName(StrUtil.subBefore(table.getTableName(), - '_', false))); // 第一个 _ 前缀的前面,作为 module 名字 + // 以 system_dept 举例子。moduleName 为 system、businessName 为 dept、className 为 SystemDept + // 如果不希望 System 前缀,则可以手动在【代码生成 - 修改生成配置 - 基本信息】,将实体类名称改为 Dept 即可 + table.setModuleName(StrUtil.subBefore(table.getTableName(), + '_', false)); // 第一个 _ 前缀的前面,作为 module 名字 table.setBusinessName(toCamelCase(subAfter(table.getTableName(), '_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰 table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 @@ -208,27 +198,4 @@ public class CodegenBuilder { } } - /** - * 获得模块的缩略名 - * - * @param fullModuleName 模块的完整名 - * @return 缩略名 - */ - public String getSimpleModuleName(String fullModuleName) { - return moduleNames.getOrDefault(fullModuleName, fullModuleName); - } - - /** - * 获得模块的完整名 - * - * @param shortModuleName 模块的缩略名 - * @return 完整名 - */ - public String getFullModuleName(String shortModuleName) { - return moduleNames.entrySet().stream() - .filter(entry -> entry.getValue().equals(shortModuleName)) // 匹配 - .findFirst().map(Map.Entry::getKey) // 返回 key - .orElse(shortModuleName); // 兜底返回 shortModuleName - } - } diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java index 89a3af161..21e6ecb9e 100644 --- a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java @@ -53,38 +53,39 @@ public class CodegenEngine { * value:生成的路径 */ private static final Map TEMPLATES = MapUtil.builder(new LinkedHashMap<>()) // 有序 - // Java Main + // Java module-impl Main .put(javaTemplatePath("controller/vo/baseVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}BaseVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}BaseVO")) .put(javaTemplatePath("controller/vo/createReqVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO")) .put(javaTemplatePath("controller/vo/pageReqVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO")) .put(javaTemplatePath("controller/vo/respVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) .put(javaTemplatePath("controller/vo/updateReqVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) .put(javaTemplatePath("controller/vo/exportReqVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) .put(javaTemplatePath("controller/vo/excelVO"), - javaFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) .put(javaTemplatePath("controller/controller"), - javaFilePath("controller/${table.businessName}/${table.className}Controller")) + javaModuleImplMainFilePath("controller/${table.businessName}/${table.className}Controller")) .put(javaTemplatePath("convert/convert"), - javaFilePath("convert/${table.businessName}/${table.className}Convert")) + javaModuleImplMainFilePath("convert/${table.businessName}/${table.className}Convert")) .put(javaTemplatePath("dal/do"), - javaFilePath("dal/dataobject/${table.businessName}/${table.className}DO")) + javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${table.className}DO")) .put(javaTemplatePath("dal/mapper"), - javaFilePath("dal/mysql/${table.businessName}/${table.className}Mapper")) - .put(javaTemplatePath("enums/errorcode"), - javaFilePath("enums/${simpleModuleName_upperFirst}ErrorCodeConstants")) + javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${table.className}Mapper")) .put(javaTemplatePath("service/serviceImpl"), - javaFilePath("service/${table.businessName}/impl/${table.className}ServiceImpl")) + javaModuleImplMainFilePath("service/${table.businessName}/${table.className}ServiceImpl")) .put(javaTemplatePath("service/service"), - javaFilePath("service/${table.businessName}/${table.className}Service")) - // Java Test + javaModuleImplMainFilePath("service/${table.businessName}/${table.className}Service")) + // Java module-impl Test .put(javaTemplatePath("test/serviceTest"), - javaFilePath("service/${table.businessName}/${table.className}ServiceTest")) + javaModuleImplTestFilePath("service/${table.businessName}/${table.className}ServiceTest")) + // Java module-api Main + .put(javaTemplatePath("enums/errorcode"), + javaModuleApiMainFilePath("enums/ErrorCodeConstants")) // Vue .put(vueTemplatePath("views/index.vue"), vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue")) @@ -121,7 +122,7 @@ public class CodegenEngine { // 全局配置 globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); globalBindingMap.put("baseFrameworkPackage", StrUtil.subBefore(codegenProperties.getBasePackage(), - '.', true) + '.' + "framework"); + '.', true) + '.' + "framework"); // 用于后续获取测试类的 package 地址 // 全局 Java Bean globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); globalBindingMap.put("PageResultClassName", PageResult.class.getName()); @@ -149,13 +150,9 @@ public class CodegenEngine { bindingMap.put("table", table); bindingMap.put("columns", columns); bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 - // moduleName 相关 - String simpleModuleName = codegenBuilder.getSimpleModuleName(table.getModuleName()); - bindingMap.put("simpleModuleName", simpleModuleName); // 将 system 转成 sys - bindingMap.put("simpleModuleName_upperFirst", upperFirst(simpleModuleName)); // 将 sys 转成 Sys // className 相关 // 去掉指定前缀 将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 - String simpleClassName = removePrefix(table.getClassName(), upperFirst(simpleModuleName)); + String simpleClassName = removePrefix(table.getClassName(), upperFirst(table.getModuleName())); bindingMap.put("simpleClassName", simpleClassName); bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量 @@ -177,8 +174,6 @@ public class CodegenEngine { private String formatFilePath(String filePath, Map bindingMap) { filePath = StrUtil.replace(filePath, "${basePackage}", getStr(bindingMap, "basePackage").replaceAll("\\.", "/")); - filePath = StrUtil.replace(filePath, "${simpleModuleName_upperFirst}", - getStr(bindingMap, "simpleModuleName_upperFirst")); filePath = StrUtil.replace(filePath, "${classNameVar}", getStr(bindingMap, "classNameVar")); @@ -194,8 +189,23 @@ public class CodegenEngine { return "codegen/java/" + path + ".vm"; } - private static String javaFilePath(String path) { - return "java/${basePackage}/modules/${table.moduleName}/" + path + ".java"; + private static String javaModuleImplMainFilePath(String path) { + return javaModuleFilePath(path, "impl", "main"); + } + + private static String javaModuleApiMainFilePath(String path) { + return javaModuleFilePath(path, "api", "main"); + + } + + private static String javaModuleImplTestFilePath(String path) { + return javaModuleFilePath(path, "impl", "test"); + } + + private static String javaModuleFilePath(String path, String module, String src) { + return "yudao-module-${table.moduleName}/" + // 顶级模块 + "yudao-module-${table.moduleName}-" + module + "/" + // 子模块 + "src/" + src + "/java/${basePackage}/module/${table.moduleName}/" + path + ".java"; } private static String vueTemplatePath(String path) { diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/controller.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm similarity index 90% rename from yudao-admin-server/src/main/resources/codegen/java/controller/controller.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm index 6038d3937..7c5e63a67 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/controller.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -22,10 +22,10 @@ import ${ExcelUtilsClassName}; import ${OperateLogClassName}; import static ${OperateTypeEnumClassName}.*; -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; -import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; -import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service; +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; @Api(tags = "${table.classComment}") @RestController diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/_column.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/_column.vm similarity index 100% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/_column.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/_column.vm diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/baseVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/baseVO.vm similarity index 91% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/baseVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/baseVO.vm index 705869a8d..43fc531c9 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/baseVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/baseVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/createReqVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/createReqVO.vm similarity index 91% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/createReqVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/createReqVO.vm index cfb288241..145c36a0e 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/createReqVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/createReqVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/excelVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/excelVO.vm similarity index 90% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/excelVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/excelVO.vm index b91e4e178..0698ce5d6 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/excelVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/excelVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/exportReqVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/exportReqVO.vm similarity index 94% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/exportReqVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/exportReqVO.vm index cd0e340e8..42b88582c 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/exportReqVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/exportReqVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/pageReqVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/pageReqVO.vm similarity index 94% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/pageReqVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/pageReqVO.vm index 0ac69e94d..721c67d2b 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/pageReqVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/pageReqVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/respVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/respVO.vm similarity index 88% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/respVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/respVO.vm index a100dd16c..b52c98bb6 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/respVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/respVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/updateReqVO.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/updateReqVO.vm similarity index 91% rename from yudao-admin-server/src/main/resources/codegen/java/controller/vo/updateReqVO.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/updateReqVO.vm index a05ae8d66..67bd1da2c 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/controller/vo/updateReqVO.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/updateReqVO.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/convert/convert.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/convert/convert.vm similarity index 74% rename from yudao-admin-server/src/main/resources/codegen/java/convert/convert.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/convert/convert.vm index 4302bd2c5..43bf1d0b2 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/convert/convert.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/convert/convert.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}; +package ${basePackage}.module.${table.moduleName}.convert.${table.businessName}; import java.util.*; @@ -6,8 +6,8 @@ import ${PageResultClassName}; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; /** * ${table.classComment} Convert diff --git a/yudao-admin-server/src/main/resources/codegen/java/dal/do.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/do.vm similarity index 90% rename from yudao-admin-server/src/main/resources/codegen/java/dal/do.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/do.vm index 8f10fd5e4..687a09010 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/dal/do.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/do.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}; +package ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}; import lombok.*; import java.util.*; diff --git a/yudao-admin-server/src/main/resources/codegen/java/dal/mapper.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/mapper.vm similarity index 89% rename from yudao-admin-server/src/main/resources/codegen/java/dal/mapper.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/mapper.vm index 2452ca8f6..54831fc60 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/dal/mapper.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/mapper.vm @@ -1,13 +1,13 @@ -package ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}; +package ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}; import java.util.*; import ${PageResultClassName}; import ${QueryWrapperClassName}; import ${BaseMapperClassName}; -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import org.apache.ibatis.annotations.Mapper; -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; ## 字段模板 #macro(listCondition) diff --git a/yudao-admin-server/src/main/resources/codegen/java/enums/errorcode.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/enums/errorcode.vm similarity index 100% rename from yudao-admin-server/src/main/resources/codegen/java/enums/errorcode.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/enums/errorcode.vm diff --git a/yudao-admin-server/src/main/resources/codegen/java/service/service.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/service.vm similarity index 85% rename from yudao-admin-server/src/main/resources/codegen/java/service/service.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/service.vm index 17a9b3953..9895780c3 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/service/service.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/service.vm @@ -1,9 +1,9 @@ -package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}; +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; import java.util.*; import javax.validation.*; -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${PageResultClassName}; /** diff --git a/yudao-admin-server/src/main/resources/codegen/java/service/serviceImpl.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/serviceImpl.vm similarity index 77% rename from yudao-admin-server/src/main/resources/codegen/java/service/serviceImpl.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/serviceImpl.vm index 33201a6d8..979e312ab 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/service/serviceImpl.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/serviceImpl.vm @@ -1,20 +1,20 @@ -package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl; +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; import java.util.*; -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${PageResultClassName}; -import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; -import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; -import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service; +import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; +import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; import static ${ServiceExceptionUtilClassName}.exception; -import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; +import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; /** * ${table.classComment} Service 实现类 diff --git a/yudao-admin-server/src/main/resources/codegen/java/test/serviceTest.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/test/serviceTest.vm similarity index 90% rename from yudao-admin-server/src/main/resources/codegen/java/test/serviceTest.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/test/serviceTest.vm index 511d65148..e4556c49b 100644 --- a/yudao-admin-server/src/main/resources/codegen/java/test/serviceTest.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/test/serviceTest.vm @@ -1,4 +1,4 @@ -package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}; +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; @@ -6,10 +6,10 @@ import org.springframework.boot.test.mock.mockito.MockBean; import javax.annotation.Resource; import ${basePackage}.BaseDbUnitTest; -import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl; -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; -import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl; +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; +import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; import ${PageResultClassName}; import javax.annotation.Resource; @@ -17,7 +17,7 @@ import org.springframework.context.annotation.Import; import java.util.*; import static cn.hutool.core.util.RandomUtil.*; -import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; +import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; import static ${baseFrameworkPackage}.test.core.util.AssertUtils.*; import static ${baseFrameworkPackage}.test.core.util.RandomUtils.*; import static ${ObjectUtilsClassName}.*; diff --git a/yudao-admin-server/src/main/resources/codegen/sql/sql.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/sql/sql.vm similarity index 94% rename from yudao-admin-server/src/main/resources/codegen/sql/sql.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/sql/sql.vm index 741016c23..25d76ae1d 100644 --- a/yudao-admin-server/src/main/resources/codegen/sql/sql.vm +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/sql/sql.vm @@ -1,5 +1,5 @@ -- 菜单 SQL -INSERT INTO `sys_menu`( +INSERT INTO `system_menu`( `name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status` ) @@ -16,7 +16,7 @@ SELECT @parentId := LAST_INSERT_ID(); #set ($functionOps = ['query', 'create', 'update', 'delete', 'export']) #foreach ($functionName in $functionNames) #set ($index = $foreach.count - 1) -INSERT INTO `sys_menu`( +INSERT INTO `system_menu`( `name`, `permission`, `menu_type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status` ) diff --git a/yudao-admin-server/src/main/resources/codegen/vue/api/api.js.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/api/api.js.vm similarity index 100% rename from yudao-admin-server/src/main/resources/codegen/vue/api/api.js.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/api/api.js.vm diff --git a/yudao-admin-server/src/main/resources/codegen/vue/views/index.vue.vm b/yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/views/index.vue.vm similarity index 100% rename from yudao-admin-server/src/main/resources/codegen/vue/views/index.vue.vm rename to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/views/index.vue.vm