ai-engineering-init 1.3.4 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/skill-forced-eval.js +2 -0
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +79 -32
- package/.claude/skills/api-development/SKILL.md +83 -377
- package/.claude/skills/architecture-design/SKILL.md +138 -632
- package/.claude/skills/backend-annotations/SKILL.md +134 -506
- package/.claude/skills/banana-image/SKILL.md +10 -3
- package/.claude/skills/brainstorm/SKILL.md +103 -535
- package/.claude/skills/bug-detective/SKILL.md +147 -1097
- package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
- package/.claude/skills/code-patterns/SKILL.md +116 -426
- package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.claude/skills/crud-development/SKILL.md +64 -304
- package/.claude/skills/data-permission/SKILL.md +105 -412
- package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.claude/skills/file-oss-management/SKILL.md +106 -714
- package/.claude/skills/file-oss-management/references/entities.md +105 -0
- package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
- package/.claude/skills/leniu-api-development/SKILL.md +142 -626
- package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
- package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
- package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
- package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
- package/.claude/skills/leniu-java-export/SKILL.md +94 -379
- package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
- package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
- package/.claude/skills/mysql-debug/SKILL.md +364 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
- package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
- package/.claude/skills/openspec-explore/SKILL.md +10 -1
- package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
- package/.claude/skills/openspec-new-change/SKILL.md +9 -1
- package/.claude/skills/openspec-onboard/SKILL.md +15 -130
- package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
- package/.claude/skills/performance-doctor/SKILL.md +110 -434
- package/.claude/skills/redis-cache/SKILL.md +89 -595
- package/.claude/skills/redis-cache/references/listeners.md +23 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
- package/.claude/skills/security-guard/SKILL.md +137 -532
- package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
- package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.claude/skills/sms-mail/SKILL.md +116 -574
- package/.claude/skills/sms-mail/references/mail-config.md +88 -0
- package/.claude/skills/sms-mail/references/sms-config.md +74 -0
- package/.claude/skills/social-login/SKILL.md +112 -514
- package/.claude/skills/social-login/references/provider-configs.md +118 -0
- package/.claude/skills/tenant-management/SKILL.md +129 -444
- package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.claude/skills/test-development/SKILL.md +86 -540
- package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
- package/.claude/skills/utils-toolkit/SKILL.md +52 -305
- package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.claude/skills/websocket-sse/SKILL.md +105 -550
- package/.claude/skills/workflow-engine/SKILL.md +147 -502
- package/.codex/skills/add-skill/SKILL.md +79 -32
- package/.codex/skills/api-development/SKILL.md +172 -599
- package/.codex/skills/architecture-design/SKILL.md +138 -504
- package/.codex/skills/backend-annotations/SKILL.md +134 -496
- package/.codex/skills/banana-image/SKILL.md +10 -3
- package/.codex/skills/brainstorm/SKILL.md +103 -535
- package/.codex/skills/bug-detective/SKILL.md +147 -1097
- package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
- package/.codex/skills/code-patterns/SKILL.md +120 -282
- package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.codex/skills/crud-development/SKILL.md +64 -292
- package/.codex/skills/data-permission/SKILL.md +108 -407
- package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.codex/skills/database-ops/SKILL.md +8 -154
- package/.codex/skills/error-handler/SKILL.md +10 -0
- package/.codex/skills/file-oss-management/SKILL.md +106 -714
- package/.codex/skills/file-oss-management/references/entities.md +105 -0
- package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
- package/.codex/skills/git-workflow/SKILL.md +27 -5
- package/.codex/skills/leniu-api-development/SKILL.md +142 -626
- package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
- package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
- package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
- package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
- package/.codex/skills/leniu-java-export/SKILL.md +94 -379
- package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
- package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
- package/.codex/skills/mysql-debug/SKILL.md +364 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
- package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
- package/.codex/skills/openspec-explore/SKILL.md +10 -1
- package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
- package/.codex/skills/openspec-new-change/SKILL.md +9 -1
- package/.codex/skills/openspec-onboard/SKILL.md +15 -130
- package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
- package/.codex/skills/performance-doctor/SKILL.md +110 -434
- package/.codex/skills/project-navigator/SKILL.md +20 -1
- package/.codex/skills/redis-cache/SKILL.md +93 -589
- package/.codex/skills/redis-cache/references/listeners.md +23 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
- package/.codex/skills/security-guard/SKILL.md +141 -527
- package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
- package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.codex/skills/sms-mail/SKILL.md +116 -574
- package/.codex/skills/sms-mail/references/mail-config.md +88 -0
- package/.codex/skills/sms-mail/references/sms-config.md +74 -0
- package/.codex/skills/social-login/SKILL.md +112 -514
- package/.codex/skills/social-login/references/provider-configs.md +118 -0
- package/.codex/skills/store-pc/SKILL.md +258 -383
- package/.codex/skills/tenant-management/SKILL.md +129 -444
- package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.codex/skills/test-development/SKILL.md +86 -540
- package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
- package/.codex/skills/ui-pc/SKILL.md +350 -387
- package/.codex/skills/utils-toolkit/SKILL.md +52 -283
- package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.codex/skills/websocket-sse/SKILL.md +105 -550
- package/.codex/skills/workflow-engine/SKILL.md +147 -502
- package/.cursor/hooks/cursor-skill-eval.js +53 -1
- package/.cursor/hooks.json +3 -3
- package/.cursor/skills/add-skill/SKILL.md +79 -32
- package/.cursor/skills/api-development/SKILL.md +83 -377
- package/.cursor/skills/architecture-design/SKILL.md +138 -632
- package/.cursor/skills/backend-annotations/SKILL.md +134 -506
- package/.cursor/skills/banana-image/SKILL.md +10 -3
- package/.cursor/skills/brainstorm/SKILL.md +103 -535
- package/.cursor/skills/bug-detective/SKILL.md +147 -1097
- package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
- package/.cursor/skills/code-patterns/SKILL.md +116 -426
- package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.cursor/skills/crud-development/SKILL.md +64 -304
- package/.cursor/skills/data-permission/SKILL.md +105 -412
- package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.cursor/skills/file-oss-management/SKILL.md +106 -714
- package/.cursor/skills/file-oss-management/references/entities.md +105 -0
- package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
- package/.cursor/skills/git-workflow/SKILL.md +27 -5
- package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
- package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
- package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
- package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
- package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
- package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
- package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
- package/.cursor/skills/mysql-debug/SKILL.md +364 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
- package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-explore/SKILL.md +10 -1
- package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
- package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
- package/.cursor/skills/performance-doctor/SKILL.md +110 -434
- package/.cursor/skills/redis-cache/SKILL.md +89 -595
- package/.cursor/skills/redis-cache/references/listeners.md +23 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
- package/.cursor/skills/security-guard/SKILL.md +137 -532
- package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
- package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.cursor/skills/sms-mail/SKILL.md +116 -574
- package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
- package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
- package/.cursor/skills/social-login/SKILL.md +112 -514
- package/.cursor/skills/social-login/references/provider-configs.md +118 -0
- package/.cursor/skills/tenant-management/SKILL.md +129 -444
- package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.cursor/skills/test-development/SKILL.md +86 -540
- package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
- package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.cursor/skills/websocket-sse/SKILL.md +105 -550
- package/.cursor/skills/workflow-engine/SKILL.md +147 -502
- package/package.json +1 -1
|
@@ -1,282 +1,83 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: leniu-java-entity
|
|
3
3
|
description: |
|
|
4
|
-
leniu-tengyun-core 项目 Entity
|
|
4
|
+
leniu-tengyun-core 项目 Entity/VO/DTO/Param/Enum 数据类规范。
|
|
5
5
|
|
|
6
6
|
触发场景:
|
|
7
|
-
- 创建 Entity 实体类(@TableName
|
|
8
|
-
- 创建 VO
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- 创建 Entity 实体类(@TableName、审计字段 crby/crtime/upby/uptime)
|
|
8
|
+
- 创建 VO/DTO/Param 数据传输对象
|
|
9
|
+
- 使用 Jakarta Validation 参数校验
|
|
10
|
+
- 创建枚举类(含国际化 I18n)
|
|
11
|
+
- Excel 导出 VO(EasyExcel)
|
|
12
12
|
|
|
13
|
-
触发词:Entity实体类、VO视图对象、DTO数据传输、Param参数类、@TableName、@TableField
|
|
13
|
+
触发词:Entity实体类、VO视图对象、DTO数据传输、Param参数类、@TableName、@TableField、审计字段、枚举类、Excel导出、Jakarta校验
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
# leniu
|
|
16
|
+
# leniu Entity/VO/DTO 规范
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## 项目特征速查
|
|
19
19
|
|
|
20
|
-
|
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
| **逻辑删除** | 1=删除,2=正常 |
|
|
20
|
+
| 项 | 值 |
|
|
21
|
+
|---|---|
|
|
22
|
+
| 包名 | `net.xnzn.core.*` |
|
|
23
|
+
| JDK | 21 → `jakarta.validation.*`(禁用 javax) |
|
|
24
|
+
| 工具库 | Hutool(BeanUtil / CollUtil / ObjectUtil / StrUtil) |
|
|
25
|
+
| 金额 | `Long`(分)或 `BigDecimal`(分),前端用 `money()` 转元 |
|
|
26
|
+
| 审计字段 | crby / crtime / upby / uptime |
|
|
27
|
+
| 逻辑删除 | **1=删除,2=正常**(与 RuoYi 相反) |
|
|
28
|
+
| Entity 特点 | 无基类、无 Serializable |
|
|
30
29
|
|
|
31
|
-
##
|
|
32
|
-
|
|
33
|
-
`OrderInfo` 是订单模块的核心 Model,体现了 leniu 项目的真实代码风格:
|
|
30
|
+
## Entity 模板(核心)
|
|
34
31
|
|
|
35
32
|
```java
|
|
36
|
-
import com.baomidou.mybatisplus.annotation.*;
|
|
37
|
-
import io.swagger.annotations.ApiModel;
|
|
38
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
39
|
-
import lombok.Data;
|
|
40
|
-
import lombok.experimental.Accessors;
|
|
41
|
-
|
|
42
|
-
import java.math.BigDecimal;
|
|
43
|
-
import java.time.LocalDateTime;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 关键特征:
|
|
47
|
-
* 1. 无基类(不继承任何 Entity 基类)
|
|
48
|
-
* 2. 无 Serializable
|
|
49
|
-
* 3. @TableName 不带 autoResultMap(报表 Mapper 无 BaseMapper)
|
|
50
|
-
* 4. BigDecimal 存储分为单位的金额
|
|
51
|
-
* 5. 包含静态工厂方法 newDefaultInstance()
|
|
52
|
-
* 6. 包含领域业务方法(计算/重置等)
|
|
53
|
-
*/
|
|
54
33
|
@Data
|
|
55
34
|
@Accessors(chain = true)
|
|
56
|
-
@ApiModel(value = "订单信息")
|
|
57
|
-
@TableName("order_info")
|
|
58
|
-
public class OrderInfo {
|
|
59
|
-
|
|
60
|
-
@TableId
|
|
61
|
-
@ApiModelProperty(value = "订单ID")
|
|
62
|
-
private Long id;
|
|
63
|
-
|
|
64
|
-
@ApiModelProperty(value = "食堂ID")
|
|
65
|
-
private Long canteenId;
|
|
66
|
-
|
|
67
|
-
@ApiModelProperty(value = "用户ID")
|
|
68
|
-
private Long userId;
|
|
69
|
-
|
|
70
|
-
@ApiModelProperty(value = "应付金额(分)")
|
|
71
|
-
private BigDecimal payableAmount;
|
|
72
|
-
|
|
73
|
-
@ApiModelProperty(value = "实付金额(分)")
|
|
74
|
-
private BigDecimal realAmount;
|
|
75
|
-
|
|
76
|
-
@ApiModelProperty(value = "优惠金额(分)")
|
|
77
|
-
private BigDecimal discountsAmount;
|
|
78
|
-
|
|
79
|
-
@ApiModelProperty(value = "订单状态")
|
|
80
|
-
private Integer status;
|
|
81
|
-
|
|
82
|
-
@ApiModelProperty(value = "删除标识(1-删除,2-正常)")
|
|
83
|
-
private Integer delFlag;
|
|
84
|
-
|
|
85
|
-
// 审计字段(INSERT 自动填充)
|
|
86
|
-
@TableField(fill = FieldFill.INSERT)
|
|
87
|
-
@ApiModelProperty(value = "创建人")
|
|
88
|
-
private String crby;
|
|
89
|
-
|
|
90
|
-
@TableField(fill = FieldFill.INSERT)
|
|
91
|
-
@ApiModelProperty(value = "创建时间")
|
|
92
|
-
private LocalDateTime crtime;
|
|
93
|
-
|
|
94
|
-
// 审计字段(INSERT + UPDATE 自动填充)
|
|
95
|
-
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
96
|
-
@ApiModelProperty(value = "更新人")
|
|
97
|
-
private String upby;
|
|
98
|
-
|
|
99
|
-
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
100
|
-
@ApiModelProperty(value = "更新时间")
|
|
101
|
-
private LocalDateTime uptime;
|
|
102
|
-
|
|
103
|
-
// ===== 静态工厂方法 =====
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 创建默认实例(预设默认值)
|
|
107
|
-
*/
|
|
108
|
-
public static OrderInfo newDefaultInstance() {
|
|
109
|
-
OrderInfo orderInfo = new OrderInfo();
|
|
110
|
-
orderInfo.setDelFlag(2); // 2=正常
|
|
111
|
-
orderInfo.setPayableAmount(BigDecimal.ZERO);
|
|
112
|
-
orderInfo.setRealAmount(BigDecimal.ZERO);
|
|
113
|
-
orderInfo.setDiscountsAmount(BigDecimal.ZERO);
|
|
114
|
-
return orderInfo;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ===== 领域业务方法 =====
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 计算需付金额 = 应付 - 优惠
|
|
121
|
-
*/
|
|
122
|
-
public BigDecimal calcNeedPayAmount() {
|
|
123
|
-
return payableAmount.subtract(discountsAmount);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* 重置所有金额为零
|
|
128
|
-
*/
|
|
129
|
-
public void resetAmountsZero() {
|
|
130
|
-
this.payableAmount = BigDecimal.ZERO;
|
|
131
|
-
this.realAmount = BigDecimal.ZERO;
|
|
132
|
-
this.discountsAmount = BigDecimal.ZERO;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
**设计要点**:
|
|
138
|
-
- 无基类,所有字段直接定义在类中
|
|
139
|
-
- 无 `implements Serializable`
|
|
140
|
-
- `@TableName("order_info")` 不带 `autoResultMap = true`(报表 Mapper 是 XML,无需 TypeHandler)
|
|
141
|
-
- 静态工厂方法 `newDefaultInstance()` 预设业务默认值
|
|
142
|
-
- 领域业务方法直接放在 Model 类中(非 Service),体现贫血/充血混合模式
|
|
143
|
-
|
|
144
|
-
## Entity 实体类模板
|
|
145
|
-
|
|
146
|
-
### 基础 Entity
|
|
147
|
-
|
|
148
|
-
```java
|
|
149
|
-
import com.baomidou.mybatisplus.annotation.*;
|
|
150
|
-
import io.swagger.annotations.ApiModel;
|
|
151
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
152
|
-
import lombok.Data;
|
|
153
|
-
|
|
154
|
-
import java.time.LocalDateTime;
|
|
155
|
-
|
|
156
|
-
@Data
|
|
157
35
|
@TableName(value = "table_name", autoResultMap = true)
|
|
158
36
|
public class XxxEntity {
|
|
159
37
|
|
|
160
38
|
@TableId
|
|
161
|
-
@ApiModelProperty(
|
|
39
|
+
@ApiModelProperty("主键ID")
|
|
162
40
|
private Long id;
|
|
163
41
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
@ApiModelProperty(value = "创建人")
|
|
168
|
-
private String crby;
|
|
169
|
-
|
|
170
|
-
@ApiModelProperty(value = "创建时间")
|
|
171
|
-
private LocalDateTime crtime;
|
|
172
|
-
|
|
173
|
-
@ApiModelProperty(value = "更新人")
|
|
174
|
-
private String upby;
|
|
42
|
+
// --- 业务字段 ---
|
|
43
|
+
@ApiModelProperty("名称")
|
|
44
|
+
private String name;
|
|
175
45
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### 自动填充字段 Entity
|
|
182
|
-
|
|
183
|
-
```java
|
|
184
|
-
import com.baomidou.mybatisplus.annotation.*;
|
|
185
|
-
import io.swagger.annotations.ApiModel;
|
|
186
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
187
|
-
import lombok.Data;
|
|
188
|
-
|
|
189
|
-
import java.time.LocalDateTime;
|
|
190
|
-
|
|
191
|
-
@Data
|
|
192
|
-
@TableName(value = "table_name", autoResultMap = true)
|
|
193
|
-
public class XxxEntity {
|
|
194
|
-
|
|
195
|
-
@TableId
|
|
196
|
-
private Long id;
|
|
46
|
+
// --- 审计字段 ---
|
|
47
|
+
@ApiModelProperty("删除标识(1-删除,2-正常)")
|
|
48
|
+
private Integer delFlag;
|
|
197
49
|
|
|
198
|
-
// 插入时自动填充
|
|
199
50
|
@TableField(fill = FieldFill.INSERT)
|
|
200
|
-
@ApiModelProperty(value = "创建人")
|
|
201
51
|
private String crby;
|
|
202
52
|
|
|
203
53
|
@TableField(fill = FieldFill.INSERT)
|
|
204
|
-
@ApiModelProperty(value = "创建时间")
|
|
205
54
|
private LocalDateTime crtime;
|
|
206
55
|
|
|
207
|
-
// 插入或更新时自动填充
|
|
208
56
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
209
|
-
@ApiModelProperty(value = "更新人")
|
|
210
57
|
private String upby;
|
|
211
58
|
|
|
212
59
|
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
213
|
-
@ApiModelProperty(value = "更新时间")
|
|
214
60
|
private LocalDateTime uptime;
|
|
215
61
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
```java
|
|
224
|
-
import com.baomidou.mybatisplus.annotation.*;
|
|
225
|
-
import io.swagger.annotations.ApiModel;
|
|
226
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
227
|
-
import lombok.Data;
|
|
228
|
-
|
|
229
|
-
import java.math.BigDecimal;
|
|
230
|
-
import java.time.LocalDateTime;
|
|
231
|
-
|
|
232
|
-
@Data
|
|
233
|
-
@TableName(value = "order_table", autoResultMap = true)
|
|
234
|
-
public class OrderEntity {
|
|
235
|
-
|
|
236
|
-
@TableId
|
|
237
|
-
@ApiModelProperty(value = "订单ID")
|
|
238
|
-
private Long orderId;
|
|
239
|
-
|
|
240
|
-
@ApiModelProperty(value = "用户ID")
|
|
241
|
-
private Long userId;
|
|
242
|
-
|
|
243
|
-
@ApiModelProperty(value = "订单金额(分)")
|
|
244
|
-
private Long orderAmount;
|
|
245
|
-
|
|
246
|
-
@ApiModelProperty(value = "订单状态")
|
|
247
|
-
private Integer status;
|
|
248
|
-
|
|
249
|
-
@ApiModelProperty(value = "删除标识(1-删除,2-正常)")
|
|
250
|
-
private Integer delFlag;
|
|
251
|
-
|
|
252
|
-
@TableField(fill = FieldFill.INSERT)
|
|
253
|
-
@ApiModelProperty(value = "创建人")
|
|
254
|
-
private String crby;
|
|
255
|
-
|
|
256
|
-
@TableField(fill = FieldFill.INSERT)
|
|
257
|
-
@ApiModelProperty(value = "创建时间")
|
|
258
|
-
private LocalDateTime crtime;
|
|
259
|
-
|
|
260
|
-
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
261
|
-
@ApiModelProperty(value = "更新人")
|
|
262
|
-
private String upby;
|
|
62
|
+
// --- 静态工厂(预设默认值) ---
|
|
63
|
+
public static XxxEntity newDefaultInstance() {
|
|
64
|
+
XxxEntity e = new XxxEntity();
|
|
65
|
+
e.setDelFlag(2); // 2=正常
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
263
68
|
|
|
264
|
-
|
|
265
|
-
@ApiModelProperty(value = "更新时间")
|
|
266
|
-
private LocalDateTime uptime;
|
|
69
|
+
// --- 领域业务方法(可选) ---
|
|
267
70
|
}
|
|
268
71
|
```
|
|
269
72
|
|
|
270
|
-
|
|
73
|
+
**要点**:
|
|
74
|
+
- 无基类,审计字段直接定义
|
|
75
|
+
- `@TableName` 一般带 `autoResultMap = true`;报表 Model 不带(无 BaseMapper)
|
|
76
|
+
- 可含 `newDefaultInstance()` 工厂方法和领域业务方法
|
|
271
77
|
|
|
272
|
-
|
|
78
|
+
## VO 模板
|
|
273
79
|
|
|
274
80
|
```java
|
|
275
|
-
import io.swagger.annotations.ApiModel;
|
|
276
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
277
|
-
import lombok.Data;
|
|
278
|
-
import lombok.experimental.Accessors;
|
|
279
|
-
|
|
280
81
|
@Data
|
|
281
82
|
@Accessors(chain = true)
|
|
282
83
|
@ApiModel("订单信息")
|
|
@@ -285,167 +86,42 @@ public class OrderVO {
|
|
|
285
86
|
@ApiModelProperty("订单ID")
|
|
286
87
|
private Long orderId;
|
|
287
88
|
|
|
288
|
-
@ApiModelProperty("用户ID")
|
|
289
|
-
private Long userId;
|
|
290
|
-
|
|
291
89
|
@ApiModelProperty("订单金额(元)")
|
|
292
90
|
private BigDecimal orderAmount;
|
|
293
91
|
|
|
294
|
-
@ApiModelProperty("订单状态")
|
|
295
|
-
private Integer status;
|
|
296
|
-
|
|
297
92
|
@ApiModelProperty("创建时间")
|
|
298
93
|
private LocalDateTime crtime;
|
|
299
94
|
}
|
|
300
95
|
```
|
|
301
96
|
|
|
302
|
-
|
|
97
|
+
带校验的 VO:
|
|
303
98
|
|
|
304
99
|
```java
|
|
305
|
-
import io.swagger.annotations.ApiModel;
|
|
306
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
307
|
-
import jakarta.validation.constraints.*;
|
|
308
|
-
import lombok.Data;
|
|
309
|
-
import lombok.experimental.Accessors;
|
|
310
|
-
|
|
311
|
-
import java.time.LocalDateTime;
|
|
312
|
-
|
|
313
100
|
@Data
|
|
314
101
|
@Accessors(chain = true)
|
|
315
102
|
@ApiModel("订单信息")
|
|
316
103
|
public class OrderVO {
|
|
317
104
|
|
|
318
|
-
@ApiModelProperty("订单ID")
|
|
319
|
-
private Long orderId;
|
|
320
|
-
|
|
321
|
-
@ApiModelProperty("用户ID")
|
|
322
105
|
@NotNull(message = "用户ID不能为空")
|
|
106
|
+
@ApiModelProperty("用户ID")
|
|
323
107
|
private Long userId;
|
|
324
108
|
|
|
325
|
-
@ApiModelProperty("订单金额(元)")
|
|
326
109
|
@NotNull(message = "订单金额不能为空")
|
|
327
110
|
@DecimalMin(value = "0.01", message = "订单金额必须大于0")
|
|
328
|
-
private BigDecimal orderAmount;
|
|
329
|
-
|
|
330
|
-
@ApiModelProperty("订单状态")
|
|
331
|
-
private Integer status;
|
|
332
|
-
|
|
333
|
-
@ApiModelProperty("创建时间")
|
|
334
|
-
private LocalDateTime crtime;
|
|
335
|
-
}
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
### Excel 导出 VO
|
|
339
|
-
|
|
340
|
-
```java
|
|
341
|
-
import com.alibaba.excel.annotation.ExcelProperty;
|
|
342
|
-
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
|
343
|
-
import io.swagger.annotations.ApiModel;
|
|
344
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
345
|
-
import lombok.Data;
|
|
346
|
-
import lombok.experimental.Accessors;
|
|
347
|
-
import net.xnzn.core.common.export.converter.CustomNumberConverter;
|
|
348
|
-
|
|
349
|
-
import java.math.BigDecimal;
|
|
350
|
-
import java.time.LocalDateTime;
|
|
351
|
-
|
|
352
|
-
@Data
|
|
353
|
-
@Accessors(chain = true)
|
|
354
|
-
@ApiModel("订单信息")
|
|
355
|
-
public class OrderExportVO {
|
|
356
|
-
|
|
357
|
-
@ExcelProperty(value = "订单ID", order = 1)
|
|
358
|
-
@ColumnWidth(15)
|
|
359
|
-
@ApiModelProperty("订单ID")
|
|
360
|
-
private Long orderId;
|
|
361
|
-
|
|
362
|
-
@ExcelProperty(value = "用户ID", order = 2)
|
|
363
|
-
@ColumnWidth(15)
|
|
364
|
-
@ApiModelProperty("用户ID")
|
|
365
|
-
private Long userId;
|
|
366
|
-
|
|
367
|
-
@ExcelProperty(value = "订单金额(元)", order = 3, converter = CustomNumberConverter.class)
|
|
368
|
-
@ColumnWidth(15)
|
|
369
111
|
@ApiModelProperty("订单金额(元)")
|
|
370
112
|
private BigDecimal orderAmount;
|
|
371
|
-
|
|
372
|
-
@ExcelProperty(value = "创建时间", order = 4)
|
|
373
|
-
@ColumnWidth(20)
|
|
374
|
-
@ApiModelProperty("创建时间")
|
|
375
|
-
private LocalDateTime crtime;
|
|
376
|
-
}
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
## DTO 类模板
|
|
380
|
-
|
|
381
|
-
### 基础 DTO
|
|
382
|
-
|
|
383
|
-
```java
|
|
384
|
-
import io.swagger.annotations.ApiModel;
|
|
385
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
386
|
-
import lombok.Data;
|
|
387
|
-
|
|
388
|
-
@Data
|
|
389
|
-
@ApiModel("订单数据传输对象")
|
|
390
|
-
public class OrderDTO {
|
|
391
|
-
|
|
392
|
-
@ApiModelProperty("订单ID")
|
|
393
|
-
private Long orderId;
|
|
394
|
-
|
|
395
|
-
@ApiModelProperty("用户ID")
|
|
396
|
-
private Long userId;
|
|
397
|
-
|
|
398
|
-
@ApiModelProperty("订单状态")
|
|
399
|
-
private Integer status;
|
|
400
|
-
}
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
## Param 类模板
|
|
404
|
-
|
|
405
|
-
### 基础 Param
|
|
406
|
-
|
|
407
|
-
```java
|
|
408
|
-
import io.swagger.annotations.ApiModel;
|
|
409
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
410
|
-
import lombok.Data;
|
|
411
|
-
import net.xnzn.core.common.page.PageDTO;
|
|
412
|
-
|
|
413
|
-
import java.io.Serializable;
|
|
414
|
-
|
|
415
|
-
@Data
|
|
416
|
-
@ApiModel("查询参数")
|
|
417
|
-
public class OrderQueryParam implements Serializable {
|
|
418
|
-
|
|
419
|
-
@ApiModelProperty(value = "分页参数", required = true)
|
|
420
|
-
@NotNull(message = "分页参数不能为空")
|
|
421
|
-
private PageDTO page;
|
|
422
|
-
|
|
423
|
-
@ApiModelProperty("关键字")
|
|
424
|
-
private String keyword;
|
|
425
|
-
|
|
426
|
-
@ApiModelProperty("状态")
|
|
427
|
-
private Integer status;
|
|
428
113
|
}
|
|
429
114
|
```
|
|
430
115
|
|
|
431
|
-
|
|
116
|
+
## Param 模板(分页查询)
|
|
432
117
|
|
|
433
118
|
```java
|
|
434
|
-
import io.swagger.annotations.ApiModel;
|
|
435
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
436
|
-
import jakarta.validation.constraints.NotNull;
|
|
437
|
-
import lombok.Data;
|
|
438
|
-
import net.xnzn.core.common.page.PageDTO;
|
|
439
|
-
|
|
440
|
-
import java.io.Serializable;
|
|
441
|
-
import java.time.LocalDate;
|
|
442
|
-
|
|
443
119
|
@Data
|
|
444
120
|
@ApiModel("订单查询参数")
|
|
445
121
|
public class OrderQueryParam implements Serializable {
|
|
446
122
|
|
|
447
|
-
@ApiModelProperty(value = "分页参数", required = true)
|
|
448
123
|
@NotNull(message = "分页参数不能为空")
|
|
124
|
+
@ApiModelProperty(value = "分页参数", required = true)
|
|
449
125
|
private PageDTO page;
|
|
450
126
|
|
|
451
127
|
@ApiModelProperty("关键字")
|
|
@@ -462,54 +138,27 @@ public class OrderQueryParam implements Serializable {
|
|
|
462
138
|
}
|
|
463
139
|
```
|
|
464
140
|
|
|
465
|
-
|
|
141
|
+
## DTO 模板
|
|
466
142
|
|
|
467
143
|
```java
|
|
468
|
-
import com.alibaba.excel.annotation.ExcelIgnore;
|
|
469
|
-
import io.swagger.annotations.ApiModel;
|
|
470
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
471
|
-
import lombok.Data;
|
|
472
|
-
import lombok.EqualsAndHashCode;
|
|
473
|
-
|
|
474
|
-
import java.io.Serializable;
|
|
475
|
-
import java.time.LocalDate;
|
|
476
|
-
import java.util.List;
|
|
477
|
-
|
|
478
144
|
@Data
|
|
479
|
-
@
|
|
480
|
-
|
|
481
|
-
public class OrderReportParam implements Serializable {
|
|
482
|
-
|
|
483
|
-
@ExcelIgnore
|
|
484
|
-
@ApiModelProperty(value = "分页参数", required = true)
|
|
485
|
-
private PageDTO page;
|
|
486
|
-
|
|
487
|
-
@ExcelIgnore
|
|
488
|
-
@ApiModelProperty("关键字")
|
|
489
|
-
private String keyword;
|
|
490
|
-
|
|
491
|
-
@ApiModelProperty("开始日期")
|
|
492
|
-
private LocalDate startDate;
|
|
145
|
+
@ApiModel("订单数据传输对象")
|
|
146
|
+
public class OrderDTO {
|
|
493
147
|
|
|
494
|
-
@ApiModelProperty("
|
|
495
|
-
private
|
|
148
|
+
@ApiModelProperty("订单ID")
|
|
149
|
+
private Long orderId;
|
|
496
150
|
|
|
497
|
-
@ApiModelProperty("
|
|
498
|
-
private
|
|
151
|
+
@ApiModelProperty("用户ID")
|
|
152
|
+
private Long userId;
|
|
499
153
|
|
|
500
|
-
@ApiModelProperty("
|
|
154
|
+
@ApiModelProperty("订单状态")
|
|
501
155
|
private Integer status;
|
|
502
156
|
}
|
|
503
157
|
```
|
|
504
158
|
|
|
505
|
-
##
|
|
506
|
-
|
|
507
|
-
### 基础枚举
|
|
159
|
+
## 枚举模板
|
|
508
160
|
|
|
509
161
|
```java
|
|
510
|
-
import lombok.AllArgsConstructor;
|
|
511
|
-
import lombok.Getter;
|
|
512
|
-
|
|
513
162
|
@Getter
|
|
514
163
|
@AllArgsConstructor
|
|
515
164
|
public enum OrderStatusEnum {
|
|
@@ -523,142 +172,23 @@ public enum OrderStatusEnum {
|
|
|
523
172
|
private final String desc;
|
|
524
173
|
|
|
525
174
|
public static OrderStatusEnum getByKey(Integer key) {
|
|
526
|
-
if (key == null)
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
for (OrderStatusEnum status : values()) {
|
|
530
|
-
if (status.getKey().equals(key)) {
|
|
531
|
-
return status;
|
|
532
|
-
}
|
|
175
|
+
if (key == null) return null;
|
|
176
|
+
for (OrderStatusEnum e : values()) {
|
|
177
|
+
if (e.getKey().equals(key)) return e;
|
|
533
178
|
}
|
|
534
179
|
return null;
|
|
535
180
|
}
|
|
536
181
|
|
|
537
182
|
public static String getDescByKey(Integer key) {
|
|
538
|
-
OrderStatusEnum
|
|
539
|
-
return
|
|
183
|
+
OrderStatusEnum e = getByKey(key);
|
|
184
|
+
return e != null ? e.getDesc() : "";
|
|
540
185
|
}
|
|
541
186
|
}
|
|
542
187
|
```
|
|
543
188
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
```java
|
|
547
|
-
import lombok.AllArgsConstructor;
|
|
548
|
-
import lombok.Getter;
|
|
549
|
-
import net.xnzn.core.common.i18n.I18n;
|
|
550
|
-
|
|
551
|
-
@Getter
|
|
552
|
-
@AllArgsConstructor
|
|
553
|
-
public enum OrderStatusEnum {
|
|
554
|
-
|
|
555
|
-
CREATED(1, "{order.status.created}"),
|
|
556
|
-
PAID(2, "{order.status.paid}"),
|
|
557
|
-
COMPLETED(3, "{order.status.completed}"),
|
|
558
|
-
CANCELLED(4, "{order.status.cancelled}");
|
|
559
|
-
|
|
560
|
-
private final Integer key;
|
|
561
|
-
private final String desc;
|
|
562
|
-
|
|
563
|
-
public String getDesc() {
|
|
564
|
-
return I18n.getMessage(desc);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
public static OrderStatusEnum getByKey(Integer key) {
|
|
568
|
-
if (key == null) {
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
for (OrderStatusEnum status : values()) {
|
|
572
|
-
if (status.getKey().equals(key)) {
|
|
573
|
-
return status;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
return null;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
public static String getDescByKey(Integer key) {
|
|
580
|
-
OrderStatusEnum status = getByKey(key);
|
|
581
|
-
return status != null ? status.getDesc() : "";
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
## 常用注解
|
|
587
|
-
|
|
588
|
-
### MyBatis-Plus 注解
|
|
589
|
-
|
|
590
|
-
| 注解 | 用途 | 示例 |
|
|
591
|
-
|------|------|------|
|
|
592
|
-
| `@TableName` | 表名映射 | `@TableName("order_table")` |
|
|
593
|
-
| `@TableId` | 主键标识 | `@TableId private Long id;` |
|
|
594
|
-
| `@TableField` | 字段映射 | `@TableField("user_name")` |
|
|
595
|
-
| `@TableField(fill = FieldFill.INSERT)` | 插入时填充 | `@TableField(fill = FieldFill.INSERT) private String crby;` |
|
|
596
|
-
| `@TableField(fill = FieldFill.INSERT_UPDATE)` | 插入或更新时填充 | `@TableField(fill = FieldFill.INSERT_UPDATE) private LocalDateTime uptime;` |
|
|
597
|
-
| `@TableField(exist = false)` | 非数据库字段 | `@TableField(exist = false) private String tempField;` |
|
|
598
|
-
|
|
599
|
-
### Jakarta Validation 注解
|
|
600
|
-
|
|
601
|
-
**重要**:项目使用 JDK 21,必须使用 `jakarta.validation.constraints.*` 包
|
|
602
|
-
|
|
603
|
-
```java
|
|
604
|
-
import jakarta.validation.constraints.*;
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
| 注解 | 用途 | 示例 |
|
|
608
|
-
|------|------|------|
|
|
609
|
-
| `@NotNull` | 不能为null | `@NotNull(message = "用户ID不能为空")` |
|
|
610
|
-
| `@NotBlank` | 字符串不能为空 | `@NotBlank(message = "名称不能为空")` |
|
|
611
|
-
| `@NotEmpty` | 集合不能为空 | `@NotEmpty(message = "列表不能为空")` |
|
|
612
|
-
| `@Size` | 大小范围 | `@Size(min = 1, max = 100, message = "长度1-100")` |
|
|
613
|
-
| `@Min` | 最小值 | `@Min(value = 0, message = "金额不能为负数")` |
|
|
614
|
-
| `@Max` | 最大值 | `@Max(value = 1000, message = "数量不能超过1000")` |
|
|
615
|
-
| `@DecimalMin` | 小数最小值 | `@DecimalMin(value = "0.01", message = "金额必须大于0.01")` |
|
|
616
|
-
| `@DecimalMax` | 小数最大值 | `@DecimalMax(value = "999999.99", message = "金额不能超过999999.99")` |
|
|
617
|
-
| `@Email` | 邮箱格式 | `@Email(message = "邮箱格式不正确")` |
|
|
618
|
-
| `@Pattern` | 正则匹配 | `@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")` |
|
|
619
|
-
|
|
620
|
-
### Swagger 注解
|
|
621
|
-
|
|
622
|
-
| 注解 | 用途 | 示例 |
|
|
623
|
-
|------|------|------|
|
|
624
|
-
| `@ApiModel` | 类描述 | `@ApiModel("订单信息")` |
|
|
625
|
-
| `@ApiModelProperty` | 字段描述 | `@ApiModelProperty("订单ID")` |
|
|
626
|
-
| `@ApiModelProperty(value = "...", required = true)` | 必填字段 | `@ApiModelProperty(value = "用户ID", required = true)` |
|
|
627
|
-
|
|
628
|
-
### Lombok 注解
|
|
629
|
-
|
|
630
|
-
| 注解 | 用途 | 示例 |
|
|
631
|
-
|------|------|------|
|
|
632
|
-
| `@Data` | getter/setter | `@Data public class Xxx {}` |
|
|
633
|
-
| `@Slf4j` | 日志 | `@Slf4j public class Xxx {}` |
|
|
634
|
-
| `@Builder` | 建造者模式 | `@Builder public class Xxx {}` |
|
|
635
|
-
| `@AllArgsConstructor` | 全参构造 | `@AllArgsConstructor public class Xxx {}` |
|
|
636
|
-
| `@NoArgsConstructor` | 无参构造 | `@NoArgsConstructor public class Xxx {}` |
|
|
637
|
-
| `@Accessors(chain = true)` | 链式调用 | `@Accessors(chain = true) public class Xxx {}` |
|
|
638
|
-
| `@Getter` | getter方法 | `@Getter public enum XxxEnum {}` |
|
|
639
|
-
|
|
640
|
-
### EasyExcel 注解
|
|
641
|
-
|
|
642
|
-
```java
|
|
643
|
-
import com.alibaba.excel.annotation.ExcelProperty;
|
|
644
|
-
import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
|
645
|
-
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
|
646
|
-
import com.alibaba.excel.annotation.ExcelIgnore;
|
|
647
|
-
```
|
|
189
|
+
含国际化时,`desc` 用占位符 `"{order.status.created}"`,重写 `getDesc()` 调用 `I18n.getMessage(desc)`。
|
|
648
190
|
|
|
649
|
-
|
|
650
|
-
|------|------|------|
|
|
651
|
-
| `@ExcelProperty` | Excel列名 | `@ExcelProperty(value = "订单ID", order = 1)` |
|
|
652
|
-
| `@ColumnWidth` | 列宽 | `@ColumnWidth(15)` |
|
|
653
|
-
| `@ContentRowHeight` | 行高 | `@ContentRowHeight(20)` |
|
|
654
|
-
| `@ExcelIgnore` | 忽略导出 | `@ExcelIgnore private String tempField;` |
|
|
655
|
-
|
|
656
|
-
### JSON 格式化注解
|
|
657
|
-
|
|
658
|
-
```java
|
|
659
|
-
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
660
|
-
import org.springframework.format.annotation.DateTimeFormat;
|
|
661
|
-
```
|
|
191
|
+
## 时间格式化
|
|
662
192
|
|
|
663
193
|
```java
|
|
664
194
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
@@ -670,82 +200,38 @@ private LocalDateTime createTime;
|
|
|
670
200
|
private LocalDate date;
|
|
671
201
|
```
|
|
672
202
|
|
|
673
|
-
##
|
|
674
|
-
|
|
675
|
-
### Hutool 工具类
|
|
203
|
+
## 对象转换
|
|
676
204
|
|
|
677
205
|
```java
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
// 集合判空
|
|
684
|
-
if (CollUtil.isEmpty(list)) { }
|
|
685
|
-
if (CollUtil.isNotEmpty(list)) { }
|
|
686
|
-
|
|
687
|
-
// 对象判空
|
|
688
|
-
if (ObjectUtil.isNull(obj)) { }
|
|
689
|
-
if (ObjectUtil.isNotNull(obj)) { }
|
|
690
|
-
|
|
691
|
-
// 字符串判空
|
|
692
|
-
if (StrUtil.isBlank(str)) { }
|
|
693
|
-
if (StrUtil.isNotBlank(str)) { }
|
|
694
|
-
|
|
695
|
-
// 对象拷贝
|
|
696
|
-
Target target = BeanUtil.copyProperties(source, Target.class);
|
|
697
|
-
List<Target> targets = BeanUtil.copyToList(sources, Target.class);
|
|
206
|
+
// 单对象
|
|
207
|
+
Target t = BeanUtil.copyProperties(source, Target.class);
|
|
208
|
+
// 列表
|
|
209
|
+
List<Target> list = BeanUtil.copyToList(sources, Target.class);
|
|
698
210
|
```
|
|
699
211
|
|
|
700
|
-
##
|
|
701
|
-
|
|
702
|
-
### 错误1:使用 RuoYi 的 TenantEntity
|
|
212
|
+
## 禁止项
|
|
703
213
|
|
|
704
214
|
```java
|
|
705
|
-
// ❌
|
|
215
|
+
// ❌ 继承 RuoYi TenantEntity / BaseEntity
|
|
706
216
|
import org.dromara.common.mybatis.core.domain.TenantEntity;
|
|
707
217
|
|
|
708
|
-
//
|
|
709
|
-
@Data
|
|
710
|
-
@TableName("table_name")
|
|
711
|
-
public class XxxEntity {
|
|
712
|
-
@TableId
|
|
713
|
-
private Long id;
|
|
714
|
-
}
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
### 错误2:使用 javax.validation
|
|
718
|
-
|
|
719
|
-
```java
|
|
720
|
-
// ❌ 错误:使用 javax.validation(JDK 21 应该用 jakarta)
|
|
218
|
+
// ❌ javax.validation(JDK 21 必须用 jakarta)
|
|
721
219
|
import javax.validation.constraints.NotNull;
|
|
722
220
|
|
|
723
|
-
//
|
|
724
|
-
|
|
725
|
-
```
|
|
726
|
-
|
|
727
|
-
### 错误3:使用 MapstructUtils
|
|
728
|
-
|
|
729
|
-
```java
|
|
730
|
-
// ❌ 错误:使用 RuoYi 的工具类
|
|
731
|
-
import org.dromara.common.core.utils.MapstructUtils;
|
|
732
|
-
Target target = MapstructUtils.convert(source, Target.class);
|
|
733
|
-
|
|
734
|
-
// ✅ 正确:leniu 使用 Hutool
|
|
735
|
-
import cn.hutool.core.bean.BeanUtil;
|
|
736
|
-
Target target = BeanUtil.copyProperties(source, Target.class);
|
|
737
|
-
```
|
|
738
|
-
|
|
739
|
-
### 错误4:delFlag 判断错误
|
|
221
|
+
// ❌ MapstructUtils(用 BeanUtil.copyProperties)
|
|
222
|
+
MapstructUtils.convert(source, Target.class);
|
|
740
223
|
|
|
741
|
-
|
|
742
|
-
// ❌ 错误:使用 RuoYi 的值
|
|
224
|
+
// ❌ delFlag: 0=正常(leniu 是 2=正常)
|
|
743
225
|
wrapper.eq(XxxEntity::getDelFlag, 0);
|
|
744
226
|
|
|
745
|
-
//
|
|
746
|
-
|
|
227
|
+
// ❌ 错误审计字段名
|
|
228
|
+
private String createBy; // 必须 crby
|
|
229
|
+
private LocalDateTime createTime; // 必须 crtime
|
|
230
|
+
|
|
231
|
+
// ❌ Entity 加 tenant_id(双库物理隔离,不需要)
|
|
747
232
|
```
|
|
748
233
|
|
|
749
234
|
## 参考文档
|
|
750
235
|
|
|
751
|
-
|
|
236
|
+
- 完整模板示例(Excel导出VO、报表Param等):详见 `references/templates.md`
|
|
237
|
+
- 生产代码参考:`sys-canteen/.../order/common/model/OrderInfo.java`
|