Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
计算机应用开发
后
后端
J
Java
后台管理
Ruoyi Vue Pro
提交
b0c25ea9
R
Ruoyi Vue Pro
项目概览
计算机应用开发
/
后端
/
Java
/
后台管理
/
Ruoyi Vue Pro
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Ruoyi Vue Pro
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b0c25ea9
编写于
2月 02, 2022
作者:
公众号-芋道源码
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
多模块重构 11:修改代码生成器的实现
上级
8d593849
变更
52
隐藏空白更改
内联
并排
Showing
52 changed file
with
195 addition
and
163 deletion
+195
-163
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/AdminServerApplication.java
.../java/cn/iocoder/yudao/server/AdminServerApplication.java
+3
-4
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java
...er/framework/monitor/config/AdminServerConfiguration.java
+1
-1
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java
.../iocoder/yudao/server/framework/monitor/package-info.java
+1
-1
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md
...erver/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md
+0
-0
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/package-info.java
.../java/cn/iocoder/yudao/server/framework/package-info.java
+1
-1
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java
...udao/server/framework/security/SecurityConfiguration.java
+1
-1
yudao-admin-server/src/main/resources/application-local.yaml
yudao-admin-server/src/main/resources/application-local.yaml
+5
-10
yudao-admin-server/src/main/resources/application.yaml
yudao-admin-server/src/main/resources/application.yaml
+2
-5
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java
...oder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java
...n/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java
...minserver/framework/quartz/core/SchedulerManagerTest.java
+2
-2
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java
...inserver/framework/redis/core/stream/RedisStreamTest.java
+2
-2
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java
...ules/system/service/sms/SysSmsServiceIntegrationTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java
.../mysql/codegen/ToolInformationSchemaColumnMapperTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java
...l/mysql/codegen/ToolInformationSchemaTableMapperTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java
...r/modules/tool/service/codegen/ToolCodegenEngineTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java
...odules/tool/service/codegen/ToolCodegenSQLParserTest.java
+1
-1
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java
...ules/tool/service/codegen/ToolCodegenServiceImplTest.java
+1
-1
yudao-admin-ui/src/utils/dict.js
yudao-admin-ui/src/utils/dict.js
+1
-0
yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue
yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue
+15
-7
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
...amework/mybatis/config/YudaoMybatisAutoConfiguration.java
+1
-3
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java
...dao/module/bpm/service/definition/BpmFormServiceTest.java
+1
-1
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java
...odule/bpm/service/definition/BpmUserGroupServiceTest.java
+1
-1
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java
...src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java
+1
-1
yudao-module-tool/yudao-module-tool-impl/pom.xml
yudao-module-tool/yudao-module-tool-impl/pom.xml
+5
-0
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java
...dule/tool/controller/admin/codegen/CodegenController.java
+4
-2
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java
...controller/admin/codegen/vo/table/CodegenTableBaseVO.java
+4
-0
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java
...ao/module/tool/dal/dataobject/codegen/CodegenTableDO.java
+7
-0
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java
...der/yudao/module/tool/enums/codegen/CodegenSceneEnum.java
+31
-0
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java
...der/yudao/module/tool/service/codegen/CodegenService.java
+7
-4
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java
...yudao/module/tool/service/codegen/CodegenServiceImpl.java
+12
-7
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java
...dao/module/tool/service/codegen/inner/CodegenBuilder.java
+4
-37
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java
...udao/module/tool/service/codegen/inner/CodegenEngine.java
+38
-28
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm
.../src/main/resources/codegen/java/controller/controller.vm
+5
-5
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/_column.vm
.../src/main/resources/codegen/java/controller/vo/_column.vm
+0
-0
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/baseVO.vm
...l/src/main/resources/codegen/java/controller/vo/baseVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/createReqVO.vm
.../main/resources/codegen/java/controller/vo/createReqVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/excelVO.vm
.../src/main/resources/codegen/java/controller/vo/excelVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
.../main/resources/codegen/java/controller/vo/exportReqVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
...rc/main/resources/codegen/java/controller/vo/pageReqVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/respVO.vm
...l/src/main/resources/codegen/java/controller/vo/respVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
.../main/resources/codegen/java/controller/vo/updateReqVO.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/convert/convert.vm
...l-impl/src/main/resources/codegen/java/convert/convert.vm
+3
-3
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/do.vm
...odule-tool-impl/src/main/resources/codegen/java/dal/do.vm
+1
-1
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/dal/mapper.vm
...e-tool-impl/src/main/resources/codegen/java/dal/mapper.vm
+3
-3
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/enums/errorcode.vm
...l-impl/src/main/resources/codegen/java/enums/errorcode.vm
+0
-0
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/service.vm
...l-impl/src/main/resources/codegen/java/service/service.vm
+3
-3
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/service/serviceImpl.vm
...pl/src/main/resources/codegen/java/service/serviceImpl.vm
+7
-7
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/test/serviceTest.vm
...-impl/src/main/resources/codegen/java/test/serviceTest.vm
+6
-6
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/sql/sql.vm
...ao-module-tool-impl/src/main/resources/codegen/sql/sql.vm
+2
-2
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/api/api.js.vm
...le-tool-impl/src/main/resources/codegen/vue/api/api.js.vm
+0
-0
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/views/index.vue.vm
...ol-impl/src/main/resources/codegen/vue/views/index.vue.vm
+0
-0
未找到文件。
yudao-admin-server/src/main/java/cn/iocoder/yudao/
admin
server/AdminServerApplication.java
→
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/AdminServerApplication.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server
;
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
)
{
...
...
yudao-admin-server/src/main/java/cn/iocoder/yudao/
admin
server/framework/monitor/config/AdminServerConfiguration.java
→
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/config/AdminServerConfiguration.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server.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
;
...
...
yudao-admin-server/src/main/java/cn/iocoder/yudao/
admin
server/framework/monitor/package-info.java
→
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/package-info.java
浏览文件 @
b0c25ea9
/**
* 使用 Spring Boot Admin 实现简单的监控平台
*/
package
cn.iocoder.yudao.
admin
server.framework.monitor
;
package
cn.iocoder.yudao.server.framework.monitor
;
yudao-admin-server/src/main/java/cn/iocoder/yudao/
admin
server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md
→
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/monitor/《芋道 Spring Boot 监控工具 Admin 入门》.md
浏览文件 @
b0c25ea9
文件已移动
yudao-admin-server/src/main/java/cn/iocoder/yudao/
admin
server/framework/package-info.java
→
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/package-info.java
浏览文件 @
b0c25ea9
...
...
@@ -3,4 +3,4 @@
*
* @author 芋道源码
*/
package
cn.iocoder.yudao.
admin
server.framework
;
package
cn.iocoder.yudao.server.framework
;
yudao-admin-server/src/main/java/cn/iocoder/yudao/
admin
server/framework/security/SecurityConfiguration.java
→
yudao-admin-server/src/main/java/cn/iocoder/yudao/server/framework/security/SecurityConfiguration.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server.framework.security
;
package
cn.iocoder.yudao.server.framework.security
;
import
cn.iocoder.yudao.framework.web.config.WebProperties
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
yudao-admin-server/src/main/resources/application-local.yaml
浏览文件 @
b0c25ea9
...
...
@@ -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 文档
...
...
yudao-admin-server/src/main/resources/application.yaml
浏览文件 @
b0c25ea9
...
...
@@ -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}.module
s.*.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
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseDbAndRedisIntegrationTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server
;
package
cn.iocoder.yudao.server
;
import
cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration
;
import
cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/BaseRedisIntegrationTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server
;
package
cn.iocoder.yudao.server
;
import
cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration
;
import
org.redisson.spring.starter.RedissonAutoConfiguration
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/quartz/core/SchedulerManagerTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server.framework.quartz.core
;
package
cn.iocoder.yudao.server.framework.quartz.core
;
import
cn.hutool.core.util.StrUtil
;
import
cn.iocoder.yudao.
admin
server.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
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/framework/redis/core/stream/RedisStreamTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server.framework.redis.core.stream
;
package
cn.iocoder.yudao.server.framework.redis.core.stream
;
import
cn.hutool.core.thread.ThreadUtil
;
import
cn.iocoder.yudao.
admin
server.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
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/system/service/sms/SysSmsServiceIntegrationTest.java
浏览文件 @
b0c25ea9
...
...
@@ -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.
admin
server.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
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.tool.dal.mysql.codegen
;
import
cn.iocoder.yudao.
admin
server.BaseDbUnitTest
;
import
cn.iocoder.yudao.server.BaseDbUnitTest
;
import
cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO
;
import
org.junit.jupiter.api.Test
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.tool.dal.mysql.codegen
;
import
cn.iocoder.yudao.
admin
server.BaseDbUnitTest
;
import
cn.iocoder.yudao.server.BaseDbUnitTest
;
import
javax.annotation.Resource
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.tool.service.codegen
;
import
cn.iocoder.yudao.
admin
server.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
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.tool.service.codegen
;
import
cn.iocoder.yudao.
admin
server.BaseDbUnitTest
;
import
cn.iocoder.yudao.server.BaseDbUnitTest
;
import
cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser
;
import
org.junit.jupiter.api.Test
;
...
...
yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.tool.service.codegen
;
import
cn.iocoder.yudao.
admin
server.BaseDbUnitTest
;
import
cn.iocoder.yudao.server.BaseDbUnitTest
;
import
cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl
;
import
org.junit.jupiter.api.Test
;
...
...
yudao-admin-ui/src/utils/dict.js
浏览文件 @
b0c25ea9
...
...
@@ -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
'
,
...
...
yudao-admin-ui/src/views/tool/codegen/genInfoForm.vue
浏览文件 @
b0c25ea9
...
...
@@ -2,15 +2,20 @@
<el-form
ref=
"genInfoForm"
:model=
"info"
:rules=
"rules"
label-width=
"150px"
>
<el-row>
<el-col
:span=
"12"
>
<el-form-item
prop=
"t
plCategory
"
>
<el-form-item
prop=
"t
emplateType
"
>
<span
slot=
"label"
>
生成模板
</span>
<el-select
v-model=
"info.templateType"
@
change=
"tplSelectChange"
>
<el-option
v-for=
"dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_TEMPLATE_TYPE)"
:key=
"parseInt(dict.value)"
:label=
"dict.label"
:value=
"parseInt(dict.value)"
/>
<el-option
v-for=
"dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_TEMPLATE_TYPE)"
:key=
"parseInt(dict.value)"
:label=
"dict.label"
:value=
"parseInt(dict.value)"
/>
</el-select>
</el-form-item>
</el-col>
<el-col
:span=
"12"
>
<el-form-item
prop=
"scene"
>
<span
slot=
"label"
>
生成模板
</span>
<el-select
v-model=
"info.scene"
>
<el-option
v-for=
"dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_SCENE)"
:key=
"parseInt(dict.value)"
:label=
"dict.label"
:value=
"parseInt(dict.value)"
/>
</el-select>
</el-form-item>
</el-col>
...
...
@@ -249,6 +254,9 @@ export default {
templateType
:
[
{
required
:
true
,
message
:
"
请选择生成模板
"
,
trigger
:
"
blur
"
}
],
scene
:
[
{
required
:
true
,
message
:
"
请选择生成场景
"
,
trigger
:
"
blur
"
}
],
// packageName: [
// { required: true, message: "请输入生成包路径", trigger: "blur" }
// ],
...
...
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/config/YudaoMybatisAutoConfiguration.java
浏览文件 @
b0c25ea9
...
...
@@ -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
{
...
...
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmFormServiceTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.bpm.service.definition
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.iocoder.yudao.
admin
server.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
;
...
...
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/module/bpm/service/definition/BpmUserGroupServiceTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.module.bpm.service.definition
;
import
cn.iocoder.yudao.
admin
server.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
;
...
...
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/
admin
server/BaseDbUnitTest.java
→
yudao-module-bpm/yudao-module-bpm-base/src/test/java/cn/iocoder/yudao/server/BaseDbUnitTest.java
浏览文件 @
b0c25ea9
package
cn.iocoder.yudao.
admin
server
;
package
cn.iocoder.yudao.server
;
import
cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration
;
import
cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration
;
...
...
yudao-module-tool/yudao-module-tool-impl/pom.xml
浏览文件 @
b0c25ea9
...
...
@@ -23,6 +23,11 @@
<artifactId>
yudao-module-tool-api
</artifactId>
<version>
${revision}
</version>
</dependency>
<dependency>
<groupId>
cn.iocoder.boot
</groupId>
<artifactId>
yudao-module-system-api
</artifactId>
<version>
${revision}
</version>
</dependency>
<!-- 业务组件 -->
<dependency>
...
...
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java
浏览文件 @
b0c25ea9
...
...
@@ -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
<
List
<
Long
>>
createCodegenListFromDB
(
@RequestParam
(
"tableNames"
)
List
<
String
>
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
<
Long
>
createCodegenListFromSQL
(
@RequestParam
(
"sql"
)
String
sql
)
{
return
success
(
codegenService
.
createCodegenListFromSQL
(
sql
));
return
success
(
codegenService
.
createCodegenListFromSQL
(
getLoginUserId
(),
sql
));
}
@ApiOperation
(
"更新数据库的表和字段定义"
)
...
...
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java
浏览文件 @
b0c25ea9
...
...
@@ -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
;
...
...
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java
浏览文件 @
b0c25ea9
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
;
// ========== 表相关字段 ==========
...
...
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenSceneEnum.java
0 → 100644
浏览文件 @
b0c25ea9
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
;
}
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java
浏览文件 @
b0c25ea9
...
...
@@ -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
<
Long
>
createCodegenListFromDB
(
List
<
String
>
tableNames
);
List
<
Long
>
createCodegenListFromDB
(
L
ong
userId
,
L
ist
<
String
>
tableNames
);
/**
* 更新数据库的表和字段定义
...
...
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java
浏览文件 @
b0c25ea9
...
...
@@ -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
<
SchemaColumnDO
>
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
<
CodegenColumnDO
>
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
<
SchemaColumnDO
>
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
<
SchemaColumnDO
>
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
<
Long
>
createCodegenListFromDB
(
List
<
String
>
tableNames
)
{
public
List
<
Long
>
createCodegenListFromDB
(
L
ong
userId
,
L
ist
<
String
>
tableNames
)
{
List
<
Long
>
ids
=
new
ArrayList
<>(
tableNames
.
size
());
// 遍历添加。虽然效率会低一点,但是没必要做成完全批量,因为不会这么大量
tableNames
.
forEach
(
tableName
->
ids
.
add
(
createCodegen
(
tableName
)));
tableNames
.
forEach
(
tableName
->
ids
.
add
(
createCodegen
(
userId
,
tableName
)));
return
ids
;
}
...
...
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java
浏览文件 @
b0c25ea9
...
...
@@ -27,18 +27,6 @@ import static cn.hutool.core.text.CharSequenceUtil.*;
@Component
public
class
CodegenBuilder
{
/**
* Module 名字的映射 TODO 后续梳理到配置类
*
* key:模块的完整名
* value:模块的缩写名
*/
private
static
final
Map
<
String
,
String
>
moduleNames
=
MapUtil
.<
String
,
String
>
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
}
}
yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java
浏览文件 @
b0c25ea9
...
...
@@ -53,38 +53,39 @@ public class CodegenEngine {
* value:生成的路径
*/
private
static
final
Map
<
String
,
String
>
TEMPLATES
=
MapUtil
.<
String
,
String
>
builder
(
new
LinkedHashMap
<>())
// 有序
// Java Main
// Java
module-impl
Main
.
put
(
javaTemplatePath
(
"controller/vo/baseVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}BaseVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}BaseVO"
))
.
put
(
javaTemplatePath
(
"controller/vo/createReqVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}CreateReqVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}CreateReqVO"
))
.
put
(
javaTemplatePath
(
"controller/vo/pageReqVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}PageReqVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}PageReqVO"
))
.
put
(
javaTemplatePath
(
"controller/vo/respVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}RespVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}RespVO"
))
.
put
(
javaTemplatePath
(
"controller/vo/updateReqVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}UpdateReqVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}UpdateReqVO"
))
.
put
(
javaTemplatePath
(
"controller/vo/exportReqVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}ExportReqVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}ExportReqVO"
))
.
put
(
javaTemplatePath
(
"controller/vo/excelVO"
),
javaFilePath
(
"controller/${table.businessName}/vo/${table.className}ExcelVO"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/vo/${table.className}ExcelVO"
))
.
put
(
javaTemplatePath
(
"controller/controller"
),
javaFilePath
(
"controller/${table.businessName}/${table.className}Controller"
))
java
ModuleImplMain
FilePath
(
"controller/${table.businessName}/${table.className}Controller"
))
.
put
(
javaTemplatePath
(
"convert/convert"
),
javaFilePath
(
"convert/${table.businessName}/${table.className}Convert"
))
java
ModuleImplMain
FilePath
(
"convert/${table.businessName}/${table.className}Convert"
))
.
put
(
javaTemplatePath
(
"dal/do"
),
javaFilePath
(
"dal/dataobject/${table.businessName}/${table.className}DO"
))
java
ModuleImplMain
FilePath
(
"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"
),
java
FilePath
(
"service/${table.businessName}/impl
/${table.className}ServiceImpl"
))
java
ModuleImplMainFilePath
(
"service/${table.businessName}
/${table.className}ServiceImpl"
))
.
put
(
javaTemplatePath
(
"service/service"
),
javaFilePath
(
"service/${table.businessName}/${table.className}Service"
))
// Java Test
java
ModuleImplMain
FilePath
(
"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
<
String
,
Object
>
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
)
{
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/controller.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/controller.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
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
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
import
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.dal.dataobject.
${
table
.
businessName
}
.
${
table
.
className
}
DO;
import
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.convert.
${
table
.
businessName
}
.
${
table
.
className
}
Convert;
import
${
basePackage
}
.module
s
.
${
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
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/_column.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/_column.vm
浏览文件 @
b0c25ea9
文件已移动
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/baseVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/baseVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/createReqVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/createReqVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/excelVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/excelVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/exportReqVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/pageReqVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/respVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/respVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/controller/vo/updateReqVO.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/convert/convert.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/convert/convert.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
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
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
import
${
basePackage
}
.module
s
.
${
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
...
...
yudao-
admin-server
/src/main/resources/codegen/java/dal/do.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/dal/do.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.dal.dataobject.
${
table
.
businessName
}
;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.dal.dataobject.
${
table
.
businessName
}
;
import lombok.*;
import java.util.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/java/dal/mapper.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/dal/mapper.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
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
}
.module
s
.
${
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
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
import
${
basePackage
}
.module.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
## 字段模板
#
macro
(
listCondition
)
...
...
yudao-
admin-server
/src/main/resources/codegen/java/enums/errorcode.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/enums/errorcode.vm
浏览文件 @
b0c25ea9
文件已移动
yudao-
admin-server
/src/main/resources/codegen/java/service/service.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/service/service.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.service.
${
table
.
businessName
}
;
package
${
basePackage
}
.module.
${
table
.
moduleName
}
.service.
${
table
.
businessName
}
;
import java.util.*;
import javax.validation.*;
import
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
import
${
basePackage
}
.module
s
.
${
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
}
;
/**
...
...
yudao-
admin-server
/src/main/resources/codegen/java/service/serviceImpl.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/service/serviceImpl.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s.
${
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
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
import
${
basePackage
}
.module
s
.
${
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
}
.module
s
.
${
table
.
moduleName
}
.convert.
${
table
.
businessName
}
.
${
table
.
className
}
Convert;
import
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.dal.mysql.
${
table
.
businessName
}
.
${
table
.
className
}
Mapper;
import
${
basePackage
}
.module
s
.
${
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
}
.module
s.
${
table
.
moduleName
}
.enums.
${
simpleModuleName_upperFirst
}
ErrorCodeConstants.*;
import static
${
basePackage
}
.module
.
${
table
.
moduleName
}
.enums.
ErrorCodeConstants.*;
/**
*
${
table
.
classComment
}
Service 实现类
...
...
yudao-
admin-server
/src/main/resources/codegen/java/test/serviceTest.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/java/test/serviceTest.vm
浏览文件 @
b0c25ea9
package
${
basePackage
}
.module
s
.
${
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
}
.module
s
.
${
table
.
moduleName
}
.service.
${
table
.
businessName
}
.impl.
${
table
.
className
}
ServiceImpl;
import
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.controller.
${
table
.
businessName
}
.vo.*;
import
${
basePackage
}
.module
s
.
${
table
.
moduleName
}
.dal.dataobject.
${
table
.
businessName
}
.
${
table
.
className
}
DO;
import
${
basePackage
}
.module
s
.
${
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
}
.module
s.
${
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
}
.*;
...
...
yudao-
admin-server
/src/main/resources/codegen/sql/sql.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/sql/sql.vm
浏览文件 @
b0c25ea9
-- 菜单 SQL
INSERT INTO `sys_menu`(
INSERT INTO `sys
tem
_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 `sys
tem
_menu`(
`name`, `permission`, `menu_type`, `sort`, `parent_id`,
`path`, `icon`, `component`, `status`
)
...
...
yudao-
admin-server
/src/main/resources/codegen/vue/api/api.js.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/vue/api/api.js.vm
浏览文件 @
b0c25ea9
文件已移动
yudao-
admin-server
/src/main/resources/codegen/vue/views/index.vue.vm
→
yudao-
module-tool/yudao-module-tool-impl
/src/main/resources/codegen/vue/views/index.vue.vm
浏览文件 @
b0c25ea9
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录