Commit b0c25ea9f45149303c11e40dbb610b7f90e5d875
1 parent
8d593849
多模块重构 11:修改代码生成器的实现
Showing
52 changed files
with
195 additions
and
163 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/AdminServerApplication.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/AdminServerApplication.java
| 1 | -package cn.iocoder.yudao.adminserver; | 1 | +package cn.iocoder.yudao.server; |
| 2 | 2 | ||
| 3 | import org.springframework.boot.SpringApplication; | 3 | import org.springframework.boot.SpringApplication; |
| 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| 5 | 5 | ||
| 6 | -@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} 和 ${yudao.core-service.base-package} | ||
| 7 | -@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}", "${yudao.core-service.base-package}", | ||
| 8 | - "${yudao.info.base-package2}"}) // TODO 芋艿:重构 | 6 | +@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} |
| 7 | +@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"}) | ||
| 9 | public class AdminServerApplication { | 8 | public class AdminServerApplication { |
| 10 | 9 | ||
| 11 | public static void main(String[] args) { | 10 | public static void main(String[] args) { |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/config/AdminServerConfiguration.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java
| 1 | -package cn.iocoder.yudao.adminserver.framework.monitor.config; | 1 | +package cn.iocoder.yudao.server.framework.monitor.config; |
| 2 | 2 | ||
| 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; | 3 | import de.codecentric.boot.admin.server.config.EnableAdminServer; |
| 4 | import org.springframework.context.annotation.Configuration; | 4 | import org.springframework.context.annotation.Configuration; |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/package-info.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/package-info.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/package-info.java
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/framework/security/SecurityConfiguration.java renamed to yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java
| 1 | -package cn.iocoder.yudao.adminserver.framework.security; | 1 | +package cn.iocoder.yudao.server.framework.security; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.web.config.WebProperties; | 3 | import cn.iocoder.yudao.framework.web.config.WebProperties; |
| 4 | import org.springframework.beans.factory.annotation.Value; | 4 | import org.springframework.beans.factory.annotation.Value; |
yudao-admin-server/src/main/resources/application-local.yaml
| @@ -163,16 +163,11 @@ logging: | @@ -163,16 +163,11 @@ logging: | ||
| 163 | name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 | 163 | name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 |
| 164 | level: | 164 | level: |
| 165 | # 配置自己写的 MyBatis Mapper 打印日志 | 165 | # 配置自己写的 MyBatis Mapper 打印日志 |
| 166 | - cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql: debug | ||
| 167 | - cn.iocoder.yudao.adminserver.modules.infra.dal.mysql: debug | ||
| 168 | - cn.iocoder.yudao.adminserver.modules.pay.dal.mysql: debug | ||
| 169 | - cn.iocoder.yudao.adminserver.modules.system.dal.mysql: debug | ||
| 170 | - cn.iocoder.yudao.adminserver.modules.tool.dal.mysql: debug | ||
| 171 | - cn.iocoder.yudao.coreservice.modules.bpm.dal.mysql: debug | ||
| 172 | - cn.iocoder.yudao.coreservice.modules.infra.dal.mysql: debug | ||
| 173 | - cn.iocoder.yudao.coreservice.modules.pay.dal.mysql: debug | ||
| 174 | - cn.iocoder.yudao.coreservice.modules.system.dal.mysql: debug | ||
| 175 | - cn.iocoder.yudao.coreservice.modules.tool.dal.mysql: debug | 166 | + cn.iocoder.yudao.module.bpm.dal.mysql: debug |
| 167 | + cn.iocoder.yudao.module.infra.dal.mysql: debug | ||
| 168 | + cn.iocoder.yudao.module.pay.dal.mysql: debug | ||
| 169 | + cn.iocoder.yudao.module.system.dal.mysql: debug | ||
| 170 | + cn.iocoder.yudao.module.tool.dal.mysql: debug | ||
| 176 | 171 | ||
| 177 | --- #################### 微信公众号相关配置 #################### | 172 | --- #################### 微信公众号相关配置 #################### |
| 178 | wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 | 173 | wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 |
yudao-admin-server/src/main/resources/application.yaml
| @@ -40,17 +40,14 @@ mybatis-plus: | @@ -40,17 +40,14 @@ mybatis-plus: | ||
| 40 | id-type: AUTO # 自增 ID | 40 | id-type: AUTO # 自增 ID |
| 41 | logic-delete-value: 1 # 逻辑已删除值(默认为 1) | 41 | logic-delete-value: 1 # 逻辑已删除值(默认为 1) |
| 42 | logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) | 42 | logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) |
| 43 | - type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject, ${yudao.core-service.base-package}.modules.*.dal.dataobject | 43 | + type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject |
| 44 | 44 | ||
| 45 | --- #################### 芋道相关配置 #################### | 45 | --- #################### 芋道相关配置 #################### |
| 46 | 46 | ||
| 47 | yudao: | 47 | yudao: |
| 48 | info: | 48 | info: |
| 49 | version: 1.0.0 | 49 | version: 1.0.0 |
| 50 | - base-package: cn.iocoder.yudao.adminserver | ||
| 51 | - base-package2: cn.iocoder.yudao.module | ||
| 52 | - core-service: | ||
| 53 | - base-package: cn.iocoder.yudao.coreservice | 50 | + base-package: cn.iocoder.yudao |
| 54 | web: | 51 | web: |
| 55 | admin-api: | 52 | admin-api: |
| 56 | prefix: /admin-api | 53 | prefix: /admin-api |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java
| 1 | -package cn.iocoder.yudao.adminserver; | 1 | +package cn.iocoder.yudao.server; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; | 3 | import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; |
| 4 | import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; | 4 | import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java
| 1 | -package cn.iocoder.yudao.adminserver; | 1 | +package cn.iocoder.yudao.server; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; | 3 | import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; |
| 4 | import org.redisson.spring.starter.RedissonAutoConfiguration; | 4 | import org.redisson.spring.starter.RedissonAutoConfiguration; |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java
| 1 | -package cn.iocoder.yudao.adminserver.framework.quartz.core; | 1 | +package cn.iocoder.yudao.server.framework.quartz.core; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.StrUtil; | 3 | import cn.hutool.core.util.StrUtil; |
| 4 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 4 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 5 | import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob; | 5 | import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob; |
| 6 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; | 6 | import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; |
| 7 | import org.junit.jupiter.api.Test; | 7 | import org.junit.jupiter.api.Test; |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java
| 1 | -package cn.iocoder.yudao.adminserver.framework.redis.core.stream; | 1 | +package cn.iocoder.yudao.server.framework.redis.core.stream; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.thread.ThreadUtil; | 3 | import cn.hutool.core.thread.ThreadUtil; |
| 4 | -import cn.iocoder.yudao.adminserver.BaseRedisIntegrationTest; | 4 | +import cn.iocoder.yudao.server.BaseRedisIntegrationTest; |
| 5 | import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer; | 5 | import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer; |
| 6 | import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; | 6 | import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; |
| 7 | import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage; | 7 | import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage; |
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; | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.sms; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.map.MapUtil; | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | import cn.hutool.core.thread.ThreadUtil; | 4 | import cn.hutool.core.thread.ThreadUtil; |
| 5 | -import cn.iocoder.yudao.adminserver.BaseDbAndRedisIntegrationTest; | 5 | +import cn.iocoder.yudao.server.BaseDbAndRedisIntegrationTest; |
| 6 | import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; | 6 | import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; |
| 7 | import cn.iocoder.yudao.module.system.mq.producer.sms.SysSmsProducer; | 7 | import cn.iocoder.yudao.module.system.mq.producer.sms.SysSmsProducer; |
| 8 | import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl; | 8 | import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl; |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java
| 1 | package cn.iocoder.yudao.module.tool.dal.mysql.codegen; | 1 | package cn.iocoder.yudao.module.tool.dal.mysql.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 4 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO; | 4 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO; |
| 5 | import org.junit.jupiter.api.Test; | 5 | import org.junit.jupiter.api.Test; |
| 6 | 6 |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java
| 1 | package cn.iocoder.yudao.module.tool.dal.mysql.codegen; | 1 | package cn.iocoder.yudao.module.tool.dal.mysql.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 4 | 4 | ||
| 5 | import javax.annotation.Resource; | 5 | import javax.annotation.Resource; |
| 6 | 6 |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen; | 1 | package cn.iocoder.yudao.module.tool.service.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 4 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO; | 4 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO; |
| 5 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO; | 5 | import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO; |
| 6 | import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper; | 6 | import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper; |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen; | 1 | package cn.iocoder.yudao.module.tool.service.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 4 | import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser; | 4 | import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser; |
| 5 | import org.junit.jupiter.api.Test; | 5 | import org.junit.jupiter.api.Test; |
| 6 | 6 |
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java
| 1 | package cn.iocoder.yudao.module.tool.service.codegen; | 1 | package cn.iocoder.yudao.module.tool.service.codegen; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 4 | import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl; | 4 | import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl; |
| 5 | import org.junit.jupiter.api.Test; | 5 | import org.junit.jupiter.api.Test; |
| 6 | 6 |
yudao-admin-ui/src/utils/dict.js
| @@ -33,6 +33,7 @@ export const DICT_TYPE = { | @@ -33,6 +33,7 @@ export const DICT_TYPE = { | ||
| 33 | 33 | ||
| 34 | // ========== TOOL 模块 ========== | 34 | // ========== TOOL 模块 ========== |
| 35 | TOOL_CODEGEN_TEMPLATE_TYPE: 'tool_codegen_template_type', | 35 | TOOL_CODEGEN_TEMPLATE_TYPE: 'tool_codegen_template_type', |
| 36 | + TOOL_CODEGEN_SCENE: 'tool_codegen_scene', | ||
| 36 | 37 | ||
| 37 | // ========== BPM 模块 ========== | 38 | // ========== BPM 模块 ========== |
| 38 | BPM_MODEL_CATEGORY: 'bpm_model_category', | 39 | BPM_MODEL_CATEGORY: 'bpm_model_category', |
yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue
| @@ -2,15 +2,20 @@ | @@ -2,15 +2,20 @@ | ||
| 2 | <el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px"> | 2 | <el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px"> |
| 3 | <el-row> | 3 | <el-row> |
| 4 | <el-col :span="12"> | 4 | <el-col :span="12"> |
| 5 | - <el-form-item prop="tplCategory"> | 5 | + <el-form-item prop="templateType"> |
| 6 | <span slot="label">生成模板</span> | 6 | <span slot="label">生成模板</span> |
| 7 | <el-select v-model="info.templateType" @change="tplSelectChange"> | 7 | <el-select v-model="info.templateType" @change="tplSelectChange"> |
| 8 | - <el-option | ||
| 9 | - v-for="dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_TEMPLATE_TYPE)" | ||
| 10 | - :key="parseInt(dict.value)" | ||
| 11 | - :label="dict.label" | ||
| 12 | - :value="parseInt(dict.value)" | ||
| 13 | - /> | 8 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_TEMPLATE_TYPE)" |
| 9 | + :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/> | ||
| 10 | + </el-select> | ||
| 11 | + </el-form-item> | ||
| 12 | + </el-col> | ||
| 13 | + <el-col :span="12"> | ||
| 14 | + <el-form-item prop="scene"> | ||
| 15 | + <span slot="label">生成模板</span> | ||
| 16 | + <el-select v-model="info.scene"> | ||
| 17 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_SCENE)" | ||
| 18 | + :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/> | ||
| 14 | </el-select> | 19 | </el-select> |
| 15 | </el-form-item> | 20 | </el-form-item> |
| 16 | </el-col> | 21 | </el-col> |
| @@ -249,6 +254,9 @@ export default { | @@ -249,6 +254,9 @@ export default { | ||
| 249 | templateType: [ | 254 | templateType: [ |
| 250 | { required: true, message: "请选择生成模板", trigger: "blur" } | 255 | { required: true, message: "请选择生成模板", trigger: "blur" } |
| 251 | ], | 256 | ], |
| 257 | + scene: [ | ||
| 258 | + { required: true, message: "请选择生成场景", trigger: "blur" } | ||
| 259 | + ], | ||
| 252 | // packageName: [ | 260 | // packageName: [ |
| 253 | // { required: true, message: "请输入生成包路径", trigger: "blur" } | 261 | // { required: true, message: "请输入生成包路径", trigger: "blur" } |
| 254 | // ], | 262 | // ], |
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; | @@ -15,9 +15,7 @@ import org.springframework.context.annotation.Configuration; | ||
| 15 | * @author 芋道源码 | 15 | * @author 芋道源码 |
| 16 | */ | 16 | */ |
| 17 | @Configuration | 17 | @Configuration |
| 18 | -@MapperScan(value = {"${yudao.info.base-package}", "${yudao.core-service.base-package}", | ||
| 19 | - "${yudao.info.base-package2}"}, | ||
| 20 | - annotationClass = Mapper.class, | 18 | +@MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class, |
| 21 | lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 | 19 | lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载,目前仅用于单元测试 |
| 22 | public class YudaoMybatisAutoConfiguration { | 20 | public class YudaoMybatisAutoConfiguration { |
| 23 | 21 |
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java
| 1 | package cn.iocoder.yudao.module.bpm.service.definition; | 1 | package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.RandomUtil; | 3 | import cn.hutool.core.util.RandomUtil; |
| 4 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 4 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 5 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; | 5 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; |
| 6 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; | 6 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; |
| 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; |
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java
| 1 | package cn.iocoder.yudao.module.bpm.service.definition; | 1 | package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.adminserver.BaseDbUnitTest; | 3 | +import cn.iocoder.yudao.server.BaseDbUnitTest; |
| 4 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; | 4 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; |
| 5 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; | 5 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; |
| 6 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; | 6 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; |
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/adminserver/BaseDbUnitTest.java renamed to yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java
| 1 | -package cn.iocoder.yudao.adminserver; | 1 | +package cn.iocoder.yudao.server; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; | 3 | import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; |
| 4 | import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; | 4 | import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; |
yudao-module-tool/yudao-module-tool-impl/pom.xml
| @@ -23,6 +23,11 @@ | @@ -23,6 +23,11 @@ | ||
| 23 | <artifactId>yudao-module-tool-api</artifactId> | 23 | <artifactId>yudao-module-tool-api</artifactId> |
| 24 | <version>${revision}</version> | 24 | <version>${revision}</version> |
| 25 | </dependency> | 25 | </dependency> |
| 26 | + <dependency> | ||
| 27 | + <groupId>cn.iocoder.boot</groupId> | ||
| 28 | + <artifactId>yudao-module-system-api</artifactId> | ||
| 29 | + <version>${revision}</version> | ||
| 30 | + </dependency> | ||
| 26 | 31 | ||
| 27 | <!-- 业务组件 --> | 32 | <!-- 业务组件 --> |
| 28 | <dependency> | 33 | <dependency> |
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; | @@ -4,6 +4,7 @@ import cn.hutool.core.io.IoUtil; | ||
| 4 | import cn.hutool.core.util.ZipUtil; | 4 | import cn.hutool.core.util.ZipUtil; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | ||
| 7 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenDetailRespVO; | 8 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenDetailRespVO; |
| 8 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenPreviewRespVO; | 9 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenPreviewRespVO; |
| 9 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; | 10 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; |
| @@ -36,6 +37,7 @@ import java.util.Map; | @@ -36,6 +37,7 @@ import java.util.Map; | ||
| 36 | import java.util.Set; | 37 | import java.util.Set; |
| 37 | 38 | ||
| 38 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 39 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 40 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 39 | 41 | ||
| 40 | @Api(tags = "管理后台 - 代码生成器") | 42 | @Api(tags = "管理后台 - 代码生成器") |
| 41 | @RestController | 43 | @RestController |
| @@ -88,7 +90,7 @@ public class CodegenController { | @@ -88,7 +90,7 @@ public class CodegenController { | ||
| 88 | @PostMapping("/create-list-from-db") | 90 | @PostMapping("/create-list-from-db") |
| 89 | @PreAuthorize("@ss.hasPermission('tool:codegen:create')") | 91 | @PreAuthorize("@ss.hasPermission('tool:codegen:create')") |
| 90 | public CommonResult<List<Long>> createCodegenListFromDB(@RequestParam("tableNames") List<String> tableNames) { | 92 | public CommonResult<List<Long>> createCodegenListFromDB(@RequestParam("tableNames") List<String> tableNames) { |
| 91 | - return success(codegenService.createCodegenListFromDB(tableNames)); | 93 | + return success(codegenService.createCodegenListFromDB(getLoginUserId(), tableNames)); |
| 92 | } | 94 | } |
| 93 | 95 | ||
| 94 | @ApiOperation("基于 SQL 建表语句,创建代码生成器的表和字段定义") | 96 | @ApiOperation("基于 SQL 建表语句,创建代码生成器的表和字段定义") |
| @@ -96,7 +98,7 @@ public class CodegenController { | @@ -96,7 +98,7 @@ public class CodegenController { | ||
| 96 | @PostMapping("/create-list-from-sql") | 98 | @PostMapping("/create-list-from-sql") |
| 97 | @PreAuthorize("@ss.hasPermission('tool:codegen:create')") | 99 | @PreAuthorize("@ss.hasPermission('tool:codegen:create')") |
| 98 | public CommonResult<Long> createCodegenListFromSQL(@RequestParam("sql") String sql) { | 100 | public CommonResult<Long> createCodegenListFromSQL(@RequestParam("sql") String sql) { |
| 99 | - return success(codegenService.createCodegenListFromSQL(sql)); | 101 | + return success(codegenService.createCodegenListFromSQL(getLoginUserId(), sql)); |
| 100 | } | 102 | } |
| 101 | 103 | ||
| 102 | @ApiOperation("更新数据库的表和字段定义") | 104 | @ApiOperation("更新数据库的表和字段定义") |
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 { | @@ -16,6 +16,10 @@ public class CodegenTableBaseVO { | ||
| 16 | @NotNull(message = "导入类型不能为空") | 16 | @NotNull(message = "导入类型不能为空") |
| 17 | private Integer importType; | 17 | private Integer importType; |
| 18 | 18 | ||
| 19 | + @ApiModelProperty(value = "生成场景", required = true, example = "1", notes = "参见 CodegenSceneEnum 枚举") | ||
| 20 | + @NotNull(message = "导入类型不能为空") | ||
| 21 | + private Integer scene; | ||
| 22 | + | ||
| 19 | @ApiModelProperty(value = "表名称", required = true, example = "yudao") | 23 | @ApiModelProperty(value = "表名称", required = true, example = "yudao") |
| 20 | @NotNull(message = "表名称不能为空") | 24 | @NotNull(message = "表名称不能为空") |
| 21 | private String tableName; | 25 | private String tableName; |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java
| 1 | package cn.iocoder.yudao.module.tool.dal.dataobject.codegen; | 1 | package cn.iocoder.yudao.module.tool.dal.dataobject.codegen; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenSceneEnum; | ||
| 4 | import cn.iocoder.yudao.module.tool.enums.codegen.CodegenTemplateTypeEnum; | 5 | import cn.iocoder.yudao.module.tool.enums.codegen.CodegenTemplateTypeEnum; |
| 5 | import com.baomidou.mybatisplus.annotation.TableName; | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -29,6 +30,12 @@ public class CodegenTableDO extends BaseDO { | @@ -29,6 +30,12 @@ public class CodegenTableDO extends BaseDO { | ||
| 29 | * 枚举 {@link CodegenTemplateTypeEnum} | 30 | * 枚举 {@link CodegenTemplateTypeEnum} |
| 30 | */ | 31 | */ |
| 31 | private Integer importType; | 32 | private Integer importType; |
| 33 | + /** | ||
| 34 | + * 生成场景 | ||
| 35 | + * | ||
| 36 | + * 枚举 {@link CodegenSceneEnum} | ||
| 37 | + */ | ||
| 38 | + private Integer scene; | ||
| 32 | 39 | ||
| 33 | // ========== 表相关字段 ========== | 40 | // ========== 表相关字段 ========== |
| 34 | 41 |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.tool.enums.codegen; | ||
| 2 | + | ||
| 3 | +import lombok.AllArgsConstructor; | ||
| 4 | +import lombok.Getter; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 代码生成的场景枚举 | ||
| 8 | + * | ||
| 9 | + * @author 芋道源码 | ||
| 10 | + */ | ||
| 11 | +@AllArgsConstructor | ||
| 12 | +@Getter | ||
| 13 | +public enum CodegenSceneEnum { | ||
| 14 | + | ||
| 15 | + ADMIN(1, "管理后台", "admin"), | ||
| 16 | + APP(2, "用户 APP", "app"); | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 场景 | ||
| 20 | + */ | ||
| 21 | + private final Integer scene; | ||
| 22 | + /** | ||
| 23 | + * 场景名 | ||
| 24 | + */ | ||
| 25 | + private final String name; | ||
| 26 | + /** | ||
| 27 | + * 基础包名 | ||
| 28 | + */ | ||
| 29 | + private final String basePackage; | ||
| 30 | + | ||
| 31 | +} |
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 { | @@ -20,26 +20,29 @@ public interface CodegenService { | ||
| 20 | /** | 20 | /** |
| 21 | * 基于 SQL 建表语句,创建代码生成器的表定义 | 21 | * 基于 SQL 建表语句,创建代码生成器的表定义 |
| 22 | * | 22 | * |
| 23 | + * @param userId 用户编号 | ||
| 23 | * @param sql SQL 建表语句 | 24 | * @param sql SQL 建表语句 |
| 24 | * @return 创建的表定义的编号 | 25 | * @return 创建的表定义的编号 |
| 25 | */ | 26 | */ |
| 26 | - Long createCodegenListFromSQL(String sql); | 27 | + Long createCodegenListFromSQL(Long userId, String sql); |
| 27 | 28 | ||
| 28 | /** | 29 | /** |
| 29 | * 基于数据库的表结构,创建代码生成器的表定义 | 30 | * 基于数据库的表结构,创建代码生成器的表定义 |
| 30 | * | 31 | * |
| 32 | + * @param userId 用户编号 | ||
| 31 | * @param tableName 表名称 | 33 | * @param tableName 表名称 |
| 32 | * @return 创建的表定义的编号 | 34 | * @return 创建的表定义的编号 |
| 33 | */ | 35 | */ |
| 34 | - Long createCodegen(String tableName); | 36 | + Long createCodegen(Long userId, String tableName); |
| 35 | 37 | ||
| 36 | /** | 38 | /** |
| 37 | - * 基于 {@link #createCodegen(String)} 的批量创建 | 39 | + * 基于 {@link #createCodegen(Long, String)} 的批量创建 |
| 38 | * | 40 | * |
| 41 | + * @param userId 用户编号 | ||
| 39 | * @param tableNames 表名称数组 | 42 | * @param tableNames 表名称数组 |
| 40 | * @return 创建的表定义的编号数组 | 43 | * @return 创建的表定义的编号数组 |
| 41 | */ | 44 | */ |
| 42 | - List<Long> createCodegenListFromDB(List<String> tableNames); | 45 | + List<Long> createCodegenListFromDB(Long userId, List<String> tableNames); |
| 43 | 46 | ||
| 44 | /** | 47 | /** |
| 45 | * 更新数据库的表和字段定义 | 48 | * 更新数据库的表和字段定义 |
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; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tool.service.codegen; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 5 | import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; | 6 | import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; |
| 6 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; | 7 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; |
| 7 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO; | 8 | import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO; |
| @@ -51,6 +52,9 @@ public class CodegenServiceImpl implements CodegenService { | @@ -51,6 +52,9 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 51 | private CodegenColumnMapper codegenColumnMapper; | 52 | private CodegenColumnMapper codegenColumnMapper; |
| 52 | 53 | ||
| 53 | @Resource | 54 | @Resource |
| 55 | + private AdminUserApi userApi; | ||
| 56 | + | ||
| 57 | + @Resource | ||
| 54 | private CodegenBuilder codegenBuilder; | 58 | private CodegenBuilder codegenBuilder; |
| 55 | @Resource | 59 | @Resource |
| 56 | private CodegenEngine codegenEngine; | 60 | private CodegenEngine codegenEngine; |
| @@ -58,7 +62,7 @@ public class CodegenServiceImpl implements CodegenService { | @@ -58,7 +62,7 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 58 | @Resource | 62 | @Resource |
| 59 | private CodegenProperties codegenProperties; | 63 | private CodegenProperties codegenProperties; |
| 60 | 64 | ||
| 61 | - private Long createCodegen0(CodegenImportTypeEnum importType, | 65 | + private Long createCodegen0(Long userId, CodegenImportTypeEnum importType, |
| 62 | SchemaTableDO schemaTable, List<SchemaColumnDO> schemaColumns) { | 66 | SchemaTableDO schemaTable, List<SchemaColumnDO> schemaColumns) { |
| 63 | // 校验导入的表和字段非空 | 67 | // 校验导入的表和字段非空 |
| 64 | if (schemaTable == null) { | 68 | if (schemaTable == null) { |
| @@ -75,6 +79,7 @@ public class CodegenServiceImpl implements CodegenService { | @@ -75,6 +79,7 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 75 | // 构建 CodegenTableDO 对象,插入到 DB 中 | 79 | // 构建 CodegenTableDO 对象,插入到 DB 中 |
| 76 | CodegenTableDO table = codegenBuilder.buildTable(schemaTable); | 80 | CodegenTableDO table = codegenBuilder.buildTable(schemaTable); |
| 77 | table.setImportType(importType.getType()); | 81 | table.setImportType(importType.getType()); |
| 82 | + table.setAuthor(userApi.getUser(userId).getNickname()); | ||
| 78 | codegenTableMapper.insert(table); | 83 | codegenTableMapper.insert(table); |
| 79 | // 构建 CodegenColumnDO 数组,插入到 DB 中 | 84 | // 构建 CodegenColumnDO 数组,插入到 DB 中 |
| 80 | List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); | 85 | List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); |
| @@ -86,7 +91,7 @@ public class CodegenServiceImpl implements CodegenService { | @@ -86,7 +91,7 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 86 | } | 91 | } |
| 87 | 92 | ||
| 88 | @Override | 93 | @Override |
| 89 | - public Long createCodegenListFromSQL(String sql) { | 94 | + public Long createCodegenListFromSQL(Long userId, String sql) { |
| 90 | // 从 SQL 中,获得数据库表结构 | 95 | // 从 SQL 中,获得数据库表结构 |
| 91 | SchemaTableDO schemaTable; | 96 | SchemaTableDO schemaTable; |
| 92 | List<SchemaColumnDO> schemaColumns; | 97 | List<SchemaColumnDO> schemaColumns; |
| @@ -98,26 +103,26 @@ public class CodegenServiceImpl implements CodegenService { | @@ -98,26 +103,26 @@ public class CodegenServiceImpl implements CodegenService { | ||
| 98 | throw exception(CODEGEN_PARSE_SQL_ERROR); | 103 | throw exception(CODEGEN_PARSE_SQL_ERROR); |
| 99 | } | 104 | } |
| 100 | // 导入 | 105 | // 导入 |
| 101 | - return this.createCodegen0(CodegenImportTypeEnum.SQL, schemaTable, schemaColumns); | 106 | + return this.createCodegen0(userId, CodegenImportTypeEnum.SQL, schemaTable, schemaColumns); |
| 102 | } | 107 | } |
| 103 | 108 | ||
| 104 | @Override | 109 | @Override |
| 105 | - public Long createCodegen(String tableName) { | 110 | + public Long createCodegen(Long userId, String tableName) { |
| 106 | // 获取当前schema | 111 | // 获取当前schema |
| 107 | String tableSchema = codegenProperties.getDbSchemas().iterator().next(); | 112 | String tableSchema = codegenProperties.getDbSchemas().iterator().next(); |
| 108 | // 从数据库中,获得数据库表结构 | 113 | // 从数据库中,获得数据库表结构 |
| 109 | SchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName); | 114 | SchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName); |
| 110 | List<SchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, tableName); | 115 | List<SchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, tableName); |
| 111 | // 导入 | 116 | // 导入 |
| 112 | - return this.createCodegen0(CodegenImportTypeEnum.DB, schemaTable, schemaColumns); | 117 | + return this.createCodegen0(userId, CodegenImportTypeEnum.DB, schemaTable, schemaColumns); |
| 113 | } | 118 | } |
| 114 | 119 | ||
| 115 | @Override | 120 | @Override |
| 116 | @Transactional(rollbackFor = Exception.class) | 121 | @Transactional(rollbackFor = Exception.class) |
| 117 | - public List<Long> createCodegenListFromDB(List<String> tableNames) { | 122 | + public List<Long> createCodegenListFromDB(Long userId, List<String> tableNames) { |
| 118 | List<Long> ids = new ArrayList<>(tableNames.size()); | 123 | List<Long> ids = new ArrayList<>(tableNames.size()); |
| 119 | // 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量 | 124 | // 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量 |
| 120 | - tableNames.forEach(tableName -> ids.add(createCodegen(tableName))); | 125 | + tableNames.forEach(tableName -> ids.add(createCodegen(userId, tableName))); |
| 121 | return ids; | 126 | return ids; |
| 122 | } | 127 | } |
| 123 | 128 |
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java
| @@ -28,18 +28,6 @@ import static cn.hutool.core.text.CharSequenceUtil.*; | @@ -28,18 +28,6 @@ import static cn.hutool.core.text.CharSequenceUtil.*; | ||
| 28 | public class CodegenBuilder { | 28 | public class CodegenBuilder { |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | - * Module 名字的映射 TODO 后续梳理到配置类 | ||
| 32 | - * | ||
| 33 | - * key:模块的完整名 | ||
| 34 | - * value:模块的缩写名 | ||
| 35 | - */ | ||
| 36 | - private static final Map<String, String> moduleNames = MapUtil.<String, String>builder() | ||
| 37 | - .put("system", "sys") | ||
| 38 | - .put("infra", "inf") | ||
| 39 | - .put("tool", "tool") | ||
| 40 | - .build(); | ||
| 41 | - | ||
| 42 | - /** | ||
| 43 | * 字段名与 {@link CodegenColumnListConditionEnum} 的默认映射 | 31 | * 字段名与 {@link CodegenColumnListConditionEnum} 的默认映射 |
| 44 | * 注意,字段的匹配以后缀的方式 | 32 | * 注意,字段的匹配以后缀的方式 |
| 45 | */ | 33 | */ |
| @@ -125,8 +113,10 @@ public class CodegenBuilder { | @@ -125,8 +113,10 @@ public class CodegenBuilder { | ||
| 125 | * @param table 表定义 | 113 | * @param table 表定义 |
| 126 | */ | 114 | */ |
| 127 | private void initTableDefault(CodegenTableDO table) { | 115 | private void initTableDefault(CodegenTableDO table) { |
| 128 | - table.setModuleName(getFullModuleName(StrUtil.subBefore(table.getTableName(), | ||
| 129 | - '_', false))); // 第一个 _ 前缀的前面,作为 module 名字 | 116 | + // 以 system_dept 举例子。moduleName 为 system、businessName 为 dept、className 为 SystemDept |
| 117 | + // 如果不希望 System 前缀,则可以手动在【代码生成 - 修改生成配置 - 基本信息】,将实体类名称改为 Dept 即可 | ||
| 118 | + table.setModuleName(StrUtil.subBefore(table.getTableName(), | ||
| 119 | + '_', false)); // 第一个 _ 前缀的前面,作为 module 名字 | ||
| 130 | table.setBusinessName(toCamelCase(subAfter(table.getTableName(), | 120 | table.setBusinessName(toCamelCase(subAfter(table.getTableName(), |
| 131 | '_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰 | 121 | '_', false))); // 第一步,第一个 _ 前缀的后面,作为 module 名字; 第二步,可能存在多个 _ 的情况,转换成驼峰 |
| 132 | table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 | 122 | table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 |
| @@ -208,27 +198,4 @@ public class CodegenBuilder { | @@ -208,27 +198,4 @@ public class CodegenBuilder { | ||
| 208 | } | 198 | } |
| 209 | } | 199 | } |
| 210 | 200 | ||
| 211 | - /** | ||
| 212 | - * 获得模块的缩略名 | ||
| 213 | - * | ||
| 214 | - * @param fullModuleName 模块的完整名 | ||
| 215 | - * @return 缩略名 | ||
| 216 | - */ | ||
| 217 | - public String getSimpleModuleName(String fullModuleName) { | ||
| 218 | - return moduleNames.getOrDefault(fullModuleName, fullModuleName); | ||
| 219 | - } | ||
| 220 | - | ||
| 221 | - /** | ||
| 222 | - * 获得模块的完整名 | ||
| 223 | - * | ||
| 224 | - * @param shortModuleName 模块的缩略名 | ||
| 225 | - * @return 完整名 | ||
| 226 | - */ | ||
| 227 | - public String getFullModuleName(String shortModuleName) { | ||
| 228 | - return moduleNames.entrySet().stream() | ||
| 229 | - .filter(entry -> entry.getValue().equals(shortModuleName)) // 匹配 | ||
| 230 | - .findFirst().map(Map.Entry::getKey) // 返回 key | ||
| 231 | - .orElse(shortModuleName); // 兜底返回 shortModuleName | ||
| 232 | - } | ||
| 233 | - | ||
| 234 | } | 201 | } |
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 { | @@ -53,38 +53,39 @@ public class CodegenEngine { | ||
| 53 | * value:生成的路径 | 53 | * value:生成的路径 |
| 54 | */ | 54 | */ |
| 55 | private static final Map<String, String> TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序 | 55 | private static final Map<String, String> TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序 |
| 56 | - // Java Main | 56 | + // Java module-impl Main |
| 57 | .put(javaTemplatePath("controller/vo/baseVO"), | 57 | .put(javaTemplatePath("controller/vo/baseVO"), |
| 58 | - javaFilePath("controller/${table.businessName}/vo/${table.className}BaseVO")) | 58 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}BaseVO")) |
| 59 | .put(javaTemplatePath("controller/vo/createReqVO"), | 59 | .put(javaTemplatePath("controller/vo/createReqVO"), |
| 60 | - javaFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO")) | 60 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO")) |
| 61 | .put(javaTemplatePath("controller/vo/pageReqVO"), | 61 | .put(javaTemplatePath("controller/vo/pageReqVO"), |
| 62 | - javaFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO")) | 62 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO")) |
| 63 | .put(javaTemplatePath("controller/vo/respVO"), | 63 | .put(javaTemplatePath("controller/vo/respVO"), |
| 64 | - javaFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) | 64 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) |
| 65 | .put(javaTemplatePath("controller/vo/updateReqVO"), | 65 | .put(javaTemplatePath("controller/vo/updateReqVO"), |
| 66 | - javaFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) | 66 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) |
| 67 | .put(javaTemplatePath("controller/vo/exportReqVO"), | 67 | .put(javaTemplatePath("controller/vo/exportReqVO"), |
| 68 | - javaFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) | 68 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) |
| 69 | .put(javaTemplatePath("controller/vo/excelVO"), | 69 | .put(javaTemplatePath("controller/vo/excelVO"), |
| 70 | - javaFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) | 70 | + javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) |
| 71 | .put(javaTemplatePath("controller/controller"), | 71 | .put(javaTemplatePath("controller/controller"), |
| 72 | - javaFilePath("controller/${table.businessName}/${table.className}Controller")) | 72 | + javaModuleImplMainFilePath("controller/${table.businessName}/${table.className}Controller")) |
| 73 | .put(javaTemplatePath("convert/convert"), | 73 | .put(javaTemplatePath("convert/convert"), |
| 74 | - javaFilePath("convert/${table.businessName}/${table.className}Convert")) | 74 | + javaModuleImplMainFilePath("convert/${table.businessName}/${table.className}Convert")) |
| 75 | .put(javaTemplatePath("dal/do"), | 75 | .put(javaTemplatePath("dal/do"), |
| 76 | - javaFilePath("dal/dataobject/${table.businessName}/${table.className}DO")) | 76 | + javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${table.className}DO")) |
| 77 | .put(javaTemplatePath("dal/mapper"), | 77 | .put(javaTemplatePath("dal/mapper"), |
| 78 | - javaFilePath("dal/mysql/${table.businessName}/${table.className}Mapper")) | ||
| 79 | - .put(javaTemplatePath("enums/errorcode"), | ||
| 80 | - javaFilePath("enums/${simpleModuleName_upperFirst}ErrorCodeConstants")) | 78 | + javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${table.className}Mapper")) |
| 81 | .put(javaTemplatePath("service/serviceImpl"), | 79 | .put(javaTemplatePath("service/serviceImpl"), |
| 82 | - javaFilePath("service/${table.businessName}/impl/${table.className}ServiceImpl")) | 80 | + javaModuleImplMainFilePath("service/${table.businessName}/${table.className}ServiceImpl")) |
| 83 | .put(javaTemplatePath("service/service"), | 81 | .put(javaTemplatePath("service/service"), |
| 84 | - javaFilePath("service/${table.businessName}/${table.className}Service")) | ||
| 85 | - // Java Test | 82 | + javaModuleImplMainFilePath("service/${table.businessName}/${table.className}Service")) |
| 83 | + // Java module-impl Test | ||
| 86 | .put(javaTemplatePath("test/serviceTest"), | 84 | .put(javaTemplatePath("test/serviceTest"), |
| 87 | - javaFilePath("service/${table.businessName}/${table.className}ServiceTest")) | 85 | + javaModuleImplTestFilePath("service/${table.businessName}/${table.className}ServiceTest")) |
| 86 | + // Java module-api Main | ||
| 87 | + .put(javaTemplatePath("enums/errorcode"), | ||
| 88 | + javaModuleApiMainFilePath("enums/ErrorCodeConstants")) | ||
| 88 | // Vue | 89 | // Vue |
| 89 | .put(vueTemplatePath("views/index.vue"), | 90 | .put(vueTemplatePath("views/index.vue"), |
| 90 | vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue")) | 91 | vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue")) |
| @@ -121,7 +122,7 @@ public class CodegenEngine { | @@ -121,7 +122,7 @@ public class CodegenEngine { | ||
| 121 | // 全局配置 | 122 | // 全局配置 |
| 122 | globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); | 123 | globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); |
| 123 | globalBindingMap.put("baseFrameworkPackage", StrUtil.subBefore(codegenProperties.getBasePackage(), | 124 | globalBindingMap.put("baseFrameworkPackage", StrUtil.subBefore(codegenProperties.getBasePackage(), |
| 124 | - '.', true) + '.' + "framework"); | 125 | + '.', true) + '.' + "framework"); // 用于后续获取测试类的 package 地址 |
| 125 | // 全局 Java Bean | 126 | // 全局 Java Bean |
| 126 | globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); | 127 | globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); |
| 127 | globalBindingMap.put("PageResultClassName", PageResult.class.getName()); | 128 | globalBindingMap.put("PageResultClassName", PageResult.class.getName()); |
| @@ -149,13 +150,9 @@ public class CodegenEngine { | @@ -149,13 +150,9 @@ public class CodegenEngine { | ||
| 149 | bindingMap.put("table", table); | 150 | bindingMap.put("table", table); |
| 150 | bindingMap.put("columns", columns); | 151 | bindingMap.put("columns", columns); |
| 151 | bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 | 152 | bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 |
| 152 | - // moduleName 相关 | ||
| 153 | - String simpleModuleName = codegenBuilder.getSimpleModuleName(table.getModuleName()); | ||
| 154 | - bindingMap.put("simpleModuleName", simpleModuleName); // 将 system 转成 sys | ||
| 155 | - bindingMap.put("simpleModuleName_upperFirst", upperFirst(simpleModuleName)); // 将 sys 转成 Sys | ||
| 156 | // className 相关 | 153 | // className 相关 |
| 157 | // 去掉指定前缀 将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 | 154 | // 去掉指定前缀 将 TestDictType 转换成 DictType. 因为在 create 等方法后,不需要带上 Test 前缀 |
| 158 | - String simpleClassName = removePrefix(table.getClassName(), upperFirst(simpleModuleName)); | 155 | + String simpleClassName = removePrefix(table.getClassName(), upperFirst(table.getModuleName())); |
| 159 | bindingMap.put("simpleClassName", simpleClassName); | 156 | bindingMap.put("simpleClassName", simpleClassName); |
| 160 | bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type | 157 | bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // 将 DictType 转换成 dict_type |
| 161 | bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量 | 158 | bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // 将 DictType 转换成 dictType,用于变量 |
| @@ -177,8 +174,6 @@ public class CodegenEngine { | @@ -177,8 +174,6 @@ public class CodegenEngine { | ||
| 177 | private String formatFilePath(String filePath, Map<String, Object> bindingMap) { | 174 | private String formatFilePath(String filePath, Map<String, Object> bindingMap) { |
| 178 | filePath = StrUtil.replace(filePath, "${basePackage}", | 175 | filePath = StrUtil.replace(filePath, "${basePackage}", |
| 179 | getStr(bindingMap, "basePackage").replaceAll("\\.", "/")); | 176 | getStr(bindingMap, "basePackage").replaceAll("\\.", "/")); |
| 180 | - filePath = StrUtil.replace(filePath, "${simpleModuleName_upperFirst}", | ||
| 181 | - getStr(bindingMap, "simpleModuleName_upperFirst")); | ||
| 182 | filePath = StrUtil.replace(filePath, "${classNameVar}", | 177 | filePath = StrUtil.replace(filePath, "${classNameVar}", |
| 183 | getStr(bindingMap, "classNameVar")); | 178 | getStr(bindingMap, "classNameVar")); |
| 184 | 179 | ||
| @@ -194,8 +189,23 @@ public class CodegenEngine { | @@ -194,8 +189,23 @@ public class CodegenEngine { | ||
| 194 | return "codegen/java/" + path + ".vm"; | 189 | return "codegen/java/" + path + ".vm"; |
| 195 | } | 190 | } |
| 196 | 191 | ||
| 197 | - private static String javaFilePath(String path) { | ||
| 198 | - return "java/${basePackage}/modules/${table.moduleName}/" + path + ".java"; | 192 | + private static String javaModuleImplMainFilePath(String path) { |
| 193 | + return javaModuleFilePath(path, "impl", "main"); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + private static String javaModuleApiMainFilePath(String path) { | ||
| 197 | + return javaModuleFilePath(path, "api", "main"); | ||
| 198 | + | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + private static String javaModuleImplTestFilePath(String path) { | ||
| 202 | + return javaModuleFilePath(path, "impl", "test"); | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + private static String javaModuleFilePath(String path, String module, String src) { | ||
| 206 | + return "yudao-module-${table.moduleName}/" + // 顶级模块 | ||
| 207 | + "yudao-module-${table.moduleName}-" + module + "/" + // 子模块 | ||
| 208 | + "src/" + src + "/java/${basePackage}/module/${table.moduleName}/" + path + ".java"; | ||
| 199 | } | 209 | } |
| 200 | 210 | ||
| 201 | private static String vueTemplatePath(String path) { | 211 | private static String vueTemplatePath(String path) { |
yudao-admin-server/src/main/resources/codegen/java/controller/controller.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm
| 1 | -package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}; | 1 | +package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}; |
| 2 | 2 | ||
| 3 | import org.springframework.web.bind.annotation.*; | 3 | import org.springframework.web.bind.annotation.*; |
| 4 | import javax.annotation.Resource; | 4 | import javax.annotation.Resource; |
| @@ -22,10 +22,10 @@ import ${ExcelUtilsClassName}; | @@ -22,10 +22,10 @@ import ${ExcelUtilsClassName}; | ||
| 22 | import ${OperateLogClassName}; | 22 | import ${OperateLogClassName}; |
| 23 | import static ${OperateTypeEnumClassName}.*; | 23 | import static ${OperateTypeEnumClassName}.*; |
| 24 | 24 | ||
| 25 | -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; | ||
| 26 | -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 27 | -import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; | ||
| 28 | -import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service; | 25 | +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 26 | +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 27 | +import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; | ||
| 28 | +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; | ||
| 29 | 29 | ||
| 30 | @Api(tags = "${table.classComment}") | 30 | @Api(tags = "${table.classComment}") |
| 31 | @RestController | 31 | @RestController |
yudao-admin-server/src/main/resources/codegen/java/controller/vo/_column.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/_column.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/baseVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/baseVO.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/createReqVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/createReqVO.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/excelVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/excelVO.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/exportReqVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/pageReqVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/respVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/respVO.vm
yudao-admin-server/src/main/resources/codegen/java/controller/vo/updateReqVO.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
yudao-admin-server/src/main/resources/codegen/java/convert/convert.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/convert/convert.vm
| 1 | -package ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}; | 1 | +package ${basePackage}.module.${table.moduleName}.convert.${table.businessName}; |
| 2 | 2 | ||
| 3 | import java.util.*; | 3 | import java.util.*; |
| 4 | 4 | ||
| @@ -6,8 +6,8 @@ import ${PageResultClassName}; | @@ -6,8 +6,8 @@ import ${PageResultClassName}; | ||
| 6 | 6 | ||
| 7 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 8 | import org.mapstruct.factory.Mappers; | 8 | import org.mapstruct.factory.Mappers; |
| 9 | -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; | ||
| 10 | -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | 9 | +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 10 | +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 11 | 11 | ||
| 12 | /** | 12 | /** |
| 13 | * ${table.classComment} Convert | 13 | * ${table.classComment} Convert |
yudao-admin-server/src/main/resources/codegen/java/dal/do.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/do.vm
yudao-admin-server/src/main/resources/codegen/java/dal/mapper.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/mapper.vm
| 1 | -package ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}; | 1 | +package ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}; |
| 2 | 2 | ||
| 3 | import java.util.*; | 3 | import java.util.*; |
| 4 | 4 | ||
| 5 | import ${PageResultClassName}; | 5 | import ${PageResultClassName}; |
| 6 | import ${QueryWrapperClassName}; | 6 | import ${QueryWrapperClassName}; |
| 7 | import ${BaseMapperClassName}; | 7 | import ${BaseMapperClassName}; |
| 8 | -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | 8 | +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; | 10 | +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 11 | 11 | ||
| 12 | ## 字段模板 | 12 | ## 字段模板 |
| 13 | #macro(listCondition) | 13 | #macro(listCondition) |
yudao-admin-server/src/main/resources/codegen/java/enums/errorcode.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/enums/errorcode.vm
yudao-admin-server/src/main/resources/codegen/java/service/service.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/service.vm
| 1 | -package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}; | 1 | +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; |
| 2 | 2 | ||
| 3 | import java.util.*; | 3 | import java.util.*; |
| 4 | import javax.validation.*; | 4 | import javax.validation.*; |
| 5 | -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; | ||
| 6 | -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | 5 | +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 6 | +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 7 | import ${PageResultClassName}; | 7 | import ${PageResultClassName}; |
| 8 | 8 | ||
| 9 | /** | 9 | /** |
yudao-admin-server/src/main/resources/codegen/java/service/serviceImpl.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/serviceImpl.vm
| 1 | -package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl; | 1 | +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; |
| 2 | 2 | ||
| 3 | import org.springframework.stereotype.Service; | 3 | import org.springframework.stereotype.Service; |
| 4 | import javax.annotation.Resource; | 4 | import javax.annotation.Resource; |
| 5 | import org.springframework.validation.annotation.Validated; | 5 | import org.springframework.validation.annotation.Validated; |
| 6 | 6 | ||
| 7 | import java.util.*; | 7 | import java.util.*; |
| 8 | -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; | ||
| 9 | -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | 8 | +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; |
| 9 | +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 10 | import ${PageResultClassName}; | 10 | import ${PageResultClassName}; |
| 11 | 11 | ||
| 12 | -import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; | ||
| 13 | -import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; | ||
| 14 | -import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service; | 12 | +import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; |
| 13 | +import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; | ||
| 14 | +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service; | ||
| 15 | 15 | ||
| 16 | import static ${ServiceExceptionUtilClassName}.exception; | 16 | import static ${ServiceExceptionUtilClassName}.exception; |
| 17 | -import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; | 17 | +import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * ${table.classComment} Service 实现类 | 20 | * ${table.classComment} Service 实现类 |
yudao-admin-server/src/main/resources/codegen/java/test/serviceTest.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/test/serviceTest.vm
| 1 | -package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}; | 1 | +package ${basePackage}.module.${table.moduleName}.service.${table.businessName}; |
| 2 | 2 | ||
| 3 | import org.junit.jupiter.api.Test; | 3 | import org.junit.jupiter.api.Test; |
| 4 | import org.springframework.boot.test.mock.mockito.MockBean; | 4 | import org.springframework.boot.test.mock.mockito.MockBean; |
| @@ -6,10 +6,10 @@ import org.springframework.boot.test.mock.mockito.MockBean; | @@ -6,10 +6,10 @@ import org.springframework.boot.test.mock.mockito.MockBean; | ||
| 6 | import javax.annotation.Resource; | 6 | import javax.annotation.Resource; |
| 7 | 7 | ||
| 8 | import ${basePackage}.BaseDbUnitTest; | 8 | import ${basePackage}.BaseDbUnitTest; |
| 9 | -import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl; | ||
| 10 | -import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; | ||
| 11 | -import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 12 | -import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; | 9 | +import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl; |
| 10 | +import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*; | ||
| 11 | +import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; | ||
| 12 | +import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; | ||
| 13 | import ${PageResultClassName}; | 13 | import ${PageResultClassName}; |
| 14 | 14 | ||
| 15 | import javax.annotation.Resource; | 15 | import javax.annotation.Resource; |
| @@ -17,7 +17,7 @@ import org.springframework.context.annotation.Import; | @@ -17,7 +17,7 @@ import org.springframework.context.annotation.Import; | ||
| 17 | import java.util.*; | 17 | import java.util.*; |
| 18 | 18 | ||
| 19 | import static cn.hutool.core.util.RandomUtil.*; | 19 | import static cn.hutool.core.util.RandomUtil.*; |
| 20 | -import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; | 20 | +import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*; |
| 21 | import static ${baseFrameworkPackage}.test.core.util.AssertUtils.*; | 21 | import static ${baseFrameworkPackage}.test.core.util.AssertUtils.*; |
| 22 | import static ${baseFrameworkPackage}.test.core.util.RandomUtils.*; | 22 | import static ${baseFrameworkPackage}.test.core.util.RandomUtils.*; |
| 23 | import static ${ObjectUtilsClassName}.*; | 23 | import static ${ObjectUtilsClassName}.*; |
yudao-admin-server/src/main/resources/codegen/sql/sql.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/sql/sql.vm
| 1 | -- 菜单 SQL | 1 | -- 菜单 SQL |
| 2 | -INSERT INTO `sys_menu`( | 2 | +INSERT INTO `system_menu`( |
| 3 | `name`, `permission`, `menu_type`, `sort`, `parent_id`, | 3 | `name`, `permission`, `menu_type`, `sort`, `parent_id`, |
| 4 | `path`, `icon`, `component`, `status` | 4 | `path`, `icon`, `component`, `status` |
| 5 | ) | 5 | ) |
| @@ -16,7 +16,7 @@ SELECT @parentId := LAST_INSERT_ID(); | @@ -16,7 +16,7 @@ SELECT @parentId := LAST_INSERT_ID(); | ||
| 16 | #set ($functionOps = ['query', 'create', 'update', 'delete', 'export']) | 16 | #set ($functionOps = ['query', 'create', 'update', 'delete', 'export']) |
| 17 | #foreach ($functionName in $functionNames) | 17 | #foreach ($functionName in $functionNames) |
| 18 | #set ($index = $foreach.count - 1) | 18 | #set ($index = $foreach.count - 1) |
| 19 | -INSERT INTO `sys_menu`( | 19 | +INSERT INTO `system_menu`( |
| 20 | `name`, `permission`, `menu_type`, `sort`, `parent_id`, | 20 | `name`, `permission`, `menu_type`, `sort`, `parent_id`, |
| 21 | `path`, `icon`, `component`, `status` | 21 | `path`, `icon`, `component`, `status` |
| 22 | ) | 22 | ) |
yudao-admin-server/src/main/resources/codegen/vue/api/api.js.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/api/api.js.vm
yudao-admin-server/src/main/resources/codegen/vue/views/index.vue.vm renamed to yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/views/index.vue.vm