Skip to content

Commit

Permalink
!249 修复代码生成-同步功能删除存在的字段问题。
Browse files Browse the repository at this point in the history
Merge pull request !249 from xrcoder/master
  • Loading branch information
YunaiV authored and gitee-org committed Aug 19, 2022
2 parents 1097c63 + 5b2e6eb commit 96b3cb2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ private void syncCodegen0(Long tableId, TableInfo tableInfo) {
// 构建 CodegenColumnDO 数组,只同步新增的字段
List<CodegenColumnDO> codegenColumns = codegenColumnMapper.selectListByTableId(tableId);
Set<String> codegenColumnNames = CollectionUtils.convertSet(codegenColumns, CodegenColumnDO::getColumnName);
// 移除已经存在的字段
tableFields.removeIf(column -> codegenColumnNames.contains(column.getColumnName()));
// 计算需要删除的字段
Set<String> tableFieldNames = CollectionUtils.convertSet(tableFields, TableField::getName);
Set<Long> deleteColumnIds = codegenColumns.stream().filter(column -> !tableFieldNames.contains(column.getColumnName()))
.map(CodegenColumnDO::getId).collect(Collectors.toSet());
// 移除已经存在的字段
tableFields.removeIf(column -> codegenColumnNames.contains(column.getColumnName()));
if (CollUtil.isEmpty(tableFields) && CollUtil.isEmpty(deleteColumnIds)) {
throw exception(CODEGEN_SYNC_NONE_CHANGE);
}
Expand Down

0 comments on commit 96b3cb2

Please sign in to comment.