From a2f7067494c37712a4e05184d342db12763c146c Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 16 Nov 2023 00:11:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=A0=91=E5=BD=A2=E8=A1=A8=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/codegen/vo/CodegenUpdateReqVO.java | 7 +++++++ .../admin/codegen/vo/table/CodegenTableBaseVO.java | 5 +++++ .../module/infra/dal/dataobject/demo/package-info.java | 1 + .../yudao/module/infra/dal/mysql/demo/package-info.java | 1 + .../yudao/module/infra/service/demo/package-info.java | 1 + .../main/resources/codegen/java/controller/vo/respVO.vm | 2 +- .../main/resources/codegen/java/controller/vo/saveReqVO.vm | 2 +- .../src/main/resources/codegen/java/enums/errorcode.vm | 5 ++++- 8 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/package-info.java create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/package-info.java create mode 100644 yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/package-info.java diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenUpdateReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenUpdateReqVO.java index cdbc9347b..a43aa987a 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenUpdateReqVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/CodegenUpdateReqVO.java @@ -53,6 +53,13 @@ public class CodegenUpdateReqVO { || (ObjectUtil.isAllNotEmpty(getMasterTableId(), getSubJoinColumnId(), getSubJoinMany())); } + @AssertTrue(message = "关联的树表信息不全") + @JsonIgnore + public boolean isTreeValid() { + return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.TREE) + || (ObjectUtil.isAllNotEmpty(getTreeParentColumnId(), getTreeNameColumnId())); + } + } @Schema(description = "更新表定义") diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableBaseVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableBaseVO.java index 49cf51b70..dff1115f3 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableBaseVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/codegen/vo/table/CodegenTableBaseVO.java @@ -65,4 +65,9 @@ public class CodegenTableBaseVO { @Schema(description = "主表与子表是否一对多", example = "4096") private Boolean subJoinMany; + @Schema(description = "树表的父字段编号", example = "8192") + private Long treeParentColumnId; + @Schema(description = "树表的名字字段编号", example = "16384") + private Long treeNameColumnId; + } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/package-info.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/package-info.java new file mode 100644 index 000000000..16bcbbfe6 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.infra.dal.dataobject.demo; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/package-info.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/package-info.java new file mode 100644 index 000000000..7df22a3c1 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.infra.dal.mysql.demo; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/package-info.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/package-info.java new file mode 100644 index 000000000..b99cfaf83 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.infra.service.demo; \ No newline at end of file diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm index 4ee0081a1..54c16671d 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm @@ -13,7 +13,7 @@ import java.math.BigDecimal; #end ## 处理 LocalDateTime 字段的引入 #foreach ($column in $columns) -#if (${table.listOperationResult} && ${column.javaType} == "LocalDateTime") +#if (${column.listOperationResult} && ${column.javaType} == "LocalDateTime") import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; #break diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm index 233325aab..872f69142 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/saveReqVO.vm @@ -34,8 +34,8 @@ public class ${sceneEnum.prefixClass}${table.className}SaveReqVO { #if (${column.createOperation} || ${column.updateOperation}) ## 1. 处理 Swagger 注解 @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end) -#if (!${column.nullable}) ## 2. 处理 Validator 参数校验 +#if (!${column.nullable} && !${column.primaryKey}) #if (${column.javaType} == 'String') @NotEmpty(message = "${column.columnComment}不能为空") #else diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm index 4f10fa6e1..c4aa87ea7 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm @@ -1,4 +1,7 @@ // TODO 待办:请将下面的错误码复制到 yudao-module-${table.moduleName}-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!! // ========== ${table.classComment} TODO 补充编号 ========== ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在"); -ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子${table.classComment},无法删除"); \ No newline at end of file +## 特殊:树表专属逻辑 +#if ( $table.templateType == 2 ) +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子${table.classComment},无法删除"); +#end \ No newline at end of file