From 9f028aa4764e88792a4937f555b7589dc61b7823 Mon Sep 17 00:00:00 2001 From: jay <75509151@qq.com> Date: Thu, 22 Jun 2023 17:13:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iot-module/iot-generator/pom.xml | 67 +++--- .../generator/config/MybatisPlusConfig.java | 106 ++++++++++ .../generator/controller/GenController.java | 39 ++-- .../iotkit/generator/core/BaseMapperPlus.java | 2 +- .../cc/iotkit/generator/core/PageBuilder.java | 35 ++++ .../cc/iotkit/generator/domain/GenTable.java | 6 + .../generator/domain/GenTableColumn.java | 8 +- .../factory/YmlPropertySourceFactory.java | 32 +++ .../service/GenTableServiceImpl.java | 12 +- .../generator/service/IGenTableService.java | 8 +- ...ot.autoconfigure.AutoConfiguration.imports | 1 + .../src/main/resources/common-mybatis.yml | 33 +++ .../mapper/generator/GenTableMapper.xml | 192 ++++++++++-------- .../src/main/resources/sql/generator.sql | 61 ++++++ 14 files changed, 458 insertions(+), 144 deletions(-) create mode 100644 iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java create mode 100644 iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java create mode 100644 iot-module/iot-generator/src/main/java/cc/iotkit/generator/factory/YmlPropertySourceFactory.java create mode 100644 iot-module/iot-generator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports create mode 100644 iot-module/iot-generator/src/main/resources/common-mybatis.yml create mode 100644 iot-module/iot-generator/src/main/resources/sql/generator.sql diff --git a/iot-module/iot-generator/pom.xml b/iot-module/iot-generator/pom.xml index f9a312ef..0cac745a 100644 --- a/iot-module/iot-generator/pom.xml +++ b/iot-module/iot-generator/pom.xml @@ -2,37 +2,24 @@ - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - + + iot-module + cc.iotkit + ${revision} + + 4.0.0 iot-generator - 1.0.0 + generator 代码生成 - 3.6.1 - 1.2.1 + 3.5.1 0.2.0 - 3.0.1 3.5.3.1 @@ -74,11 +61,7 @@ ${dynamic-ds.version} - - org.mybatis.spring.boot - mybatis-spring-boot-starter - ${spring-boot.mybatis} - + com.baomidou @@ -93,5 +76,37 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + ${java.version} + ${java.version} + utf8 + + + org.projectlombok + lombok + ${lombok.version} + + + io.github.linpeilie + mapstruct-plus-processor + ${mapstruct-plus.version} + + + org.projectlombok + lombok-mapstruct-binding + 0.2.0 + + + + + + + diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java new file mode 100644 index 00000000..eb08c6c0 --- /dev/null +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/config/MybatisPlusConfig.java @@ -0,0 +1,106 @@ +package cc.iotkit.generator.config; + +import cc.iotkit.generator.factory.YmlPropertySourceFactory; +import cn.hutool.core.net.NetUtil; +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; +import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +//import org.dromara.common.core.factory.YmlPropertySourceFactory; +//import org.dromara.common.mybatis.handler.InjectionMetaObjectHandler; +//import org.dromara.common.mybatis.interceptor.PlusDataPermissionInterceptor; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.PropertySource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +/** + * mybatis-plus配置类(下方注释有插件介绍) + * + * @author Lion Li + */ +@EnableTransactionManagement(proxyTargetClass = true) +@AutoConfiguration +@MapperScan("${mybatis-plus.mapperPackage}") +//@PropertySource(value = "classpath:common-mybatis.yml", factory = YmlPropertySourceFactory.class) +public class MybatisPlusConfig { + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + // 数据权限处理 +// interceptor.addInnerInterceptor(dataPermissionInterceptor()); + // 分页插件 + interceptor.addInnerInterceptor(paginationInnerInterceptor()); + // 乐观锁插件 + interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor()); + return interceptor; + } + + /** + * 数据权限拦截器 + */ +// public PlusDataPermissionInterceptor dataPermissionInterceptor() { +// return new PlusDataPermissionInterceptor(); +// } + + /** + * 分页插件,自动识别数据库类型 + */ + public PaginationInnerInterceptor paginationInnerInterceptor() { + PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(); + // 设置最大单页限制数量,默认 500 条,-1 不受限制 + paginationInnerInterceptor.setMaxLimit(-1L); + // 分页合理化 + paginationInnerInterceptor.setOverflow(true); + return paginationInnerInterceptor; + } + + /** + * 乐观锁插件 + */ + public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() { + return new OptimisticLockerInnerInterceptor(); + } + + /** + * 元对象字段填充控制器 + */ +// @Bean +// public MetaObjectHandler metaObjectHandler() { +// return new InjectionMetaObjectHandler(); +// } + + /** + * 使用网卡信息绑定雪花生成器 + * 防止集群雪花ID重复 + */ + @Bean + public IdentifierGenerator idGenerator() { + return new DefaultIdentifierGenerator(NetUtil.getLocalhost()); + } + + /** + * PaginationInnerInterceptor 分页插件,自动识别数据库类型 + * https://baomidou.com/pages/97710a/ + * OptimisticLockerInnerInterceptor 乐观锁插件 + * https://baomidou.com/pages/0d93c0/ + * MetaObjectHandler 元对象字段填充控制器 + * https://baomidou.com/pages/4c6bcf/ + * ISqlInjector sql注入器 + * https://baomidou.com/pages/42ea4a/ + * BlockAttackInnerInterceptor 如果是对全表的删除或更新操作,就会终止该操作 + * https://baomidou.com/pages/f9a237/ + * IllegalSQLInnerInterceptor sql性能规范插件(垃圾SQL拦截) + * IdentifierGenerator 自定义主键策略 + * https://baomidou.com/pages/568eb2/ + * TenantLineInnerInterceptor 多租户插件 + * https://baomidou.com/pages/aef2f2/ + * DynamicTableNameInnerInterceptor 动态表名插件 + * https://baomidou.com/pages/2a45ff/ + */ + +} diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java index 18ced508..759f1925 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/controller/GenController.java @@ -2,8 +2,6 @@ package cc.iotkit.generator.controller; import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; -import cc.iotkit.generator.core.PageQuery; -import cn.dev33.satoken.annotation.SaCheckPermission; import cn.hutool.core.convert.Convert; import cn.hutool.core.io.IoUtil; @@ -14,11 +12,13 @@ import cc.iotkit.common.log.enums.BusinessType; import cc.iotkit.generator.domain.GenTable; import cc.iotkit.generator.domain.GenTableColumn; import cc.iotkit.generator.service.IGenTableService; +import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import jakarta.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponse; + import java.io.IOException; import java.util.HashMap; import java.util.List; @@ -40,10 +40,11 @@ public class GenController extends BaseController { /** * 查询代码生成列表 */ - @SaCheckPermission("tool:gen:list") +// @SaCheckPermission("tool:gen:list") + @ApiOperation(value = "查询代码生成列表", notes = "查询代码生成列表,根据查询条件分页") @PostMapping("/list") - public Paging genList(GenTable genTable, PageQuery pageQuery) { - return genTableService.selectPageGenTableList(genTable, pageQuery); + public Paging genList(@RequestBody @Validated PageRequest query) { + return genTableService.selectPageGenTableList(query ); } /** @@ -51,7 +52,7 @@ public class GenController extends BaseController { * * @param tableId 表ID */ - @SaCheckPermission("tool:gen:query") +// @SaCheckPermission("tool:gen:query") @PostMapping(value = "/{tableId}") public Map getInfo(@PathVariable Long tableId) { GenTable table = genTableService.selectGenTableById(tableId); @@ -67,10 +68,10 @@ public class GenController extends BaseController { /** * 查询数据库列表 */ - @SaCheckPermission("tool:gen:list") +// @SaCheckPermission("tool:gen:list") @PostMapping("/db/list") - public Paging dataList(GenTable genTable, PageQuery pageQuery) { - return genTableService.selectPageDbTableList(genTable, pageQuery); + public Paging dataList(@RequestBody @Validated PageRequest pageQuery) { + return genTableService.selectPageDbTableList( pageQuery); } /** @@ -78,7 +79,7 @@ public class GenController extends BaseController { * * @param tableId 表ID */ - @SaCheckPermission("tool:gen:list") +// @SaCheckPermission("tool:gen:list") @PostMapping(value = "/column/{tableId}") public Paging columnList(Long tableId) { @@ -92,7 +93,7 @@ public class GenController extends BaseController { * * @param tables 表名串 */ - @SaCheckPermission("tool:gen:import") +// @SaCheckPermission("tool:gen:import") @Log(title = "代码生成", businessType = BusinessType.IMPORT) @PostMapping("/importTable") public void importTableSave(String tables) { @@ -106,7 +107,7 @@ public class GenController extends BaseController { /** * 修改保存代码生成业务 */ - @SaCheckPermission("tool:gen:edit") +// @SaCheckPermission("tool:gen:edit") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PutMapping public void editSave(@Validated @RequestBody GenTable genTable) { @@ -120,7 +121,7 @@ public class GenController extends BaseController { * * @param tableIds 表ID串 */ - @SaCheckPermission("tool:gen:remove") +// @SaCheckPermission("tool:gen:remove") @Log(title = "代码生成", businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") public void remove(@PathVariable Long[] tableIds) { @@ -133,7 +134,7 @@ public class GenController extends BaseController { * * @param tableId 表ID */ - @SaCheckPermission("tool:gen:preview") +// @SaCheckPermission("tool:gen:preview") @PostMapping("/preview/{tableId}") public Map preview(@PathVariable("tableId") Long tableId) throws IOException { Map dataMap = genTableService.previewCode(tableId); @@ -145,7 +146,7 @@ public class GenController extends BaseController { * * @param tableName 表名 */ - @SaCheckPermission("tool:gen:code") +// @SaCheckPermission("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @PostMapping("/download/{tableName}") public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { @@ -158,7 +159,7 @@ public class GenController extends BaseController { * * @param tableName 表名 */ - @SaCheckPermission("tool:gen:code") +// @SaCheckPermission("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @PostMapping("/genCode/{tableName}") public void genCode(@PathVariable("tableName") String tableName) { @@ -171,7 +172,7 @@ public class GenController extends BaseController { * * @param tableName 表名 */ - @SaCheckPermission("tool:gen:edit") +// @SaCheckPermission("tool:gen:edit") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PostMapping("/synchDb/{tableName}") public void synchDb(@PathVariable("tableName") String tableName) { @@ -184,7 +185,7 @@ public class GenController extends BaseController { * * @param tables 表名串 */ - @SaCheckPermission("tool:gen:code") +// @SaCheckPermission("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @PostMapping("/batchGenCode") public void batchGenCode(HttpServletResponse response, String tables) throws IOException { diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java index 8c4f5359..cb2d67ec 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/BaseMapperPlus.java @@ -10,10 +10,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ReflectionKit; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.toolkit.Db; + import org.apache.ibatis.logging.Log; import org.apache.ibatis.logging.LogFactory; - import java.io.Serializable; import java.util.Collection; import java.util.List; diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java new file mode 100644 index 00000000..ac4a3ffe --- /dev/null +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/core/PageBuilder.java @@ -0,0 +1,35 @@ +package cc.iotkit.generator.core; + +import cc.iotkit.common.api.PageRequest; +import cc.iotkit.common.exception.BizException; +import cc.iotkit.common.utils.StringUtils; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.metadata.OrderItem; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.Data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 分页查询实体类 + * + * @author Lion Li + */ + + +public class PageBuilder implements Serializable { + + + static public Page build(PageRequest pageRequest) { + Integer pageNum = ObjectUtil.defaultIfNull(pageRequest.getPageNum(), PageQuery.DEFAULT_PAGE_NUM); + Integer pageSize = ObjectUtil.defaultIfNull(pageRequest.getPageSize(), PageQuery.DEFAULT_PAGE_SIZE); + Page page = new Page(pageNum, pageSize); + + return page; + } + +} diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java index 3c424ed4..be58149b 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTable.java @@ -32,6 +32,12 @@ public class GenTable extends BaseEntity { @TableId(value = "table_id") private Long tableId; + /** + * 数据源名称 + */ + @NotBlank(message = "数据源名称不能为空") + private String dataName; + /** * 表名称 */ diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java index b1b0734c..2d07c9dc 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/domain/GenTableColumn.java @@ -190,10 +190,10 @@ public class GenTableColumn extends BaseEntity { public static boolean isSuperColumn(String javaField) { return StringUtils.equalsAnyIgnoreCase(javaField, - // BaseEntity - "createBy", "createTime", "updateBy", "updateTime", - // TreeEntity - "parentName", "parentId"); + // BaseEntity + "createBy", "createTime", "updateBy", "updateTime", + // TreeEntity + "parentName", "parentId"); } public boolean isUsableColumn() { diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/factory/YmlPropertySourceFactory.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/factory/YmlPropertySourceFactory.java new file mode 100644 index 00000000..cd5933b8 --- /dev/null +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/factory/YmlPropertySourceFactory.java @@ -0,0 +1,32 @@ +package cc.iotkit.generator.factory; + + +import cc.iotkit.common.utils.StringUtils; +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; +import org.springframework.core.env.PropertiesPropertySource; +import org.springframework.core.env.PropertySource; +import org.springframework.core.io.support.DefaultPropertySourceFactory; +import org.springframework.core.io.support.EncodedResource; + +import java.io.IOException; + +/** + * yml 配置源工厂 + * + * @author Lion Li + */ +public class YmlPropertySourceFactory extends DefaultPropertySourceFactory { + + @Override + public PropertySource createPropertySource(String name, EncodedResource resource) throws IOException { + String sourceName = resource.getResource().getFilename(); + if (StringUtils.isNotBlank(sourceName) && StringUtils.endsWithAny(sourceName, ".yml", ".yaml")) { + YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); + factory.setResources(resource.getResource()); + factory.afterPropertiesSet(); + return new PropertiesPropertySource(sourceName, factory.getObject()); + } + return super.createPropertySource(name, resource); + } + +} diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java index fec2343c..69a88040 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/GenTableServiceImpl.java @@ -1,5 +1,6 @@ package cc.iotkit.generator.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.common.constant.Constants; import cc.iotkit.common.exception.BizException; @@ -7,6 +8,7 @@ import cc.iotkit.common.utils.JsonUtils; import cc.iotkit.common.utils.StreamUtils; import cc.iotkit.common.utils.StringUtils; import cc.iotkit.common.utils.file.FileUtils; +import cc.iotkit.generator.core.PageBuilder; import cc.iotkit.generator.core.PageQuery; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.IoUtil; @@ -88,8 +90,8 @@ public class GenTableServiceImpl implements IGenTableService { } @Override - public Paging selectPageGenTableList(GenTable genTable, PageQuery pageQuery) { - Page page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable)); + public Paging selectPageGenTableList( PageRequest pageQuery) { + Page page = baseMapper.selectPage(PageBuilder.build(pageQuery), this.buildGenTableQueryWrapper(pageQuery.getData())); return new Paging<>(page.getTotal(), page.getRecords()); } @@ -98,15 +100,15 @@ public class GenTableServiceImpl implements IGenTableService { QueryWrapper wrapper = Wrappers.query(); wrapper.like(StringUtils.isNotBlank(genTable.getTableName()), "lower(table_name)", StringUtils.lowerCase(genTable.getTableName())) .like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment())) - .between(params.get("beginTime") != null && params.get("endTime") != null, + .between(StringUtils.isNotBlank((CharSequence) params.get("beginTime")) && StringUtils.isNotBlank((CharSequence) params.get("endTime")), "create_time", params.get("beginTime"), params.get("endTime")); return wrapper; } @Override - public Paging selectPageDbTableList(GenTable genTable, PageQuery pageQuery) { - Page page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable); + public Paging selectPageDbTableList(PageRequest pageQuery) { + Page page = baseMapper.selectPageDbTableList(PageBuilder.build(pageQuery), pageQuery.getData()); return new Paging<>(page.getTotal(), page.getRecords()); } diff --git a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java index e2d2253e..ac4a2679 100644 --- a/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java +++ b/iot-module/iot-generator/src/main/java/cc/iotkit/generator/service/IGenTableService.java @@ -2,6 +2,7 @@ package cc.iotkit.generator.service; +import cc.iotkit.common.api.PageRequest; import cc.iotkit.common.api.Paging; import cc.iotkit.generator.core.PageQuery; import cc.iotkit.generator.domain.GenTable; @@ -28,18 +29,17 @@ public interface IGenTableService { /** * 查询业务列表 * - * @param genTable 业务信息 + * * @return 业务集合 */ - Paging selectPageGenTableList(GenTable genTable, PageQuery pageQuery); + Paging selectPageGenTableList(PageRequest pageQuery); /** * 查询据库列表 * - * @param genTable 业务信息 * @return 数据库表集合 */ - Paging selectPageDbTableList(GenTable genTable, PageQuery pageQuery); + Paging selectPageDbTableList(PageRequest pageQuery); /** * 查询据库列表 diff --git a/iot-module/iot-generator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/iot-module/iot-generator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 00000000..6919707b --- /dev/null +++ b/iot-module/iot-generator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +cc.iotkit.generator.config.MybatisPlusConfig \ No newline at end of file diff --git a/iot-module/iot-generator/src/main/resources/common-mybatis.yml b/iot-module/iot-generator/src/main/resources/common-mybatis.yml new file mode 100644 index 00000000..f5dc6375 --- /dev/null +++ b/iot-module/iot-generator/src/main/resources/common-mybatis.yml @@ -0,0 +1,33 @@ +# 内置配置 不允许修改 如需修改请在 nacos 上写相同配置覆盖 +# MyBatisPlus配置 +# https://baomidou.com/config/ +mybatis-plus: + # 启动时是否检查 MyBatis XML 文件的存在,默认不检查 + checkConfigLocation: false + configuration: + # 自动驼峰命名规则(camel case)映射 + mapUnderscoreToCamelCase: true + # MyBatis 自动映射策略 + # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射 + autoMappingBehavior: FULL + # MyBatis 自动映射时未知列或未知属性处理策 + # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息 + autoMappingUnknownColumnBehavior: NONE + # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl + # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl + # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl + logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl + global-config: + # 是否打印 Logo banner + banner: true + dbConfig: + # 主键类型 + # AUTO 自增 NONE 空 INPUT 用户输入 ASSIGN_ID 雪花 ASSIGN_UUID 唯一 UUID + idType: ASSIGN_ID + # 逻辑已删除值(框架表均使用此值 禁止随意修改) + logicDeleteValue: 2 + # 逻辑未删除值 + logicNotDeleteValue: 0 + insertStrategy: NOT_NULL + updateStrategy: NOT_NULL + whereStrategy: NOT_NULL diff --git a/iot-module/iot-generator/src/main/resources/mapper/generator/GenTableMapper.xml b/iot-module/iot-generator/src/main/resources/mapper/generator/GenTableMapper.xml index b9af9350..2a81e50d 100644 --- a/iot-module/iot-generator/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/iot-module/iot-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -1,7 +1,7 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -15,12 +15,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + diff --git a/iot-module/iot-generator/src/main/resources/sql/generator.sql b/iot-module/iot-generator/src/main/resources/sql/generator.sql new file mode 100644 index 00000000..e99a1ff1 --- /dev/null +++ b/iot-module/iot-generator/src/main/resources/sql/generator.sql @@ -0,0 +1,61 @@ +-- ---------------------------- +-- 18、代码生成业务表 +-- ---------------------------- +drop table if exists gen_table; +create table gen_table ( + table_id bigint(20) not null comment '编号', + data_name varchar(200) default '' comment '数据源名称', + table_name varchar(200) default '' comment '表名称', + table_comment varchar(500) default '' comment '表描述', + sub_table_name varchar(64) default null comment '关联子表的表名', + sub_table_fk_name varchar(64) default null comment '子表关联的外键名', + class_name varchar(100) default '' comment '实体类名称', + tpl_category varchar(200) default 'crud' comment '使用的模板(crud单表操作 tree树表操作)', + package_name varchar(100) comment '生成包路径', + module_name varchar(30) comment '生成模块名', + business_name varchar(30) comment '生成业务名', + function_name varchar(50) comment '生成功能名', + function_author varchar(50) comment '生成功能作者', + gen_type char(1) default '0' comment '生成代码方式(0zip压缩包 1自定义路径)', + gen_path varchar(200) default '/' comment '生成路径(不填默认项目路径)', + options varchar(1000) comment '其它生成选项', + create_dept bigint(20) default null comment '创建部门', + create_by bigint(20) default null comment '创建者', + create_time datetime comment '创建时间', + update_by bigint(20) default null comment '更新者', + update_time datetime comment '更新时间', + remark varchar(500) default null comment '备注', + primary key (table_id) +) engine=innodb comment = '代码生成业务表'; + + +-- ---------------------------- +-- 19、代码生成业务表字段 +-- ---------------------------- +drop table if exists gen_table_column; +create table gen_table_column ( + column_id bigint(20) not null comment '编号', + table_id bigint(20) comment '归属表编号', + column_name varchar(200) comment '列名称', + column_comment varchar(500) comment '列描述', + column_type varchar(100) comment '列类型', + java_type varchar(500) comment 'JAVA类型', + java_field varchar(200) comment 'JAVA字段名', + is_pk char(1) comment '是否主键(1是)', + is_increment char(1) comment '是否自增(1是)', + is_required char(1) comment '是否必填(1是)', + is_insert char(1) comment '是否为插入字段(1是)', + is_edit char(1) comment '是否编辑字段(1是)', + is_list char(1) comment '是否列表字段(1是)', + is_query char(1) comment '是否查询字段(1是)', + query_type varchar(200) default 'EQ' comment '查询方式(等于、不等于、大于、小于、范围)', + html_type varchar(200) comment '显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)', + dict_type varchar(200) default '' comment '字典类型', + sort int comment '排序', + create_dept bigint(20) default null comment '创建部门', + create_by bigint(20) default null comment '创建者', + create_time datetime comment '创建时间', + update_by bigint(20) default null comment '更新者', + update_time datetime comment '更新时间', + primary key (column_id) +) engine=innodb comment = '代码生成业务表字段'; \ No newline at end of file