From d601b5781ea977e4afdba5f87f37635b65910a32 Mon Sep 17 00:00:00 2001 From: runphp Date: Wed, 12 Jan 2022 02:12:09 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E6=9B=B4=E6=96=B0=E6=9C=AA?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ruoyi/gen/service/GenTableServiceImpl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java index 6bd1aa9..de4ea4d 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/com/ruoyi/gen/service/GenTableServiceImpl.java @@ -7,6 +7,7 @@ import java.io.StringWriter; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -286,7 +287,7 @@ public class GenTableServiceImpl implements IGenTableService { GenTable table = genTableMapper.selectGenTableByName(tableName); List tableColumns = table.getColumns(); - List tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); + Map tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity())); List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); if (StringUtils.isEmpty(dbTableColumns)) @@ -296,9 +297,17 @@ public class GenTableServiceImpl implements IGenTableService List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); dbTableColumns.forEach(column -> { - if (!tableColumnNames.contains(column.getColumnName())) + GenUtils.initColumnField(column, table); + if (tableColumnMap.containsKey(column.getColumnName())) { - GenUtils.initColumnField(column, table); + GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); + column.setColumnId(prevColumn.getColumnId()); + if (column.isList()) { + // 如果是列表,继续保留字典类型 + column.setDictType(prevColumn.getDictType()); + } + genTableColumnMapper.updateGenTableColumn(column); + } else { genTableColumnMapper.insertGenTableColumn(column); } });