Переглянути джерело

更新 生成代码模块版本

wanggaokun 1 рік тому
батько
коміт
d54e051e08
20 змінених файлів з 437 додано та 73 видалено
  1. 5 1
      taais-common/taais-common-orm/src/main/java/com/taais/common/orm/helper/DataBaseHelper.java
  2. 1 1
      taais-modules/taais-generator/src/main/java/com/taais/generator/service/GenTableServiceImpl.java
  3. 16 6
      taais-modules/taais-generator/src/main/java/com/taais/generator/util/VelocityUtils.java
  4. 1 1
      taais-modules/taais-generator/src/main/resources/generator.yml
  5. 31 0
      taais-modules/taais-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml
  6. 48 0
      taais-modules/taais-generator/src/main/resources/mapper/generator/GenTableMapper.xml
  7. 59 0
      taais-modules/taais-generator/src/main/resources/vm/api/api.ts.types.vm
  8. 8 8
      taais-modules/taais-generator/src/main/resources/vm/api/api.ts.vm
  9. 2 3
      taais-modules/taais-generator/src/main/resources/vm/java/bo.java.vm
  10. 10 10
      taais-modules/taais-generator/src/main/resources/vm/java/controller.java.vm
  11. 2 2
      taais-modules/taais-generator/src/main/resources/vm/java/domain.java.vm
  12. 127 0
      taais-modules/taais-generator/src/main/resources/vm/java/listener.java.vm
  13. 3 3
      taais-modules/taais-generator/src/main/resources/vm/java/service.java.vm
  14. 10 12
      taais-modules/taais-generator/src/main/resources/vm/java/serviceImpl.java.vm
  15. 2 2
      taais-modules/taais-generator/src/main/resources/vm/java/sub-domain.java.vm
  16. 70 0
      taais-modules/taais-generator/src/main/resources/vm/java/vo-import.java.vm
  17. 4 4
      taais-modules/taais-generator/src/main/resources/vm/java/vo.java.vm
  18. 19 0
      taais-modules/taais-generator/src/main/resources/vm/sql/dm8/sql.vm
  19. 6 6
      taais-modules/taais-generator/src/main/resources/vm/sql/mysql/sql.vm
  20. 13 14
      taais-modules/taais-generator/src/main/resources/vm/vue/index.vue.vm

+ 5 - 1
taais-common/taais-common-orm/src/main/java/com/taais/common/orm/helper/DataBaseHelper.java

@@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
 /**
  * 数据库助手:判断数据库类型
  *
- * @author wgk
+ * @author taais
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
 public class DataBaseHelper {
@@ -20,4 +20,8 @@ public class DataBaseHelper {
     public static boolean isPostgreSql() {
         return DbType.POSTGRE_SQL == FlexGlobalConfig.getDefaultConfig().getDbType();
     }
+
+    public static boolean isDmSql() {
+        return DbType.DM == FlexGlobalConfig.getDefaultConfig().getDbType();
+    }
 }

+ 1 - 1
taais-modules/taais-generator/src/main/java/com/taais/generator/service/GenTableServiceImpl.java

@@ -320,7 +320,7 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
         // 查询表信息
         Result result = getResult(tableId);
         for (String template : result.templates()) {
-            if (!StringUtils.containsAny(template, "sql.vm", "api.ts.vm", "index.vue.vm", "index-tree.vue.vm")) {
+            if (!StringUtils.containsAny(template, "sql.vm", "api.ts.types.vm", "index.vue.vm", "index-tree.vue.vm")) {
                 // 渲染模板
                 StringWriter sw = new StringWriter();
                 Template tpl = Velocity.getTemplate(template, Constants.UTF8);

+ 16 - 6
taais-modules/taais-generator/src/main/java/com/taais/generator/util/VelocityUtils.java

@@ -19,7 +19,7 @@ import java.util.Set;
 /**
  * 模板处理工具类
  *
- * @author wgk
+ * @author km
  */
 public class VelocityUtils {
     /**
@@ -133,18 +133,23 @@ public class VelocityUtils {
         List<String> templates = new ArrayList<>();
         templates.add("vm/java/domain.java.vm");
         templates.add("vm/java/vo.java.vm");
+        templates.add("vm/java/vo-import.java.vm");
         templates.add("vm/java/bo.java.vm");
         templates.add("vm/java/mapper.java.vm");
         templates.add("vm/java/service.java.vm");
         templates.add("vm/java/serviceImpl.java.vm");
+        templates.add("vm/java/listener.java.vm");
         templates.add("vm/java/controller.java.vm");
         templates.add("vm/xml/mapper.xml.vm");
         if (DataBaseHelper.isPostgreSql()) {
             templates.add("vm/sql/postgresql/sql.vm");
+        } else if (DataBaseHelper.isDmSql()) {
+            templates.add("vm/sql/dm8/sql.vm");
         } else {
             templates.add("vm/sql/mysql/sql.vm");
         }
         templates.add("vm/api/api.ts.vm");
+        templates.add("vm/api/api.ts.types.vm");
         if (GenConstants.TPL_CRUD.equals(tplCategory)) {
             templates.add("vm/vue/index.vue.vm");
         } else if (GenConstants.TPL_TREE.equals(tplCategory)) {
@@ -175,13 +180,15 @@ public class VelocityUtils {
 
         String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
         String mybatisPath = MYBATIS_PATH + "/" + moduleName;
+        String apiTypesPath = "interface" + "/" + moduleName;
+        String apiModulesPath = "modules" + "/" + moduleName;
         String vuePath = "vue";
-
         switch (template) {
             case "vm/java/domain.java.vm" -> fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
             case "vm/java/sub-domain.java.vm" ->
                 fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
             case "vm/java/vo.java.vm" -> fileName = StringUtils.format("{}/domain/vo/{}Vo.java", javaPath, className);
+            case "vm/java/vo-import.java.vm" -> fileName = StringUtils.format("{}/domain/vo/{}ImportVo.java", javaPath, className);
             case "vm/java/bo.java.vm" -> fileName = StringUtils.format("{}/domain/bo/{}Bo.java", javaPath, className);
             case "vm/java/mapper.java.vm" ->
                 fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
@@ -193,16 +200,19 @@ public class VelocityUtils {
                 fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
             case "vm/java/controller.java.vm" ->
                 fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
+            case "vm/java/listener.java.vm" ->
+                fileName = StringUtils.format("{}/listener/{}ImportListener.java", javaPath, className);
             case "vm/xml/mapper.xml.vm" -> fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
             case "vm/xml/sub-mapper.xml.vm" ->
                 fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, genTable.getSubTable().getClassName());
             case "vm/sql/postgresql/sql.vm" -> fileName = businessName + "Menu(postgresql).sql";
+            case "vm/sql/dm8/sql.vm" -> fileName = businessName + "Menu(dm8).sql";
             case "vm/sql/mysql/sql.vm" -> fileName = businessName + "Menu(mysql).sql";
             case "vm/api/api.ts.vm" ->
-                fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
-            case "vm/vue/index.vue.vm" ->
-                fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
-            case "vm/vue/index-tree.vue.vm" ->
+                fileName = StringUtils.format("{}/api/{}/{}.ts", vuePath, apiModulesPath, businessName);
+            case "vm/api/api.ts.types.vm" ->
+                fileName = StringUtils.format("{}/api/{}/{}.ts", vuePath, apiTypesPath, businessName);
+            case "vm/vue/index.vue.vm", "vm/vue/index-tree.vue.vm" ->
                 fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
             default -> fileName = "default.xml";
         }

+ 1 - 1
taais-modules/taais-generator/src/main/resources/generator.yml

@@ -3,7 +3,7 @@ gen:
   # 作者
   author: km
   # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
-  packageName: com.taais.demo
+  packageName: com.km.demo
   # 自动去除表前缀,默认是false
   autoRemovePre: false
   # 表前缀(生成类名不会包含表前缀,多个用逗号分隔)

+ 31 - 0
taais-modules/taais-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml

@@ -101,6 +101,37 @@
             WHERE table_name = (#{tableName})
             AND column_type <![CDATA[ <> ]]> '-'
         </if>
+        <if test="@com.taais.common.orm.helper.DataBaseHelper@isDmSql()">
+            select sc.NAME column_name,
+            (case when sc.NULLABLE$ = 'N' then '1' else null end) as is_required,
+            (case when sc.INFO2 = 1 then '1' else '0' end) is_pk,
+            sc.COLID sort,
+            scc.COMMENT$ column_comment,
+            (case when sc.INFO2 = 1 then '1' else '0' end) as is_increment,
+            LOWER(sc.TYPE$) column_type
+            from SYS.SYSCOLUMNS sc
+            left join SYS.SYSOBJECTS so on sc.ID = so.ID
+            left join SYS.SYSCOLUMNCOMMENTS SCC
+            on sc.NAME = scc.COLNAME and scc.TABLE_TYPE = 'TABLE' and
+            scc.SCHNAME = (select CURR_SCH
+            from V$SESSIONS
+            WHERE CURR_SCH = 'taais'
+            LIMIT 1) and
+            scc.TVNAME = so.NAME
+            where so.TYPE$ = 'SCHOBJ'
+            and so.SUBTYPE$ = 'UTAB'
+            and so.PID = -1
+            and so.SCHID =
+            (select ID
+            from SYS.SYSOBJECTS
+            where TYPE$ = 'SCH'
+            and NAME = (select CURR_SCH
+            from V$SESSIONS
+            WHERE CURR_SCH = 'taais'
+            LIMIT 1))
+            and so.NAME = #{tableName}
+            order by sc.COLID
+        </if>
 
     </select>
 

+ 48 - 0
taais-modules/taais-generator/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -118,6 +118,24 @@
             order by create_time desc
             limit ${pageSize} OFFSET ${pageOffset}
         </if>
+        <if test="@com.taais.common.orm.helper.DataBaseHelper@isDmSql()">
+            select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left join
+            SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH
+            from V$SESSIONS WHERE CURR_SCH = 'taais' LIMIT 1)
+            where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID =
+            (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH
+            from V$SESSIONS WHERE CURR_SCH = 'taais' LIMIT 1)) and
+            so.NAME NOT LIKE 'pj_%' AND so.NAME NOT LIKE 'gen_%'
+            and so.NAME NOT IN (select table_name from gen_table)
+            <if test="tableName != null and tableName != ''">
+                and lower(so.NAME) like lower(concat('%', #{tableName}, '%'))
+            </if>
+            <if test="tableComment != null and tableComment != ''">
+                and lower(st.COMMENT$) like lower(concat('%', #{tableComment}, '%'))
+            </if>
+            order by so.CRTDATE desc
+            limit ${pageOffset}, ${pageSize}
+        </if>
 
     </select>
 
@@ -160,6 +178,23 @@
                 AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
             </if>) t
         </if>
+        <if test="@com.taais.common.orm.helper.DataBaseHelper@isDmSql()">
+            (select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left
+            join
+            SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH
+            from V$SESSIONS WHERE CURR_SCH = 'taais' LIMIT 1)
+            where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID =
+            (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH
+            from V$SESSIONS WHERE CURR_SCH = 'taais' LIMIT 1)) and
+            so.NAME NOT LIKE 'pj_%' AND so.NAME NOT LIKE 'gen_%'
+            and so.NAME NOT IN (select table_name from gen_table)
+            <if test="tableName != null and tableName != ''">
+                and lower(so.NAME) like lower(concat('%', #{tableName}, '%'))
+            </if>
+            <if test="tableComment != null and tableComment != ''">
+                and lower(st.COMMENT$) like lower(concat('%', #{tableComment}, '%'))
+            </if>)
+        </if>
 
     </select>
 
@@ -192,6 +227,19 @@
                 #{name}
             </foreach>
         </if>
+        <if test="@com.taais.common.orm.helper.DataBaseHelper@isDmSql()">
+            select so.NAME table_name, st.COMMENT$ table_comment, so.CRTDATE create_time from SYS.SYSOBJECTS so left join
+            SYS.SYSTABLECOMMENTS st on so.NAME = st.TVNAME and st.TABLE_TYPE = 'TABLE' and st.SCHNAME = (select CURR_SCH
+            from V$SESSIONS WHERE CURR_SCH = 'taais' LIMIT 1)
+            where so.TYPE$='SCHOBJ' and so.SUBTYPE$='UTAB' and so.PID = -1 and INSTR(so.NAME,'##') = 0 and so.SCHID =
+            (select ID from SYS.SYSOBJECTS where TYPE$='SCH' and NAME= (select CURR_SCH
+            from V$SESSIONS WHERE CURR_SCH = 'taais' LIMIT 1)) and
+            so.NAME NOT LIKE 'pj_%' and so.NAME NOT LIKE 'gen_%'
+            and so.NAME in
+            <foreach collection="array" item="name" open="(" separator="," close=")">
+                #{name}
+            </foreach>
+        </if>
     </select>
 
     <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">

+ 59 - 0
taais-modules/taais-generator/src/main/resources/vm/api/api.ts.types.vm

@@ -0,0 +1,59 @@
+import { PageQuery, BaseEntity } from '@/api/interface/index'
+export interface ${BusinessName}VO extends BaseEntity {
+#foreach ($column in $columns)
+    #if($column.list)
+    /**
+    * $column.columnComment
+    */
+        $column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
+    #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
+    #elseif($column.javaType == 'Boolean') boolean;
+    #else string;
+    #end
+    #end
+#end
+#if ($table.tree)
+/**
+* 子树对象
+*/
+children: ${BusinessName}VO[];
+#end
+#if($table.sub)
+/** $table.subTable.functionName信息 */
+    ${subclassName}List: Array<${subClassName}VO>;
+#end
+    }
+
+    export interface ${BusinessName}Form {
+#foreach ($column in $columns)
+    #if($column.insert || $column.edit)
+        /**
+        * $column.columnComment
+        */
+        $column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
+    #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
+    #elseif($column.javaType == 'Boolean') boolean;
+    #else string;
+    #end
+    #end
+#end
+    }
+
+    export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{
+#foreach ($column in $columns)
+    #if($column.query)
+        /**
+        * $column.columnComment
+        */
+        $column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
+    #elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
+    #elseif($column.javaType == 'Boolean') boolean;
+    #else string;
+    #end
+    #end
+#end
+    /**
+    * 日期范围参数
+    */
+    params?: any;
+    }

+ 8 - 8
taais-modules/taais-generator/src/main/resources/vm/api/api.ts.vm

@@ -1,12 +1,12 @@
 import http from '@/api'
-
+import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query  } from '@/api/interface/${moduleName}/${businessName}'
 /**
  * @name 查询${functionName}列表
  * @param query 参数
  * @returns 返回列表
  */
-export const list${BusinessName}Api = (query: any) => {
-    return http.get<any>('/${moduleName}/${businessName}/list', query, { loading: true })
+export const list${BusinessName}Api = (query: ${BusinessName}Query) => {
+    return http.get<${BusinessName}VO[]>('/${moduleName}/${businessName}/list', query, { loading: true })
 }
 
 /**
@@ -14,8 +14,8 @@ export const list${BusinessName}Api = (query: any) => {
  * @param ${pkColumn.javaField} ${pkColumn.javaField}
  * @returns returns
  */
-export const get${BusinessName}Api = (${pkColumn.javaField}: any) => {
-    return http.get<any>(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`)
+export const get${BusinessName}Api = (${pkColumn.javaField}: string | number) => {
+    return http.get<${BusinessName}VO>(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`)
 }
 
 /**
@@ -23,7 +23,7 @@ export const get${BusinessName}Api = (${pkColumn.javaField}: any) => {
  * @param data data
  * @returns returns
  */
-export const add${BusinessName}Api = (data: any) => {
+export const add${BusinessName}Api = (data: ${BusinessName}Form) => {
     return http.post<any>('/${moduleName}/${businessName}', data, { loading: false })
 }
 
@@ -32,7 +32,7 @@ export const add${BusinessName}Api = (data: any) => {
  * @param data data
  * @returns returns
  */
-export const update${BusinessName}Api = (data: any) => {
+export const update${BusinessName}Api = (data: ${BusinessName}Form) => {
     return http.put<any>('/${moduleName}/${businessName}', data, { loading: false })
 }
 
@@ -41,7 +41,7 @@ export const update${BusinessName}Api = (data: any) => {
  * @param ${pkColumn.javaField} ${pkColumn.javaField}
  * @returns returns
  */
-export const del${BusinessName}Api = (${pkColumn.javaField}: any) => {
+export const del${BusinessName}Api = (${pkColumn.javaField}: string | number | Array<string | number>) => {
     return http.delete<any>(`/${moduleName}/${businessName}/${${pkColumn.javaField}}`)
 }
 

+ 2 - 3
taais-modules/taais-generator/src/main/resources/vm/java/bo.java.vm

@@ -12,12 +12,11 @@ import jakarta.validation.constraints.*;
 import ${import};
 #end
 #if($table.crud || $table.sub)
-import com.taais.common.orm.core.domain.BaseEntity;
+import com.km.common.orm.core.domain.BaseEntity;
 #elseif($table.tree)
-import com.taais.common.orm.core.domain.TreeEntity;
+import com.km.common.orm.core.domain.TreeEntity;
 #end
 
-
 /**
  * ${functionName}业务对象 ${tableName}
  *

+ 10 - 10
taais-modules/taais-generator/src/main/resources/vm/java/controller.java.vm

@@ -7,19 +7,19 @@ import jakarta.servlet.http.HttpServletResponse;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
-import com.taais.common.core.core.domain.CommonResult;
-import com.taais.common.excel.utils.ExcelUtil;
-import com.taais.common.log.annotation.Log;
-import com.taais.common.log.enums.BusinessType;
-import com.taais.common.web.annotation.RepeatSubmit;
-import com.taais.common.web.core.BaseController;
+import com.km.common.core.core.domain.CommonResult;
+import com.km.common.excel.utils.ExcelUtil;
+import com.km.common.log.annotation.Log;
+import com.km.common.log.enums.BusinessType;
+import com.km.common.web.annotation.RepeatSubmit;
+import com.km.common.web.core.BaseController;
 import jakarta.annotation.Resource;
 import ${packageName}.domain.vo.${ClassName}Vo;
 import ${packageName}.domain.bo.${ClassName}Bo;
 import ${packageName}.service.I${ClassName}Service;
 
 #if($table.crud || $table.sub)
-import com.taais.common.orm.core.page.TableDataInfo;
+import com.km.common.core.core.page.PageResult;
 #elseif($table.tree)
 #end
 
@@ -43,8 +43,8 @@ public class ${ClassName}Controller extends BaseController {
     @SaCheckPermission("${permissionPrefix}:list")
     @GetMapping("/list")
     #if($table.crud || $table.sub)
-    public TableDataInfo<${ClassName}Vo> list(${ClassName}Bo ${className}Bo) {
-        return ${className}Service.selectPage(${className}Bo);
+    public CommonResult<PageResult<${ClassName}Vo>> list(${ClassName}Bo ${className}Bo) {
+        return CommonResult.success(${className}Service.selectPage(${className}Bo));
     }
     #elseif($table.tree)
     public CommonResult<List<${ClassName}Vo>> list(${ClassName}Bo ${className}Bo) {
@@ -70,7 +70,7 @@ public class ${ClassName}Controller extends BaseController {
     @SaCheckPermission("${permissionPrefix}:query")
     @GetMapping(value = "/{${pkColumn.javaField}}")
     public CommonResult<${ClassName}Vo> getInfo(@PathVariable ${pkColumn.javaType} ${pkColumn.javaField}) {
-        return CommonResult.ok(${className}Service.selectById(${pkColumn.javaField}));
+        return CommonResult.success(${className}Service.selectById(${pkColumn.javaField}));
     }
 
     /**

+ 2 - 2
taais-modules/taais-generator/src/main/resources/vm/java/domain.java.vm

@@ -27,9 +27,9 @@ import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
 #if($table.crud || $table.sub)
-import com.taais.common.orm.core.domain.BaseEntity;
+import com.km.common.orm.core.domain.BaseEntity;
 #elseif($table.tree)
-import com.taais.common.orm.core.domain.TreeEntity;
+import com.km.common.orm.core.domain.TreeEntity;
 #end
 
 /**

+ 127 - 0
taais-modules/taais-generator/src/main/resources/vm/java/listener.java.vm

@@ -0,0 +1,127 @@
+package ${packageName}.listener;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
+import com.km.common.core.exception.ServiceException;
+import com.km.common.core.utils.SpringUtils;
+import com.km.common.core.utils.ValidatorUtils;
+import com.km.common.excel.core.ExcelListener;
+import com.km.common.excel.core.ExcelResult;
+import ${packageName}.domain.bo.${ClassName}Bo;
+import ${packageName}.domain.vo.${ClassName}ImportVo;
+import ${packageName}.domain.vo.${ClassName}Vo;
+import ${packageName}.service.I${ClassName}Service;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+
+/**
+ * ${functionName}自定义导入
+ *
+ * @author ${author}
+ */
+@Slf4j
+public class ${ClassName}ImportListener extends AnalysisEventListener<${ClassName}ImportVo> implements ExcelListener<${ClassName}ImportVo> {
+    private final I${ClassName}Service ${className}Service;
+
+    private final Boolean isUpdateSupport;
+    private int successNum = 0;
+    private int failureNum = 0;
+    private final StringBuilder successMsg = new StringBuilder();
+    private final StringBuilder failureMsg = new StringBuilder();
+
+    public ${ClassName}ImportListener(Boolean isUpdateSupport) {
+        this.${className}Service = SpringUtils.getBean(I${ClassName}Service.class);
+        this.isUpdateSupport = isUpdateSupport;
+    }
+
+    @Override
+    public void invoke(${ClassName}ImportVo ${className}Vo, AnalysisContext context) {
+        try {
+
+            ${ClassName}Bo ${className}Bo = BeanUtil.toBean(${className}Vo, ${ClassName}Bo.class);
+
+            //TODO:根据某个字段,查询数据库表中是否存在记录,不存在就新增,存在就更新
+            ${ClassName}Vo ${className}Vo1 = null;
+
+            #if($table.tree)
+            ${className}Vo1 = ${className}Service.selectById(${className}Vo.get${pkColumn.capJavaField}());
+            #else
+            //${className}Vo1 = ${className}Service.selectBySomefield(${className}Vo.getSomefield());
+            #end
+            if (ObjectUtil.isNull(${className}Vo1)) {
+                //不存在就新增
+                ${className}Bo.setVersion(0);
+                ValidatorUtils.validate(${className}Bo);
+              #if($table.tree)
+                boolean inserted = ${className}Service.insertWithPk(${className}Bo);//树表需要前台传来主键值
+              #else
+                boolean inserted = ${className}Service.insert(${className}Bo);
+              #end
+
+                if (inserted) {
+                    successNum++;
+                    successMsg.append("<br/>").append(successNum).append("、${functionName} 记录导入成功");
+                    return;
+                } else {
+                    failureNum++;
+                    failureMsg.append("<br/>").append(failureNum).append("、${functionName} 记录导入失败");
+                    return;
+                }
+            } else if (isUpdateSupport) {
+                //存在就更新
+                ${className}Bo.set${pkColumn.capJavaField}(${className}Vo1.get${pkColumn.capJavaField}());//主键
+                ${className}Bo.setVersion(${className}Vo1.getVersion());
+                boolean updated = ${className}Service.update(${className}Bo);
+                if (updated) {
+                    successNum++;
+                    successMsg.append("<br/>").append(successNum).append("、${functionName} 记录更新成功");
+                    return;
+                } else {
+                    failureNum++;
+                    failureMsg.append("<br/>").append(failureNum).append("、${functionName} 记录更新失败");
+                    return;
+                }
+            }
+        } catch (Exception e) {
+            failureNum++;
+            String msg = "<br/>" + failureNum + "、${functionName} 记录导入失败:";
+            failureMsg.append(msg).append(e.getMessage());
+            log.error(msg, e);
+        }
+    }
+
+    @Override
+    public void doAfterAllAnalysed(AnalysisContext context) {
+
+    }
+
+    @Override
+    public ExcelResult<${ClassName}ImportVo> getExcelResult() {
+        return new ExcelResult<>() {
+
+            @Override
+            public String getAnalysis() {
+                if (failureNum > 0) {
+                    failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据没有成功导入,错误如下:");
+                    throw new ServiceException(failureMsg.toString());
+                } else {
+                    successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
+                }
+                return successMsg.toString();
+            }
+
+            @Override
+            public List<${ClassName}ImportVo> getList() {
+                return null;
+            }
+
+            @Override
+            public List<String> getErrorList() {
+                return null;
+            }
+        };
+    }
+}

+ 3 - 3
taais-modules/taais-generator/src/main/resources/vm/java/service.java.vm

@@ -5,9 +5,9 @@ import java.util.List;
 import ${packageName}.domain.${ClassName};
 import ${packageName}.domain.vo.${ClassName}Vo;
 import ${packageName}.domain.bo.${ClassName}Bo;
-import com.taais.common.orm.core.service.IBaseService;
+import com.km.common.orm.core.service.IBaseService;
 #if($table.crud || $table.sub)
-import com.taais.common.orm.core.page.TableDataInfo;
+import com.km.common.core.core.page.PageResult;
 #end
 
 /**
@@ -40,7 +40,7 @@ public interface I${ClassName}Service extends IBaseService<${ClassName}> {
      * @param ${className}Bo ${functionName}Bo
      * @return 分页${functionName}集合
      */
-    TableDataInfo<${ClassName}Vo> selectPage(${ClassName}Bo ${className}Bo);
+    PageResult<${ClassName}Vo> selectPage(${ClassName}Bo ${className}Bo);
     #end
 
     /**

+ 10 - 12
taais-modules/taais-generator/src/main/resources/vm/java/serviceImpl.java.vm

@@ -6,11 +6,11 @@ import java.util.List;
 import cn.hutool.core.util.ObjectUtil;
 import com.mybatisflex.core.paginate.Page;
 import com.mybatisflex.core.query.QueryWrapper;
-import com.taais.common.core.utils.MapstructUtils;
-import com.taais.common.core.utils.StringUtils;
-import com.taais.common.orm.core.page.PageQuery;
-import com.taais.common.orm.core.page.TableDataInfo;
-import com.taais.common.orm.core.service.impl.BaseServiceImpl;
+import com.km.common.core.utils.MapstructUtils;
+import com.km.common.core.utils.StringUtils;
+import com.km.common.orm.core.page.PageQuery;
+import com.km.common.core.core.page.PageResult;
+import com.km.common.orm.core.service.impl.BaseServiceImpl;
     #foreach ($column in $columns)
         #if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
             #break
@@ -31,7 +31,7 @@ import ${packageName}.domain.${ClassName};
 import ${packageName}.domain.bo.${ClassName}Bo;
 import ${packageName}.domain.vo.${ClassName}Vo;
 import ${packageName}.service.I${ClassName}Service;
-import static ${packageName}.domain.table.${ClassName}TableDef .${CapitalUnderScoreClassName};
+import static ${packageName}.domain.table.${ClassName}TableDef.${CapitalUnderScoreClassName};
 
 /**
  * ${functionName}Service业务层处理
@@ -90,11 +90,9 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper,
     public ${ClassName}Vo selectById(${pkColumn.javaType} ${pkColumn.javaField}) {
         #set($CapitalPkColumn=${pkColumn.columnName.toUpperCase()})
         #if($table.sub)
-            return ${className}Mapper.selectOneWithRelationsByQueryAs(query().where(${CapitalUnderScoreClassName}.${CapitalPkColumn}.eq(${pkColumn.javaField})), ${ClassName}
-            Vo.class);
+            return ${className}Mapper.selectOneWithRelationsByQueryAs(query().where(${CapitalUnderScoreClassName}.${CapitalPkColumn}.eq(${pkColumn.javaField})), ${ClassName}Vo.class);
         #else
-            return this.getOneAs(query().where(${CapitalUnderScoreClassName}.${CapitalPkColumn}.eq(${pkColumn.javaField})), ${ClassName}
-            Vo.class);
+            return this.getOneAs(query().where(${CapitalUnderScoreClassName}.${CapitalPkColumn}.eq(${pkColumn.javaField})), ${ClassName}Vo.class);
         #end
 
     }
@@ -123,14 +121,14 @@ public class ${ClassName}ServiceImpl extends BaseServiceImpl<${ClassName}Mapper,
      * @return 分页${functionName}集合
      */
     @Override
-    public TableDataInfo<${ClassName}Vo> selectPage(${ClassName}Bo ${className}Bo) {
+    public PageResult<${ClassName}Vo> selectPage(${ClassName}Bo ${className}Bo) {
         QueryWrapper queryWrapper = buildQueryWrapper(${className}Bo);
         #if($table.sub)
             Page<${ClassName}Vo> page = ${className}Mapper.paginateWithRelationsAs(PageQuery.build(), queryWrapper, ${ClassName}Vo.class);
         #else
             Page<${ClassName}Vo> page = this.pageAs(PageQuery.build(), queryWrapper, ${ClassName}Vo.class);
         #end
-        return TableDataInfo.build(page);
+        return PageResult.build(page);
     }
     #end
 

+ 2 - 2
taais-modules/taais-generator/src/main/resources/vm/java/sub-domain.java.vm

@@ -10,9 +10,9 @@ import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
 #if($table.crud || $table.sub)
-import com.taais.common.orm.core.domain.BaseEntity;
+import com.km.common.orm.core.domain.BaseEntity;
 #elseif($table.tree)
-import com.taais.common.orm.core.domain.TreeEntity;
+import com.km.common.orm.core.domain.TreeEntity;
 #end
 
 /**

+ 70 - 0
taais-modules/taais-generator/src/main/resources/vm/java/vo-import.java.vm

@@ -0,0 +1,70 @@
+package ${packageName}.domain.vo;
+
+#foreach ($import in $importList)
+import ${import};
+#end
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.km.common.excel.annotation.ExcelDictFormat;
+import com.km.common.excel.convert.ExcelDictConvert;
+import lombok.Data;
+import java.io.Serial;
+import java.io.Serializable;
+import lombok.NoArgsConstructor;
+
+/**
+ * ${functionName}导入视图对象 ${tableName}
+ *
+ * @author ${author}
+ * @date ${datetime}
+ */
+
+@Data
+@NoArgsConstructor
+public class ${ClassName}ImportVo implements Serializable
+{
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+#foreach ($column in $columns)
+ #if($column.isPk=='1')
+    #if($table.tree)
+     /** $column.columnComment */
+     @ExcelProperty(value = "${column.columnComment}")
+     private $column.javaType $column.javaField;
+    #end
+ #end
+#end
+
+    #foreach ($column in $columns)
+#if($column.isPk!='1')
+#if(!$table.isSuperColumn($column.javaField)  || ($column.javaField.equals("parentId"))  || ($column.javaField.equals("orderNum")))
+     /** $column.columnComment */
+#if($column.list)
+#set($parentheseIndex=$column.columnComment.indexOf("("))
+#if($parentheseIndex != -1)
+#set($comment=$column.columnComment.substring(0, $parentheseIndex))
+#else
+#set($comment=$column.columnComment)
+#end
+#if(${column.dictType} && ${column.dictType} != '')
+    @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "${column.dictType}")
+#elseif($parentheseIndex != -1)
+    @ExcelProperty(value = "${comment}", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "$column.readConverterExp()")
+#else
+    @ExcelProperty(value = "${comment}")
+#end
+    private $column.javaType $column.javaField;
+
+#else
+    @ExcelProperty(value = "${column.columnComment}")
+    private $column.javaType $column.javaField;
+
+#end
+#end
+#end
+#end
+
+}

+ 4 - 4
taais-modules/taais-generator/src/main/resources/vm/java/vo.java.vm

@@ -6,8 +6,8 @@ import ${import};
 import ${packageName}.domain.${ClassName};
 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
 import com.alibaba.excel.annotation.ExcelProperty;
-import com.taais.common.excel.annotation.ExcelDictFormat;
-import com.taais.common.excel.convert.ExcelDictConvert;
+import com.km.common.excel.annotation.ExcelDictFormat;
+import com.km.common.excel.convert.ExcelDictConvert;
 import io.github.linpeilie.annotations.AutoMapper;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -18,9 +18,9 @@ import ${packageName}.domain.${subClassName};
 import java.io.Serial;
 import java.io.Serializable;
 #if($table.crud || $table.sub)
-import com.taais.common.orm.core.domain.BaseEntity;
+import com.km.common.orm.core.domain.BaseEntity;
 #elseif($table.tree)
-import com.taais.common.orm.core.domain.TreeEntity;
+import com.km.common.orm.core.domain.TreeEntity;
 #end
 
 /**

+ 19 - 0
taais-modules/taais-generator/src/main/resources/vm/sql/dm8/sql.vm

@@ -0,0 +1,19 @@
+-- 菜单 SQL
+insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values(${table.menuIds[0]}, '${functionName}', ${parentMenuId}, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '', 1, now(), 1, null, '${functionName}菜单');
+
+-- 按钮 SQL
+insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query',        '', 1, now(), 1, null, '');
+
+insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add',          '', 1, now(), 1, null, '');
+
+insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit',         '', 1, now(), 1, null, '');
+
+insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove',       '', 1, now(), 1, null, '');
+
+insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export',       '', 1, now(), 1, null, '');

+ 6 - 6
taais-modules/taais-generator/src/main/resources/vm/sql/mysql/sql.vm

@@ -1,19 +1,19 @@
 -- 菜单 SQL
 insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values(${table.menuIds[0]}, '${functionName}', ${parentMenuId}, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '', 1, sysdate(), 1, null, '${functionName}菜单');
+values(${table.menuIds[0]}, '${functionName}', ${parentMenuId}, '1', '${businessName}', '${moduleName}/${businessName}/index', 1, 0, 'C', '0', '0', '${permissionPrefix}:list', '#', 1, sysdate(), 1, null, '${functionName}菜单');
 
 -- 按钮 SQL
 insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query',        '', 1, sysdate(), 1, null, '');
+values(${table.menuIds[1]}, '${functionName}查询', ${table.menuIds[0]}, '1',  '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:query',        '#', 1, sysdate(), 1, null, '');
 
 insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add',          '', 1, sysdate(), 1, null, '');
+values(${table.menuIds[2]}, '${functionName}新增', ${table.menuIds[0]}, '2',  '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:add',          '#', 1, sysdate(), 1, null, '');
 
 insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit',         '', 1, sysdate(), 1, null, '');
+values(${table.menuIds[3]}, '${functionName}修改', ${table.menuIds[0]}, '3',  '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:edit',         '#', 1, sysdate(), 1, null, '');
 
 insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove',       '', 1, sysdate(), 1, null, '');
+values(${table.menuIds[4]}, '${functionName}删除', ${table.menuIds[0]}, '4',  '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:remove',       '#', 1, sysdate(), 1, null, '');
 
 insert into sys_menu (menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
-values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5',  '', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export',       '', 1, sysdate(), 1, null, '');
+values(${table.menuIds[5]}, '${functionName}导出', ${table.menuIds[0]}, '5',  '#', '', 1, 0, 'F', '0', '0', '${permissionPrefix}:export',       '#', 1, sysdate(), 1, null, '');

+ 13 - 14
taais-modules/taais-generator/src/main/resources/vm/vue/index.vue.vm

@@ -3,19 +3,19 @@
         <ProTable ref="proTable" :columns="columns" row-key="${pkColumn.javaField}" :request-api="list${BusinessName}Api" >
             <!-- 表格 header 按钮 -->
             <template #tableHeader="scope">
-                <el-button type="primary" v-auth="['${moduleName}:${businessName}:add']" :icon="CirclePlus" @click="openDialog(1, '${functionName}新增')">
+                <el-button type="primary" v-auth="['${moduleName}:${businessName}:add']" icon="CirclePlus" @click="openDialog(1, '${functionName}新增')">
                     新增
                 </el-button>
-                <el-button type="primary" v-auth="['${moduleName}:${businessName}:import']" :icon="Upload" plain @click="batchAdd">
+                <el-button type="primary" v-auth="['${moduleName}:${businessName}:import']" icon="Upload" plain @click="batchAdd">
                     导入
                 </el-button>
-                <el-button type="primary" v-auth="['${moduleName}:${businessName}:export']" :icon="Download" plain @click="downloadFile">
+                <el-button type="primary" v-auth="['${moduleName}:${businessName}:export']" icon="Download" plain @click="downloadFile">
                     导出
                 </el-button>
                 <el-button
                     type="danger"
                     v-auth="['${moduleName}:${businessName}:remove']"
-                    :icon="Delete"
+                    icon="Delete"
                     plain
                     :disabled="!scope.isSelected"
                     @click="batchDelete(scope.selectedListIds)"
@@ -28,7 +28,7 @@
                 <el-button
                     type="primary"
                     link
-                    :icon="View"
+                    icon="View"
                     v-auth="['${moduleName}:${businessName}:query']"
                     @click="openDialog(3, '${functionName}查看', scope.row)"
                 >
@@ -37,13 +37,13 @@
                 <el-button
                     type="primary"
                     link
-                    :icon="EditPen"
+                    icon="EditPen"
                     v-auth="['${moduleName}:${businessName}:edit']"
                     @click="openDialog(2, '${functionName}编辑', scope.row)"
                 >
                     编辑
                 </el-button>
-                <el-button type="primary" link :icon="Delete" v-auth="['${moduleName}:${businessName}:remove']" @click="delete${BusinessName}(scope.row)">
+                <el-button type="primary" link icon="Delete" v-auth="['${moduleName}:${businessName}:remove']" @click="delete${BusinessName}(scope.row)">
                     删除
                 </el-button>
             </template>
@@ -62,7 +62,6 @@
     import ImportExcel from '@/components/ImportExcel/index.vue'
     import FormDialog from '@/components/FormDialog/index.vue'
     import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
-    import { Delete, EditPen, Download, Upload, View, CirclePlus } from '@element-plus/icons-vue'
     import {
         list${BusinessName}Api,
         del${BusinessName}Api,
@@ -82,7 +81,7 @@
 
     // 删除${functionName}信息
     const delete${BusinessName} = async (params: any) => {
-        await useHandleData(del${BusinessName}Api, params.${pkColumn.javaField}, `删除【params.${pkColumn.javaField}】${functionName}`)
+        await useHandleData(del${BusinessName}Api, params.${pkColumn.javaField}, '删除【' + params.${pkColumn.javaField} + '】${functionName}')
         proTable.value?.getTableList()
     }
 
@@ -120,12 +119,12 @@
             res = await get${BusinessName}Api(row?.${pkColumn.javaField} || null)
         }
         // 重置表单
-        setFormItems()
+        setItemsOptions()
         const params = {
             title,
             width: 580,
             isEdit: type !== 3,
-            fieldList: formItems,
+            itemsOptions: itemsOptions,
             model: type == 1 ? {} : res.data,
             api: type == 1 ? add${BusinessName}Api : update${BusinessName}Api,
             getTableList: proTable.value?.getTableList
@@ -190,9 +189,9 @@
         { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
     ])
     // 表单配置项
-    let formItems: ProForm.ItemsOptions[] = []
-    const setFormItems = () => {
-        formItems = [
+    let itemsOptions: ProForm.ItemsOptions[] = []
+    const setItemsOptions = () => {
+        itemsOptions = [
             #foreach($column in $columns)
                 #set($field=$column.javaField)
                 #if($column.insert && !$column.pk)