Przeglądaj źródła

fix: 代码生成器

jay 1 rok temu
rodzic
commit
9f028aa476

+ 41 - 26
iot-module/iot-generator/pom.xml

@@ -2,37 +2,24 @@
 <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>cc.iotkit</groupId>-->
-<!--        <artifactId>iot-module</artifactId>-->
-<!--        <version>${revision}</version>-->
-<!--    </parent>-->
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <configuration>
-                    <source>8</source>
-                    <target>8</target>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+    <parent>
+        <artifactId>iot-module</artifactId>
+        <groupId>cc.iotkit</groupId>
+        <version>${revision}</version>
+    </parent>
+
     <modelVersion>4.0.0</modelVersion>
 
     <artifactId>iot-generator</artifactId>
-    <version>1.0.0</version>
+
 
     <description>
         generator 代码生成
     </description>
 
     <properties>
-        <dynamic-ds.version>3.6.1</dynamic-ds.version>
-        <mapstruct-plus.version>1.2.1</mapstruct-plus.version>
+        <dynamic-ds.version>3.5.1</dynamic-ds.version>
         <mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
-        <spring-boot.mybatis>3.0.1</spring-boot.mybatis>
         <mybatis-plus.version>3.5.3.1</mybatis-plus.version>
 
     </properties>
@@ -74,11 +61,7 @@
             <version>${dynamic-ds.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>org.mybatis.spring.boot</groupId>
-            <artifactId>mybatis-spring-boot-starter</artifactId>
-            <version>${spring-boot.mybatis}</version>
-        </dependency>
+
 
         <dependency>
             <groupId>com.baomidou</groupId>
@@ -93,5 +76,37 @@
         </dependency>
 
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <source>${java.version}</source> <!-- depending on your project -->
+                    <target>${java.version}</target> <!-- depending on your project -->
+                    <encoding>utf8</encoding>
+                    <annotationProcessorPaths>
+                        <path>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok</artifactId>
+                            <version>${lombok.version}</version>
+                        </path>
+                        <path>
+                            <groupId>io.github.linpeilie</groupId>
+                            <artifactId>mapstruct-plus-processor</artifactId>
+                            <version>${mapstruct-plus.version}</version>
+                        </path>
+                        <path>
+                            <groupId>org.projectlombok</groupId>
+                            <artifactId>lombok-mapstruct-binding</artifactId>
+                            <version>0.2.0</version>
+                        </path>
+                        <!-- other annotation processors -->
+                    </annotationProcessorPaths>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>

+ 106 - 0
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/
+     */
+
+}

