Sfoglia il codice sorgente

update 优化 代码生成 创建更新时间被覆盖问题

疯狂的狮子Li 4 mesi fa
parent
commit
ed6f8262c6

+ 1 - 2
ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/service/GenTableServiceImpl.java

@@ -106,7 +106,7 @@ public class GenTableServiceImpl implements IGenTableService {
             .like(StringUtils.isNotBlank(genTable.getTableComment()), "lower(table_comment)", StringUtils.lowerCase(genTable.getTableComment()))
             .between(params.get("beginTime") != null && params.get("endTime") != null,
                 "create_time", params.get("beginTime"), params.get("endTime"))
-            .orderByDesc("update_time", "create_time");
+            .orderByDesc("update_time");
         return wrapper;
     }
 
@@ -275,7 +275,6 @@ public class GenTableServiceImpl implements IGenTableService {
                 String tableName = table.getTableName();
                 GenUtils.initTable(table);
                 table.setDataName(dataName);
-                table.setCreateTime(new Date());
                 int row = baseMapper.insert(table);
                 if (row > 0) {
                     // 保存列信息

+ 4 - 0
ruoyi-modules/ruoyi-generator/src/main/java/org/dromara/generator/util/GenUtils.java

@@ -29,6 +29,8 @@ public class GenUtils {
         genTable.setBusinessName(getBusinessName(genTable.getTableName()));
         genTable.setFunctionName(replaceText(genTable.getTableComment()));
         genTable.setFunctionAuthor(GenConfig.getAuthor());
+        genTable.setCreateTime(null);
+        genTable.setUpdateTime(null);
     }
 
     /**
@@ -39,6 +41,8 @@ public class GenUtils {
         // 统一转小写 避免有些数据库默认大写问题 如果需要特别书写方式 请在实体类增加注解标注别名
         String columnName = column.getColumnName().toLowerCase();
         column.setTableId(table.getTableId());
+        column.setCreateTime(null);
+        column.setUpdateTime(null);
         // 设置java字段名
         column.setJavaField(StringUtils.toCamelCase(columnName));
         // 设置默认类型