多模块重构 6:tool 模块的迁移完成
parent
fffd023d31
commit
e7e3b18704
@ -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<ToolCodegenColumnRespVO> columns;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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<ToolCodegenColumnDO> convertList(List<ToolSchemaColumnDO> list);
|
|
||||||
|
|
||||||
ToolCodegenTableRespVO convert(ToolSchemaColumnDO bean);
|
|
||||||
|
|
||||||
// ========== ToolCodegenTableDO 相关 ==========
|
|
||||||
|
|
||||||
// List<ToolCodegenTableRespVO> convertList02(List<ToolCodegenTableDO> list);
|
|
||||||
|
|
||||||
ToolCodegenTableRespVO convert(ToolCodegenTableDO bean);
|
|
||||||
|
|
||||||
PageResult<ToolCodegenTableRespVO> convertPage(PageResult<ToolCodegenTableDO> page);
|
|
||||||
|
|
||||||
// ========== ToolCodegenTableDO 相关 ==========
|
|
||||||
|
|
||||||
List<ToolCodegenColumnRespVO> convertList02(List<ToolCodegenColumnDO> list);
|
|
||||||
|
|
||||||
ToolCodegenTableDO convert(ToolCodegenUpdateReqVO.Table bean);
|
|
||||||
|
|
||||||
List<ToolCodegenColumnDO> convertList03(List<ToolCodegenUpdateReqVO.Column> columns);
|
|
||||||
|
|
||||||
List<ToolSchemaTableRespVO> convertList04(List<ToolSchemaTableDO> list);
|
|
||||||
|
|
||||||
// ========== 其它 ==========
|
|
||||||
|
|
||||||
default ToolCodegenDetailRespVO convert(ToolCodegenTableDO table, List<ToolCodegenColumnDO> columns) {
|
|
||||||
ToolCodegenDetailRespVO respVO = new ToolCodegenDetailRespVO();
|
|
||||||
respVO.setTable(convert(table));
|
|
||||||
respVO.setColumns(convertList02(columns));
|
|
||||||
return respVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
default List<ToolCodegenPreviewRespVO> convert(Map<String, String> codes) {
|
|
||||||
return codes.entrySet().stream().map(entry -> {
|
|
||||||
ToolCodegenPreviewRespVO respVO = new ToolCodegenPreviewRespVO();
|
|
||||||
respVO.setFilePath(entry.getKey());
|
|
||||||
respVO.setCode(entry.getValue());
|
|
||||||
return respVO;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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<ToolTestDemoRespVO> convertList(List<ToolTestDemoDO> list);
|
|
||||||
|
|
||||||
PageResult<ToolTestDemoRespVO> convertPage(PageResult<ToolTestDemoDO> page);
|
|
||||||
|
|
||||||
List<ToolTestDemoExcelVO> convertList02(List<ToolTestDemoDO> list);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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<ToolCodegenColumnDO> {
|
|
||||||
|
|
||||||
default List<ToolCodegenColumnDO> selectListByTableId(Long tableId) {
|
|
||||||
return selectList(new QueryWrapper<ToolCodegenColumnDO>().eq("table_id", tableId)
|
|
||||||
.orderByAsc("ordinal_position"));
|
|
||||||
}
|
|
||||||
|
|
||||||
default void deleteListByTableId(Long tableId) {
|
|
||||||
delete(new QueryWrapper<ToolCodegenColumnDO>().eq("table_id", tableId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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<ToolCodegenTableDO> {
|
|
||||||
|
|
||||||
default ToolCodegenTableDO selectByTableName(String tableName) {
|
|
||||||
return selectOne(new QueryWrapper<ToolCodegenTableDO>().eq("table_name", tableName));
|
|
||||||
}
|
|
||||||
|
|
||||||
default PageResult<ToolCodegenTableDO> selectPage(ToolCodegenTablePageReqVO pageReqVO) {
|
|
||||||
return selectPage(pageReqVO, new QueryWrapperX<ToolCodegenTableDO>()
|
|
||||||
.likeIfPresent("table_name", pageReqVO.getTableName())
|
|
||||||
.likeIfPresent("table_comment", pageReqVO.getTableComment())
|
|
||||||
.betweenIfPresent("create_time", pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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<ToolSchemaColumnDO> {
|
|
||||||
|
|
||||||
default List<ToolSchemaColumnDO> selectListByTableName(String tableSchema, String tableName) {
|
|
||||||
return selectList(new QueryWrapper<ToolSchemaColumnDO>().eq("table_name", tableName)
|
|
||||||
.eq("table_schema", tableSchema)
|
|
||||||
.orderByAsc("ordinal_position"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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<ToolSchemaTableDO> {
|
|
||||||
|
|
||||||
default List<ToolSchemaTableDO> selectList(Collection<String> tableSchemas, String tableName, String tableComment) {
|
|
||||||
return selectList(new QueryWrapperX<ToolSchemaTableDO>().in("table_schema", tableSchemas)
|
|
||||||
.likeIfPresent("table_name", tableName)
|
|
||||||
.likeIfPresent("table_comment", tableComment));
|
|
||||||
}
|
|
||||||
|
|
||||||
default ToolSchemaTableDO selectByTableSchemaAndTableName(String tableSchema, String tableName) {
|
|
||||||
return selectOne(new QueryWrapper<ToolSchemaTableDO>().eq("table_schema",tableSchema)
|
|
||||||
.eq("table_name", tableName));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* 代码生成器
|
|
||||||
*/
|
|
||||||
package cn.iocoder.yudao.adminserver.modules.tool.framework.codegen;
|
|
||||||
@ -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<ToolTestDemoDO> getTestDemoList(Collection<Long> ids) {
|
|
||||||
return testDemoMapper.selectBatchIds(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<ToolTestDemoDO> getTestDemoPage(ToolTestDemoPageReqVO pageReqVO) {
|
|
||||||
return testDemoMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<ToolTestDemoDO> getTestDemoList(ToolTestDemoExportReqVO exportReqVO) {
|
|
||||||
return testDemoMapper.selectList(exportReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.system.api;
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<modules>
|
||||||
|
<module>yudao-module-tool-api</module>
|
||||||
|
<module>yudao-module-tool-impl</module>
|
||||||
|
</modules>
|
||||||
|
<artifactId>yudao-module-tool</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<name>${artifactId}</name>
|
||||||
|
<description>
|
||||||
|
tool 模块,我们放研发工具,提升研发效率与质量。
|
||||||
|
例如说:代码生成器、接口文档等等
|
||||||
|
</description>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -1,11 +1,11 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.tool.enums;
|
package cn.iocoder.yudao.module.tool.enums;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tool 字典类型的枚举类
|
* Tool 字典类型的枚举类
|
||||||
*
|
*
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
public interface ToolDictTypeConstants {
|
public interface DictTypeConstants {
|
||||||
|
|
||||||
String TEST_DEMO_TYPE = "tool_test_demo_type";
|
String TEST_DEMO_TYPE = "tool_test_demo_type";
|
||||||
|
|
||||||
@ -0,0 +1 @@
|
|||||||
|
package cn.iocoder.yudao.module.tool;
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>yudao-module-tool</artifactId>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>yudao-module-tool-impl</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>${artifactId}</name>
|
||||||
|
<description>
|
||||||
|
tool 模块,我们放研发工具,提升研发效率与质量。
|
||||||
|
例如说:代码生成器、接口文档等等
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-module-tool-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 业务组件 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Web 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- DB 相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-mybatis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Test 测试相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 工具类相关 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- 设置构建的 jar 包名 -->
|
||||||
|
<finalName>${artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<!-- 打包 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<fork>true</fork>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -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<CodegenColumnRespVO> columns;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ApiModel(value = "代码生成预览 Response VO", description ="注意,每个文件都是一个该对象")
|
@ApiModel(value = "管理后台 - 代码生成预览 Response VO", description ="注意,每个文件都是一个该对象")
|
||||||
@Data
|
@Data
|
||||||
public class ToolCodegenPreviewRespVO {
|
public class CodegenPreviewRespVO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "文件路径", required = true, example = "java/cn/iocoder/yudao/adminserver/modules/system/controller/test/SysTestDemoController.java")
|
@ApiModelProperty(value = "文件路径", required = true, example = "java/cn/iocoder/yudao/adminserver/modules/system/controller/test/SysTestDemoController.java")
|
||||||
private String filePath;
|
private String filePath;
|
||||||
@ -1,7 +1,9 @@
|
|||||||
### 请求 /tool/test-demo/get 接口 => 成功
|
### 请求 /tool/test-demo/get 接口 => 成功
|
||||||
GET {{baseUrl}}/tool/test-demo/get?id=1
|
GET {{baseUrl}}/tool/test-demo/get?id=1
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
tenant-id: {{adminTenentId}}
|
||||||
|
|
||||||
### 请求 /tool/test-demo/list 接口 => 成功
|
### 请求 /tool/test-demo/list 接口 => 成功
|
||||||
GET {{baseUrl}}/tool/test-demo/list?ids=1
|
GET {{baseUrl}}/tool/test-demo/list?ids=1
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
tenant-id: {{adminTenentId}}
|
||||||
@ -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 io.swagger.annotations.ApiModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
@ApiModel("字典类型创建 Request VO")
|
@ApiModel("管理后台 - 字典类型创建 Request VO")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class ToolTestDemoCreateReqVO extends ToolTestDemoBaseVO {
|
public class TestDemoCreateReqVO extends TestDemoBaseVO {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -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<CodegenColumnDO> convertList(List<SchemaColumnDO> list);
|
||||||
|
|
||||||
|
CodegenTableRespVO convert(SchemaColumnDO bean);
|
||||||
|
|
||||||
|
// ========== CodegenTableDO 相关 ==========
|
||||||
|
|
||||||
|
// List<CodegenTableRespVO> convertList02(List<CodegenTableDO> list);
|
||||||
|
|
||||||
|
CodegenTableRespVO convert(CodegenTableDO bean);
|
||||||
|
|
||||||
|
PageResult<CodegenTableRespVO> convertPage(PageResult<CodegenTableDO> page);
|
||||||
|
|
||||||
|
// ========== CodegenTableDO 相关 ==========
|
||||||
|
|
||||||
|
List<CodegenColumnRespVO> convertList02(List<CodegenColumnDO> list);
|
||||||
|
|
||||||
|
CodegenTableDO convert(CodegenUpdateReqVO.Table bean);
|
||||||
|
|
||||||
|
List<CodegenColumnDO> convertList03(List<CodegenUpdateReqVO.Column> columns);
|
||||||
|
|
||||||
|
List<SchemaTableRespVO> convertList04(List<SchemaTableDO> list);
|
||||||
|
|
||||||
|
// ========== 其它 ==========
|
||||||
|
|
||||||
|
default CodegenDetailRespVO convert(CodegenTableDO table, List<CodegenColumnDO> columns) {
|
||||||
|
CodegenDetailRespVO respVO = new CodegenDetailRespVO();
|
||||||
|
respVO.setTable(convert(table));
|
||||||
|
respVO.setColumns(convertList02(columns));
|
||||||
|
return respVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<CodegenPreviewRespVO> convert(Map<String, String> codes) {
|
||||||
|
return codes.entrySet().stream().map(entry -> {
|
||||||
|
CodegenPreviewRespVO respVO = new CodegenPreviewRespVO();
|
||||||
|
respVO.setFilePath(entry.getKey());
|
||||||
|
respVO.setCode(entry.getValue());
|
||||||
|
return respVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<TestDemoRespVO> convertList(List<TestDemoDO> list);
|
||||||
|
|
||||||
|
PageResult<TestDemoRespVO> convertPage(PageResult<TestDemoDO> page);
|
||||||
|
|
||||||
|
List<TestDemoExcelVO> convertList02(List<TestDemoDO> list);
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<CodegenColumnDO> {
|
||||||
|
|
||||||
|
default List<CodegenColumnDO> selectListByTableId(Long tableId) {
|
||||||
|
return selectList(new QueryWrapper<CodegenColumnDO>().eq("table_id", tableId)
|
||||||
|
.orderByAsc("ordinal_position"));
|
||||||
|
}
|
||||||
|
|
||||||
|
default void deleteListByTableId(Long tableId) {
|
||||||
|
delete(new QueryWrapper<CodegenColumnDO>().eq("table_id", tableId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<CodegenTableDO> {
|
||||||
|
|
||||||
|
default CodegenTableDO selectByTableName(String tableName) {
|
||||||
|
return selectOne(new QueryWrapper<CodegenTableDO>().eq("table_name", tableName));
|
||||||
|
}
|
||||||
|
|
||||||
|
default PageResult<CodegenTableDO> selectPage(CodegenTablePageReqVO pageReqVO) {
|
||||||
|
return selectPage(pageReqVO, new QueryWrapperX<CodegenTableDO>()
|
||||||
|
.likeIfPresent("table_name", pageReqVO.getTableName())
|
||||||
|
.likeIfPresent("table_comment", pageReqVO.getTableComment())
|
||||||
|
.betweenIfPresent("create_time", pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<SchemaColumnDO> {
|
||||||
|
|
||||||
|
default List<SchemaColumnDO> selectListByTableName(String tableSchema, String tableName) {
|
||||||
|
return selectList(new QueryWrapper<SchemaColumnDO>().eq("table_name", tableName)
|
||||||
|
.eq("table_schema", tableSchema)
|
||||||
|
.orderByAsc("ordinal_position"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -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<SchemaTableDO> {
|
||||||
|
|
||||||
|
default List<SchemaTableDO> selectList(Collection<String> tableSchemas, String tableName, String tableComment) {
|
||||||
|
return selectList(new QueryWrapperX<SchemaTableDO>().in("table_schema", tableSchemas)
|
||||||
|
.likeIfPresent("table_name", tableName)
|
||||||
|
.likeIfPresent("table_comment", tableComment));
|
||||||
|
}
|
||||||
|
|
||||||
|
default SchemaTableDO selectByTableSchemaAndTableName(String tableSchema, String tableName) {
|
||||||
|
return selectOne(new QueryWrapper<SchemaTableDO>().eq("table_schema",tableSchema)
|
||||||
|
.eq("table_name", tableName));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 占位
|
||||||
|
*/
|
||||||
|
package cn.iocoder.yudao.module.tool.enums;
|
||||||
@ -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.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -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 lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 代码生成器
|
||||||
|
*/
|
||||||
|
package cn.iocoder.yudao.module.tool.framework.codegen;
|
||||||
@ -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<TestDemoDO> getTestDemoList(Collection<Long> ids) {
|
||||||
|
return testDemoMapper.selectBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<TestDemoDO> getTestDemoPage(TestDemoPageReqVO pageReqVO) {
|
||||||
|
return testDemoMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TestDemoDO> getTestDemoList(TestDemoExportReqVO exportReqVO) {
|
||||||
|
return testDemoMapper.selectList(exportReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue