ai-engineering-init 1.3.3 → 1.4.0
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 +4 -1
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +252 -116
- 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 -325
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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 +252 -116
- 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 -325
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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.json +3 -3
- package/.cursor/rules/skill-activation.mdc +2 -0
- package/.cursor/skills/add-skill/SKILL.md +252 -116
- 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 -325
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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/AGENTS.md +1 -0
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ description: |
|
|
|
13
13
|
触发词:API、接口、RESTful、Controller、GetMapping、PostMapping、权限注解、日志注解、分页查询、接口规范
|
|
14
14
|
|
|
15
15
|
注意:
|
|
16
|
-
- 本项目是三层架构:Controller
|
|
16
|
+
- 本项目是三层架构:Controller -> Service -> Mapper
|
|
17
17
|
- 参考 java-controller 技能获取更详细的 Controller 层规范
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -21,43 +21,38 @@ description: |
|
|
|
21
21
|
|
|
22
22
|
## 核心规范
|
|
23
23
|
|
|
24
|
-
### 1. 接口定义原则
|
|
25
|
-
|
|
26
24
|
| 原则 | 说明 |
|
|
27
25
|
|------|------|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
33
|
-
### 2. HTTP 方法规范
|
|
34
|
-
|
|
35
|
-
| 操作 | HTTP 方法 | 路径 | 说明 |
|
|
36
|
-
|------|---------|------|------|
|
|
37
|
-
| **列表查询** | POST/GET | `/query` 或 `/list` | 分页查询列表 |
|
|
38
|
-
| **获取详情** | POST/GET | `/{id}` 或 `/detail` | 根据 ID 查询 |
|
|
39
|
-
| **新增** | POST | `/add` | 创建新数据 |
|
|
40
|
-
| **修改** | POST/PUT | `/update` | 更新数据 |
|
|
41
|
-
| **删除** | POST/DELETE | `/delete` 或 `/batch/delete` | 删除数据 |
|
|
42
|
-
| **导出** | POST | `/export` | 导出数据到 Excel |
|
|
43
|
-
| **导入** | POST | `/import-excel` | 从 Excel 导入数据 |
|
|
26
|
+
| 统一入口 | 所有接口使用 POST 或 RESTful 风格 |
|
|
27
|
+
| 认证保护 | 所有业务接口必须添加认证注解 |
|
|
28
|
+
| 参数校验 | 使用分组校验区分新增/修改场景 |
|
|
29
|
+
| 统一响应 | 使用统一的响应格式包装返回数据 |
|
|
44
30
|
|
|
45
|
-
|
|
31
|
+
### HTTP 方法规范
|
|
46
32
|
|
|
47
|
-
|
|
33
|
+
| 操作 | 方法 | 路径 |
|
|
34
|
+
|------|------|------|
|
|
35
|
+
| 列表查询 | POST/GET | `/query` 或 `/list` |
|
|
36
|
+
| 获取详情 | POST/GET | `/{id}` 或 `/detail` |
|
|
37
|
+
| 新增 | POST | `/add` |
|
|
38
|
+
| 修改 | POST/PUT | `/update` |
|
|
39
|
+
| 删除 | POST/DELETE | `/delete` 或 `/batch/delete` |
|
|
40
|
+
| 导出 | POST | `/export` |
|
|
41
|
+
| 导入 | POST | `/import-excel` |
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Controller 标准模板
|
|
50
46
|
|
|
51
47
|
```java
|
|
52
48
|
@Slf4j
|
|
53
49
|
@RestController
|
|
54
|
-
@RequiresAuthentication
|
|
50
|
+
@RequiresAuthentication
|
|
55
51
|
@RequestMapping("/module/feature")
|
|
56
52
|
@Api(value = "模块/功能", tags = "模块/功能")
|
|
57
53
|
public class XxxController {
|
|
58
54
|
|
|
59
|
-
@Resource
|
|
60
|
-
@Lazy
|
|
55
|
+
@Resource @Lazy
|
|
61
56
|
private XxxService xxxService;
|
|
62
57
|
|
|
63
58
|
@PostMapping("/add")
|
|
@@ -90,47 +85,33 @@ public class XxxController {
|
|
|
90
85
|
|
|
91
86
|
## 参数封装规范
|
|
92
87
|
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
使用统一的请求包装类 `LeRequest<T>`:
|
|
88
|
+
### 请求参数用 LeRequest 包装
|
|
96
89
|
|
|
97
90
|
```java
|
|
98
91
|
@PostMapping("/query")
|
|
99
92
|
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
100
|
-
|
|
101
|
-
return xxxService.pageList(param);
|
|
93
|
+
return xxxService.pageList(request.getContent());
|
|
102
94
|
}
|
|
103
95
|
```
|
|
104
96
|
|
|
105
|
-
###
|
|
97
|
+
### 分页参数
|
|
106
98
|
|
|
107
99
|
```java
|
|
108
100
|
@Data
|
|
109
101
|
public class XxxPageParam implements Serializable {
|
|
110
|
-
|
|
111
|
-
@ApiModelProperty(value = "分页参数", required = true)
|
|
112
102
|
@NotNull(message = "分页参数不能为空")
|
|
113
103
|
private PageDTO page;
|
|
114
|
-
|
|
115
|
-
@ApiModelProperty("关键字")
|
|
116
104
|
private String keyword;
|
|
117
|
-
|
|
118
|
-
@ApiModelProperty("状态")
|
|
119
105
|
private Integer status;
|
|
120
106
|
}
|
|
121
107
|
```
|
|
122
108
|
|
|
123
|
-
###
|
|
109
|
+
### 分组校验
|
|
124
110
|
|
|
125
111
|
```java
|
|
126
|
-
// 定义校验分组
|
|
127
|
-
public interface InsertGroup {}
|
|
128
|
-
public interface UpdateGroup {}
|
|
129
|
-
|
|
130
112
|
// DTO 中使用分组
|
|
131
113
|
@Data
|
|
132
114
|
public class XxxDTO {
|
|
133
|
-
|
|
134
115
|
@NotNull(message = "ID不能为空", groups = {UpdateGroup.class})
|
|
135
116
|
private Long id;
|
|
136
117
|
|
|
@@ -138,164 +119,36 @@ public class XxxDTO {
|
|
|
138
119
|
private String name;
|
|
139
120
|
}
|
|
140
121
|
|
|
141
|
-
// Controller
|
|
122
|
+
// Controller 中应用
|
|
142
123
|
@PostMapping("/add")
|
|
143
124
|
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request)
|
|
144
|
-
|
|
145
|
-
@PostMapping("/update")
|
|
146
|
-
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request)
|
|
147
125
|
```
|
|
148
126
|
|
|
149
|
-
|
|
127
|
+
> Jakarta Validation: 项目用 JDK 21,必须 `import jakarta.validation.constraints.*`
|
|
150
128
|
|
|
151
|
-
|
|
129
|
+
---
|
|
152
130
|
|
|
153
|
-
|
|
131
|
+
## 响应格式
|
|
154
132
|
|
|
155
133
|
```java
|
|
156
|
-
//
|
|
134
|
+
// 分页响应
|
|
157
135
|
@PostMapping("/query")
|
|
158
|
-
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
159
|
-
return xxxService.pageList(request.getContent());
|
|
160
|
-
}
|
|
136
|
+
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) { ... }
|
|
161
137
|
|
|
162
|
-
//
|
|
163
|
-
public class PageVO<T> {
|
|
164
|
-
private List<T> records; // 数据列表
|
|
165
|
-
private Long total; // 总条数
|
|
166
|
-
private Integer pageNum; // 当前页
|
|
167
|
-
private Integer pageSize; // 每页条数
|
|
168
|
-
}
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 2. 单条数据响应
|
|
172
|
-
|
|
173
|
-
```java
|
|
174
|
-
// 直接返回 VO 对象
|
|
138
|
+
// 单条数据
|
|
175
139
|
@GetMapping("/{id}")
|
|
176
|
-
public XxxVO getById(@PathVariable Long id) {
|
|
177
|
-
return xxxService.getById(id);
|
|
178
|
-
}
|
|
140
|
+
public XxxVO getById(@PathVariable Long id) { ... }
|
|
179
141
|
|
|
180
|
-
//
|
|
181
|
-
@GetMapping("/{id}")
|
|
182
|
-
public R<XxxVO> getById(@PathVariable Long id) {
|
|
183
|
-
return R.ok(xxxService.getById(id));
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 3. 无返回值操作
|
|
188
|
-
|
|
189
|
-
```java
|
|
190
|
-
// 新增/修改/删除可以直接返回 void
|
|
142
|
+
// 新增返回 ID / 修改删除返回 void
|
|
191
143
|
@PostMapping("/add")
|
|
192
|
-
public
|
|
193
|
-
xxxService.add(request.getContent());
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// 或返回 ID
|
|
197
|
-
@PostMapping("/add")
|
|
198
|
-
public Long add(@RequestBody LeRequest<XxxDTO> request) {
|
|
199
|
-
return xxxService.add(request.getContent());
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## 参数校验规范
|
|
206
|
-
|
|
207
|
-
### 1. Jakarta Validation 注解
|
|
208
|
-
|
|
209
|
-
**重要**: 项目使用 JDK 21,必须使用 `jakarta.validation.constraints.*` 包
|
|
210
|
-
|
|
211
|
-
```java
|
|
212
|
-
import jakarta.validation.Valid;
|
|
213
|
-
import jakarta.validation.constraints.NotNull;
|
|
214
|
-
import jakarta.validation.constraints.NotBlank;
|
|
215
|
-
import jakarta.validation.constraints.NotEmpty;
|
|
216
|
-
import jakarta.validation.constraints.Size;
|
|
217
|
-
import jakarta.validation.constraints.Pattern;
|
|
218
|
-
import jakarta.validation.constraints.Min;
|
|
219
|
-
import jakarta.validation.constraints.Max;
|
|
220
|
-
|
|
221
|
-
@Data
|
|
222
|
-
public class XxxDTO {
|
|
223
|
-
|
|
224
|
-
@NotNull(message = "ID不能为空", groups = {UpdateGroup.class})
|
|
225
|
-
private Long id;
|
|
226
|
-
|
|
227
|
-
@NotBlank(message = "名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
228
|
-
@Size(max = 100, message = "名称长度不能超过100个字符")
|
|
229
|
-
private String name;
|
|
230
|
-
|
|
231
|
-
@Min(value = 0, message = "数量不能小于0")
|
|
232
|
-
@Max(value = 9999, message = "数量不能大于9999")
|
|
233
|
-
private Integer count;
|
|
234
|
-
|
|
235
|
-
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
|
236
|
-
private String phone;
|
|
237
|
-
|
|
238
|
-
@Email(message = "邮箱格式不正确")
|
|
239
|
-
private String email;
|
|
240
|
-
}
|
|
144
|
+
public Long add(@RequestBody LeRequest<XxxDTO> request) { ... }
|
|
241
145
|
```
|
|
242
146
|
|
|
243
|
-
### 2. 校验注解速查表
|
|
244
|
-
|
|
245
|
-
| 注解 | 用途 | 示例 |
|
|
246
|
-
|------|------|------|
|
|
247
|
-
| `@NotNull` | 不能为 null | `@NotNull(message = "ID不能为空")` |
|
|
248
|
-
| `@NotBlank` | 字符串不能为空或空白 | `@NotBlank(message = "名称不能为空")` |
|
|
249
|
-
| `@NotEmpty` | 集合/数组不能为空 | `@NotEmpty(message = "ID列表不能为空")` |
|
|
250
|
-
| `@Size` | 集合/字符串长度 | `@Size(min = 1, max = 100)` |
|
|
251
|
-
| `@Min` | 最小值 | `@Min(value = 0, message = "不能小于0")` |
|
|
252
|
-
| `@Max` | 最大值 | `@Max(value = 100, message = "不能大于100")` |
|
|
253
|
-
| `@Pattern` | 正则表达式 | `@Pattern(regexp = "^[0-9]+$")` |
|
|
254
|
-
| `@Email` | 邮箱格式 | `@Email(message = "邮箱格式错误")` |
|
|
255
|
-
|
|
256
147
|
---
|
|
257
148
|
|
|
258
|
-
##
|
|
149
|
+
## 常见场景
|
|
259
150
|
|
|
260
|
-
###
|
|
261
|
-
|
|
262
|
-
```java
|
|
263
|
-
import io.swagger.annotations.Api;
|
|
264
|
-
import io.swagger.annotations.ApiOperation;
|
|
265
|
-
import io.swagger.annotations.ApiModel;
|
|
266
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
267
|
-
|
|
268
|
-
// Controller 类级别
|
|
269
|
-
@Api(value = "模块/功能", tags = "模块/功能")
|
|
270
|
-
@RestController
|
|
271
|
-
public class XxxController {
|
|
272
|
-
|
|
273
|
-
// 方法级别
|
|
274
|
-
@ApiOperation(value = "功能描述-新增")
|
|
275
|
-
@PostMapping("/add")
|
|
276
|
-
public Long add(@RequestBody LeRequest<XxxDTO> request) {
|
|
277
|
-
// ...
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// DTO/VO 类级别
|
|
282
|
-
@Data
|
|
283
|
-
@ApiModel("功能描述DTO")
|
|
284
|
-
public class XxxDTO {
|
|
285
|
-
|
|
286
|
-
@ApiModelProperty(value = "主键ID", required = true)
|
|
287
|
-
private Long id;
|
|
288
|
-
|
|
289
|
-
@ApiModelProperty("名称")
|
|
290
|
-
private String name;
|
|
291
|
-
}
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
## 常见场景示例
|
|
297
|
-
|
|
298
|
-
### 1. 带 Redisson 分布式锁的导入
|
|
151
|
+
### 带 Redisson 分布式锁的导入
|
|
299
152
|
|
|
300
153
|
```java
|
|
301
154
|
@PostMapping("/import-excel")
|
|
@@ -318,7 +171,7 @@ public void importExcel(@RequestParam(value = "file") MultipartFile file) {
|
|
|
318
171
|
}
|
|
319
172
|
```
|
|
320
173
|
|
|
321
|
-
###
|
|
174
|
+
### 批量删除
|
|
322
175
|
|
|
323
176
|
```java
|
|
324
177
|
@RequestMapping(value = "/batch/delete", method = {RequestMethod.POST, RequestMethod.PUT})
|
|
@@ -331,230 +184,83 @@ public void batchDelete(@RequestBody LeRequest<List<Long>> request) {
|
|
|
331
184
|
}
|
|
332
185
|
```
|
|
333
186
|
|
|
334
|
-
###
|
|
187
|
+
### 带合计行的分页查询
|
|
335
188
|
|
|
336
189
|
```java
|
|
337
190
|
@PostMapping("/query")
|
|
338
191
|
@ApiOperation(value = "分页查询(带合计)")
|
|
339
192
|
public ReportBaseTotalVO<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
340
193
|
ReportBaseTotalVO<XxxVO> result = new ReportBaseTotalVO<>();
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
XxxVO totalLine = xxxService.getSummaryTotal(request.getContent());
|
|
344
|
-
result.setTotalLine(totalLine);
|
|
345
|
-
|
|
346
|
-
// 分页查询
|
|
347
|
-
Page<XxxVO> page = xxxService.pageList(request.getContent());
|
|
348
|
-
result.setResultPage(PageVO.of(page));
|
|
349
|
-
|
|
194
|
+
result.setTotalLine(xxxService.getSummaryTotal(request.getContent()));
|
|
195
|
+
result.setResultPage(PageVO.of(xxxService.pageList(request.getContent())));
|
|
350
196
|
return result;
|
|
351
197
|
}
|
|
352
198
|
```
|
|
353
199
|
|
|
354
200
|
---
|
|
355
201
|
|
|
356
|
-
##
|
|
357
|
-
|
|
358
|
-
生成 API 代码前必须检查:
|
|
359
|
-
|
|
360
|
-
- [ ] **认证注解是否添加**?(`@RequiresAuthentication` 或类似)
|
|
361
|
-
- [ ] **API 文档注解是否添加**?(`@ApiOperation`)
|
|
362
|
-
- [ ] **参数校验是否正确**?(`@Validated` + 分组)
|
|
363
|
-
- [ ] **返回值类型是否正确**?(分页用 `Page<VO>`,单条用 VO 或 `R<VO>`)
|
|
364
|
-
- [ ] **HTTP 方法是否正确**?(查询 POST/GET,新增 POST,修改 POST/PUT)
|
|
365
|
-
- [ ] **路径命名是否规范**?(`/add`, `/update`, `/query`, `/delete`)
|
|
366
|
-
- [ ] **是否使用了 `LeRequest<T>` 封装请求**?
|
|
367
|
-
- [ ] **是否使用中文注释和错误提示**?
|
|
368
|
-
- [ ] **敏感操作是否加了分布式锁**?
|
|
369
|
-
|
|
370
|
-
---
|
|
371
|
-
|
|
372
|
-
## 错误对比
|
|
373
|
-
|
|
374
|
-
### ❌ 不要做
|
|
202
|
+
## Swagger 注解
|
|
375
203
|
|
|
376
204
|
```java
|
|
377
|
-
//
|
|
378
|
-
@
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
// 错误 2: 不使用参数封装
|
|
382
|
-
@PostMapping("/add")
|
|
383
|
-
public Long add(@RequestBody XxxDTO dto) { } // 应该用 LeRequest<XxxDTO>
|
|
384
|
-
|
|
385
|
-
// 错误 3: 不使用分组校验
|
|
386
|
-
@PostMapping("/add")
|
|
387
|
-
public Long add(@Valid @RequestBody LeRequest<XxxDTO> request) { } // 应该用 @Validated(InsertGroup.class)
|
|
388
|
-
|
|
389
|
-
// 错误 4: 使用 javax.validation(JDK 21 应用 jakarta.validation)
|
|
390
|
-
import javax.validation.constraints.NotNull; // ❌ 错误
|
|
391
|
-
```
|
|
392
|
-
|
|
393
|
-
### ✅ 正确做法
|
|
394
|
-
|
|
395
|
-
```java
|
|
396
|
-
// 正确 1: 添加认证注解
|
|
397
|
-
@RestController
|
|
398
|
-
@RequiresAuthentication
|
|
399
|
-
public class XxxController { }
|
|
400
|
-
|
|
401
|
-
// 正确 2: 使用参数封装
|
|
402
|
-
@PostMapping("/add")
|
|
403
|
-
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
404
|
-
return xxxService.add(request.getContent());
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
// 正确 3: 使用分组校验
|
|
408
|
-
@Validated(InsertGroup.class)
|
|
409
|
-
|
|
410
|
-
// 正确 4: 使用 Jakarta Validation
|
|
411
|
-
import jakarta.validation.constraints.NotNull; // ✅ 正确
|
|
205
|
+
@Api(value = "模块/功能", tags = "模块/功能") // Controller 类
|
|
206
|
+
@ApiOperation(value = "功能描述-新增") // 方法
|
|
207
|
+
@ApiModel("功能描述DTO") // DTO/VO 类
|
|
208
|
+
@ApiModelProperty(value = "主键ID", required = true) // 字段
|
|
412
209
|
```
|
|
413
210
|
|
|
414
211
|
---
|
|
415
212
|
|
|
416
|
-
##
|
|
213
|
+
## 检查清单
|
|
417
214
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
| 数据库设计 | `java-database` / `database-ops` |
|
|
215
|
+
- [ ] 认证注解 `@RequiresAuthentication`
|
|
216
|
+
- [ ] API 文档注解 `@ApiOperation`
|
|
217
|
+
- [ ] 参数校验 `@Validated` + 分组
|
|
218
|
+
- [ ] 返回值类型正确(分页用 `Page<VO>`)
|
|
219
|
+
- [ ] 使用 `LeRequest<T>` 封装请求
|
|
220
|
+
- [ ] 敏感操作加分布式锁
|
|
425
221
|
|
|
426
222
|
---
|
|
427
223
|
|
|
428
|
-
##
|
|
429
|
-
|
|
430
|
-
### 项目架构差异详解
|
|
224
|
+
## 多项目对比
|
|
431
225
|
|
|
432
226
|
| 特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
433
227
|
|-----|----------------|-------------------|
|
|
434
|
-
|
|
|
435
|
-
|
|
|
436
|
-
|
|
|
437
|
-
|
|
|
438
|
-
|
|
|
439
|
-
|
|
|
440
|
-
|
|
|
441
|
-
|
|
|
442
|
-
|
|
443
|
-
### leniu-tengyun-core Controller 完整示例
|
|
228
|
+
| JDK | 17 | 21 |
|
|
229
|
+
| 包名 | `org.dromara.*` | `net.xnzn.core.*` |
|
|
230
|
+
| 请求封装 | 直接 BO | `LeRequest<T>` |
|
|
231
|
+
| 响应封装 | `R<T>`, `TableDataInfo<T>` | `Page<T>`, `void` |
|
|
232
|
+
| 分组校验 | `AddGroup`, `EditGroup` | `InsertGroup`, `UpdateGroup` |
|
|
233
|
+
| 认证 | `@SaCheckPermission` | `@RequiresAuthentication` |
|
|
234
|
+
| 异常 | `ServiceException` | `LeException` |
|
|
235
|
+
| 国际化 | `MessageUtils.message()` | `I18n.getMessage()` |
|
|
444
236
|
|
|
445
|
-
|
|
446
|
-
@RequiresAuthentication
|
|
447
|
-
@RestController
|
|
448
|
-
@RequestMapping("/back/attendance/leave-info")
|
|
449
|
-
@Api(value = "考勤/请假信息", tags = "考勤/请假信息")
|
|
450
|
-
public class LeaveInfoController {
|
|
451
|
-
|
|
452
|
-
@Resource
|
|
453
|
-
@Lazy
|
|
454
|
-
private LeaveInfoService leaveInfoService;
|
|
455
|
-
|
|
456
|
-
@PostMapping("/add")
|
|
457
|
-
@ApiOperation(value = "请假信息-新增")
|
|
458
|
-
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<LeaveInfoDTO> request) {
|
|
459
|
-
return leaveInfoService.add(request.getContent());
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
@PostMapping("/update")
|
|
463
|
-
@ApiOperation(value = "请假信息-修改")
|
|
464
|
-
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<LeaveInfoDTO> request) {
|
|
465
|
-
leaveInfoService.update(request.getContent());
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
@PostMapping("/query")
|
|
469
|
-
@ApiOperation(value = "请假信息-分页查询")
|
|
470
|
-
public Page<LeaveInfoVO> query(@Validated @RequestBody LeRequest<LeaveInfoQueryParam> request) {
|
|
471
|
-
return leaveInfoService.pageList(request.getContent());
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
@PostMapping("/delete")
|
|
475
|
-
@ApiOperation(value = "请假信息-删除")
|
|
476
|
-
public void delete(@RequestBody LeRequest<Long> request) {
|
|
477
|
-
leaveInfoService.delete(request.getContent());
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
```
|
|
481
|
-
|
|
482
|
-
### Redisson 分布式锁完整示例
|
|
483
|
-
|
|
484
|
-
```java
|
|
485
|
-
import org.redisson.api.RLock;
|
|
486
|
-
import org.redisson.api.RedissonClient;
|
|
487
|
-
import java.util.concurrent.TimeUnit;
|
|
488
|
-
|
|
489
|
-
@Resource
|
|
490
|
-
private RedissonClient redissonClient;
|
|
491
|
-
|
|
492
|
-
@PostMapping("/import-excel")
|
|
493
|
-
@ApiOperation(value = "Excel导入")
|
|
494
|
-
public void importExcel(@RequestParam(value = "file") MultipartFile file) {
|
|
495
|
-
if (Objects.isNull(file) || file.isEmpty()) {
|
|
496
|
-
throw new LeException("文件不能为空");
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// 获取分布式锁
|
|
500
|
-
RLock lock = redissonClient.getLock("import:lock:" + TenantContextHolder.getTenantId());
|
|
501
|
-
|
|
502
|
-
// 尝试获取锁:等待5秒,锁定60秒后自动释放
|
|
503
|
-
if (!lock.tryLock(5, 60, TimeUnit.SECONDS)) {
|
|
504
|
-
throw new LeException("正在处理中,请稍后再试");
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
try {
|
|
508
|
-
xxxService.importExcel(file);
|
|
509
|
-
} finally {
|
|
510
|
-
// 释放锁前检查当前线程是否持有锁
|
|
511
|
-
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
|
512
|
-
lock.unlock();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
```
|
|
237
|
+
---
|
|
517
238
|
|
|
518
|
-
|
|
239
|
+
## 错误对比
|
|
519
240
|
|
|
520
241
|
```java
|
|
521
|
-
|
|
522
|
-
@
|
|
523
|
-
public
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
@PostMapping("/batch/update-status")
|
|
532
|
-
@ApiOperation(value = "批量更新状态")
|
|
533
|
-
public void batchUpdateStatus(@RequestBody LeRequest<BatchUpdateDTO> request) {
|
|
534
|
-
BatchUpdateDTO dto = request.getContent();
|
|
535
|
-
if (CollUtil.isEmpty(dto.getIds())) {
|
|
536
|
-
throw new LeException("ID列表不能为空");
|
|
537
|
-
}
|
|
538
|
-
xxxService.batchUpdateStatus(dto.getIds(), dto.getStatus());
|
|
242
|
+
// ---- 错误 ----
|
|
243
|
+
@RestController // 缺认证注解
|
|
244
|
+
public Long add(@RequestBody XxxDTO dto) { } // 不用 LeRequest
|
|
245
|
+
public Long add(@Valid @RequestBody LeRequest<XxxDTO> request) { } // @Valid 应为 @Validated(InsertGroup.class)
|
|
246
|
+
import javax.validation.constraints.NotNull; // JDK 21 用 jakarta
|
|
247
|
+
|
|
248
|
+
// ---- 正确 ----
|
|
249
|
+
@RestController @RequiresAuthentication
|
|
250
|
+
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
251
|
+
return xxxService.add(request.getContent());
|
|
539
252
|
}
|
|
253
|
+
import jakarta.validation.constraints.NotNull;
|
|
540
254
|
```
|
|
541
255
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
```java
|
|
545
|
-
@PostMapping("/query")
|
|
546
|
-
@ApiOperation(value = "分页查询(带合计)")
|
|
547
|
-
public ReportBaseTotalVO<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
548
|
-
ReportBaseTotalVO<XxxVO> result = new ReportBaseTotalVO<>();
|
|
549
|
-
|
|
550
|
-
// 1. 查询合计行
|
|
551
|
-
XxxVO totalLine = xxxService.getSummaryTotal(request.getContent());
|
|
552
|
-
result.setTotalLine(totalLine);
|
|
256
|
+
---
|
|
553
257
|
|
|
554
|
-
|
|
555
|
-
Page<XxxVO> page = xxxService.pageList(request.getContent());
|
|
556
|
-
result.setResultPage(PageVO.of(page));
|
|
258
|
+
## 相关技能
|
|
557
259
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
260
|
+
| 需要了解 | Skill |
|
|
261
|
+
|---------|-------|
|
|
262
|
+
| Service 层 | `java-service` |
|
|
263
|
+
| Controller 详细 | `java-controller` |
|
|
264
|
+
| 异常处理 | `error-handler` |
|
|
265
|
+
| 参数校验 | `java-entity` |
|
|
266
|
+
| 数据库设计 | `database-ops` |
|