提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.infra.controller.admin.codegen.vo.table; |
H |
2 |
|
|
3 |
import cn.hutool.core.util.ObjectUtil; |
|
4 |
import com.iailab.module.infra.enums.codegen.CodegenSceneEnum; |
|
5 |
import com.iailab.module.infra.enums.codegen.CodegenTemplateTypeEnum; |
|
6 |
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
7 |
import io.swagger.v3.oas.annotations.media.Schema; |
|
8 |
import lombok.Data; |
|
9 |
|
|
10 |
import javax.validation.constraints.AssertTrue; |
|
11 |
import javax.validation.constraints.NotNull; |
|
12 |
|
|
13 |
@Schema(description = "管理后台 - 代码生成表定义创建/修改 Response VO") |
|
14 |
@Data |
|
15 |
public class CodegenTableSaveReqVO { |
|
16 |
|
|
17 |
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
|
18 |
private Long id; |
|
19 |
|
|
20 |
@Schema(description = "生成场景,参见 CodegenSceneEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
|
21 |
@NotNull(message = "导入类型不能为空") |
|
22 |
private Integer scene; |
|
23 |
|
|
24 |
@Schema(description = "表名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "iailab") |
|
25 |
@NotNull(message = "表名称不能为空") |
|
26 |
private String tableName; |
|
27 |
|
|
28 |
@Schema(description = "表描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "平台") |
|
29 |
@NotNull(message = "表描述不能为空") |
|
30 |
private String tableComment; |
|
31 |
|
|
32 |
@Schema(description = "备注", example = "我是备注") |
|
33 |
private String remark; |
|
34 |
|
|
35 |
@Schema(description = "模块名", requiredMode = Schema.RequiredMode.REQUIRED, example = "system") |
|
36 |
@NotNull(message = "模块名不能为空") |
|
37 |
private String moduleName; |
|
38 |
|
|
39 |
@Schema(description = "业务名", requiredMode = Schema.RequiredMode.REQUIRED, example = "codegen") |
|
40 |
@NotNull(message = "业务名不能为空") |
|
41 |
private String businessName; |
|
42 |
|
|
43 |
@Schema(description = "类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "CodegenTable") |
|
44 |
@NotNull(message = "类名称不能为空") |
|
45 |
private String className; |
|
46 |
|
|
47 |
@Schema(description = "类描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "代码生成器的表定义") |
|
48 |
@NotNull(message = "类描述不能为空") |
|
49 |
private String classComment; |
|
50 |
|
|
51 |
@Schema(description = "作者", requiredMode = Schema.RequiredMode.REQUIRED, example = "iailab") |
|
52 |
@NotNull(message = "作者不能为空") |
|
53 |
private String author; |
|
54 |
|
|
55 |
@Schema(description = "模板类型,参见 CodegenTemplateTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
|
56 |
@NotNull(message = "模板类型不能为空") |
|
57 |
private Integer templateType; |
|
58 |
|
|
59 |
@Schema(description = "前端类型,参见 CodegenFrontTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") |
|
60 |
@NotNull(message = "前端类型不能为空") |
|
61 |
private Integer frontType; |
|
62 |
|
|
63 |
@Schema(description = "父菜单编号", example = "1024") |
|
64 |
private Long parentMenuId; |
|
65 |
|
|
66 |
@Schema(description = "主表的编号", example = "2048") |
|
67 |
private Long masterTableId; |
|
68 |
@Schema(description = "子表关联主表的字段编号", example = "4096") |
|
69 |
private Long subJoinColumnId; |
|
70 |
@Schema(description = "主表与子表是否一对多", example = "4096") |
|
71 |
private Boolean subJoinMany; |
|
72 |
|
|
73 |
@Schema(description = "树表的父字段编号", example = "8192") |
|
74 |
private Long treeParentColumnId; |
|
75 |
@Schema(description = "树表的名字字段编号", example = "16384") |
|
76 |
private Long treeNameColumnId; |
|
77 |
|
|
78 |
@AssertTrue(message = "上级菜单不能为空,请前往 [修改生成配置 -> 生成信息] 界面,设置“上级菜单”字段") |
|
79 |
@JsonIgnore |
|
80 |
public boolean isParentMenuIdValid() { |
|
81 |
// 生成场景为管理后台时,必须设置上级菜单,不然生成的菜单 SQL 是无父级菜单的 |
|
82 |
return ObjectUtil.notEqual(getScene(), CodegenSceneEnum.ADMIN.getScene()) |
|
83 |
|| getParentMenuId() != null; |
|
84 |
} |
|
85 |
|
|
86 |
@AssertTrue(message = "关联的父表信息不全") |
|
87 |
@JsonIgnore |
|
88 |
public boolean isSubValid() { |
|
89 |
return ObjectUtil.notEqual(getTemplateType(), CodegenTemplateTypeEnum.SUB) |
|
90 |
|| (ObjectUtil.isAllNotEmpty(masterTableId, subJoinColumnId, subJoinMany)); |
|
91 |
} |
|
92 |
|
|
93 |
@AssertTrue(message = "关联的树表信息不全") |
|
94 |
@JsonIgnore |
|
95 |
public boolean isTreeValid() { |
|
96 |
return ObjectUtil.notEqual(templateType, CodegenTemplateTypeEnum.TREE) |
|
97 |
|| (ObjectUtil.isAllNotEmpty(treeParentColumnId, treeNameColumnId)); |
|
98 |
} |
|
99 |
|
|
100 |
} |