正在显示
1 个修改的文件
包含
17 行增加
和
5 行删除
| @@ -7,6 +7,7 @@ import java.io.StringWriter; | @@ -7,6 +7,7 @@ import java.io.StringWriter; | ||
| 7 | import java.util.LinkedHashMap; | 7 | import java.util.LinkedHashMap; |
| 8 | import java.util.List; | 8 | import java.util.List; |
| 9 | import java.util.Map; | 9 | import java.util.Map; |
| 10 | +import java.util.function.Function; | ||
| 10 | import java.util.stream.Collectors; | 11 | import java.util.stream.Collectors; |
| 11 | import java.util.zip.ZipEntry; | 12 | import java.util.zip.ZipEntry; |
| 12 | import java.util.zip.ZipOutputStream; | 13 | import java.util.zip.ZipOutputStream; |
| @@ -286,7 +287,7 @@ public class GenTableServiceImpl implements IGenTableService | @@ -286,7 +287,7 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 286 | { | 287 | { |
| 287 | GenTable table = genTableMapper.selectGenTableByName(tableName); | 288 | GenTable table = genTableMapper.selectGenTableByName(tableName); |
| 288 | List<GenTableColumn> tableColumns = table.getColumns(); | 289 | List<GenTableColumn> tableColumns = table.getColumns(); |
| 289 | - List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); | 290 | + Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity())); |
| 290 | 291 | ||
| 291 | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); | 292 | List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); |
| 292 | if (StringUtils.isEmpty(dbTableColumns)) | 293 | if (StringUtils.isEmpty(dbTableColumns)) |
| @@ -296,9 +297,20 @@ public class GenTableServiceImpl implements IGenTableService | @@ -296,9 +297,20 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 296 | List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); | 297 | List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); |
| 297 | 298 | ||
| 298 | dbTableColumns.forEach(column -> { | 299 | dbTableColumns.forEach(column -> { |
| 299 | - if (!tableColumnNames.contains(column.getColumnName())) | 300 | + GenUtils.initColumnField(column, table); |
| 301 | + if (tableColumnMap.containsKey(column.getColumnName())) | ||
| 302 | + { | ||
| 303 | + GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); | ||
| 304 | + column.setColumnId(prevColumn.getColumnId()); | ||
| 305 | + if (column.isList()) | ||
| 306 | + { | ||
| 307 | + // 如果是列表,继续保留字典类型 | ||
| 308 | + column.setDictType(prevColumn.getDictType()); | ||
| 309 | + } | ||
| 310 | + genTableColumnMapper.updateGenTableColumn(column); | ||
| 311 | + } | ||
| 312 | + else | ||
| 300 | { | 313 | { |
| 301 | - GenUtils.initColumnField(column, table); | ||
| 302 | genTableColumnMapper.insertGenTableColumn(column); | 314 | genTableColumnMapper.insertGenTableColumn(column); |
| 303 | } | 315 | } |
| 304 | }); | 316 | }); |
| @@ -359,7 +371,7 @@ public class GenTableServiceImpl implements IGenTableService | @@ -359,7 +371,7 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 359 | zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); | 371 | zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); |
| 360 | IOUtils.write(sw.toString(), zip, Constants.UTF8); | 372 | IOUtils.write(sw.toString(), zip, Constants.UTF8); |
| 361 | IOUtils.closeQuietly(sw); | 373 | IOUtils.closeQuietly(sw); |
| 362 | - zip.flush(); | 374 | + zip.flush(); |
| 363 | zip.closeEntry(); | 375 | zip.closeEntry(); |
| 364 | } | 376 | } |
| 365 | catch (IOException e) | 377 | catch (IOException e) |
| @@ -472,7 +484,7 @@ public class GenTableServiceImpl implements IGenTableService | @@ -472,7 +484,7 @@ public class GenTableServiceImpl implements IGenTableService | ||
| 472 | String treeName = paramsObj.getString(GenConstants.TREE_NAME); | 484 | String treeName = paramsObj.getString(GenConstants.TREE_NAME); |
| 473 | String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID); | 485 | String parentMenuId = paramsObj.getString(GenConstants.PARENT_MENU_ID); |
| 474 | String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME); | 486 | String parentMenuName = paramsObj.getString(GenConstants.PARENT_MENU_NAME); |
| 475 | - | 487 | + |
| 476 | genTable.setTreeCode(treeCode); | 488 | genTable.setTreeCode(treeCode); |
| 477 | genTable.setTreeParentCode(treeParentCode); | 489 | genTable.setTreeParentCode(treeParentCode); |
| 478 | genTable.setTreeName(treeName); | 490 | genTable.setTreeName(treeName); |
-
请 注册 或 登录 后发表评论