From 62f7d349520545409eff471fad6da5b4914687a7 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 19 Mar 2022 16:11:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=E7=94=9F?= =?UTF-8?q?=E6=88=90=E5=AF=BC=E5=85=A5=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/infra/service/codegen/CodegenServiceImpl.java | 4 ++-- .../module/infra/service/codegen/inner/CodegenBuilder.java | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java index 31db3d572..cdf5d3dc7 100644 --- a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java @@ -82,7 +82,7 @@ public class CodegenServiceImpl implements CodegenService { table.setAuthor(userApi.getUser(userId).getNickname()); codegenTableMapper.insert(table); // 构建 CodegenColumnDO 数组,插入到 DB 中 - List columns = codegenBuilder.buildColumns(schemaColumns); + List columns = codegenBuilder.buildColumns(table.getId(), schemaColumns); codegenColumnMapper.insertBatch(columns); return table.getId(); } @@ -196,7 +196,7 @@ public class CodegenServiceImpl implements CodegenService { } // 插入新增的字段 - List columns = codegenBuilder.buildColumns(schemaColumns); + List columns = codegenBuilder.buildColumns(tableId, schemaColumns); codegenColumnMapper.insertBatch(columns); // 删除不存在的字段 if (CollUtil.isNotEmpty(deleteColumnIds)) { diff --git a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilder.java b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilder.java index 4c7ba479f..2a4281e50 100644 --- a/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilder.java +++ b/yudao-module-infra/yudao-module-infra-impl/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/inner/CodegenBuilder.java @@ -133,9 +133,12 @@ public class CodegenBuilder { table.setTemplateType(CodegenTemplateTypeEnum.CRUD.getType()); } - public List buildColumns(List schemaColumns) { + public List buildColumns(Long tableId, List schemaColumns) { List columns = CodegenConvert.INSTANCE.convertList(schemaColumns); - columns.forEach(this::initColumnDefault); + for (CodegenColumnDO column : columns) { + column.setTableId(tableId); + initColumnDefault(column); + } return columns; }