refactor(代码生成): anyline 切换数据库适配器不变,导致读取的数据库信息错误

This commit is contained in:
冷冷 committed 2024-08-16 15:28:10 +08:00
1 parent f2921c2102
commit d5daf6b27d
2 files changed
+17 -4

No files matched your search

@@ -2,6 +2,8 @@ package com.pig4cloud.pigx.codegen.config;
import cn.smallbun.screw.core.constant.DefaultConstants;
import lombok.Data;
import org.anyline.util.ConfigTable;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@@ -14,7 +16,7 @@ import org.springframework.context.annotation.Configuration;
@Data
@Configuration(proxyBeanMethods = false)
@ConfigurationProperties(prefix = PigxCodeGenDefaultProperties.PREFIX)
public class PigxCodeGenDefaultProperties {
public class PigxCodeGenDefaultProperties implements InitializingBean {
public static final String PREFIX = "codegen";
@@ -78,4 +80,13 @@ public class PigxCodeGenDefaultProperties {
*/
private String syncRoute = "1";
/**
* <a href="http://doc.anyline.org/aa/3c_14011">集成mybatis动态数据源</a>
*
* @throws Exception 例外
*/
@Override
public void afterPropertiesSet() throws Exception {
ConfigTable.KEEP_ADAPTER = 0;
}
}
@@ -125,10 +125,12 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
return StrUtil.containsIgnoreCase(t.getName(false), table.getTableName())
|| StrUtil.containsIgnoreCase(t.getComment(), table.getTableName());
})
// 根据 createTime 、updateTime 倒序排序 ,如果有 updateTime 则按 updateTime ,如果有 createTime 则按 createTime
// 根据 createTime 、updateTime 倒序排序
.sorted((o1, o2) -> {
long time1 = o1.getUpdateTime() == null ? o1.getCreateTime().getTime() : o1.getUpdateTime().getTime();
long time2 = o2.getUpdateTime() == null ? o2.getCreateTime().getTime() : o2.getUpdateTime().getTime();
long time1 = (o1.getUpdateTime() != null ? o1.getUpdateTime().getTime() :
(o1.getCreateTime() != null ? o1.getCreateTime().getTime() : 0));
long time2 = (o2.getUpdateTime() != null ? o2.getUpdateTime().getTime() :
(o2.getCreateTime() != null ? o2.getCreateTime().getTime() : 0));
return NumberUtil.compare(time2, time1);
}).collect(Collectors.toList());