+ 20 - 19
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<GenTable> genList(GenTable genTable, PageQuery pageQuery) {
-        return genTableService.selectPageGenTableList(genTable, pageQuery);
+    public Paging<GenTable> genList(@RequestBody @Validated PageRequest<GenTable> 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<String, Object> 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<GenTable> dataList(GenTable genTable, PageQuery pageQuery) {
-        return genTableService.selectPageDbTableList(genTable, pageQuery);
+    public Paging<GenTable> dataList(@RequestBody @Validated PageRequest<GenTable> 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<GenTableColumn> 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<String, String> preview(@PathVariable("tableId") Long tableId) throws IOException {
         Map<String, String> 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 {

+ 1 - 1
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;

+ 35 - 0
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;
+   }
+
+}

+ 6 - 0
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;
+
     /**
      * 表名称
      */

+ 4 - 4
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() {

+ 32 - 0
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);
+    }
+
+}

+ 7 - 5
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<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery) {
-        Page<GenTable> page = baseMapper.selectPage(pageQuery.build(), this.buildGenTableQueryWrapper(genTable));
+    public Paging<GenTable> selectPageGenTableList(  PageRequest<GenTable> pageQuery) {
+        Page<GenTable> 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<GenTable> 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<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery) {
-        Page<GenTable> page = baseMapper.selectPageDbTableList(pageQuery.build(), genTable);
+    public Paging<GenTable> selectPageDbTableList(PageRequest<GenTable> pageQuery) {
+        Page<GenTable> page = baseMapper.selectPageDbTableList(PageBuilder.build(pageQuery), pageQuery.getData());
         return new Paging<>(page.getTotal(), page.getRecords());
     }
 

+ 4 - 4
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<GenTable> selectPageGenTableList(GenTable genTable, PageQuery pageQuery);
+    Paging<GenTable> selectPageGenTableList(PageRequest<GenTable> pageQuery);
 
     /**
      * 查询据库列表
      *
-     * @param genTable 业务信息
      * @return 数据库表集合
      */
-    Paging<GenTable> selectPageDbTableList(GenTable genTable, PageQuery pageQuery);
+    Paging<GenTable> selectPageDbTableList(PageRequest<GenTable>  pageQuery);
 
     /**
      * 查询据库列表

+ 1 - 0
iot-module/iot-generator/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -0,0 +1 @@
+cc.iotkit.generator.config.MybatisPlusConfig

+ 33 - 0
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

+ 107 - 85
iot-module/iot-generator/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cc.iotkit.generator.mapper.GenTableMapper">
 
     <!-- 多结构嵌套自动映射需带上每个实体的主键id 否则映射会失败 -->
@@ -15,12 +15,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <select id="selectPageDbTableList" resultMap="GenTableResult">
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isMySql()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isMySql()">
             select table_name, table_comment, create_time, update_time
             from information_schema.tables
             where table_schema = (select database())
-            AND table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
-            AND table_name NOT IN (select table_name from gen_table)
+            AND table_name NOT LIKE 'pj_%' AND table_name NOT LIKE 'gen_%'
+            <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
+                AND table_name NOT IN
+                <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
             <if test="genTable.tableName != null and genTable.tableName != ''">
                 AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
             </if>
@@ -29,14 +34,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
             order by create_time desc
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isOracle()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isOracle()">
             select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
             from user_tables dt, user_tab_comments dtc, user_objects uo
             where dt.table_name = dtc.table_name
             and dt.table_name = uo.object_name
             and uo.object_type = 'TABLE'
-            AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
-            AND lower(dt.table_name) NOT IN (select table_name from gen_table)
+            AND dt.table_name NOT LIKE 'pj_%' AND dt.table_name NOT LIKE 'GEN_%'
+            <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
+                AND lower(dt.table_name) NOT IN
+                <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
             <if test="genTable.tableName != null and genTable.tableName != ''">
                 AND lower(dt.table_name) like lower(concat(concat('%', #{genTable.tableName}), '%'))
             </if>
@@ -45,22 +55,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
             order by create_time desc
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isPostgerSql()">
             select table_name, table_comment, create_time, update_time
             from (
-                SELECT c.relname AS table_name,
-                        obj_description(c.oid) AS table_comment,
-                        CURRENT_TIMESTAMP AS create_time,
-                        CURRENT_TIMESTAMP AS update_time
-                FROM pg_class c
-                    LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
-                WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
-                    AND c.relname != 'spatial_%'::text
-                    AND n.nspname = 'public'::name
-                    AND n.nspname <![CDATA[ <> ]]> ''::name
+            SELECT c.relname AS table_name,
+            obj_description(c.oid) AS table_comment,
+            CURRENT_TIMESTAMP AS create_time,
+            CURRENT_TIMESTAMP AS update_time
+            FROM pg_class c
+            LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
+            WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
+            AND c.relname != 'spatial_%'::text
+            AND n.nspname = 'public'::name
+            AND n.nspname <![CDATA[ <> ]]> ''::name
             ) list_table
-            where table_name NOT LIKE 'xxl_job_%' AND table_name NOT LIKE 'gen_%'
-            AND table_name NOT IN (select table_name from gen_table)
+            where table_name NOT LIKE 'pj_%' AND table_name NOT LIKE 'gen_%'
+            <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
+                AND table_name NOT IN
+                <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
             <if test="genTable.tableName != null and genTable.tableName != ''">
                 AND lower(table_name) like lower(concat('%', #{genTable.tableName}, '%'))
             </if>
@@ -69,16 +84,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
             order by create_time desc
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isSqlServer()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isSqlServer()">
             SELECT cast(D.NAME as nvarchar) as table_name,
-                   cast(F.VALUE as nvarchar) as table_comment,
-                   crdate as create_time,
-                   refdate as update_time
+            cast(F.VALUE as nvarchar) as table_comment,
+            crdate as create_time,
+            refdate as update_time
             FROM SYSOBJECTS D
-                INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
-                    AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
-                    AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%'
-                    AND D.NAME NOT IN (select table_name from gen_table)
+            INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
+            AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
+            AND D.NAME NOT LIKE 'pj_%' AND D.NAME NOT LIKE 'gen_%'
+            <if test="genTable.params.genTableNames != null and genTable.params.genTableNames.size > 0">
+                AND D.NAME NOT IN
+                <foreach collection="genTable.params.genTableNames" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
             <if test="genTable.tableName != null and genTable.tableName != ''">
                 AND lower(D.NAME) like lower(concat(N'%', N'${genTable.tableName}', N'%'))
             </if>
@@ -90,57 +110,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectDbTableListByNames" resultMap="GenTableResult">
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isMySql()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isMySql()">
             select table_name, table_comment, create_time, update_time from information_schema.tables
-            where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
+            where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
             and table_name in
             <foreach collection="array" item="name" open="(" separator="," close=")">
-                 #{name}
+                #{name}
             </foreach>
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isOracle()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isOracle()">
             select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
             from user_tables dt, user_tab_comments dtc, user_objects uo
             where dt.table_name = dtc.table_name
             and dt.table_name = uo.object_name
             and uo.object_type = 'TABLE'
-            AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
-            AND dt.table_name NOT IN (select table_name from gen_table)
+            AND dt.table_name NOT LIKE 'pj_%' AND dt.table_name NOT LIKE 'GEN_%'
             and lower(dt.table_name) in
             <foreach collection="array" item="name" open="(" separator="," close=")">
                 #{name}
             </foreach>
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isPostgerSql()">
             select table_name, table_comment, create_time, update_time
             from (
-                SELECT c.relname AS table_name,
-                        obj_description(c.oid) AS table_comment,
-                        CURRENT_TIMESTAMP AS create_time,
-                        CURRENT_TIMESTAMP AS update_time
-                FROM pg_class c
-                    LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
-                WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
-                    AND c.relname != 'spatial_%'::text
-                    AND n.nspname = 'public'::name
-                    AND n.nspname <![CDATA[ <> ]]> ''::name
+            SELECT c.relname AS table_name,
+            obj_description(c.oid) AS table_comment,
+            CURRENT_TIMESTAMP AS create_time,
+            CURRENT_TIMESTAMP AS update_time
+            FROM pg_class c
+            LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
+            WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
+            AND c.relname != 'spatial_%'::text
+            AND n.nspname = 'public'::name
+            AND n.nspname <![CDATA[ <> ]]> ''::name
             ) list_table
-            where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%'
+            where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%'
             and table_name in
             <foreach collection="array" item="name" open="(" separator="," close=")">
                 #{name}
             </foreach>
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isSqlServer()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isSqlServer()">
             SELECT cast(D.NAME as nvarchar) as table_name,
-                   cast(F.VALUE as nvarchar) as table_comment,
-                   crdate as create_time,
-                   refdate as update_time
+            cast(F.VALUE as nvarchar) as table_comment,
+            crdate as create_time,
+            refdate as update_time
             FROM SYSOBJECTS D
-                INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
-                    AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
-                    AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%'
-                    AND D.NAME in
+            INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
+            AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
+            AND D.NAME NOT LIKE 'pj_%' AND D.NAME NOT LIKE 'gen_%'
+            AND D.NAME in
             <foreach collection="array" item="name" open="(" separator="," close=")">
                 #{name}
             </foreach>
@@ -148,73 +167,76 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isMySql()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isMySql()">
             select table_name, table_comment, create_time, update_time from information_schema.tables
-            where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
+            where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
             and table_name = #{tableName}
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isOracle()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isOracle()">
             select lower(dt.table_name) as table_name, dtc.comments as table_comment, uo.created as create_time, uo.last_ddl_time as update_time
             from user_tables dt, user_tab_comments dtc, user_objects uo
             where dt.table_name = dtc.table_name
             and dt.table_name = uo.object_name
             and uo.object_type = 'TABLE'
-            AND dt.table_name NOT LIKE 'XXL_JOB_%' AND dt.table_name NOT LIKE 'GEN_%'
+            AND dt.table_name NOT LIKE 'pj_%' AND dt.table_name NOT LIKE 'GEN_%'
             AND dt.table_name NOT IN (select table_name from gen_table)
             and lower(dt.table_name) = #{tableName}
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isPostgerSql()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isPostgerSql()">
             select table_name, table_comment, create_time, update_time
             from (
-                SELECT c.relname AS table_name,
-                        obj_description(c.oid) AS table_comment,
-                        CURRENT_TIMESTAMP AS create_time,
-                        CURRENT_TIMESTAMP AS update_time
-                FROM pg_class c
-                    LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
-                WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
-                    AND c.relname != 'spatial_%'::text
-                    AND n.nspname = 'public'::name
-                    AND n.nspname <![CDATA[ <> ]]> ''::name
+            SELECT c.relname AS table_name,
+            obj_description(c.oid) AS table_comment,
+            CURRENT_TIMESTAMP AS create_time,
+            CURRENT_TIMESTAMP AS update_time
+            FROM pg_class c
+            LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
+            WHERE (c.relkind = ANY (ARRAY ['r'::"char", 'p'::"char"]))
+            AND c.relname != 'spatial_%'::text
+            AND n.nspname = 'public'::name
+            AND n.nspname <![CDATA[ <> ]]> ''::name
             ) list_table
-            where table_name NOT LIKE 'xxl_job_%' and table_name NOT LIKE 'gen_%'
+            where table_name NOT LIKE 'pj_%' and table_name NOT LIKE 'gen_%'
             and table_name = #{tableName}
         </if>
-        <if test="@cc.iotkit.common.mybatis.helper.DataBaseHelper@isSqlServer()">
+        <if test="@cc.iotkit.generator.core.DataBaseHelper@isSqlServer()">
             SELECT cast(D.NAME as nvarchar) as table_name,
-                   cast(F.VALUE as nvarchar) as table_comment,
-                   crdate as create_time,
-                   refdate as update_time
+            cast(F.VALUE as nvarchar) as table_comment,
+            crdate as create_time,
+            refdate as update_time
             FROM SYSOBJECTS D
-                INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
-                    AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
-                    AND D.NAME NOT LIKE 'xxl_job_%' AND D.NAME NOT LIKE 'gen_%'
-                    AND D.NAME = #{tableName}
+            INNER JOIN SYS.EXTENDED_PROPERTIES F ON D.ID = F.MAJOR_ID
+            AND F.MINOR_ID = 0 AND D.XTYPE = 'U' AND D.NAME != 'DTPROPERTIES'
+            AND D.NAME NOT LIKE 'pj_%' AND D.NAME NOT LIKE 'gen_%'
+            AND D.NAME = #{tableName}
         </if>
     </select>
 
     <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
-        SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
+        SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
         FROM gen_table t
-             LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+                 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
         where t.table_id = #{tableId} order by c.sort
     </select>
 
     <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
-        SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
+        SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
         FROM gen_table t
-             LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+                 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
         where t.table_name = #{tableName} order by c.sort
     </select>
 
     <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
-        SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
+        SELECT t.table_id, t.data_name, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
                c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
         FROM gen_table t
-             LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+                 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
         order by c.sort
     </select>
 
+    <select id="selectTableNameList" resultType="java.lang.String">
+        select table_name from gen_table where data_name = #{dataName,jdbcType=VARCHAR}
+    </select>
 </mapper>

+ 61 - 0
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 = '代码生成业务表字段';