diff --git a/pom.xml b/pom.xml index 1b4e139ee1..f56f07ddb7 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ yudao-module-system yudao-module-infra + yudao-module-tool ${artifactId} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenDetailRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenDetailRespVO.java deleted file mode 100644 index 4a1b10c517..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenDetailRespVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo; - -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.column.ToolCodegenColumnRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTableRespVO; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - -import java.util.List; - -@ApiModel("代码生成表和字段的明细 Response VO") -@Data -public class ToolCodegenDetailRespVO { - - @ApiModelProperty("表定义") - private ToolCodegenTableRespVO table; - - @ApiModelProperty("字段定义") - private List columns; - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/convert/codegen/ToolCodegenConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/convert/codegen/ToolCodegenConvert.java deleted file mode 100644 index 65bf461000..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/convert/codegen/ToolCodegenConvert.java +++ /dev/null @@ -1,70 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.convert.codegen; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenDetailRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenPreviewRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.column.ToolCodegenColumnRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTableRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolSchemaTableRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Mapper -public interface ToolCodegenConvert { - - ToolCodegenConvert INSTANCE = Mappers.getMapper(ToolCodegenConvert.class); - - // ========== ToolInformationSchemaTableDO 和 ToolInformationSchemaColumnDO 相关 ========== - - ToolCodegenTableDO convert(ToolSchemaTableDO bean); - - List convertList(List list); - - ToolCodegenTableRespVO convert(ToolSchemaColumnDO bean); - - // ========== ToolCodegenTableDO 相关 ========== - -// List convertList02(List list); - - ToolCodegenTableRespVO convert(ToolCodegenTableDO bean); - - PageResult convertPage(PageResult page); - - // ========== ToolCodegenTableDO 相关 ========== - - List convertList02(List list); - - ToolCodegenTableDO convert(ToolCodegenUpdateReqVO.Table bean); - - List convertList03(List columns); - - List convertList04(List list); - - // ========== 其它 ========== - - default ToolCodegenDetailRespVO convert(ToolCodegenTableDO table, List columns) { - ToolCodegenDetailRespVO respVO = new ToolCodegenDetailRespVO(); - respVO.setTable(convert(table)); - respVO.setColumns(convertList02(columns)); - return respVO; - } - - default List convert(Map codes) { - return codes.entrySet().stream().map(entry -> { - ToolCodegenPreviewRespVO respVO = new ToolCodegenPreviewRespVO(); - respVO.setFilePath(entry.getKey()); - respVO.setCode(entry.getValue()); - return respVO; - }).collect(Collectors.toList()); - } - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/convert/test/ToolTestDemoConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/convert/test/ToolTestDemoConvert.java deleted file mode 100644 index 8e88c59f4f..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/convert/test/ToolTestDemoConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.convert.test; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo.*; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.test.ToolTestDemoDO; - -/** - * 字典类型 Convert - * - * @author 芋艿 - */ -@Mapper -public interface ToolTestDemoConvert { - - ToolTestDemoConvert INSTANCE = Mappers.getMapper(ToolTestDemoConvert.class); - - ToolTestDemoDO convert(ToolTestDemoCreateReqVO bean); - - ToolTestDemoDO convert(ToolTestDemoUpdateReqVO bean); - - ToolTestDemoRespVO convert(ToolTestDemoDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolCodegenColumnMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolCodegenColumnMapper.java deleted file mode 100644 index 2fae426917..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolCodegenColumnMapper.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ToolCodegenColumnMapper extends BaseMapperX { - - default List selectListByTableId(Long tableId) { - return selectList(new QueryWrapper().eq("table_id", tableId) - .orderByAsc("ordinal_position")); - } - - default void deleteListByTableId(Long tableId) { - delete(new QueryWrapper().eq("table_id", tableId)); - } - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolCodegenTableMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolCodegenTableMapper.java deleted file mode 100644 index 31ce16f7b0..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolCodegenTableMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTablePageReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ToolCodegenTableMapper extends BaseMapperX { - - default ToolCodegenTableDO selectByTableName(String tableName) { - return selectOne(new QueryWrapper().eq("table_name", tableName)); - } - - default PageResult selectPage(ToolCodegenTablePageReqVO pageReqVO) { - return selectPage(pageReqVO, new QueryWrapperX() - .likeIfPresent("table_name", pageReqVO.getTableName()) - .likeIfPresent("table_comment", pageReqVO.getTableComment()) - .betweenIfPresent("create_time", pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime())); - } - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java deleted file mode 100644 index 4778da065f..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolSchemaColumnMapper.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaColumnDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -@Mapper -public interface ToolSchemaColumnMapper extends BaseMapperX { - - default List selectListByTableName(String tableSchema, String tableName) { - return selectList(new QueryWrapper().eq("table_name", tableName) - .eq("table_schema", tableSchema) - .orderByAsc("ordinal_position")); - } - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java deleted file mode 100644 index 7430ef69e3..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolSchemaTableMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen; - -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.List; - -@Mapper -public interface ToolSchemaTableMapper extends BaseMapperX { - - default List selectList(Collection tableSchemas, String tableName, String tableComment) { - return selectList(new QueryWrapperX().in("table_schema", tableSchemas) - .likeIfPresent("table_name", tableName) - .likeIfPresent("table_comment", tableComment)); - } - - default ToolSchemaTableDO selectByTableSchemaAndTableName(String tableSchema, String tableName) { - return selectOne(new QueryWrapper().eq("table_schema",tableSchema) - .eq("table_name", tableName)); - } - -} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/package-info.java deleted file mode 100644 index bb13d52514..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 代码生成器 - */ -package cn.iocoder.yudao.adminserver.modules.tool.framework.codegen; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/package-info.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/package-info.java deleted file mode 100644 index f1e361d134..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * tool 包下,我们放研发工具,提升研发效率与质量。 - * 例如说:代码生成器、接口文档等等 - * - * 缩写:tool - */ -package cn.iocoder.yudao.adminserver.modules.tool; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/test/impl/ToolTestDemoServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/test/impl/ToolTestDemoServiceImpl.java deleted file mode 100644 index ad8fd1e81e..0000000000 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/test/impl/ToolTestDemoServiceImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.test.impl; - -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; -import cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo.*; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.test.ToolTestDemoDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.adminserver.modules.tool.convert.test.ToolTestDemoConvert; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.test.ToolTestDemoMapper; -import cn.iocoder.yudao.adminserver.modules.tool.service.test.ToolTestDemoService; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.adminserver.modules.tool.enums.ToolErrorCodeConstants.*; - -/** - * 字典类型 Service 实现类 - * - * @author 芋艿 - */ -@Service -@Validated -public class ToolTestDemoServiceImpl implements ToolTestDemoService { - - @Resource - private ToolTestDemoMapper testDemoMapper; - - @Override - public Long createTestDemo(ToolTestDemoCreateReqVO createReqVO) { - // 插入 - ToolTestDemoDO testDemo = ToolTestDemoConvert.INSTANCE.convert(createReqVO); - testDemoMapper.insert(testDemo); - // 返回 - return testDemo.getId(); - } - - @Override - public void updateTestDemo(ToolTestDemoUpdateReqVO updateReqVO) { - // 校验存在 - this.validateTestDemoExists(updateReqVO.getId()); - // 更新 - ToolTestDemoDO updateObj = ToolTestDemoConvert.INSTANCE.convert(updateReqVO); - testDemoMapper.updateById(updateObj); - } - - @Override - public void deleteTestDemo(Long id) { - // 校验存在 - this.validateTestDemoExists(id); - // 删除 - testDemoMapper.deleteById(id); - } - - private void validateTestDemoExists(Long id) { - if (testDemoMapper.selectById(id) == null) { - throw exception(TEST_DEMO_NOT_EXISTS); - } - } - - @Override - public ToolTestDemoDO getTestDemo(Long id) { - return testDemoMapper.selectById(id); - } - - @Override - public List getTestDemoList(Collection ids) { - return testDemoMapper.selectBatchIds(ids); - } - - @Override - public PageResult getTestDemoPage(ToolTestDemoPageReqVO pageReqVO) { - return testDemoMapper.selectPage(pageReqVO); - } - - @Override - public List getTestDemoList(ToolTestDemoExportReqVO exportReqVO) { - return testDemoMapper.selectList(exportReqVO); - } - -} diff --git a/yudao-admin-server/src/main/resources/application-dev.yaml b/yudao-admin-server/src/main/resources/application-dev.yaml index 246d5e8830..d240bf0c65 100644 --- a/yudao-admin-server/src/main/resources/application-dev.yaml +++ b/yudao-admin-server/src/main/resources/application-dev.yaml @@ -100,7 +100,7 @@ apollo: eagerLoad: enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 - dao: cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigCoreDAOImpl + dao: cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigDAOImpl url: ${spring.datasource.dynamic.datasource.master.url} username: ${spring.datasource.dynamic.datasource.master.username} password: ${spring.datasource.dynamic.datasource.master.password} diff --git a/yudao-admin-server/src/main/resources/application-local.yaml b/yudao-admin-server/src/main/resources/application-local.yaml index 9bdeb775bb..addd7fbfa0 100644 --- a/yudao-admin-server/src/main/resources/application-local.yaml +++ b/yudao-admin-server/src/main/resources/application-local.yaml @@ -113,7 +113,7 @@ apollo: eagerLoad: enabled: true # 设置 Apollo 在日志初始化前生效,可以实现日志的动态级别配置 jdbc: # 自定义的 JDBC 配置项,用于数据库的地址 - dao: cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigCoreDAOImpl + dao: cn.iocoder.yudao.module.infra.dal.mysql.config.ConfigDAOImpl url: ${spring.datasource.dynamic.datasource.master.url} username: ${spring.datasource.dynamic.datasource.master.username} password: ${spring.datasource.dynamic.datasource.master.password} diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java index 1e86eb5d82..f945ddbe2d 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaColumnMapperTest.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen; +package cn.iocoder.yudao.module.tool.dal.mysql.codegen; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.ToolSchemaColumnDO; import org.junit.jupiter.api.Test; import javax.annotation.Resource; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java index 35d91b8c45..88b4c58b2c 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/codegen/ToolInformationSchemaTableMapperTest.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen; +package cn.iocoder.yudao.module.tool.dal.mysql.codegen; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java index a8a7857e97..6a461f0c06 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenEngineTest.java @@ -1,11 +1,11 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen; +package cn.iocoder.yudao.module.tool.service.codegen; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen.ToolCodegenColumnMapper; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen.ToolCodegenTableMapper; -import cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl.ToolCodegenEngine; +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; +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.ToolCodegenTableMapper; +import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenEngine; import org.junit.jupiter.api.Test; import javax.annotation.Resource; diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java index 44c909118a..e498dc02ee 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenSQLParserTest.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen; +package cn.iocoder.yudao.module.tool.service.codegen; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; -import cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl.ToolCodegenSQLParser; +import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenSQLParser; import org.junit.jupiter.api.Test; public class ToolCodegenSQLParserTest extends BaseDbUnitTest { diff --git a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java index 87661a3cd8..cedd3870aa 100644 --- a/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java +++ b/yudao-admin-server/src/test-integration/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenServiceImplTest.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen; +package cn.iocoder.yudao.module.tool.service.codegen; import cn.iocoder.yudao.adminserver.BaseDbUnitTest; -import cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl.ToolCodegenServiceImpl; +import cn.iocoder.yudao.module.tool.service.codegen.impl.ToolCodegenServiceImpl; import org.junit.jupiter.api.Test; import javax.annotation.Resource; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/api/package-info.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/api/package-info.java deleted file mode 100644 index 0354f00bce..0000000000 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/api/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.yudao.module.system.api; diff --git a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index f237049bdd..afc66ebd2a 100644 --- a/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -137,7 +137,6 @@ public class AdminAuthServiceImpl implements AdminAuthService { // 在其内部,会调用到 loadUserByUsername 方法,获取 User 信息 authentication = authenticationManager.authenticate(new MultiUsernamePasswordAuthenticationToken( username, password, getUserType())); - // org.activiti.engine.impl.identity.Authentication.setAuthenticatedUserId(username); } catch (BadCredentialsException badCredentialsException) { this.createLoginLog(username, logTypeEnum, LoginResultEnum.BAD_CREDENTIALS); throw exception(AUTH_LOGIN_BAD_CREDENTIALS); diff --git a/yudao-module-tool/pom.xml b/yudao-module-tool/pom.xml new file mode 100644 index 0000000000..094286fa6e --- /dev/null +++ b/yudao-module-tool/pom.xml @@ -0,0 +1,24 @@ + + + + cn.iocoder.boot + yudao + ${revision} + + 4.0.0 + + yudao-module-tool-api + yudao-module-tool-impl + + yudao-module-tool + pom + + ${artifactId} + + tool 模块,我们放研发工具,提升研发效率与质量。 + 例如说:代码生成器、接口文档等等 + + + diff --git a/yudao-module-tool/yudao-module-tool-api/pom.xml b/yudao-module-tool/yudao-module-tool-api/pom.xml new file mode 100644 index 0000000000..ea237be1fc --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-api/pom.xml @@ -0,0 +1,26 @@ + + + + cn.iocoder.boot + yudao-module-tool + ${revision} + + 4.0.0 + yudao-module-tool-api + jar + + ${artifactId} + + tool 模块 API,暴露给其它模块调用 + + + + + cn.iocoder.boot + yudao-common + + + + diff --git a/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/api/package-info.java b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/api/package-info.java new file mode 100644 index 0000000000..77a92cf560 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/api/package-info.java @@ -0,0 +1,4 @@ +/** + * Tool API 包,定义暴露给其它模块的 API + */ +package cn.iocoder.yudao.module.tool.api; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/ToolDictTypeConstants.java b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/enums/DictTypeConstants.java similarity index 55% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/ToolDictTypeConstants.java rename to yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/enums/DictTypeConstants.java index 1bf2b7a1d0..f22e39f1ed 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/ToolDictTypeConstants.java +++ b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/enums/DictTypeConstants.java @@ -1,11 +1,11 @@ -package cn.iocoder.yudao.adminserver.modules.tool.enums; +package cn.iocoder.yudao.module.tool.enums; /** * Tool 字典类型的枚举类 * * @author 芋道源码 */ -public interface ToolDictTypeConstants { +public interface DictTypeConstants { String TEST_DEMO_TYPE = "tool_test_demo_type"; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/ToolErrorCodeConstants.java b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/enums/ErrorCodeConstants.java similarity index 91% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/ToolErrorCodeConstants.java rename to yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/enums/ErrorCodeConstants.java index cdf341d749..2d62edc1be 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/ToolErrorCodeConstants.java +++ b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/enums/ErrorCodeConstants.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.enums; +package cn.iocoder.yudao.module.tool.enums; import cn.iocoder.yudao.framework.common.exception.ErrorCode; @@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.common.exception.ErrorCode; * * tool 系统,使用 1-003-000-000 段 */ -public interface ToolErrorCodeConstants { +public interface ErrorCodeConstants { // ========== 字典类型(测试) 1003000000 ========== ErrorCode TEST_DEMO_NOT_EXISTS = new ErrorCode(1003000000, "测试示例不存在"); diff --git a/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/package-info.java b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/package-info.java new file mode 100644 index 0000000000..1b5a668009 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-api/src/main/java/cn/iocoder/yudao/module/tool/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.tool; diff --git a/yudao-module-tool/yudao-module-tool-impl/pom.xml b/yudao-module-tool/yudao-module-tool-impl/pom.xml new file mode 100644 index 0000000000..8c8737a4f3 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/pom.xml @@ -0,0 +1,85 @@ + + + + yudao-module-tool + cn.iocoder.boot + ${revision} + + 4.0.0 + yudao-module-tool-impl + jar + + ${artifactId} + + tool 模块,我们放研发工具,提升研发效率与质量。 + 例如说:代码生成器、接口文档等等 + + + + + cn.iocoder.boot + yudao-module-tool-api + ${revision} + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-operatelog + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-dict + + + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + + + cn.iocoder.boot + yudao-spring-boot-starter-test + test + + + + + cn.iocoder.boot + yudao-spring-boot-starter-excel + + + + + + ${artifactId} + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + repackage + + + + + + + + diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/ToolCodegenController.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java similarity index 73% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/ToolCodegenController.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java index a6bd6a64b9..4523b1ab40 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/ToolCodegenController.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/CodegenController.java @@ -1,20 +1,20 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen; +package cn.iocoder.yudao.module.tool.controller.admin.codegen; 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.adminserver.modules.tool.controller.codegen.vo.ToolCodegenDetailRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenPreviewRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTablePageReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTableRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolSchemaTableRespVO; -import cn.iocoder.yudao.adminserver.modules.tool.convert.codegen.ToolCodegenConvert; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.service.codegen.ToolCodegenService; +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; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTableRespVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.SchemaTableRespVO; +import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; +import cn.iocoder.yudao.module.tool.service.codegen.CodegenService; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import io.swagger.annotations.Api; @@ -37,14 +37,14 @@ import java.util.Set; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Api(tags = "代码生成器") +@Api(tags = "管理后台 - 代码生成器") @RestController @RequestMapping("/tool/codegen") @Validated -public class ToolCodegenController { +public class CodegenController { @Resource - private ToolCodegenService codegenService; + private CodegenService codegenService; @GetMapping("/db/table/list") @ApiOperation(value = "获得数据库自带的表定义列表", notes = "会过滤掉已经导入 Codegen 的表") @@ -53,34 +53,34 @@ public class ToolCodegenController { @ApiImplicitParam(name = "tableComment", value = "描述,模糊匹配", required = true, example = "芋道", dataTypeClass = String.class) }) @PreAuthorize("@ss.hasPermission('tool:codegen:query')") - public CommonResult> getSchemaTableList( + public CommonResult> getSchemaTableList( @RequestParam(value = "tableName", required = false) String tableName, @RequestParam(value = "tableComment", required = false) String tableComment) { // 获得数据库自带的表定义列表 - List schemaTables = codegenService.getSchemaTableList(tableName, tableComment); + List schemaTables = codegenService.getSchemaTableList(tableName, tableComment); // 移除在 Codegen 中,已经存在的 - Set existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), ToolCodegenTableDO::getTableName); + Set existsTables = CollectionUtils.convertSet(codegenService.getCodeGenTableList(), CodegenTableDO::getTableName); schemaTables.removeIf(table -> existsTables.contains(table.getTableName())); - return success(ToolCodegenConvert.INSTANCE.convertList04(schemaTables)); + return success(CodegenConvert.INSTANCE.convertList04(schemaTables)); } @GetMapping("/table/page") @ApiOperation("获得表定义分页") @PreAuthorize("@ss.hasPermission('tool:codegen:query')") - public CommonResult> getCodeGenTablePage(@Valid ToolCodegenTablePageReqVO pageReqVO) { - PageResult pageResult = codegenService.getCodegenTablePage(pageReqVO); - return success(ToolCodegenConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getCodeGenTablePage(@Valid CodegenTablePageReqVO pageReqVO) { + PageResult pageResult = codegenService.getCodegenTablePage(pageReqVO); + return success(CodegenConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/detail") @ApiOperation("获得表和字段的明细") @ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('tool:codegen:query')") - public CommonResult getCodegenDetail(@RequestParam("tableId") Long tableId) { - ToolCodegenTableDO table = codegenService.getCodegenTablePage(tableId); - List columns = codegenService.getCodegenColumnListByTableId(tableId); + public CommonResult getCodegenDetail(@RequestParam("tableId") Long tableId) { + CodegenTableDO table = codegenService.getCodegenTablePage(tableId); + List columns = codegenService.getCodegenColumnListByTableId(tableId); // 拼装返回 - return success(ToolCodegenConvert.INSTANCE.convert(table, columns)); + return success(CodegenConvert.INSTANCE.convert(table, columns)); } @ApiOperation("基于数据库的表结构,创建代码生成器的表和字段定义") @@ -102,7 +102,7 @@ public class ToolCodegenController { @ApiOperation("更新数据库的表和字段定义") @PutMapping("/update") @PreAuthorize("@ss.hasPermission('tool:codegen:update')") - public CommonResult updateCodegen(@Valid @RequestBody ToolCodegenUpdateReqVO updateReqVO) { + public CommonResult updateCodegen(@Valid @RequestBody CodegenUpdateReqVO updateReqVO) { codegenService.updateCodegen(updateReqVO); return success(true); } @@ -142,9 +142,9 @@ public class ToolCodegenController { @GetMapping("/preview") @ApiImplicitParam(name = "tableId", value = "表编号", required = true, example = "1024", dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('tool:codegen:preview')") - public CommonResult> previewCodegen(@RequestParam("tableId") Long tableId) { + public CommonResult> previewCodegen(@RequestParam("tableId") Long tableId) { Map codes = codegenService.generationCodes(tableId); - return success(ToolCodegenConvert.INSTANCE.convert(codes)); + return success(CodegenConvert.INSTANCE.convert(codes)); } @ApiOperation("下载生成代码") diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenDetailRespVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenDetailRespVO.java new file mode 100644 index 0000000000..c4e6ce068d --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenDetailRespVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo; + +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.column.CodegenColumnRespVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTableRespVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +@ApiModel("管理后台 - 代码生成表和字段的明细 Response VO") +@Data +public class CodegenDetailRespVO { + + @ApiModelProperty("表定义") + private CodegenTableRespVO table; + + @ApiModelProperty("字段定义") + private List columns; + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenPreviewRespVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenPreviewRespVO.java similarity index 65% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenPreviewRespVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenPreviewRespVO.java index 3a532708ad..5c2ec6858f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenPreviewRespVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenPreviewRespVO.java @@ -1,12 +1,12 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; -@ApiModel(value = "代码生成预览 Response VO", description ="注意,每个文件都是一个该对象") +@ApiModel(value = "管理后台 - 代码生成预览 Response VO", description ="注意,每个文件都是一个该对象") @Data -public class ToolCodegenPreviewRespVO { +public class CodegenPreviewRespVO { @ApiModelProperty(value = "文件路径", required = true, example = "java/cn/iocoder/yudao/adminserver/modules/system/controller/test/SysTestDemoController.java") private String filePath; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenUpdateReqVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenUpdateReqVO.java similarity index 65% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenUpdateReqVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenUpdateReqVO.java index b82064ecc9..eb20c60218 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/ToolCodegenUpdateReqVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/CodegenUpdateReqVO.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.column.ToolCodegenColumnBaseVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTableBaseVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTableBaseVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.column.CodegenColumnBaseVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -12,9 +12,9 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import java.util.List; -@ApiModel("代码生成表和字段的修改 Request VO") +@ApiModel("管理后台 - 代码生成表和字段的修改 Request VO") @Data -public class ToolCodegenUpdateReqVO { +public class CodegenUpdateReqVO { @Valid // 校验内嵌的字段 @NotNull(message = "表定义不能为空") @@ -28,7 +28,7 @@ public class ToolCodegenUpdateReqVO { @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) - public static class Table extends ToolCodegenTableBaseVO { + public static class Table extends CodegenTableBaseVO { @ApiModelProperty(value = "编号", required = true, example = "1") private Long id; @@ -39,7 +39,7 @@ public class ToolCodegenUpdateReqVO { @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) - public static class Column extends ToolCodegenColumnBaseVO { + public static class Column extends CodegenColumnBaseVO { @ApiModelProperty(value = "编号", required = true, example = "1") private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/column/ToolCodegenColumnBaseVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/column/CodegenColumnBaseVO.java similarity index 94% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/column/ToolCodegenColumnBaseVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/column/CodegenColumnBaseVO.java index bd899712f0..5a9b693370 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/column/ToolCodegenColumnBaseVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/column/CodegenColumnBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.column; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.column; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull; * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class ToolCodegenColumnBaseVO { +public class CodegenColumnBaseVO { @ApiModelProperty(value = "表编号", required = true, example = "1") @NotNull(message = "表编号不能为空") @@ -70,7 +70,7 @@ public class ToolCodegenColumnBaseVO { @NotNull(message = "是否为 List 查询操作的字段不能为空") private Boolean listOperation; - @ApiModelProperty(value = "List 查询操作的条件类型", required = true, example = "LIKE", notes = "参见 ToolCodegenColumnListConditionEnum 枚举") + @ApiModelProperty(value = "List 查询操作的条件类型", required = true, example = "LIKE", notes = "参见 CodegenColumnListConditionEnum 枚举") @NotNull(message = "List 查询操作的条件类型不能为空") private String listOperationCondition; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/column/ToolCodegenColumnRespVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/column/CodegenColumnRespVO.java similarity index 69% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/column/ToolCodegenColumnRespVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/column/CodegenColumnRespVO.java index c7d556427d..358f1f506f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/column/ToolCodegenColumnRespVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/column/CodegenColumnRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.column; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.column; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -8,11 +8,11 @@ import lombok.ToString; import java.util.Date; -@ApiModel("代码生成字段定义 Response VO") +@ApiModel("管理后台 - 代码生成字段定义 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolCodegenColumnRespVO extends ToolCodegenColumnBaseVO { +public class CodegenColumnRespVO extends CodegenColumnBaseVO { @ApiModelProperty(value = "编号", required = true, example = "1") private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTableBaseVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java similarity index 87% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTableBaseVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java index e4fa2ab749..1b57219fa4 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTableBaseVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,9 +10,9 @@ import javax.validation.constraints.NotNull; * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class ToolCodegenTableBaseVO { +public class CodegenTableBaseVO { - @ApiModelProperty(value = "导入类型", required = true, example = "1", notes = "参见 ToolCodegenImportTypeEnum 枚举") + @ApiModelProperty(value = "导入类型", required = true, example = "1", notes = "参见 CodegenImportTypeEnum 枚举") @NotNull(message = "导入类型不能为空") private Integer importType; @@ -35,7 +35,7 @@ public class ToolCodegenTableBaseVO { @NotNull(message = "业务名不能为空") private String businessName; - @ApiModelProperty(value = "类名称", required = true, example = "ToolCodegenTable") + @ApiModelProperty(value = "类名称", required = true, example = "CodegenTable") @NotNull(message = "类名称不能为空") private String className; @@ -47,7 +47,7 @@ public class ToolCodegenTableBaseVO { @NotNull(message = "作者不能为空") private String author; - @ApiModelProperty(value = "模板类型", required = true, example = "1", notes = "参见 ToolCodegenTemplateTypeEnum 枚举") + @ApiModelProperty(value = "模板类型", required = true, example = "1", notes = "参见 CodegenTemplateTypeEnum 枚举") @NotNull(message = "模板类型不能为空") private Integer templateType; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTablePageReqVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTablePageReqVO.java similarity index 85% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTablePageReqVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTablePageReqVO.java index b09238b062..69095e277b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTablePageReqVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTablePageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.annotations.ApiModel; @@ -12,11 +12,11 @@ import java.util.Date; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@ApiModel("表定义分页 Request VO") +@ApiModel("管理后台 - 表定义分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolCodegenTablePageReqVO extends PageParam { +public class CodegenTablePageReqVO extends PageParam { @ApiModelProperty(value = "表名称", example = "yudao", notes = "模糊匹配") private String tableName; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTableRespVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableRespVO.java similarity index 73% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTableRespVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableRespVO.java index 73ec3f880b..06d7c0d459 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolCodegenTableRespVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/CodegenTableRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -8,11 +8,11 @@ import lombok.ToString; import java.util.Date; -@ApiModel("代码生成表定义 Response VO") +@ApiModel("管理后台 - 代码生成表定义 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolCodegenTableRespVO extends ToolCodegenTableBaseVO { +public class CodegenTableRespVO extends CodegenTableBaseVO { @ApiModelProperty(value = "编号", required = true, example = "1") private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolSchemaTableRespVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/SchemaTableRespVO.java similarity index 77% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolSchemaTableRespVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/SchemaTableRespVO.java index 284856f291..8b54b64f27 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/codegen/vo/table/ToolSchemaTableRespVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/codegen/vo/table/SchemaTableRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table; +package cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -6,9 +6,9 @@ import lombok.Data; import java.util.Date; -@ApiModel("数据字典的表定义 Response VO") +@ApiModel("管理后台 - 数据字典的表定义 Response VO") @Data -public class ToolSchemaTableRespVO { +public class SchemaTableRespVO { @ApiModelProperty(value = "数据库", required = true, example = "yudao") private String tableSchema; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/ToolTestDemoController.http b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.http similarity index 80% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/ToolTestDemoController.http rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.http index b10a3d293b..25b1682dbf 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/ToolTestDemoController.http +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.http @@ -1,7 +1,9 @@ ### 请求 /tool/test-demo/get 接口 => 成功 GET {{baseUrl}}/tool/test-demo/get?id=1 Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} ### 请求 /tool/test-demo/list 接口 => 成功 GET {{baseUrl}}/tool/test-demo/list?ids=1 Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/ToolTestDemoController.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.java similarity index 60% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/ToolTestDemoController.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.java index 2249af538c..dcf2602078 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/ToolTestDemoController.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/TestDemoController.java @@ -1,15 +1,13 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test; +package cn.iocoder.yudao.module.tool.controller.admin.test; -import cn.hutool.core.thread.ThreadUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import cn.iocoder.yudao.framework.tracer.core.annotation.BizTrace; -import cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo.*; -import cn.iocoder.yudao.adminserver.modules.tool.convert.test.ToolTestDemoConvert; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.test.ToolTestDemoDO; -import cn.iocoder.yudao.adminserver.modules.tool.service.test.ToolTestDemoService; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.*; +import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; +import cn.iocoder.yudao.module.tool.service.test.TestDemoService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -23,31 +21,30 @@ import javax.validation.Valid; import java.io.IOException; import java.util.Collection; import java.util.List; -import java.util.concurrent.TimeUnit; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -@Api(tags = "测试示例") +@Api(tags = "管理后台 - 测试示例") @RestController @RequestMapping("/tool/test-demo") @Validated -public class ToolTestDemoController { +public class TestDemoController { @Resource - private ToolTestDemoService testDemoService; + private TestDemoService testDemoService; @PostMapping("/create") @ApiOperation("创建测试示例") @PreAuthorize("@ss.hasPermission('tool:test-demo:create')") - public CommonResult createTestDemo(@Valid @RequestBody ToolTestDemoCreateReqVO createReqVO) { + public CommonResult createTestDemo(@Valid @RequestBody TestDemoCreateReqVO createReqVO) { return success(testDemoService.createTestDemo(createReqVO)); } @PutMapping("/update") @ApiOperation("更新测试示例") @PreAuthorize("@ss.hasPermission('tool:test-demo:update')") - public CommonResult updateTestDemo(@Valid @RequestBody ToolTestDemoUpdateReqVO updateReqVO) { + public CommonResult updateTestDemo(@Valid @RequestBody TestDemoUpdateReqVO updateReqVO) { testDemoService.updateTestDemo(updateReqVO); return success(true); } @@ -66,12 +63,9 @@ public class ToolTestDemoController { @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") // @Lock4j // 分布式锁 - public CommonResult getTestDemo(@RequestParam("id") Long id) { - if (true) { // 测试分布式锁 - ThreadUtil.sleep(5, TimeUnit.SECONDS); - } - ToolTestDemoDO testDemo = testDemoService.getTestDemo(id); - return success(ToolTestDemoConvert.INSTANCE.convert(testDemo)); + public CommonResult getTestDemo(@RequestParam("id") Long id) { + TestDemoDO testDemo = testDemoService.getTestDemo(id); + return success(TestDemoConvert.INSTANCE.convert(testDemo)); } @GetMapping("/list") @@ -79,30 +73,29 @@ public class ToolTestDemoController { @ApiImplicitParam(name = "ids", value = "编号列表", required = true, dataTypeClass = List.class) @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") // @RateLimiter(name = "backendA") - @BizTrace(id = "#ids", type = "'user'") - public CommonResult> getTestDemoList(@RequestParam("ids") Collection ids) { - List list = testDemoService.getTestDemoList(ids); - return success(ToolTestDemoConvert.INSTANCE.convertList(list)); + public CommonResult> getTestDemoList(@RequestParam("ids") Collection ids) { + List list = testDemoService.getTestDemoList(ids); + return success(TestDemoConvert.INSTANCE.convertList(list)); } @GetMapping("/page") @ApiOperation("获得测试示例分页") @PreAuthorize("@ss.hasPermission('tool:test-demo:query')") - public CommonResult> getTestDemoPage(@Valid ToolTestDemoPageReqVO pageVO) { - PageResult pageResult = testDemoService.getTestDemoPage(pageVO); - return success(ToolTestDemoConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getTestDemoPage(@Valid TestDemoPageReqVO pageVO) { + PageResult pageResult = testDemoService.getTestDemoPage(pageVO); + return success(TestDemoConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") @ApiOperation("导出测试示例 Excel") @PreAuthorize("@ss.hasPermission('tool:test-demo:export')") @OperateLog(type = EXPORT) - public void exportTestDemoExcel(@Valid ToolTestDemoExportReqVO exportReqVO, + public void exportTestDemoExcel(@Valid TestDemoExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = testDemoService.getTestDemoList(exportReqVO); + List list = testDemoService.getTestDemoList(exportReqVO); // 导出 Excel - List datas = ToolTestDemoConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "测试示例.xls", "数据", ToolTestDemoExcelVO.class, datas); + List datas = TestDemoConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "测试示例.xls", "数据", TestDemoExcelVO.class, datas); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoBaseVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoBaseVO.java similarity index 90% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoBaseVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoBaseVO.java index 0e1af3c281..4defee52db 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoBaseVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull; * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class ToolTestDemoBaseVO { +public class TestDemoBaseVO { @ApiModelProperty(value = "名字", required = true, example = "芋道") @NotNull(message = "名字不能为空") diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoCreateReqVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoCreateReqVO.java similarity index 51% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoCreateReqVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoCreateReqVO.java index b1866f780e..7c6f6d19f3 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoCreateReqVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoCreateReqVO.java @@ -1,14 +1,14 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import io.swagger.annotations.ApiModel; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@ApiModel("字典类型创建 Request VO") +@ApiModel("管理后台 - 字典类型创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolTestDemoCreateReqVO extends ToolTestDemoBaseVO { +public class TestDemoCreateReqVO extends TestDemoBaseVO { } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoExcelVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExcelVO.java similarity index 67% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoExcelVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExcelVO.java index 384c08bc52..c947d30326 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoExcelVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExcelVO.java @@ -1,8 +1,7 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; @@ -14,7 +13,7 @@ import java.util.Date; * @author 芋艿 */ @Data -public class ToolTestDemoExcelVO { +public class TestDemoExcelVO { @ExcelProperty("编号") private Long id; @@ -23,15 +22,15 @@ public class ToolTestDemoExcelVO { private String name; @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.COMMON_STATUS) + @DictFormat("") private Integer status; @ExcelProperty(value = "类型", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.OPERATE_TYPE) + @DictFormat("sys_common_status") private Integer type; @ExcelProperty(value = "分类", converter = DictConvert.class) - @DictFormat(DictTypeConstants.REDIS_TIMEOUT_TYPE) + @DictFormat("inf_redis_timeout_type") private Integer category; @ExcelProperty("备注") diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoExportReqVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExportReqVO.java similarity index 82% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoExportReqVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExportReqVO.java index 84bce9e946..78924ec770 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoExportReqVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoExportReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -9,9 +9,9 @@ import java.util.Date; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@ApiModel(value = "字典类型 Excel 导出 Request VO", description = "参数和 ToolTestDemoPageReqVO 是一致的") +@ApiModel(value = "管理后台 - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的") @Data -public class ToolTestDemoExportReqVO { +public class TestDemoExportReqVO { @ApiModelProperty(value = "名字", example = "芋道") private String name; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoPageReqVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoPageReqVO.java similarity index 87% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoPageReqVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoPageReqVO.java index 05fa1573e4..39180a784f 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoPageReqVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoPageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.annotations.ApiModel; @@ -12,11 +12,11 @@ import java.util.Date; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@ApiModel("字典类型分页 Request VO") +@ApiModel("管理后台 - 字典类型分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolTestDemoPageReqVO extends PageParam { +public class TestDemoPageReqVO extends PageParam { @ApiModelProperty(value = "名字", example = "芋道") private String name; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoRespVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoRespVO.java similarity index 72% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoRespVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoRespVO.java index e679fd4b0f..61d2b60389 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoRespVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -8,11 +8,11 @@ import lombok.ToString; import java.util.Date; -@ApiModel("字典类型 Response VO") +@ApiModel("管理后台 - 字典类型 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolTestDemoRespVO extends ToolTestDemoBaseVO { +public class TestDemoRespVO extends TestDemoBaseVO { @ApiModelProperty(value = "编号", required = true, example = "1") private Long id; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoUpdateReqVO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoUpdateReqVO.java similarity index 70% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoUpdateReqVO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoUpdateReqVO.java index ef05d44c65..eceb3a0d3c 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/controller/test/vo/ToolTestDemoUpdateReqVO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/admin/test/vo/TestDemoUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo; +package cn.iocoder.yudao.module.tool.controller.admin.test.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -8,11 +8,11 @@ import lombok.ToString; import javax.validation.constraints.NotNull; -@ApiModel("字典类型更新 Request VO") +@ApiModel("管理后台 - 字典类型更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ToolTestDemoUpdateReqVO extends ToolTestDemoBaseVO { +public class TestDemoUpdateReqVO extends TestDemoBaseVO { @ApiModelProperty(value = "编号", required = true, example = "1") @NotNull(message = "编号不能为空") diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/package-info.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/package-info.java new file mode 100644 index 0000000000..3489a716e7 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/app/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位,避免 package 无法提交到 Git 仓库 + */ +package cn.iocoder.yudao.module.tool.controller.app; diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/package-info.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/package-info.java new file mode 100644 index 0000000000..f06bab1671 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/controller/package-info.java @@ -0,0 +1,6 @@ +/** + * 提供 RESTful API 给前端: + * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 + * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 + */ +package cn.iocoder.yudao.module.tool.controller; diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/codegen/CodegenConvert.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/codegen/CodegenConvert.java new file mode 100644 index 0000000000..08ab991bfb --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/codegen/CodegenConvert.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.tool.convert.codegen; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.column.CodegenColumnRespVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTableRespVO; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.SchemaTableRespVO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Mapper +public interface CodegenConvert { + + CodegenConvert INSTANCE = Mappers.getMapper(CodegenConvert.class); + + // ========== InformationSchemaTableDO 和 InformationSchemaColumnDO 相关 ========== + + CodegenTableDO convert(SchemaTableDO bean); + + List convertList(List list); + + CodegenTableRespVO convert(SchemaColumnDO bean); + + // ========== CodegenTableDO 相关 ========== + +// List convertList02(List list); + + CodegenTableRespVO convert(CodegenTableDO bean); + + PageResult convertPage(PageResult page); + + // ========== CodegenTableDO 相关 ========== + + List convertList02(List list); + + CodegenTableDO convert(CodegenUpdateReqVO.Table bean); + + List convertList03(List columns); + + List convertList04(List list); + + // ========== 其它 ========== + + default CodegenDetailRespVO convert(CodegenTableDO table, List columns) { + CodegenDetailRespVO respVO = new CodegenDetailRespVO(); + respVO.setTable(convert(table)); + respVO.setColumns(convertList02(columns)); + return respVO; + } + + default List convert(Map codes) { + return codes.entrySet().stream().map(entry -> { + CodegenPreviewRespVO respVO = new CodegenPreviewRespVO(); + respVO.setFilePath(entry.getKey()); + respVO.setCode(entry.getValue()); + return respVO; + }).collect(Collectors.toList()); + } + +} diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/test/TestDemoConvert.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/test/TestDemoConvert.java new file mode 100644 index 0000000000..5f2a9e5250 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/convert/test/TestDemoConvert.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.tool.convert.test; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExcelVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoRespVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; + +@Mapper +public interface TestDemoConvert { + + TestDemoConvert INSTANCE = Mappers.getMapper(TestDemoConvert.class); + + TestDemoDO convert(TestDemoCreateReqVO bean); + + TestDemoDO convert(TestDemoUpdateReqVO bean); + + TestDemoRespVO convert(TestDemoDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolCodegenColumnDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenColumnDO.java similarity index 83% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolCodegenColumnDO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenColumnDO.java index 73f9d5dd20..65f1206400 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolCodegenColumnDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenColumnDO.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.adminserver.modules.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.adminserver.modules.tool.enums.codegen.ToolCodegenColumnHtmlTypeEnum; -import cn.iocoder.yudao.adminserver.modules.tool.enums.codegen.ToolCodegenColumnListConditionEnum; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenColumnHtmlTypeEnum; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenColumnListConditionEnum; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -18,7 +18,7 @@ import lombok.experimental.Accessors; @Data @Accessors(chain = true) @EqualsAndHashCode(callSuper = true) -public class ToolCodegenColumnDO extends BaseDO { +public class CodegenColumnDO extends BaseDO { /** * ID 编号 @@ -28,7 +28,7 @@ public class ToolCodegenColumnDO extends BaseDO { /** * 表编号 * - * 关联 {@link ToolCodegenTableDO#getId()} + * 关联 {@link CodegenTableDO#getId()} */ private Long tableId; @@ -104,7 +104,7 @@ public class ToolCodegenColumnDO extends BaseDO { /** * List 查询操作的条件类型 * - * 枚举 {@link ToolCodegenColumnListConditionEnum} + * 枚举 {@link CodegenColumnListConditionEnum} */ private String listOperationCondition; /** @@ -117,7 +117,7 @@ public class ToolCodegenColumnDO extends BaseDO { /** * 显示类型 * - * 枚举 {@link ToolCodegenColumnHtmlTypeEnum} + * 枚举 {@link CodegenColumnHtmlTypeEnum} */ private String htmlType; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolCodegenTableDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java similarity index 84% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolCodegenTableDO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java index 33546b6637..c299e013bb 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolCodegenTableDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/CodegenTableDO.java @@ -1,7 +1,7 @@ -package cn.iocoder.yudao.adminserver.modules.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.adminserver.modules.tool.enums.codegen.ToolCodegenTemplateTypeEnum; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenTemplateTypeEnum; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; @@ -16,7 +16,7 @@ import lombok.experimental.Accessors; @Data @Accessors(chain = true) @EqualsAndHashCode(callSuper = true) -public class ToolCodegenTableDO extends BaseDO { +public class CodegenTableDO extends BaseDO { /** * ID 编号 @@ -26,7 +26,7 @@ public class ToolCodegenTableDO extends BaseDO { /** * 导入类型 * - * 枚举 {@link ToolCodegenTemplateTypeEnum} + * 枚举 {@link CodegenTemplateTypeEnum} */ private Integer importType; @@ -79,7 +79,7 @@ public class ToolCodegenTableDO extends BaseDO { /** * 模板类型 * - * 枚举 {@link ToolCodegenTemplateTypeEnum} + * 枚举 {@link CodegenTemplateTypeEnum} */ private Integer templateType; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolSchemaColumnDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/SchemaColumnDO.java similarity index 90% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolSchemaColumnDO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/SchemaColumnDO.java index e78e16f533..d7c2b0d22d 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolSchemaColumnDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/SchemaColumnDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen; +package cn.iocoder.yudao.module.tool.dal.dataobject.codegen; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; @@ -13,7 +13,7 @@ import lombok.Data; @TableName(value = "information_schema.columns", autoResultMap = true) @Data @Builder -public class ToolSchemaColumnDO { +public class SchemaColumnDO { /** * 表名称 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolSchemaTableDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/SchemaTableDO.java similarity index 83% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolSchemaTableDO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/SchemaTableDO.java index e3e70352d8..eaec25fae7 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/codegen/ToolSchemaTableDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/codegen/SchemaTableDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen; +package cn.iocoder.yudao.module.tool.dal.dataobject.codegen; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Builder; @@ -14,7 +14,7 @@ import java.util.Date; @TableName(value = "information_schema.tables", autoResultMap = true) @Data @Builder -public class ToolSchemaTableDO { +public class SchemaTableDO { /** * 数据库 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/test/ToolTestDemoDO.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java similarity index 81% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/test/ToolTestDemoDO.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java index 0af46d798d..fcb197307e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/dataobject/test/ToolTestDemoDO.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/dataobject/test/TestDemoDO.java @@ -1,12 +1,11 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.test; +package cn.iocoder.yudao.module.tool.dal.dataobject.test; import lombok.*; -import java.util.*; import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; /** - * 字典类型 DO + * 测试示例 DO * * @author 芋艿 */ @@ -17,7 +16,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @Builder @NoArgsConstructor @AllArgsConstructor -public class ToolTestDemoDO extends BaseDO { +public class TestDemoDO extends BaseDO { /** * 编号 diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/CodegenColumnMapper.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/CodegenColumnMapper.java new file mode 100644 index 0000000000..8c1e47ea9a --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/CodegenColumnMapper.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.tool.dal.mysql.codegen; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface CodegenColumnMapper extends BaseMapperX { + + default List selectListByTableId(Long tableId) { + return selectList(new QueryWrapper().eq("table_id", tableId) + .orderByAsc("ordinal_position")); + } + + default void deleteListByTableId(Long tableId) { + delete(new QueryWrapper().eq("table_id", tableId)); + } + +} diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/CodegenTableMapper.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/CodegenTableMapper.java new file mode 100644 index 0000000000..292941b1d8 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/CodegenTableMapper.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.tool.dal.mysql.codegen; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; +import cn.iocoder.yudao.module.tool.controller.admin.codegen.vo.table.CodegenTablePageReqVO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface CodegenTableMapper extends BaseMapperX { + + default CodegenTableDO selectByTableName(String tableName) { + return selectOne(new QueryWrapper().eq("table_name", tableName)); + } + + default PageResult selectPage(CodegenTablePageReqVO pageReqVO) { + return selectPage(pageReqVO, new QueryWrapperX() + .likeIfPresent("table_name", pageReqVO.getTableName()) + .likeIfPresent("table_comment", pageReqVO.getTableComment()) + .betweenIfPresent("create_time", pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime())); + } + +} diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaColumnMapper.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaColumnMapper.java new file mode 100644 index 0000000000..52bb6ba2c7 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaColumnMapper.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.tool.dal.mysql.codegen; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface SchemaColumnMapper extends BaseMapperX { + + default List selectListByTableName(String tableSchema, String tableName) { + return selectList(new QueryWrapper().eq("table_name", tableName) + .eq("table_schema", tableSchema) + .orderByAsc("ordinal_position")); + } + +} diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaTableMapper.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaTableMapper.java new file mode 100644 index 0000000000..51d00c2240 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/codegen/SchemaTableMapper.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.tool.dal.mysql.codegen; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Collection; +import java.util.List; + +@Mapper +public interface SchemaTableMapper extends BaseMapperX { + + default List selectList(Collection tableSchemas, String tableName, String tableComment) { + return selectList(new QueryWrapperX().in("table_schema", tableSchemas) + .likeIfPresent("table_name", tableName) + .likeIfPresent("table_comment", tableComment)); + } + + default SchemaTableDO selectByTableSchemaAndTableName(String tableSchema, String tableName) { + return selectOne(new QueryWrapper().eq("table_schema",tableSchema) + .eq("table_name", tableName)); + } + +} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/test/ToolTestDemoMapper.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/test/TestDemoMapper.java similarity index 64% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/test/ToolTestDemoMapper.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/test/TestDemoMapper.java index 4bee17eb19..59c249b025 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/dal/mysql/test/ToolTestDemoMapper.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/dal/mysql/test/TestDemoMapper.java @@ -1,24 +1,20 @@ -package cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.test; +package cn.iocoder.yudao.module.tool.dal.mysql.test; import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.test.ToolTestDemoDO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo.*; -/** - * 字典类型 Mapper - * - * @author 芋艿 - */ @Mapper -public interface ToolTestDemoMapper extends BaseMapperX { +public interface TestDemoMapper extends BaseMapperX { - default PageResult selectPage(ToolTestDemoPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() + default PageResult selectPage(TestDemoPageReqVO reqVO) { + return selectPage(reqVO, new QueryWrapperX() .likeIfPresent("name", reqVO.getName()) .eqIfPresent("status", reqVO.getStatus()) .eqIfPresent("type", reqVO.getType()) @@ -28,8 +24,8 @@ public interface ToolTestDemoMapper extends BaseMapperX { .orderByDesc("id")); } - default List selectList(ToolTestDemoExportReqVO reqVO) { - return selectList(new QueryWrapperX() + default List selectList(TestDemoExportReqVO reqVO) { + return selectList(new QueryWrapperX() .likeIfPresent("name", reqVO.getName()) .eqIfPresent("status", reqVO.getStatus()) .eqIfPresent("type", reqVO.getType()) diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenColumnHtmlTypeEnum.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenColumnHtmlTypeEnum.java similarity index 83% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenColumnHtmlTypeEnum.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenColumnHtmlTypeEnum.java index 22dbdd2b76..c7d968410e 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenColumnHtmlTypeEnum.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenColumnHtmlTypeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.enums.codegen; +package cn.iocoder.yudao.module.tool.enums.codegen; import lombok.AllArgsConstructor; import lombok.Getter; @@ -8,7 +8,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ToolCodegenColumnHtmlTypeEnum { +public enum CodegenColumnHtmlTypeEnum { INPUT("input"), // 文本框 TEXTAREA("textarea"), // 文本域 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenColumnListConditionEnum.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenColumnListConditionEnum.java similarity index 74% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenColumnListConditionEnum.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenColumnListConditionEnum.java index 0783c9869f..4264b9aa59 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenColumnListConditionEnum.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenColumnListConditionEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.enums.codegen; +package cn.iocoder.yudao.module.tool.enums.codegen; import lombok.AllArgsConstructor; import lombok.Getter; @@ -8,7 +8,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ToolCodegenColumnListConditionEnum { +public enum CodegenColumnListConditionEnum { EQ("="), NE("!="), diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenImportTypeEnum.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenImportTypeEnum.java similarity index 76% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenImportTypeEnum.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenImportTypeEnum.java index 746cb7181d..62c7e99526 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenImportTypeEnum.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenImportTypeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.enums.codegen; +package cn.iocoder.yudao.module.tool.enums.codegen; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,7 +10,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ToolCodegenImportTypeEnum { +public enum CodegenImportTypeEnum { DB(1), // 从 information_schema 的 table 和 columns 表导入 SQL(2); // 基于建表 SQL 语句导入 diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenTemplateTypeEnum.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenTemplateTypeEnum.java similarity index 73% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenTemplateTypeEnum.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenTemplateTypeEnum.java index b192c31734..9f96aaf971 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/enums/codegen/ToolCodegenTemplateTypeEnum.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/codegen/CodegenTemplateTypeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.enums.codegen; +package cn.iocoder.yudao.module.tool.enums.codegen; import lombok.AllArgsConstructor; import lombok.Getter; @@ -10,7 +10,7 @@ import lombok.Getter; */ @AllArgsConstructor @Getter -public enum ToolCodegenTemplateTypeEnum { +public enum CodegenTemplateTypeEnum { CRUD(1), // 单表(增删改查) TREE(2), // 树表(增删改查) diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/package-info.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/package-info.java new file mode 100644 index 0000000000..c2b493d907 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/enums/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.tool.enums; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/config/CodegenConfiguration.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/config/CodegenConfiguration.java similarity index 76% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/config/CodegenConfiguration.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/config/CodegenConfiguration.java index 943638c1ba..b19add66cd 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/config/CodegenConfiguration.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/config/CodegenConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.framework.codegen.config; +package cn.iocoder.yudao.module.tool.framework.codegen.config; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/config/CodegenProperties.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/config/CodegenProperties.java similarity index 89% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/config/CodegenProperties.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/config/CodegenProperties.java index c383fc55d4..ba113cf5b6 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/codegen/config/CodegenProperties.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/config/CodegenProperties.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.framework.codegen.config; +package cn.iocoder.yudao.module.tool.framework.codegen.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/package-info.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/package-info.java new file mode 100644 index 0000000000..3348d54d51 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/codegen/package-info.java @@ -0,0 +1,4 @@ +/** + * 代码生成器 + */ +package cn.iocoder.yudao.module.tool.framework.codegen; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/package-info.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/package-info.java similarity index 55% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/package-info.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/package-info.java index f9a66d3640..76dbd50012 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/framework/package-info.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/framework/package-info.java @@ -3,4 +3,4 @@ * * @author 芋道源码 */ -package cn.iocoder.yudao.adminserver.modules.tool.framework; +package cn.iocoder.yudao.module.tool.framework; diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/package-info.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/package-info.java new file mode 100644 index 0000000000..4568d4c3d6 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/package-info.java @@ -0,0 +1,8 @@ +/** + * tool 模块下,我们放研发工具,提升研发效率与质量。 + * 例如说:代码生成器、接口文档等等 + * + * 1. Controller URL:以 /tool/ 开头,避免和其它 Module 冲突 + * 2. DataObject 表名:以 tool_ 开头,方便在数据库中区分 + */ +package cn.iocoder.yudao.module.tool; diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenService.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java similarity index 69% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenService.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java index fbe61c4b16..7b8f84b2c8 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/ToolCodegenService.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenService.java @@ -1,11 +1,11 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen; +package cn.iocoder.yudao.module.tool.service.codegen; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTablePageReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; +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.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; import java.util.List; import java.util.Map; @@ -15,7 +15,7 @@ import java.util.Map; * * @author 芋道源码 */ -public interface ToolCodegenService { +public interface CodegenService { /** * 基于 SQL 建表语句,创建代码生成器的表定义 @@ -46,7 +46,7 @@ public interface ToolCodegenService { * * @param updateReqVO 更新信息 */ - void updateCodegen(ToolCodegenUpdateReqVO updateReqVO); + void updateCodegen(CodegenUpdateReqVO updateReqVO); /** * 基于数据库的表结构,同步数据库的表和字段定义 @@ -76,7 +76,7 @@ public interface ToolCodegenService { * @param pageReqVO 分页条件 * @return 表定义分页 */ - PageResult getCodegenTablePage(ToolCodegenTablePageReqVO pageReqVO); + PageResult getCodegenTablePage(CodegenTablePageReqVO pageReqVO); /** * 获得表定义 @@ -84,14 +84,14 @@ public interface ToolCodegenService { * @param id 表编号 * @return 表定义 */ - ToolCodegenTableDO getCodegenTablePage(Long id); + CodegenTableDO getCodegenTablePage(Long id); /** * 获得全部表定义 * * @return 表定义数组 */ - List getCodeGenTableList(); + List getCodeGenTableList(); /** * 获得指定表的字段定义数组 @@ -99,7 +99,7 @@ public interface ToolCodegenService { * @param tableId 表编号 * @return 字段定义数组 */ - List getCodegenColumnListByTableId(Long tableId); + List getCodegenColumnListByTableId(Long tableId); /** * 执行指定表的代码生成 @@ -116,6 +116,6 @@ public interface ToolCodegenService { * @param tableComment 表描述 * @return 表定义列表 */ - List getSchemaTableList(String tableName, String tableComment); + List getSchemaTableList(String tableName, String tableComment); } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java similarity index 60% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java index f3b69fba25..f478244d00 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenServiceImpl.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/CodegenServiceImpl.java @@ -1,22 +1,24 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl; +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.adminserver.modules.tool.framework.codegen.config.CodegenProperties; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.ToolCodegenUpdateReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.controller.codegen.vo.table.ToolCodegenTablePageReqVO; -import cn.iocoder.yudao.adminserver.modules.tool.convert.codegen.ToolCodegenConvert; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen.ToolCodegenColumnMapper; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen.ToolCodegenTableMapper; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen.ToolSchemaColumnMapper; -import cn.iocoder.yudao.adminserver.modules.tool.dal.mysql.codegen.ToolSchemaTableMapper; -import cn.iocoder.yudao.adminserver.modules.tool.enums.codegen.ToolCodegenImportTypeEnum; -import cn.iocoder.yudao.adminserver.modules.tool.service.codegen.ToolCodegenService; +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; +import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.CodegenColumnMapper; +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.CodegenTableMapper; +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.SchemaColumnMapper; +import cn.iocoder.yudao.module.tool.dal.mysql.codegen.SchemaTableMapper; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenImportTypeEnum; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.tool.service.codegen.inner.CodegenBuilder; +import cn.iocoder.yudao.module.tool.service.codegen.inner.CodegenEngine; +import cn.iocoder.yudao.module.tool.service.codegen.inner.CodegenSQLParser; import org.apache.commons.collections4.KeyValue; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -29,7 +31,7 @@ import java.util.Set; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.adminserver.modules.tool.enums.ToolErrorCodeConstants.*; +import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; /** * 代码生成 Service 实现类 @@ -37,27 +39,27 @@ import static cn.iocoder.yudao.adminserver.modules.tool.enums.ToolErrorCodeConst * @author 芋道源码 */ @Service -public class ToolCodegenServiceImpl implements ToolCodegenService { +public class CodegenServiceImpl implements CodegenService { @Resource - private ToolSchemaTableMapper schemaTableMapper; + private SchemaTableMapper schemaTableMapper; @Resource - private ToolSchemaColumnMapper schemaColumnMapper; + private SchemaColumnMapper schemaColumnMapper; @Resource - private ToolCodegenTableMapper codegenTableMapper; + private CodegenTableMapper codegenTableMapper; @Resource - private ToolCodegenColumnMapper codegenColumnMapper; + private CodegenColumnMapper codegenColumnMapper; @Resource - private ToolCodegenBuilder codegenBuilder; + private CodegenBuilder codegenBuilder; @Resource - private ToolCodegenEngine codegenEngine; + private CodegenEngine codegenEngine; @Resource private CodegenProperties codegenProperties; - private Long createCodegen0(ToolCodegenImportTypeEnum importType, - ToolSchemaTableDO schemaTable, List schemaColumns) { + private Long createCodegen0(CodegenImportTypeEnum importType, + SchemaTableDO schemaTable, List schemaColumns) { // 校验导入的表和字段非空 if (schemaTable == null) { throw exception(CODEGEN_IMPORT_TABLE_NULL); @@ -70,12 +72,12 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { throw exception(CODEGEN_TABLE_EXISTS); } - // 构建 ToolCodegenTableDO 对象,插入到 DB 中 - ToolCodegenTableDO table = codegenBuilder.buildTable(schemaTable); + // 构建 CodegenTableDO 对象,插入到 DB 中 + CodegenTableDO table = codegenBuilder.buildTable(schemaTable); table.setImportType(importType.getType()); codegenTableMapper.insert(table); - // 构建 ToolCodegenColumnDO 数组,插入到 DB 中 - List columns = codegenBuilder.buildColumns(schemaColumns); + // 构建 CodegenColumnDO 数组,插入到 DB 中 + List columns = codegenBuilder.buildColumns(schemaColumns); columns.forEach(column -> { column.setTableId(table.getId()); codegenColumnMapper.insert(column); // TODO 批量插入 @@ -86,17 +88,17 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { @Override public Long createCodegenListFromSQL(String sql) { // 从 SQL 中,获得数据库表结构 - ToolSchemaTableDO schemaTable; - List schemaColumns; + SchemaTableDO schemaTable; + List schemaColumns; try { - KeyValue> result = ToolCodegenSQLParser.parse(sql); + KeyValue> result = CodegenSQLParser.parse(sql); schemaTable = result.getKey(); schemaColumns = result.getValue(); } catch (Exception ex) { throw exception(CODEGEN_PARSE_SQL_ERROR); } // 导入 - return this.createCodegen0(ToolCodegenImportTypeEnum.SQL, schemaTable, schemaColumns); + return this.createCodegen0(CodegenImportTypeEnum.SQL, schemaTable, schemaColumns); } @Override @@ -104,10 +106,10 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { // 获取当前schema String tableSchema = codegenProperties.getDbSchemas().iterator().next(); // 从数据库中,获得数据库表结构 - ToolSchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName); - List schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, tableName); + SchemaTableDO schemaTable = schemaTableMapper.selectByTableSchemaAndTableName(tableSchema, tableName); + List schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, tableName); // 导入 - return this.createCodegen0(ToolCodegenImportTypeEnum.DB, schemaTable, schemaColumns); + return this.createCodegen0(CodegenImportTypeEnum.DB, schemaTable, schemaColumns); } @Override @@ -121,17 +123,17 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { @Override @Transactional(rollbackFor = Exception.class) - public void updateCodegen(ToolCodegenUpdateReqVO updateReqVO) { + public void updateCodegen(CodegenUpdateReqVO updateReqVO) { // 校验是否已经存在 if (codegenTableMapper.selectById(updateReqVO.getTable().getId()) == null) { throw exception(CODEGEN_TABLE_NOT_EXISTS); } // 更新 table 表定义 - ToolCodegenTableDO updateTableObj = ToolCodegenConvert.INSTANCE.convert(updateReqVO.getTable()); + CodegenTableDO updateTableObj = CodegenConvert.INSTANCE.convert(updateReqVO.getTable()); codegenTableMapper.updateById(updateTableObj); // 更新 column 字段定义 - List updateColumnObjs = ToolCodegenConvert.INSTANCE.convertList03(updateReqVO.getColumns()); + List updateColumnObjs = CodegenConvert.INSTANCE.convertList03(updateReqVO.getColumns()); updateColumnObjs.forEach(updateColumnObj -> codegenColumnMapper.updateById(updateColumnObj)); } @@ -139,13 +141,13 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { @Transactional(rollbackFor = Exception.class) public void syncCodegenFromDB(Long tableId) { // 校验是否已经存在 - ToolCodegenTableDO table = codegenTableMapper.selectById(tableId); + CodegenTableDO table = codegenTableMapper.selectById(tableId); if (table == null) { throw exception(CODEGEN_TABLE_NOT_EXISTS); } String tableSchema = codegenProperties.getDbSchemas().iterator().next(); // 从数据库中,获得数据库表结构 - List schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, table.getTableName()); + List schemaColumns = schemaColumnMapper.selectListByTableName(tableSchema, table.getTableName()); // 执行同步 this.syncCodegen0(tableId, schemaColumns); @@ -155,14 +157,14 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { @Transactional(rollbackFor = Exception.class) public void syncCodegenFromSQL(Long tableId, String sql) { // 校验是否已经存在 - ToolCodegenTableDO table = codegenTableMapper.selectById(tableId); + CodegenTableDO table = codegenTableMapper.selectById(tableId); if (table == null) { throw exception(CODEGEN_TABLE_NOT_EXISTS); } // 从 SQL 中,获得数据库表结构 - List schemaColumns; + List schemaColumns; try { - KeyValue> result = ToolCodegenSQLParser.parse(sql); + KeyValue> result = CodegenSQLParser.parse(sql); schemaColumns = result.getValue(); } catch (Exception ex) { throw exception(CODEGEN_PARSE_SQL_ERROR); @@ -172,27 +174,27 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { this.syncCodegen0(tableId, schemaColumns); } - private void syncCodegen0(Long tableId, List schemaColumns) { + private void syncCodegen0(Long tableId, List schemaColumns) { // 校验导入的字段不为空 if (CollUtil.isEmpty(schemaColumns)) { throw exception(CODEGEN_SYNC_COLUMNS_NULL); } - Set schemaColumnNames = CollectionUtils.convertSet(schemaColumns, ToolSchemaColumnDO::getColumnName); + Set schemaColumnNames = CollectionUtils.convertSet(schemaColumns, SchemaColumnDO::getColumnName); - // 构建 ToolCodegenColumnDO 数组,只同步新增的字段 - List codegenColumns = codegenColumnMapper.selectListByTableId(tableId); - Set codegenColumnNames = CollectionUtils.convertSet(codegenColumns, ToolCodegenColumnDO::getColumnName); + // 构建 CodegenColumnDO 数组,只同步新增的字段 + List codegenColumns = codegenColumnMapper.selectListByTableId(tableId); + Set codegenColumnNames = CollectionUtils.convertSet(codegenColumns, CodegenColumnDO::getColumnName); // 移除已经存在的字段 schemaColumns.removeIf(column -> codegenColumnNames.contains(column.getColumnName())); // 计算需要删除的字段 Set deleteColumnIds = codegenColumns.stream().filter(column -> !schemaColumnNames.contains(column.getColumnName())) - .map(ToolCodegenColumnDO::getId).collect(Collectors.toSet()); + .map(CodegenColumnDO::getId).collect(Collectors.toSet()); if (CollUtil.isEmpty(schemaColumns) && CollUtil.isEmpty(deleteColumnIds)) { throw exception(CODEGEN_SYNC_NONE_CHANGE); } // 插入新增的字段 - List columns = codegenBuilder.buildColumns(schemaColumns); + List columns = codegenBuilder.buildColumns(schemaColumns); columns.forEach(column -> { column.setTableId(tableId); codegenColumnMapper.insert(column); // TODO 批量插入 @@ -218,33 +220,33 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { } @Override - public PageResult getCodegenTablePage(ToolCodegenTablePageReqVO pageReqVO) { + public PageResult getCodegenTablePage(CodegenTablePageReqVO pageReqVO) { return codegenTableMapper.selectPage(pageReqVO); } @Override - public ToolCodegenTableDO getCodegenTablePage(Long id) { + public CodegenTableDO getCodegenTablePage(Long id) { return codegenTableMapper.selectById(id); } @Override - public List getCodeGenTableList() { + public List getCodeGenTableList() { return codegenTableMapper.selectList(); } @Override - public List getCodegenColumnListByTableId(Long tableId) { + public List getCodegenColumnListByTableId(Long tableId) { return codegenColumnMapper.selectListByTableId(tableId); } @Override public Map generationCodes(Long tableId) { // 校验是否已经存在 - ToolCodegenTableDO table = codegenTableMapper.selectById(tableId); + CodegenTableDO table = codegenTableMapper.selectById(tableId); if (codegenTableMapper.selectById(tableId) == null) { throw exception(CODEGEN_TABLE_NOT_EXISTS); } - List columns = codegenColumnMapper.selectListByTableId(tableId); + List columns = codegenColumnMapper.selectListByTableId(tableId); if (CollUtil.isEmpty(columns)) { throw exception(CODEGEN_COLUMN_NOT_EXISTS); } @@ -254,8 +256,8 @@ public class ToolCodegenServiceImpl implements ToolCodegenService { } @Override - public List getSchemaTableList(String tableName, String tableComment) { - List tables = schemaTableMapper.selectList(codegenProperties.getDbSchemas(), tableName, tableComment); + public List getSchemaTableList(String tableName, String tableComment) { + List tables = schemaTableMapper.selectList(codegenProperties.getDbSchemas(), tableName, tableComment); // TODO 强制移除 Quartz 的表,未来做成可配置 tables.removeIf(table -> table.getTableName().startsWith("QRTZ_")); tables.removeIf(table -> table.getTableName().startsWith("ACT_")); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenBuilder.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java similarity index 70% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenBuilder.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java index 87e6ab6bd0..cf9b6c35d1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenBuilder.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenBuilder.java @@ -1,16 +1,16 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl; +package cn.iocoder.yudao.module.tool.service.codegen.inner; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.adminserver.modules.tool.convert.codegen.ToolCodegenConvert; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; -import cn.iocoder.yudao.adminserver.modules.tool.enums.codegen.ToolCodegenColumnHtmlTypeEnum; -import cn.iocoder.yudao.adminserver.modules.tool.enums.codegen.ToolCodegenColumnListConditionEnum; -import cn.iocoder.yudao.adminserver.modules.tool.enums.codegen.ToolCodegenTemplateTypeEnum; +import cn.iocoder.yudao.module.tool.convert.codegen.CodegenConvert; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenColumnHtmlTypeEnum; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenColumnListConditionEnum; +import cn.iocoder.yudao.module.tool.enums.codegen.CodegenTemplateTypeEnum; import com.google.common.collect.Sets; import org.springframework.stereotype.Component; @@ -21,11 +21,11 @@ import static cn.hutool.core.text.CharSequenceUtil.*; /** * 代码生成器的 Builder,负责: - * 1. 将数据库的表 {@link ToolSchemaTableDO} 定义,构建成 {@link ToolCodegenTableDO} - * 2. 将数据库的列 {@link ToolSchemaColumnDO} 构定义,建成 {@link ToolCodegenColumnDO} + * 1. 将数据库的表 {@link SchemaTableDO} 定义,构建成 {@link CodegenTableDO} + * 2. 将数据库的列 {@link SchemaColumnDO} 构定义,建成 {@link CodegenColumnDO} */ @Component -public class ToolCodegenBuilder { +public class CodegenBuilder { /** * Module 名字的映射 TODO 后续梳理到配置类 @@ -40,30 +40,30 @@ public class ToolCodegenBuilder { .build(); /** - * 字段名与 {@link ToolCodegenColumnListConditionEnum} 的默认映射 + * 字段名与 {@link CodegenColumnListConditionEnum} 的默认映射 * 注意,字段的匹配以后缀的方式 */ - private static final Map columnListOperationConditionMappings = - MapUtil.builder() - .put("name", ToolCodegenColumnListConditionEnum.LIKE) - .put("time", ToolCodegenColumnListConditionEnum.BETWEEN) - .put("date", ToolCodegenColumnListConditionEnum.BETWEEN) + private static final Map columnListOperationConditionMappings = + MapUtil.builder() + .put("name", CodegenColumnListConditionEnum.LIKE) + .put("time", CodegenColumnListConditionEnum.BETWEEN) + .put("date", CodegenColumnListConditionEnum.BETWEEN) .build(); /** - * 字段名与 {@link ToolCodegenColumnHtmlTypeEnum} 的默认映射 + * 字段名与 {@link CodegenColumnHtmlTypeEnum} 的默认映射 * 注意,字段的匹配以后缀的方式 */ - private static final Map columnHtmlTypeMappings = - MapUtil.builder() - .put("status", ToolCodegenColumnHtmlTypeEnum.RADIO) - .put("sex", ToolCodegenColumnHtmlTypeEnum.RADIO) - .put("type", ToolCodegenColumnHtmlTypeEnum.SELECT) - .put("image", ToolCodegenColumnHtmlTypeEnum.UPLOAD_IMAGE) - .put("file", ToolCodegenColumnHtmlTypeEnum.UPLOAD_FILE) - .put("content", ToolCodegenColumnHtmlTypeEnum.EDITOR) - .put("time", ToolCodegenColumnHtmlTypeEnum.DATETIME) - .put("date", ToolCodegenColumnHtmlTypeEnum.DATETIME) + private static final Map columnHtmlTypeMappings = + MapUtil.builder() + .put("status", CodegenColumnHtmlTypeEnum.RADIO) + .put("sex", CodegenColumnHtmlTypeEnum.RADIO) + .put("type", CodegenColumnHtmlTypeEnum.SELECT) + .put("image", CodegenColumnHtmlTypeEnum.UPLOAD_IMAGE) + .put("file", CodegenColumnHtmlTypeEnum.UPLOAD_FILE) + .put("content", CodegenColumnHtmlTypeEnum.EDITOR) + .put("time", CodegenColumnHtmlTypeEnum.DATETIME) + .put("date", CodegenColumnHtmlTypeEnum.DATETIME) .build(); /** @@ -113,8 +113,8 @@ public class ToolCodegenBuilder { LIST_OPERATION_RESULT_EXCLUDE_COLUMN.remove("createTime"); // 创建时间,还是需要返回的 } - public ToolCodegenTableDO buildTable(ToolSchemaTableDO schemaTable) { - ToolCodegenTableDO table = ToolCodegenConvert.INSTANCE.convert(schemaTable); + public CodegenTableDO buildTable(SchemaTableDO schemaTable) { + CodegenTableDO table = CodegenConvert.INSTANCE.convert(schemaTable); initTableDefault(table); return table; } @@ -124,7 +124,7 @@ public class ToolCodegenBuilder { * * @param table 表定义 */ - private void initTableDefault(ToolCodegenTableDO table) { + private void initTableDefault(CodegenTableDO table) { table.setModuleName(getFullModuleName(StrUtil.subBefore(table.getTableName(), '_', false))); // 第一个 _ 前缀的前面,作为 module 名字 table.setBusinessName(toCamelCase(subAfter(table.getTableName(), @@ -133,11 +133,11 @@ public class ToolCodegenBuilder { table.setClassComment(subBefore(table.getTableComment(), // 去除结尾的表,作为类描述 '表', true)); table.setAuthor("芋艿"); // TODO 稍后改成创建人 - table.setTemplateType(ToolCodegenTemplateTypeEnum.CRUD.getType()); + table.setTemplateType(CodegenTemplateTypeEnum.CRUD.getType()); } - public List buildColumns(List schemaColumns) { - List columns = ToolCodegenConvert.INSTANCE.convertList(schemaColumns); + public List buildColumns(List schemaColumns) { + List columns = CodegenConvert.INSTANCE.convertList(schemaColumns); columns.forEach(this::initColumnDefault); return columns; } @@ -147,7 +147,7 @@ public class ToolCodegenBuilder { * * @param column 列定义 */ - private void initColumnDefault(ToolCodegenColumnDO column) { + private void initColumnDefault(CodegenColumnDO column) { // 处理 Java 相关的字段的默认值 processColumnJava(column); // 处理 CRUD 相关的字段的默认值 @@ -156,7 +156,7 @@ public class ToolCodegenBuilder { processColumnUI(column); } - private void processColumnJava(ToolCodegenColumnDO column) { + private void processColumnJava(CodegenColumnDO column) { // 处理 javaField 字段 column.setJavaField(toCamelCase(column.getColumnName())); // 处理 dictType 字段,暂无 @@ -171,7 +171,7 @@ public class ToolCodegenBuilder { } } - private void processColumnOperation(ToolCodegenColumnDO column) { + private void processColumnOperation(CodegenColumnDO column) { // 处理 createOperation 字段 column.setCreateOperation(!CREATE_OPERATION_EXCLUDE_COLUMN.contains(column.getJavaField()) && !column.getPrimaryKey()); // 对于主键,创建时无需传递 @@ -186,13 +186,13 @@ public class ToolCodegenBuilder { .filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey())) .findFirst().ifPresent(entry -> column.setListOperationCondition(entry.getValue().getCondition())); if (column.getListOperationCondition() == null) { - column.setListOperationCondition(ToolCodegenColumnListConditionEnum.EQ.getCondition()); + column.setListOperationCondition(CodegenColumnListConditionEnum.EQ.getCondition()); } // 处理 listOperationResult 字段 column.setListOperationResult(!LIST_OPERATION_RESULT_EXCLUDE_COLUMN.contains(column.getJavaField())); } - private void processColumnUI(ToolCodegenColumnDO column) { + private void processColumnUI(CodegenColumnDO column) { // 基于后缀进行匹配 columnHtmlTypeMappings.entrySet().stream() .filter(entry -> StrUtil.endWithIgnoreCase(column.getJavaField(), entry.getKey())) @@ -200,11 +200,11 @@ public class ToolCodegenBuilder { // 如果是 Boolean 类型时,设置为 radio 类型. // 其它类型,因为字段名可以相对保障,所以不进行处理。例如说 date 对应 datetime 类型. if (Boolean.class.getSimpleName().equals(column.getJavaType())) { - column.setHtmlType(ToolCodegenColumnHtmlTypeEnum.RADIO.getType()); + column.setHtmlType(CodegenColumnHtmlTypeEnum.RADIO.getType()); } // 兜底,设置默认为 input 类型 if (column.getHtmlType() == null) { - column.setHtmlType(ToolCodegenColumnHtmlTypeEnum.INPUT.getType()); + column.setHtmlType(CodegenColumnHtmlTypeEnum.INPUT.getType()); } } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenEngine.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java similarity index 92% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenEngine.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java index ce8f3ac116..89a3af161b 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenEngine.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenEngine.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl; +package cn.iocoder.yudao.module.tool.service.codegen.inner; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.StrUtil; @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.adminserver.modules.tool.framework.codegen.config.CodegenProperties; +import cn.iocoder.yudao.module.tool.framework.codegen.config.CodegenProperties; import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; @@ -19,8 +19,8 @@ import cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolCodegenTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.CodegenTableDO; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.date.DateUtils; import com.google.common.collect.Maps; @@ -45,7 +45,7 @@ import static cn.hutool.core.text.CharSequenceUtil.*; * @author 芋道源码 */ @Component -public class ToolCodegenEngine { +public class CodegenEngine { /** * 模板配置 @@ -95,7 +95,7 @@ public class ToolCodegenEngine { .build(); @Resource - private ToolCodegenBuilder codegenBuilder; + private CodegenBuilder codegenBuilder; @Resource private CodegenProperties codegenProperties; @@ -109,7 +109,7 @@ public class ToolCodegenEngine { */ private final Map globalBindingMap = new HashMap<>(); - public ToolCodegenEngine() { + public CodegenEngine() { // 初始化 TemplateEngine 属性 TemplateConfig config = new TemplateConfig(); config.setResourceMode(TemplateConfig.ResourceMode.CLASSPATH); @@ -129,7 +129,7 @@ public class ToolCodegenEngine { globalBindingMap.put("PageParamClassName", PageParam.class.getName()); globalBindingMap.put("DictFormatClassName", DictFormat.class.getName()); // DO 类,独有字段 - globalBindingMap.put("baseDOFields", ToolCodegenBuilder.BASE_DO_FIELDS); + globalBindingMap.put("baseDOFields", CodegenBuilder.BASE_DO_FIELDS); globalBindingMap.put("BaseDOClassName", BaseDO.class.getName()); globalBindingMap.put("QueryWrapperClassName", QueryWrapperX.class.getName()); globalBindingMap.put("BaseMapperClassName", BaseMapperX.class.getName()); @@ -143,12 +143,12 @@ public class ToolCodegenEngine { globalBindingMap.put("OperateTypeEnumClassName", OperateTypeEnum.class.getName()); } - public Map execute(ToolCodegenTableDO table, List columns) { + public Map execute(CodegenTableDO table, List columns) { // 创建 bindingMap Map bindingMap = new HashMap<>(globalBindingMap); bindingMap.put("table", table); bindingMap.put("columns", columns); - bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, ToolCodegenColumnDO::getPrimaryKey)); // 主键字段 + bindingMap.put("primaryColumn", CollectionUtils.findFirst(columns, CodegenColumnDO::getPrimaryKey)); // 主键字段 // moduleName 相关 String simpleModuleName = codegenBuilder.getSimpleModuleName(table.getModuleName()); bindingMap.put("simpleModuleName", simpleModuleName); // 将 system 转成 sys @@ -183,7 +183,7 @@ public class ToolCodegenEngine { getStr(bindingMap, "classNameVar")); // table 包含的字段 - ToolCodegenTableDO table = (ToolCodegenTableDO) bindingMap.get("table"); + CodegenTableDO table = (CodegenTableDO) bindingMap.get("table"); filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName()); filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName()); filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName()); diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenSQLParser.java similarity index 72% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenSQLParser.java index d9f2538812..d58ac04c47 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/codegen/impl/ToolCodegenSQLParser.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/codegen/inner/CodegenSQLParser.java @@ -1,8 +1,8 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.codegen.impl; +package cn.iocoder.yudao.module.tool.service.codegen.inner; import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaColumnDO; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.codegen.ToolSchemaTableDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaColumnDO; +import cn.iocoder.yudao.module.tool.dal.dataobject.codegen.SchemaTableDO; import com.alibaba.druid.DbType; import com.alibaba.druid.sql.ast.expr.SQLCharExpr; import com.alibaba.druid.sql.ast.statement.SQLColumnDefinition; @@ -21,26 +21,26 @@ import java.util.Objects; import static com.alibaba.druid.sql.SQLUtils.normalize; /** - * SQL 解析器,将创建表的 SQL,解析成 {@link ToolSchemaTableDO} 和 {@link ToolSchemaColumnDO} 对象, + * SQL 解析器,将创建表的 SQL,解析成 {@link SchemaTableDO} 和 {@link SchemaColumnDO} 对象, * 后续可以基于它们,生成代码~ * * @author 芋道源码 */ -public class ToolCodegenSQLParser { +public class CodegenSQLParser { /** - * 解析建表 SQL 语句,返回 {@link ToolSchemaTableDO} 和 {@link ToolSchemaColumnDO} 对象 + * 解析建表 SQL 语句,返回 {@link SchemaTableDO} 和 {@link SchemaColumnDO} 对象 * * @param sql 建表 SQL 语句 * @return 解析结果 */ - public static KeyValue> parse(String sql) { + public static KeyValue> parse(String sql) { // 解析 SQL 成 Statement SQLCreateTableStatement statement = parseCreateSQL(sql); // 解析 Table 表 - ToolSchemaTableDO table = parseTable(statement); + SchemaTableDO table = parseTable(statement); // 解析 Column 字段 - List columns = parseColumns(statement); + List columns = parseColumns(statement); columns.forEach(column -> column.setTableName(table.getTableName())); // 返回 return new DefaultKeyValue<>(table, columns); @@ -61,8 +61,8 @@ public class ToolCodegenSQLParser { return (MySqlCreateTableStatement) repository.findTable(tableName).getStatement(); } - private static ToolSchemaTableDO parseTable(SQLCreateTableStatement statement) { - return ToolSchemaTableDO.builder() + private static SchemaTableDO parseTable(SQLCreateTableStatement statement) { + return SchemaTableDO.builder() .tableName(statement.getTableSource().getTableName(true)) .tableComment(getCommentText(statement)) .build(); @@ -75,13 +75,13 @@ public class ToolCodegenSQLParser { return ((SQLCharExpr) statement.getComment()).getText(); } - private static List parseColumns(SQLCreateTableStatement statement) { - List columns = new ArrayList<>(); + private static List parseColumns(SQLCreateTableStatement statement) { + List columns = new ArrayList<>(); statement.getTableElementList().forEach(element -> parseColumn(columns, element)); return columns; } - private static void parseColumn(List columns, SQLTableElement element) { + private static void parseColumn(List columns, SQLTableElement element) { // 处理主键 if (element instanceof SQLPrimaryKey) { parsePrimaryKey(columns, (SQLPrimaryKey) element); @@ -93,16 +93,16 @@ public class ToolCodegenSQLParser { } } - private static void parsePrimaryKey(List columns, SQLPrimaryKey primaryKey) { + private static void parsePrimaryKey(List columns, SQLPrimaryKey primaryKey) { String columnName = normalize(primaryKey.getColumns().get(0).toString()); // 暂时不考虑联合主键 // 匹配 columns 主键字段,设置为 primary columns.stream().filter(column -> column.getColumnName().equals(columnName)) .forEach(column -> column.setPrimaryKey(true)); } - private static void parseColumnDefinition(List columns, SQLColumnDefinition definition) { + private static void parseColumnDefinition(List columns, SQLColumnDefinition definition) { String text = definition.toString().toUpperCase(); - columns.add(ToolSchemaColumnDO.builder() + columns.add(SchemaColumnDO.builder() .columnName(normalize(definition.getColumnName())) .columnType(definition.getDataType().toString()) .columnComment(Objects.isNull(definition.getComment()) ? "" diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/test/ToolTestDemoService.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoService.java similarity index 51% rename from yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/test/ToolTestDemoService.java rename to yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoService.java index 7fff9185d4..5695961d75 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/tool/service/test/ToolTestDemoService.java +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoService.java @@ -1,17 +1,21 @@ -package cn.iocoder.yudao.adminserver.modules.tool.service.test; +package cn.iocoder.yudao.module.tool.service.test; import java.util.*; import javax.validation.*; -import cn.iocoder.yudao.adminserver.modules.tool.controller.test.vo.*; -import cn.iocoder.yudao.adminserver.modules.tool.dal.dataobject.test.ToolTestDemoDO; + +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; /** - * 字典类型 Service 接口 + * 测试示例 Service 接口 * * @author 芋艿 */ -public interface ToolTestDemoService { +public interface TestDemoService { /** * 创建字典类型 @@ -19,14 +23,14 @@ public interface ToolTestDemoService { * @param createReqVO 创建信息 * @return 编号 */ - Long createTestDemo(@Valid ToolTestDemoCreateReqVO createReqVO); + Long createTestDemo(@Valid TestDemoCreateReqVO createReqVO); /** * 更新字典类型 * * @param updateReqVO 更新信息 */ - void updateTestDemo(@Valid ToolTestDemoUpdateReqVO updateReqVO); + void updateTestDemo(@Valid TestDemoUpdateReqVO updateReqVO); /** * 删除字典类型 @@ -41,7 +45,7 @@ public interface ToolTestDemoService { * @param id 编号 * @return 字典类型 */ - ToolTestDemoDO getTestDemo(Long id); + TestDemoDO getTestDemo(Long id); /** * 获得字典类型列表 @@ -49,7 +53,7 @@ public interface ToolTestDemoService { * @param ids 编号 * @return 字典类型列表 */ - List getTestDemoList(Collection ids); + List getTestDemoList(Collection ids); /** * 获得字典类型分页 @@ -57,7 +61,7 @@ public interface ToolTestDemoService { * @param pageReqVO 分页查询 * @return 字典类型分页 */ - PageResult getTestDemoPage(ToolTestDemoPageReqVO pageReqVO); + PageResult getTestDemoPage(TestDemoPageReqVO pageReqVO); /** * 获得字典类型列表, 用于 Excel 导出 @@ -65,6 +69,6 @@ public interface ToolTestDemoService { * @param exportReqVO 查询条件 * @return 字典类型列表 */ - List getTestDemoList(ToolTestDemoExportReqVO exportReqVO); + List getTestDemoList(TestDemoExportReqVO exportReqVO); } diff --git a/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImpl.java b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImpl.java new file mode 100644 index 0000000000..3181db91c6 --- /dev/null +++ b/yudao-module-tool/yudao-module-tool-impl/src/main/java/cn/iocoder/yudao/module/tool/service/test/TestDemoServiceImpl.java @@ -0,0 +1,86 @@ +package cn.iocoder.yudao.module.tool.service.test; + +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoCreateReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoExportReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoPageReqVO; +import cn.iocoder.yudao.module.tool.controller.admin.test.vo.TestDemoUpdateReqVO; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; + +import cn.iocoder.yudao.module.tool.dal.dataobject.test.TestDemoDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.tool.convert.test.TestDemoConvert; +import cn.iocoder.yudao.module.tool.dal.mysql.test.TestDemoMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.tool.enums.ErrorCodeConstants.*; + +/** + * 测试示例 Service 实现类 + * + * @author 芋艿 + */ +@Service +@Validated +public class TestDemoServiceImpl implements TestDemoService { + + @Resource + private TestDemoMapper testDemoMapper; + + @Override + public Long createTestDemo(TestDemoCreateReqVO createReqVO) { + // 插入 + TestDemoDO testDemo = TestDemoConvert.INSTANCE.convert(createReqVO); + testDemoMapper.insert(testDemo); + // 返回 + return testDemo.getId(); + } + + @Override + public void updateTestDemo(TestDemoUpdateReqVO updateReqVO) { + // 校验存在 + this.validateTestDemoExists(updateReqVO.getId()); + // 更新 + TestDemoDO updateObj = TestDemoConvert.INSTANCE.convert(updateReqVO); + testDemoMapper.updateById(updateObj); + } + + @Override + public void deleteTestDemo(Long id) { + // 校验存在 + this.validateTestDemoExists(id); + // 删除 + testDemoMapper.deleteById(id); + } + + private void validateTestDemoExists(Long id) { + if (testDemoMapper.selectById(id) == null) { + throw exception(TEST_DEMO_NOT_EXISTS); + } + } + + @Override + public TestDemoDO getTestDemo(Long id) { + return testDemoMapper.selectById(id); + } + + @Override + public List getTestDemoList(Collection ids) { + return testDemoMapper.selectBatchIds(ids); + } + + @Override + public PageResult getTestDemoPage(TestDemoPageReqVO pageReqVO) { + return testDemoMapper.selectPage(pageReqVO); + } + + @Override + public List getTestDemoList(TestDemoExportReqVO exportReqVO) { + return testDemoMapper.selectList(exportReqVO); + } + +}