mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-22 04:47:10 +08:00
fix(代码生成): 读取表信息去掉缓存,避免数据库同步修改
This commit is contained in:
parent
7dd19322fb
commit
1d1b4706c3
@ -2,6 +2,8 @@ package com.pig4cloud.pig.codegen.config;
|
|||||||
|
|
||||||
import cn.smallbun.screw.core.constant.DefaultConstants;
|
import cn.smallbun.screw.core.constant.DefaultConstants;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.anyline.util.ConfigTable;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@ -14,7 +16,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Data
|
@Data
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@ConfigurationProperties(prefix = PigCodeGenDefaultProperties.PREFIX)
|
@ConfigurationProperties(prefix = PigCodeGenDefaultProperties.PREFIX)
|
||||||
public class PigCodeGenDefaultProperties {
|
public class PigCodeGenDefaultProperties implements InitializingBean {
|
||||||
|
|
||||||
public static final String PREFIX = "codegen";
|
public static final String PREFIX = "codegen";
|
||||||
|
|
||||||
@ -73,4 +75,9 @@ public class PigCodeGenDefaultProperties {
|
|||||||
*/
|
*/
|
||||||
private String generatorType = "0";
|
private String generatorType = "0";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception {
|
||||||
|
ConfigTable.KEEP_ADAPTER = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.anyline.metadata.Column;
|
import org.anyline.metadata.Column;
|
||||||
import org.anyline.metadata.Database;
|
import org.anyline.metadata.Database;
|
||||||
import org.anyline.metadata.Table;
|
import org.anyline.metadata.Table;
|
||||||
|
import org.anyline.proxy.CacheProxy;
|
||||||
import org.anyline.proxy.ServiceProxy;
|
import org.anyline.proxy.ServiceProxy;
|
||||||
import org.anyline.service.AnylineService;
|
import org.anyline.service.AnylineService;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -96,6 +97,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
|||||||
public List<String> queryTableColumn(String dsName, String tableName) {
|
public List<String> queryTableColumn(String dsName, String tableName) {
|
||||||
// 手动切换数据源
|
// 手动切换数据源
|
||||||
DynamicDataSourceContextHolder.push(dsName);
|
DynamicDataSourceContextHolder.push(dsName);
|
||||||
|
CacheProxy.clear();
|
||||||
return ServiceProxy.metadata().columns(tableName).values().stream().map(Column::getName).toList();
|
return ServiceProxy.metadata().columns(tableName).values().stream().map(Column::getName).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +111,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
|||||||
public IPage queryTablePage(Page<Table> page, GenTable table) {
|
public IPage queryTablePage(Page<Table> page, GenTable table) {
|
||||||
// 手动切换数据源
|
// 手动切换数据源
|
||||||
DynamicDataSourceContextHolder.push(table.getDsName());
|
DynamicDataSourceContextHolder.push(table.getDsName());
|
||||||
|
CacheProxy.clear();
|
||||||
List<Table> tableList = ServiceProxy.metadata().tables().values().stream().filter(t -> {
|
List<Table> tableList = ServiceProxy.metadata().tables().values().stream().filter(t -> {
|
||||||
if (StrUtil.isBlank(table.getTableName())) {
|
if (StrUtil.isBlank(table.getTableName())) {
|
||||||
return true;
|
return true;
|
||||||
@ -132,6 +135,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
|||||||
public List<String> queryTableList(String dsName) {
|
public List<String> queryTableList(String dsName) {
|
||||||
// 手动切换数据源
|
// 手动切换数据源
|
||||||
DynamicDataSourceContextHolder.push(dsName);
|
DynamicDataSourceContextHolder.push(dsName);
|
||||||
|
CacheProxy.clear();
|
||||||
return ServiceProxy.metadata().tables().values().stream().map(Table::getName).toList();
|
return ServiceProxy.metadata().tables().values().stream().map(Table::getName).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +174,7 @@ public class GenTableServiceImpl extends ServiceImpl<GenTableMapper, GenTable> i
|
|||||||
// 查询表是否存在
|
// 查询表是否存在
|
||||||
GenTable table = new GenTable();
|
GenTable table = new GenTable();
|
||||||
// 从数据库获取表信息
|
// 从数据库获取表信息
|
||||||
|
CacheProxy.clear();
|
||||||
AnylineService service = ServiceProxy.service();
|
AnylineService service = ServiceProxy.service();
|
||||||
Table tableMetadata = service.metadata().table(tableName);
|
Table tableMetadata = service.metadata().table(tableName);
|
||||||
Database database = service.metadata().database();
|
Database database = service.metadata().database();
|
||||||
|
Loading…
Reference in New Issue
Block a user