Commit a2f7067494c37712a4e05184d342db12763c146c

Authored by YunaiV
1 parent 0d49691a

代码生成:支持树形表结构的配置

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 {
53 53 || (ObjectUtil.isAllNotEmpty(getMasterTableId(), getSubJoinColumnId(), getSubJoinMany()));
54 54 }
55 55  
  56 + @AssertTrue(message = "关联的树表信息不全")
  57 + @JsonIgnore
  58 + public boolean isTreeValid() {
  59 + return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.TREE)
  60 + || (ObjectUtil.isAllNotEmpty(getTreeParentColumnId(), getTreeNameColumnId()));
  61 + }
  62 +
56 63 }
57 64  
58 65 @Schema(description = "更新表定义")
... ...
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 {
65 65 @Schema(description = "主表与子表是否一对多", example = "4096")
66 66 private Boolean subJoinMany;
67 67  
  68 + @Schema(description = "树表的父字段编号", example = "8192")
  69 + private Long treeParentColumnId;
  70 + @Schema(description = "树表的名字字段编号", example = "16384")
  71 + private Long treeNameColumnId;
  72 +
68 73 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/demo/package-info.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.dataobject.demo;
0 2 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/demo/package-info.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.dal.mysql.demo;
0 2 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/demo/package-info.java 0 → 100644
  1 +package cn.iocoder.yudao.module.infra.service.demo;
0 2 \ No newline at end of file
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/controller/vo/respVO.vm
... ... @@ -13,7 +13,7 @@ import java.math.BigDecimal;
13 13 #end
14 14 ## 处理 LocalDateTime 字段的引入
15 15 #foreach ($column in $columns)
16   -#if (${table.listOperationResult} && ${column.javaType} == "LocalDateTime")
  16 +#if (${column.listOperationResult} && ${column.javaType} == "LocalDateTime")
17 17 import org.springframework.format.annotation.DateTimeFormat;
18 18 import java.time.LocalDateTime;
19 19 #break
... ...
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 {
34 34 #if (${column.createOperation} || ${column.updateOperation})
35 35 ## 1. 处理 Swagger 注解
36 36 @Schema(description = "${column.columnComment}"#if (!${column.nullable}), requiredMode = Schema.RequiredMode.REQUIRED#end#if ("$!column.example" != ""), example = "${column.example}"#end)
37   -#if (!${column.nullable})
38 37 ## 2. 处理 Validator 参数校验
  38 +#if (!${column.nullable} && !${column.primaryKey})
39 39 #if (${column.javaType} == 'String')
40 40 @NotEmpty(message = "${column.columnComment}不能为空")
41 41 #else
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/enums/errorcode.vm
1 1 // TODO 待办:请将下面的错误码复制到 yudao-module-${table.moduleName}-api 模块的 ErrorCodeConstants 类中。注意,请给“TODO 补充编号”设置一个错误码编号!!!
2 2 // ========== ${table.classComment} TODO 补充编号 ==========
3 3 ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_NOT_EXISTS = new ErrorCode(TODO 补充编号, "${table.classComment}不存在");
4   -ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子${table.classComment},无法删除");
5 4 \ No newline at end of file
  5 +## 特殊:树表专属逻辑
  6 +#if ( $table.templateType == 2 )
  7 +ErrorCode ${simpleClassName_underlineCase.toUpperCase()}_EXITS_CHILDREN = new ErrorCode(TODO 补充编号, "存在存在子${table.classComment},无法删除");
  8 +#end
6 9 \ No newline at end of file
... ...