多模块重构 11:修改代码生成器的实现

This commit is contained in:
YunaiV 2022-02-02 13:57:25 +08:00
parent 8d59384904
commit b0c25ea9f4
52 changed files with 195 additions and 163 deletions

View File

@ -1,11 +1,10 @@
package cn.iocoder.yudao.adminserver; package cn.iocoder.yudao.server;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package} ${yudao.core-service.base-package} @SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}", "${yudao.core-service.base-package}", @SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"})
"${yudao.info.base-package2}"}) // TODO 芋艿重构
public class AdminServerApplication { public class AdminServerApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.framework.monitor.config; package cn.iocoder.yudao.server.framework.monitor.config;
import de.codecentric.boot.admin.server.config.EnableAdminServer; import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

View File

@ -1,4 +1,4 @@
/** /**
* 使用 Spring Boot Admin 实现简单的监控平台 * 使用 Spring Boot Admin 实现简单的监控平台
*/ */
package cn.iocoder.yudao.adminserver.framework.monitor; package cn.iocoder.yudao.server.framework.monitor;

View File

@ -3,4 +3,4 @@
* *
* @author 芋道源码 * @author 芋道源码
*/ */
package cn.iocoder.yudao.adminserver.framework; package cn.iocoder.yudao.server.framework;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver.framework.security; package cn.iocoder.yudao.server.framework.security;
import cn.iocoder.yudao.framework.web.config.WebProperties; import cn.iocoder.yudao.framework.web.config.WebProperties;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;

View File

@ -163,16 +163,11 @@ logging:
name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径
level: level:
# 配置自己写的 MyBatis Mapper 打印日志 # 配置自己写的 MyBatis Mapper 打印日志
cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql: debug cn.iocoder.yudao.module.bpm.dal.mysql: debug
cn.iocoder.yudao.adminserver.modules.infra.dal.mysql: debug cn.iocoder.yudao.module.infra.dal.mysql: debug
cn.iocoder.yudao.adminserver.modules.pay.dal.mysql: debug cn.iocoder.yudao.module.pay.dal.mysql: debug
cn.iocoder.yudao.adminserver.modules.system.dal.mysql: debug cn.iocoder.yudao.module.system.dal.mysql: debug
cn.iocoder.yudao.adminserver.modules.tool.dal.mysql: debug cn.iocoder.yudao.module.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
--- #################### 微信公众号相关配置 #################### --- #################### 微信公众号相关配置 ####################
wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档 wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-starters/wx-java-mp-spring-boot-starter/README.md 文档

View File

@ -40,17 +40,14 @@ mybatis-plus:
id-type: AUTO # 自增 ID id-type: AUTO # 自增 ID
logic-delete-value: 1 # 逻辑已删除值(默认为 1) logic-delete-value: 1 # 逻辑已删除值(默认为 1)
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject, ${yudao.core-service.base-package}.modules.*.dal.dataobject type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject
--- #################### 芋道相关配置 #################### --- #################### 芋道相关配置 ####################
yudao: yudao:
info: info:
version: 1.0.0 version: 1.0.0
base-package: cn.iocoder.yudao.adminserver base-package: cn.iocoder.yudao
base-package2: cn.iocoder.yudao.module
core-service:
base-package: cn.iocoder.yudao.coreservice
web: web:
admin-api: admin-api:
prefix: /admin-api prefix: /admin-api

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver; package cn.iocoder.yudao.server;
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver; package cn.iocoder.yudao.server;
import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration; import cn.iocoder.yudao.framework.redis.config.YudaoRedisAutoConfiguration;
import org.redisson.spring.starter.RedissonAutoConfiguration; import org.redisson.spring.starter.RedissonAutoConfiguration;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.adminserver.framework.quartz.core; package cn.iocoder.yudao.server.framework.quartz.core;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob; import cn.iocoder.yudao.module.system.job.auth.SysUserSessionTimeoutJob;
import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager; import cn.iocoder.yudao.framework.quartz.core.scheduler.SchedulerManager;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.adminserver.framework.redis.core.stream; package cn.iocoder.yudao.server.framework.redis.core.stream;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.iocoder.yudao.adminserver.BaseRedisIntegrationTest; import cn.iocoder.yudao.server.BaseRedisIntegrationTest;
import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer; import cn.iocoder.yudao.module.system.mq.consumer.mail.SysMailSendConsumer;
import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer;
import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage; import cn.iocoder.yudao.module.system.mq.message.mail.SysMailSendMessage;

View File

@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.system.service.sms;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import cn.iocoder.yudao.adminserver.BaseDbAndRedisIntegrationTest; import cn.iocoder.yudao.server.BaseDbAndRedisIntegrationTest;
import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer; import cn.iocoder.yudao.module.system.mq.consumer.sms.SysSmsSendConsumer;
import cn.iocoder.yudao.module.system.mq.producer.sms.SysSmsProducer; import cn.iocoder.yudao.module.system.mq.producer.sms.SysSmsProducer;
import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl; import cn.iocoder.yudao.module.system.service.sms.impl.SysSmsChannelServiceImpl;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.tool.dal.mysql.codegen; package cn.iocoder.yudao.module.tool.dal.mysql.codegen;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.tool.dal.mysql.codegen; package cn.iocoder.yudao.module.tool.dal.mysql.codegen;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import javax.annotation.Resource; import javax.annotation.Resource;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.tool.service.codegen; package cn.iocoder.yudao.module.tool.service.codegen;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenColumnDO;
import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO; import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolCodegenTableDO;
import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper; import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenColumnMapper;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.tool.service.codegen; package cn.iocoder.yudao.module.tool.service.codegen;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser; import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.tool.service.codegen; package cn.iocoder.yudao.module.tool.service.codegen;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl; import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -33,6 +33,7 @@ export const DICT_TYPE = {
// ========== TOOL 模块 ========== // ========== TOOL 模块 ==========
TOOL_CODEGEN_TEMPLATE_TYPE: 'tool_codegen_template_type', TOOL_CODEGEN_TEMPLATE_TYPE: 'tool_codegen_template_type',
TOOL_CODEGEN_SCENE: 'tool_codegen_scene',
// ========== BPM 模块 ========== // ========== BPM 模块 ==========
BPM_MODEL_CATEGORY: 'bpm_model_category', BPM_MODEL_CATEGORY: 'bpm_model_category',

View File

@ -2,15 +2,20 @@
<el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px"> <el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px">
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item prop="tplCategory"> <el-form-item prop="templateType">
<span slot="label">生成模板</span> <span slot="label">生成模板</span>
<el-select v-model="info.templateType" @change="tplSelectChange"> <el-select v-model="info.templateType" @change="tplSelectChange">
<el-option <el-option v-for="dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_TEMPLATE_TYPE)"
v-for="dict in this.getDictDatas(DICT_TYPE.TOOL_CODEGEN_TEMPLATE_TYPE)" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
:key="parseInt(dict.value)" </el-select>
:label="dict.label" </el-form-item>
:value="parseInt(dict.value)" </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-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -249,6 +254,9 @@ export default {
templateType: [ templateType: [
{ required: true, message: "请选择生成模板", trigger: "blur" } { required: true, message: "请选择生成模板", trigger: "blur" }
], ],
scene: [
{ required: true, message: "请选择生成场景", trigger: "blur" }
],
// packageName: [ // packageName: [
// { required: true, message: "", trigger: "blur" } // { required: true, message: "", trigger: "blur" }
// ], // ],

View File

@ -15,9 +15,7 @@ import org.springframework.context.annotation.Configuration;
* @author 芋道源码 * @author 芋道源码
*/ */
@Configuration @Configuration
@MapperScan(value = {"${yudao.info.base-package}", "${yudao.core-service.base-package}", @MapperScan(value = "${yudao.info.base-package}", annotationClass = Mapper.class,
"${yudao.info.base-package2}"},
annotationClass = Mapper.class,
lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载目前仅用于单元测试 lazyInitialization = "${mybatis.lazy-initialization:false}") // Mapper 懒加载目前仅用于单元测试
public class YudaoMybatisAutoConfiguration { public class YudaoMybatisAutoConfiguration {

View File

@ -1,7 +1,7 @@
package cn.iocoder.yudao.module.bpm.service.definition; package cn.iocoder.yudao.module.bpm.service.definition;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.form.BpmFormUpdateReqVO;

View File

@ -1,6 +1,6 @@
package cn.iocoder.yudao.module.bpm.service.definition; package cn.iocoder.yudao.module.bpm.service.definition;
import cn.iocoder.yudao.adminserver.BaseDbUnitTest; import cn.iocoder.yudao.server.BaseDbUnitTest;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupCreateReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.group.BpmUserGroupUpdateReqVO;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.adminserver; package cn.iocoder.yudao.server;
import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration; import cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration;
import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration; import cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration;

View File

@ -23,6 +23,11 @@
<artifactId>yudao-module-tool-api</artifactId> <artifactId>yudao-module-tool-api</artifactId>
<version>${revision}</version> <version>${revision}</version>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 --> <!-- 业务组件 -->
<dependency> <dependency>

View File

@ -4,6 +4,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ZipUtil; import cn.hutool.core.util.ZipUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.CodegenDetailRespVO;
import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenPreviewRespVO; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenPreviewRespVO;
import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.CodegenUpdateReqVO;
@ -36,6 +37,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Api(tags = "管理后台 - 代码生成器") @Api(tags = "管理后台 - 代码生成器")
@RestController @RestController
@ -88,7 +90,7 @@ public class CodegenController {
@PostMapping("/create-list-from-db") @PostMapping("/create-list-from-db")
@PreAuthorize("@ss.hasPermission('tool:codegen:create')") @PreAuthorize("@ss.hasPermission('tool:codegen:create')")
public CommonResult<List<Long>> createCodegenListFromDB(@RequestParam("tableNames") List<String> tableNames) { public CommonResult<List<Long>> createCodegenListFromDB(@RequestParam("tableNames") List<String> tableNames) {
return success(codegenService.createCodegenListFromDB(tableNames)); return success(codegenService.createCodegenListFromDB(getLoginUserId(), tableNames));
} }
@ApiOperation("基于 SQL 建表语句,创建代码生成器的表和字段定义") @ApiOperation("基于 SQL 建表语句,创建代码生成器的表和字段定义")
@ -96,7 +98,7 @@ public class CodegenController {
@PostMapping("/create-list-from-sql") @PostMapping("/create-list-from-sql")
@PreAuthorize("@ss.hasPermission('tool:codegen:create')") @PreAuthorize("@ss.hasPermission('tool:codegen:create')")
public CommonResult<Long> createCodegenListFromSQL(@RequestParam("sql") String sql) { public CommonResult<Long> createCodegenListFromSQL(@RequestParam("sql") String sql) {
return success(codegenService.createCodegenListFromSQL(sql)); return success(codegenService.createCodegenListFromSQL(getLoginUserId(), sql));
} }
@ApiOperation("更新数据库的表和字段定义") @ApiOperation("更新数据库的表和字段定义")

View File

@ -16,6 +16,10 @@ public class CodegenTableBaseVO {
@NotNull(message = "导入类型不能为空") @NotNull(message = "导入类型不能为空")
private Integer importType; private Integer importType;
@ApiModelProperty(value = "生成场景", required = true, example = "1", notes = "参见 CodegenSceneEnum 枚举")
@NotNull(message = "导入类型不能为空")
private Integer scene;
@ApiModelProperty(value = "表名称", required = true, example = "yudao") @ApiModelProperty(value = "表名称", required = true, example = "yudao")
@NotNull(message = "表名称不能为空") @NotNull(message = "表名称不能为空")
private String tableName; private String tableName;

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.tool.dal.dataobject.codegen; package cn.iocoder.yudao.module.tool.dal.dataobject.codegen;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 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 cn.iocoder.yudao.module.tool.enums.codegen.CodegenTemplateTypeEnum;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
@ -29,6 +30,12 @@ public class CodegenTableDO extends BaseDO {
* 枚举 {@link CodegenTemplateTypeEnum} * 枚举 {@link CodegenTemplateTypeEnum}
*/ */
private Integer importType; private Integer importType;
/**
* 生成场景
*
* 枚举 {@link CodegenSceneEnum}
*/
private Integer scene;
// ========== 表相关字段 ========== // ========== 表相关字段 ==========

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.tool.enums.codegen;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 代码生成的场景枚举
*
* @author 芋道源码
*/
@AllArgsConstructor
@Getter
public enum CodegenSceneEnum {
ADMIN(1, "管理后台", "admin"),
APP(2, "用户 APP", "app");
/**
* 场景
*/
private final Integer scene;
/**
* 场景名
*/
private final String name;
/**
* 基础包名
*/
private final String basePackage;
}

View File

@ -20,26 +20,29 @@ public interface CodegenService {
/** /**
* 基于 SQL 建表语句创建代码生成器的表定义 * 基于 SQL 建表语句创建代码生成器的表定义
* *
* @param userId 用户编号
* @param sql SQL 建表语句 * @param sql SQL 建表语句
* @return 创建的表定义的编号 * @return 创建的表定义的编号
*/ */
Long createCodegenListFromSQL(String sql); Long createCodegenListFromSQL(Long userId, String sql);
/** /**
* 基于数据库的表结构创建代码生成器的表定义 * 基于数据库的表结构创建代码生成器的表定义
* *
* @param userId 用户编号
* @param tableName 表名称 * @param tableName 表名称
* @return 创建的表定义的编号 * @return 创建的表定义的编号
*/ */
Long createCodegen(String tableName); Long createCodegen(Long userId, String tableName);
/** /**
* 基于 {@link #createCodegen(String)} 的批量创建 * 基于 {@link #createCodegen(Long, String)} 的批量创建
* *
* @param userId 用户编号
* @param tableNames 表名称数组 * @param tableNames 表名称数组
* @return 创建的表定义的编号数组 * @return 创建的表定义的编号数组
*/ */
List<Long> createCodegenListFromDB(List<String> tableNames); List<Long> createCodegenListFromDB(Long userId, List<String> tableNames);
/** /**
* 更新数据库的表和字段定义 * 更新数据库的表和字段定义

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tool.service.codegen;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.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.CodegenUpdateReqVO;
import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO; import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO;
@ -50,6 +51,9 @@ public class CodegenServiceImpl implements CodegenService {
@Resource @Resource
private CodegenColumnMapper codegenColumnMapper; private CodegenColumnMapper codegenColumnMapper;
@Resource
private AdminUserApi userApi;
@Resource @Resource
private CodegenBuilder codegenBuilder; private CodegenBuilder codegenBuilder;
@Resource @Resource
@ -58,7 +62,7 @@ public class CodegenServiceImpl implements CodegenService {
@Resource @Resource
private CodegenProperties codegenProperties; private CodegenProperties codegenProperties;
private Long createCodegen0(CodegenImportTypeEnum importType, private Long createCodegen0(Long userId, CodegenImportTypeEnum importType,
SchemaTableDO schemaTable, List<SchemaColumnDO> schemaColumns) { SchemaTableDO schemaTable, List<SchemaColumnDO> schemaColumns) {
// 校验导入的表和字段非空 // 校验导入的表和字段非空
if (schemaTable == null) { if (schemaTable == null) {
@ -75,6 +79,7 @@ public class CodegenServiceImpl implements CodegenService {
// 构建 CodegenTableDO 对象插入到 DB // 构建 CodegenTableDO 对象插入到 DB
CodegenTableDO table = codegenBuilder.buildTable(schemaTable); CodegenTableDO table = codegenBuilder.buildTable(schemaTable);
table.setImportType(importType.getType()); table.setImportType(importType.getType());
table.setAuthor(userApi.getUser(userId).getNickname());
codegenTableMapper.insert(table); codegenTableMapper.insert(table);
// 构建 CodegenColumnDO 数组插入到 DB // 构建 CodegenColumnDO 数组插入到 DB
List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns); List<CodegenColumnDO> columns = codegenBuilder.buildColumns(schemaColumns);
@ -86,7 +91,7 @@ public class CodegenServiceImpl implements CodegenService {
} }
@Override @Override
public Long createCodegenListFromSQL(String sql) { public Long createCodegenListFromSQL(Long userId, String sql) {
// SQL 获得数据库表结构 // SQL 获得数据库表结构
SchemaTableDO schemaTable; SchemaTableDO schemaTable;
List<SchemaColumnDO> schemaColumns; List<SchemaColumnDO> schemaColumns;
@ -98,26 +103,26 @@ public class CodegenServiceImpl implements CodegenService {
throw exception(CODEGEN_PARSE_SQL_ERROR); throw exception(CODEGEN_PARSE_SQL_ERROR);
} }
// 导入 // 导入
return this.createCodegen0(CodegenImportTypeEnum.SQL, schemaTable, schemaColumns); return this.createCodegen0(userId, CodegenImportTypeEnum.SQL, schemaTable, schemaColumns);
} }
@Override @Override
public Long createCodegen(String tableName) { public Long createCodegen(Long userId, String tableName) {
// 获取当前schema // 获取当前schema
String tableSchema = codegenProperties.getDbSchemas().iterator().next(); String tableSchema = codegenProperties.getDbSchemas().iterator().next();
// 从数据库中获得数据库表结构 // 从数据库中获得数据库表结构
SchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName); SchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName);
List<SchemaColumnDO> schemaColumns = schemaColumnMapper.selectListByTableName(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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public List<Long> createCodegenListFromDB(List<String> tableNames) { public List<Long> createCodegenListFromDB(Long userId, List<String> tableNames) {
List<Long> ids = new ArrayList<>(tableNames.size()); List<Long> ids = new ArrayList<>(tableNames.size());
// 遍历添加虽然效率会低一点但是没必要做成完全批量因为不会这么大量 // 遍历添加虽然效率会低一点但是没必要做成完全批量因为不会这么大量
tableNames.forEach(tableName -> ids.add(createCodegen(tableName))); tableNames.forEach(tableName -> ids.add(createCodegen(userId, tableName)));
return ids; return ids;
} }

View File

@ -27,18 +27,6 @@ import static cn.hutool.core.text.CharSequenceUtil.*;
@Component @Component
public class CodegenBuilder { 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} 的默认映射 * 字段名与 {@link CodegenColumnListConditionEnum} 的默认映射
* 注意字段的匹配以后缀的方式 * 注意字段的匹配以后缀的方式
@ -125,8 +113,10 @@ public class CodegenBuilder {
* @param table 表定义 * @param table 表定义
*/ */
private void initTableDefault(CodegenTableDO table) { private void initTableDefault(CodegenTableDO table) {
table.setModuleName(getFullModuleName(StrUtil.subBefore(table.getTableName(), // system_dept 举例子moduleName systembusinessName deptclassName SystemDept
'_', false))); // 第一个 _ 前缀的前面作为 module 名字 // 如果不希望 System 前缀则可以手动在代码生成 - 修改生成配置 - 基本信息将实体类名称改为 Dept 即可
table.setModuleName(StrUtil.subBefore(table.getTableName(),
'_', false)); // 第一个 _ 前缀的前面作为 module 名字
table.setBusinessName(toCamelCase(subAfter(table.getTableName(), table.setBusinessName(toCamelCase(subAfter(table.getTableName(),
'_', false))); // 第一步第一个 _ 前缀的后面作为 module 名字; 第二步可能存在多个 _ 的情况转换成驼峰 '_', false))); // 第一步第一个 _ 前缀的后面作为 module 名字; 第二步可能存在多个 _ 的情况转换成驼峰
table.setClassName(upperFirst(toCamelCase(table.getTableName()))); // 驼峰 + 首字母大写 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
}
} }

View File

@ -53,38 +53,39 @@ public class CodegenEngine {
* value生成的路径 * value生成的路径
*/ */
private static final Map<String, String> TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序 private static final Map<String, String> TEMPLATES = MapUtil.<String, String>builder(new LinkedHashMap<>()) // 有序
// Java Main // Java module-impl Main
.put(javaTemplatePath("controller/vo/baseVO"), .put(javaTemplatePath("controller/vo/baseVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}BaseVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}BaseVO"))
.put(javaTemplatePath("controller/vo/createReqVO"), .put(javaTemplatePath("controller/vo/createReqVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}CreateReqVO"))
.put(javaTemplatePath("controller/vo/pageReqVO"), .put(javaTemplatePath("controller/vo/pageReqVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}PageReqVO"))
.put(javaTemplatePath("controller/vo/respVO"), .put(javaTemplatePath("controller/vo/respVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}RespVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}RespVO"))
.put(javaTemplatePath("controller/vo/updateReqVO"), .put(javaTemplatePath("controller/vo/updateReqVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}UpdateReqVO"))
.put(javaTemplatePath("controller/vo/exportReqVO"), .put(javaTemplatePath("controller/vo/exportReqVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExportReqVO"))
.put(javaTemplatePath("controller/vo/excelVO"), .put(javaTemplatePath("controller/vo/excelVO"),
javaFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO")) javaModuleImplMainFilePath("controller/${table.businessName}/vo/${table.className}ExcelVO"))
.put(javaTemplatePath("controller/controller"), .put(javaTemplatePath("controller/controller"),
javaFilePath("controller/${table.businessName}/${table.className}Controller")) javaModuleImplMainFilePath("controller/${table.businessName}/${table.className}Controller"))
.put(javaTemplatePath("convert/convert"), .put(javaTemplatePath("convert/convert"),
javaFilePath("convert/${table.businessName}/${table.className}Convert")) javaModuleImplMainFilePath("convert/${table.businessName}/${table.className}Convert"))
.put(javaTemplatePath("dal/do"), .put(javaTemplatePath("dal/do"),
javaFilePath("dal/dataobject/${table.businessName}/${table.className}DO")) javaModuleImplMainFilePath("dal/dataobject/${table.businessName}/${table.className}DO"))
.put(javaTemplatePath("dal/mapper"), .put(javaTemplatePath("dal/mapper"),
javaFilePath("dal/mysql/${table.businessName}/${table.className}Mapper")) javaModuleImplMainFilePath("dal/mysql/${table.businessName}/${table.className}Mapper"))
.put(javaTemplatePath("enums/errorcode"),
javaFilePath("enums/${simpleModuleName_upperFirst}ErrorCodeConstants"))
.put(javaTemplatePath("service/serviceImpl"), .put(javaTemplatePath("service/serviceImpl"),
javaFilePath("service/${table.businessName}/impl/${table.className}ServiceImpl")) javaModuleImplMainFilePath("service/${table.businessName}/${table.className}ServiceImpl"))
.put(javaTemplatePath("service/service"), .put(javaTemplatePath("service/service"),
javaFilePath("service/${table.businessName}/${table.className}Service")) javaModuleImplMainFilePath("service/${table.businessName}/${table.className}Service"))
// Java Test // Java module-impl Test
.put(javaTemplatePath("test/serviceTest"), .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 // Vue
.put(vueTemplatePath("views/index.vue"), .put(vueTemplatePath("views/index.vue"),
vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue")) vueFilePath("views/${table.moduleName}/${classNameVar}/index.vue"))
@ -121,7 +122,7 @@ public class CodegenEngine {
// 全局配置 // 全局配置
globalBindingMap.put("basePackage", codegenProperties.getBasePackage()); globalBindingMap.put("basePackage", codegenProperties.getBasePackage());
globalBindingMap.put("baseFrameworkPackage", StrUtil.subBefore(codegenProperties.getBasePackage(), globalBindingMap.put("baseFrameworkPackage", StrUtil.subBefore(codegenProperties.getBasePackage(),
'.', true) + '.' + "framework"); '.', true) + '.' + "framework"); // 用于后续获取测试类的 package 地址
// 全局 Java Bean // 全局 Java Bean
globalBindingMap.put("CommonResultClassName", CommonResult.class.getName()); globalBindingMap.put("CommonResultClassName", CommonResult.class.getName());
globalBindingMap.put("PageResultClassName", PageResult.class.getName()); globalBindingMap.put("PageResultClassName", PageResult.class.getName());
@ -149,13 +150,9 @@ public class CodegenEngine {
bindingMap.put("table", table); bindingMap.put("table", table);
bindingMap.put("columns", columns); bindingMap.put("columns", columns);
bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 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 相关 // className 相关
// 去掉指定前缀 TestDictType 转换成 DictType. 因为在 create 等方法后不需要带上 Test 前缀 // 去掉指定前缀 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", simpleClassName);
bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // DictType 转换成 dict_type bindingMap.put("simpleClassName_underlineCase", toUnderlineCase(simpleClassName)); // DictType 转换成 dict_type
bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // DictType 转换成 dictType用于变量 bindingMap.put("classNameVar", lowerFirst(simpleClassName)); // DictType 转换成 dictType用于变量
@ -177,8 +174,6 @@ public class CodegenEngine {
private String formatFilePath(String filePath, Map<String, Object> bindingMap) { private String formatFilePath(String filePath, Map<String, Object> bindingMap) {
filePath = StrUtil.replace(filePath, "${basePackage}", filePath = StrUtil.replace(filePath, "${basePackage}",
getStr(bindingMap, "basePackage").replaceAll("\\.", "/")); getStr(bindingMap, "basePackage").replaceAll("\\.", "/"));
filePath = StrUtil.replace(filePath, "${simpleModuleName_upperFirst}",
getStr(bindingMap, "simpleModuleName_upperFirst"));
filePath = StrUtil.replace(filePath, "${classNameVar}", filePath = StrUtil.replace(filePath, "${classNameVar}",
getStr(bindingMap, "classNameVar")); getStr(bindingMap, "classNameVar"));
@ -194,8 +189,23 @@ public class CodegenEngine {
return "codegen/java/" + path + ".vm"; return "codegen/java/" + path + ".vm";
} }
private static String javaFilePath(String path) { private static String javaModuleImplMainFilePath(String path) {
return "java/${basePackage}/modules/${table.moduleName}/" + path + ".java"; 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) { private static String vueTemplatePath(String path) {

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName};
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -22,10 +22,10 @@ import ${ExcelUtilsClassName};
import ${OperateLogClassName}; import ${OperateLogClassName};
import static ${OperateTypeEnumClassName}.*; import static ${OperateTypeEnumClassName}.*;
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*;
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service; import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service;
@Api(tags = "${table.classComment}") @Api(tags = "${table.classComment}")
@RestController @RestController

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo; package ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}; package ${basePackage}.module.${table.moduleName}.convert.${table.businessName};
import java.util.*; import java.util.*;
@ -6,8 +6,8 @@ import ${PageResultClassName};
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*;
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
/** /**
* ${table.classComment} Convert * ${table.classComment} Convert

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}; package ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName};
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;

View File

@ -1,13 +1,13 @@
package ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}; package ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName};
import java.util.*; import java.util.*;
import ${PageResultClassName}; import ${PageResultClassName};
import ${QueryWrapperClassName}; import ${QueryWrapperClassName};
import ${BaseMapperClassName}; import ${BaseMapperClassName};
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*;
## 字段模板 ## 字段模板
#macro(listCondition) #macro(listCondition)

View File

@ -1,9 +1,9 @@
package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}; package ${basePackage}.module.${table.moduleName}.service.${table.businessName};
import java.util.*; import java.util.*;
import javax.validation.*; import javax.validation.*;
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*;
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
import ${PageResultClassName}; import ${PageResultClassName};
/** /**

View File

@ -1,20 +1,20 @@
package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl; package ${basePackage}.module.${table.moduleName}.service.${table.businessName};
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.*; import java.util.*;
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*;
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
import ${PageResultClassName}; import ${PageResultClassName};
import ${basePackage}.modules.${table.moduleName}.convert.${table.businessName}.${table.className}Convert; import ${basePackage}.module.${table.moduleName}.convert.${table.businessName}.${table.className}Convert;
import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.${table.className}Service; import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.${table.className}Service;
import static ${ServiceExceptionUtilClassName}.exception; import static ${ServiceExceptionUtilClassName}.exception;
import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*;
/** /**
* ${table.classComment} Service 实现类 * ${table.classComment} Service 实现类

View File

@ -1,4 +1,4 @@
package ${basePackage}.modules.${table.moduleName}.service.${table.businessName}; package ${basePackage}.module.${table.moduleName}.service.${table.businessName};
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean; 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 javax.annotation.Resource;
import ${basePackage}.BaseDbUnitTest; import ${basePackage}.BaseDbUnitTest;
import ${basePackage}.modules.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl; import ${basePackage}.module.${table.moduleName}.service.${table.businessName}.impl.${table.className}ServiceImpl;
import ${basePackage}.modules.${table.moduleName}.controller.${table.businessName}.vo.*; import ${basePackage}.module.${table.moduleName}.controller.${table.businessName}.vo.*;
import ${basePackage}.modules.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO; import ${basePackage}.module.${table.moduleName}.dal.dataobject.${table.businessName}.${table.className}DO;
import ${basePackage}.modules.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper; import ${basePackage}.module.${table.moduleName}.dal.mysql.${table.businessName}.${table.className}Mapper;
import ${PageResultClassName}; import ${PageResultClassName};
import javax.annotation.Resource; import javax.annotation.Resource;
@ -17,7 +17,7 @@ import org.springframework.context.annotation.Import;
import java.util.*; import java.util.*;
import static cn.hutool.core.util.RandomUtil.*; import static cn.hutool.core.util.RandomUtil.*;
import static ${basePackage}.modules.${table.moduleName}.enums.${simpleModuleName_upperFirst}ErrorCodeConstants.*; import static ${basePackage}.module.${table.moduleName}.enums.ErrorCodeConstants.*;
import static ${baseFrameworkPackage}.test.core.util.AssertUtils.*; import static ${baseFrameworkPackage}.test.core.util.AssertUtils.*;
import static ${baseFrameworkPackage}.test.core.util.RandomUtils.*; import static ${baseFrameworkPackage}.test.core.util.RandomUtils.*;
import static ${ObjectUtilsClassName}.*; import static ${ObjectUtilsClassName}.*;

View File

@ -1,5 +1,5 @@
-- 菜单 SQL -- 菜单 SQL
INSERT INTO `sys_menu`( INSERT INTO `system_menu`(
`name`, `permission`, `menu_type`, `sort`, `parent_id`, `name`, `permission`, `menu_type`, `sort`, `parent_id`,
`path`, `icon`, `component`, `status` `path`, `icon`, `component`, `status`
) )
@ -16,7 +16,7 @@ SELECT @parentId := LAST_INSERT_ID();
#set ($functionOps = ['query', 'create', 'update', 'delete', 'export']) #set ($functionOps = ['query', 'create', 'update', 'delete', 'export'])
#foreach ($functionName in $functionNames) #foreach ($functionName in $functionNames)
#set ($index = $foreach.count - 1) #set ($index = $foreach.count - 1)
INSERT INTO `sys_menu`( INSERT INTO `system_menu`(
`name`, `permission`, `menu_type`, `sort`, `parent_id`, `name`, `permission`, `menu_type`, `sort`, `parent_id`,
`path`, `icon`, `component`, `status` `path`, `icon`, `component`, `status`
) )