修复当配置信息中不存在列信息时可能会导致表的其他配置信息丢失问题

This commit is contained in:
makejava 2022-07-06 12:21:46 +08:00
parent 55f09db096
commit 6ffdb6fad0
2 changed files with 5 additions and 1 deletions

View File

@ -70,7 +70,7 @@ public class TableInfoDTO {
}
private static void merge(TableInfoDTO oldData, TableInfoDTO newData) {
if (oldData == null || CollectionUtil.isEmpty(oldData.getFullColumn())) {
if (oldData == null) {
return;
}
if (!StringUtils.isEmpty(oldData.getPreName())) {
@ -88,6 +88,9 @@ public class TableInfoDTO {
if (!StringUtils.isEmpty(oldData.getSaveModelName())) {
newData.saveModelName = oldData.getSaveModelName();
}
if (CollectionUtil.isEmpty(oldData.getFullColumn())) {
return;
}
// 补充自定义列
for (ColumnInfoDTO oldColumn : oldData.getFullColumn()) {
if (!oldColumn.getCustom()) {

View File

@ -87,6 +87,7 @@ public class TableInfoSettingsDTO {
public TableInfo readTableInfo(DbTable dbTable) {
String key = generateKey(dbTable);
TableInfoDTO dto = this.tableInfoMap.get(key);
// 表可能新增了字段需要重新合并保存
dto = new TableInfoDTO(dto, dbTable);
this.tableInfoMap.put(key, dto);
return dto.toTableInfo(dbTable);