ai-engineering-init 1.6.0 → 1.8.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.
Files changed (187) hide show
  1. package/.claude/agents/code-reviewer.md +3 -130
  2. package/.claude/hooks/skill-forced-eval.js +46 -60
  3. package/.claude/hooks/stop.js +24 -1
  4. package/.claude/settings.json +10 -1
  5. package/.claude/skills/api-development/SKILL.md +179 -130
  6. package/.claude/skills/architecture-design/SKILL.md +102 -212
  7. package/.claude/skills/backend-annotations/SKILL.md +166 -220
  8. package/.claude/skills/bug-detective/SKILL.md +225 -186
  9. package/.claude/skills/code-patterns/SKILL.md +127 -244
  10. package/.claude/skills/codex-code-review/SKILL.md +327 -0
  11. package/.claude/skills/collaborating-with-codex/SKILL.md +96 -113
  12. package/.claude/skills/crud-development/SKILL.md +226 -307
  13. package/.claude/skills/data-permission/SKILL.md +131 -202
  14. package/.claude/skills/database-ops/SKILL.md +158 -355
  15. package/.claude/skills/error-handler/SKILL.md +224 -285
  16. package/.claude/skills/file-oss-management/SKILL.md +174 -169
  17. package/.claude/skills/git-workflow/SKILL.md +123 -341
  18. package/.claude/skills/json-serialization/SKILL.md +121 -137
  19. package/.claude/skills/leniu-report-customization/SKILL.md +82 -2
  20. package/.claude/skills/leniu-report-standard-customization/SKILL.md +65 -2
  21. package/.claude/skills/loki-log-query/SKILL.md +400 -0
  22. package/.claude/skills/mysql-debug/SKILL.md +58 -22
  23. package/.claude/skills/performance-doctor/SKILL.md +83 -89
  24. package/.claude/skills/redis-cache/SKILL.md +134 -185
  25. package/.claude/skills/scheduled-jobs/SKILL.md +187 -224
  26. package/.claude/skills/security-guard/SKILL.md +168 -276
  27. package/.claude/skills/sms-mail/SKILL.md +266 -228
  28. package/.claude/skills/social-login/SKILL.md +257 -195
  29. package/.claude/skills/sync-back-merge/SKILL.md +66 -0
  30. package/.claude/skills/tenant-management/SKILL.md +172 -188
  31. package/.claude/skills/utils-toolkit/SKILL.md +214 -222
  32. package/.claude/skills/websocket-sse/SKILL.md +251 -172
  33. package/.claude/skills/workflow-engine/SKILL.md +178 -250
  34. package/.claude/skills/yunxiao-task-management/SKILL.md +489 -0
  35. package/.codex/skills/api-development/SKILL.md +179 -130
  36. package/.codex/skills/architecture-design/SKILL.md +102 -212
  37. package/.codex/skills/backend-annotations/SKILL.md +166 -220
  38. package/.codex/skills/bug-detective/SKILL.md +225 -186
  39. package/.codex/skills/code-patterns/SKILL.md +127 -244
  40. package/.codex/skills/collaborating-with-codex/SKILL.md +96 -113
  41. package/.codex/skills/crud-development/SKILL.md +226 -307
  42. package/.codex/skills/data-permission/SKILL.md +131 -202
  43. package/.codex/skills/database-ops/SKILL.md +158 -355
  44. package/.codex/skills/error-handler/SKILL.md +224 -285
  45. package/.codex/skills/file-oss-management/SKILL.md +174 -169
  46. package/.codex/skills/git-workflow/SKILL.md +123 -341
  47. package/.codex/skills/json-serialization/SKILL.md +121 -137
  48. package/.codex/skills/leniu-report-customization/SKILL.md +82 -2
  49. package/.codex/skills/leniu-report-standard-customization/SKILL.md +65 -2
  50. package/.codex/skills/loki-log-query/SKILL.md +400 -0
  51. package/.codex/skills/loki-log-query/environments.json +45 -0
  52. package/.codex/skills/mysql-debug/SKILL.md +58 -22
  53. package/.codex/skills/performance-doctor/SKILL.md +83 -89
  54. package/.codex/skills/redis-cache/SKILL.md +134 -185
  55. package/.codex/skills/scheduled-jobs/SKILL.md +187 -224
  56. package/.codex/skills/security-guard/SKILL.md +168 -276
  57. package/.codex/skills/skill-creator/LICENSE.txt +202 -0
  58. package/.codex/skills/skill-creator/SKILL.md +479 -0
  59. package/.codex/skills/skill-creator/agents/analyzer.md +274 -0
  60. package/.codex/skills/skill-creator/agents/comparator.md +202 -0
  61. package/.codex/skills/skill-creator/agents/grader.md +223 -0
  62. package/.codex/skills/skill-creator/assets/eval_review.html +146 -0
  63. package/.codex/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  64. package/.codex/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  65. package/.codex/skills/skill-creator/references/schemas.md +430 -0
  66. package/.codex/skills/skill-creator/scripts/__init__.py +0 -0
  67. package/.codex/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  68. package/.codex/skills/skill-creator/scripts/generate_report.py +326 -0
  69. package/.codex/skills/skill-creator/scripts/improve_description.py +248 -0
  70. package/.codex/skills/skill-creator/scripts/package_skill.py +136 -0
  71. package/.codex/skills/skill-creator/scripts/quick_validate.py +103 -0
  72. package/.codex/skills/skill-creator/scripts/run_eval.py +310 -0
  73. package/.codex/skills/skill-creator/scripts/run_loop.py +332 -0
  74. package/.codex/skills/skill-creator/scripts/utils.py +47 -0
  75. package/.codex/skills/sms-mail/SKILL.md +266 -228
  76. package/.codex/skills/social-login/SKILL.md +257 -195
  77. package/.codex/skills/sync-back-merge/SKILL.md +66 -0
  78. package/.codex/skills/tenant-management/SKILL.md +172 -188
  79. package/.codex/skills/utils-toolkit/SKILL.md +214 -222
  80. package/.codex/skills/websocket-sse/SKILL.md +251 -172
  81. package/.codex/skills/workflow-engine/SKILL.md +178 -250
  82. package/.codex/skills/yunxiao-task-management/SKILL.md +489 -0
  83. package/.cursor/hooks/cursor-skill-eval.js +66 -6
  84. package/.cursor/hooks/stop.js +23 -1
  85. package/.cursor/skills/api-development/SKILL.md +179 -130
  86. package/.cursor/skills/architecture-design/SKILL.md +102 -212
  87. package/.cursor/skills/backend-annotations/SKILL.md +166 -220
  88. package/.cursor/skills/bug-detective/SKILL.md +225 -186
  89. package/.cursor/skills/code-patterns/SKILL.md +127 -244
  90. package/.cursor/skills/collaborating-with-codex/SKILL.md +96 -113
  91. package/.cursor/skills/crud-development/SKILL.md +226 -307
  92. package/.cursor/skills/data-permission/SKILL.md +131 -202
  93. package/.cursor/skills/database-ops/SKILL.md +158 -355
  94. package/.cursor/skills/error-handler/SKILL.md +224 -285
  95. package/.cursor/skills/file-oss-management/SKILL.md +174 -169
  96. package/.cursor/skills/git-workflow/SKILL.md +123 -341
  97. package/.cursor/skills/json-serialization/SKILL.md +121 -137
  98. package/.cursor/skills/leniu-report-customization/SKILL.md +82 -2
  99. package/.cursor/skills/leniu-report-standard-customization/SKILL.md +65 -2
  100. package/.cursor/skills/loki-log-query/SKILL.md +400 -0
  101. package/.cursor/skills/loki-log-query/environments.json +45 -0
  102. package/.cursor/skills/mysql-debug/SKILL.md +58 -22
  103. package/.cursor/skills/performance-doctor/SKILL.md +83 -89
  104. package/.cursor/skills/redis-cache/SKILL.md +134 -185
  105. package/.cursor/skills/scheduled-jobs/SKILL.md +187 -224
  106. package/.cursor/skills/security-guard/SKILL.md +168 -276
  107. package/.cursor/skills/skill-creator/LICENSE.txt +202 -0
  108. package/.cursor/skills/skill-creator/SKILL.md +479 -0
  109. package/.cursor/skills/skill-creator/agents/analyzer.md +274 -0
  110. package/.cursor/skills/skill-creator/agents/comparator.md +202 -0
  111. package/.cursor/skills/skill-creator/agents/grader.md +223 -0
  112. package/.cursor/skills/skill-creator/assets/eval_review.html +146 -0
  113. package/.cursor/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  114. package/.cursor/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  115. package/.cursor/skills/skill-creator/references/schemas.md +430 -0
  116. package/.cursor/skills/skill-creator/scripts/__init__.py +0 -0
  117. package/.cursor/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  118. package/.cursor/skills/skill-creator/scripts/generate_report.py +326 -0
  119. package/.cursor/skills/skill-creator/scripts/improve_description.py +248 -0
  120. package/.cursor/skills/skill-creator/scripts/package_skill.py +136 -0
  121. package/.cursor/skills/skill-creator/scripts/quick_validate.py +103 -0
  122. package/.cursor/skills/skill-creator/scripts/run_eval.py +310 -0
  123. package/.cursor/skills/skill-creator/scripts/run_loop.py +332 -0
  124. package/.cursor/skills/skill-creator/scripts/utils.py +47 -0
  125. package/.cursor/skills/sms-mail/SKILL.md +266 -228
  126. package/.cursor/skills/social-login/SKILL.md +257 -195
  127. package/.cursor/skills/sync-back-merge/SKILL.md +66 -0
  128. package/.cursor/skills/tenant-management/SKILL.md +172 -188
  129. package/.cursor/skills/utils-toolkit/SKILL.md +214 -222
  130. package/.cursor/skills/websocket-sse/SKILL.md +251 -172
  131. package/.cursor/skills/workflow-engine/SKILL.md +178 -250
  132. package/.cursor/skills/yunxiao-task-management/SKILL.md +489 -0
  133. package/AGENTS.md +49 -540
  134. package/CLAUDE.md +73 -119
  135. package/README.md +37 -6
  136. package/bin/index.js +611 -25
  137. package/package.json +1 -1
  138. package/src/platform-map.json +4 -0
  139. package/src/skills/api-development/SKILL.md +179 -130
  140. package/src/skills/architecture-design/SKILL.md +102 -212
  141. package/src/skills/backend-annotations/SKILL.md +166 -220
  142. package/src/skills/bug-detective/SKILL.md +225 -186
  143. package/src/skills/code-patterns/SKILL.md +127 -244
  144. package/src/skills/codex-code-review/SKILL.md +261 -69
  145. package/src/skills/collaborating-with-codex/SKILL.md +96 -113
  146. package/src/skills/crud-development/SKILL.md +226 -307
  147. package/src/skills/data-permission/SKILL.md +131 -202
  148. package/src/skills/database-ops/SKILL.md +158 -355
  149. package/src/skills/error-handler/SKILL.md +224 -285
  150. package/src/skills/file-oss-management/SKILL.md +174 -169
  151. package/src/skills/git-workflow/SKILL.md +123 -341
  152. package/src/skills/json-serialization/SKILL.md +121 -137
  153. package/src/skills/leniu-report-customization/SKILL.md +82 -2
  154. package/src/skills/leniu-report-standard-customization/SKILL.md +65 -2
  155. package/src/skills/loki-log-query/SKILL.md +400 -0
  156. package/src/skills/loki-log-query/environments.json +45 -0
  157. package/src/skills/mysql-debug/SKILL.md +58 -22
  158. package/src/skills/performance-doctor/SKILL.md +83 -89
  159. package/src/skills/redis-cache/SKILL.md +134 -185
  160. package/src/skills/scheduled-jobs/SKILL.md +187 -224
  161. package/src/skills/security-guard/SKILL.md +168 -276
  162. package/src/skills/skill-creator/LICENSE.txt +202 -0
  163. package/src/skills/skill-creator/SKILL.md +479 -0
  164. package/src/skills/skill-creator/agents/analyzer.md +274 -0
  165. package/src/skills/skill-creator/agents/comparator.md +202 -0
  166. package/src/skills/skill-creator/agents/grader.md +223 -0
  167. package/src/skills/skill-creator/assets/eval_review.html +146 -0
  168. package/src/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  169. package/src/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  170. package/src/skills/skill-creator/references/schemas.md +430 -0
  171. package/src/skills/skill-creator/scripts/__init__.py +0 -0
  172. package/src/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  173. package/src/skills/skill-creator/scripts/generate_report.py +326 -0
  174. package/src/skills/skill-creator/scripts/improve_description.py +248 -0
  175. package/src/skills/skill-creator/scripts/package_skill.py +136 -0
  176. package/src/skills/skill-creator/scripts/quick_validate.py +103 -0
  177. package/src/skills/skill-creator/scripts/run_eval.py +310 -0
  178. package/src/skills/skill-creator/scripts/run_loop.py +332 -0
  179. package/src/skills/skill-creator/scripts/utils.py +47 -0
  180. package/src/skills/sms-mail/SKILL.md +266 -228
  181. package/src/skills/social-login/SKILL.md +257 -195
  182. package/src/skills/sync-back-merge/SKILL.md +66 -0
  183. package/src/skills/tenant-management/SKILL.md +172 -188
  184. package/src/skills/utils-toolkit/SKILL.md +214 -222
  185. package/src/skills/websocket-sse/SKILL.md +251 -172
  186. package/src/skills/workflow-engine/SKILL.md +178 -250
  187. package/src/skills/yunxiao-task-management/SKILL.md +489 -0
@@ -1,20 +1,19 @@
1
1
  ---
2
2
  name: api-development
3
3
  description: |
4
- 后端 API 接口设计规范。基于三层架构的 RESTful API 开发指南。
4
+ 后端 API 接口设计规范。基于 Spring Boot 的 RESTful API 开发指南。
5
5
 
6
6
  触发场景:
7
7
  - 设计 RESTful API 接口
8
8
  - 编写 Controller 层代码
9
- - 配置接口权限、日志、防重复提交注解
9
+ - 配置接口权限、日志注解
10
10
  - 接口返回值类型选择
11
11
  - 数据验证和参数校验
12
12
 
13
13
  触发词:API、接口、RESTful、Controller、GetMapping、PostMapping、权限注解、日志注解、分页查询、接口规范
14
14
 
15
15
  注意:
16
- - 本项目是三层架构:Controller -> Service -> Mapper
17
- - 参考 java-controller 技能获取更详细的 Controller 层规范
16
+ - 参考项目实际架构层次选择合适的分层模式
18
17
  ---
19
18
 
20
19
  # API 接口设计规范
@@ -23,22 +22,22 @@ description: |
23
22
 
24
23
  | 原则 | 说明 |
25
24
  |------|------|
26
- | 统一入口 | 所有接口使用 POST RESTful 风格 |
25
+ | RESTful 风格 | 使用标准 HTTP 方法表达语义 |
27
26
  | 认证保护 | 所有业务接口必须添加认证注解 |
28
27
  | 参数校验 | 使用分组校验区分新增/修改场景 |
29
28
  | 统一响应 | 使用统一的响应格式包装返回数据 |
30
29
 
31
30
  ### HTTP 方法规范
32
31
 
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` |
32
+ | 操作 | 方法 | 路径示例 |
33
+ |------|------|---------|
34
+ | 列表查询 | GET | `/list` 或 `/page` |
35
+ | 获取详情 | GET | `/{id}` |
36
+ | 新增 | POST | `/` 或 `/add` |
37
+ | 修改 | PUT | `/` 或 `/update` |
38
+ | 删除 | DELETE | `/{ids}` |
40
39
  | 导出 | POST | `/export` |
41
- | 导入 | POST | `/import-excel` |
40
+ | 导入 | POST | `/import` |
42
41
 
43
42
  ---
44
43
 
@@ -47,65 +46,106 @@ description: |
47
46
  ```java
48
47
  @Slf4j
49
48
  @RestController
50
- @RequiresAuthentication
51
- @RequestMapping("/module/feature")
52
- @Api(value = "模块/功能", tags = "模块/功能")
49
+ @RequiredArgsConstructor
50
+ @RequestMapping("/api/v1/[模块]/[功能]")
53
51
  public class XxxController {
54
52
 
55
- @Resource @Lazy
56
- private XxxService xxxService;
53
+ private final XxxService xxxService;
57
54
 
58
- @PostMapping("/add")
59
- @ApiOperation(value = "功能描述-新增")
60
- public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
61
- return xxxService.add(request.getContent());
55
+ /**
56
+ * 分页查询
57
+ */
58
+ @GetMapping("/page")
59
+ public Result<PageResult<XxxVO>> page(XxxQueryDTO query) {
60
+ return Result.ok(xxxService.pageList(query));
62
61
  }
63
62
 
64
- @PostMapping("/update")
65
- @ApiOperation(value = "功能描述-修改")
66
- public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request) {
67
- xxxService.update(request.getContent());
63
+ /**
64
+ * 获取详情
65
+ */
66
+ @GetMapping("/{id}")
67
+ public Result<XxxVO> getById(@PathVariable Long id) {
68
+ return Result.ok(xxxService.getById(id));
68
69
  }
69
70
 
70
- @PostMapping("/query")
71
- @ApiOperation(value = "功能描述-分页查询")
72
- public Page<XxxVO> query(@Validated @RequestBody LeRequest<XxxQueryParam> request) {
73
- return xxxService.pageList(request.getContent());
71
+ /**
72
+ * 新增
73
+ */
74
+ @PostMapping
75
+ public Result<Long> add(@Validated(InsertGroup.class) @RequestBody XxxDTO dto) {
76
+ return Result.ok(xxxService.add(dto));
74
77
  }
75
78
 
76
- @PostMapping("/delete")
77
- @ApiOperation(value = "功能描述-删除")
78
- public void delete(@RequestBody LeRequest<Long> request) {
79
- xxxService.delete(request.getContent());
79
+ /**
80
+ * 修改
81
+ */
82
+ @PutMapping
83
+ public Result<Void> update(@Validated(UpdateGroup.class) @RequestBody XxxDTO dto) {
84
+ xxxService.update(dto);
85
+ return Result.ok();
86
+ }
87
+
88
+ /**
89
+ * 删除
90
+ */
91
+ @DeleteMapping("/{ids}")
92
+ public Result<Void> delete(@PathVariable List<Long> ids) {
93
+ xxxService.deleteByIds(ids);
94
+ return Result.ok();
80
95
  }
81
96
  }
82
97
  ```
83
98
 
84
99
  ---
85
100
 
86
- ## 参数封装规范
101
+ ## 统一响应封装
87
102
 
88
- ### 请求参数用 LeRequest 包装
103
+ ### Result 包装类(通用模式)
89
104
 
90
105
  ```java
91
- @PostMapping("/query")
92
- public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
93
- return xxxService.pageList(request.getContent());
106
+ @Data
107
+ public class Result<T> {
108
+ private int code;
109
+ private String message;
110
+ private T data;
111
+
112
+ public static <T> Result<T> ok() {
113
+ return ok(null);
114
+ }
115
+
116
+ public static <T> Result<T> ok(T data) {
117
+ Result<T> result = new Result<>();
118
+ result.setCode(200);
119
+ result.setMessage("success");
120
+ result.setData(data);
121
+ return result;
122
+ }
123
+
124
+ public static <T> Result<T> fail(String message) {
125
+ Result<T> result = new Result<>();
126
+ result.setCode(500);
127
+ result.setMessage(message);
128
+ return result;
129
+ }
94
130
  }
95
131
  ```
96
132
 
97
- ### 分页参数
133
+ ### 分页响应
98
134
 
99
135
  ```java
100
136
  @Data
101
- public class XxxPageParam implements Serializable {
102
- @NotNull(message = "分页参数不能为空")
103
- private PageDTO page;
104
- private String keyword;
105
- private Integer status;
137
+ public class PageResult<T> {
138
+ private List<T> records;
139
+ private long total;
140
+ private long current;
141
+ private long size;
106
142
  }
107
143
  ```
108
144
 
145
+ ---
146
+
147
+ ## 参数校验
148
+
109
149
  ### 分组校验
110
150
 
111
151
  ```java
@@ -116,142 +156,152 @@ public class XxxDTO {
116
156
  private Long id;
117
157
 
118
158
  @NotBlank(message = "名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
159
+ @Size(max = 100, message = "名称长度不能超过100个字符")
119
160
  private String name;
161
+
162
+ @Min(value = 0, message = "排序不能为负数")
163
+ private Integer sort;
120
164
  }
121
165
 
122
166
  // Controller 中应用
123
- @PostMapping("/add")
124
- public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request)
125
- ```
167
+ @PostMapping
168
+ public Result<Long> add(@Validated(InsertGroup.class) @RequestBody XxxDTO dto) { ... }
126
169
 
127
- > Jakarta Validation: 项目用 JDK 21,必须 `import jakarta.validation.constraints.*`
170
+ @PutMapping
171
+ public Result<Void> update(@Validated(UpdateGroup.class) @RequestBody XxxDTO dto) { ... }
172
+ ```
128
173
 
129
- ---
174
+ > Jakarta Validation: JDK 17+ 必须 `import jakarta.validation.constraints.*`
130
175
 
131
- ## 响应格式
176
+ ### 查询参数
132
177
 
133
178
  ```java
134
- // 分页响应
135
- @PostMapping("/query")
136
- public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) { ... }
179
+ @Data
180
+ public class XxxQueryDTO {
181
+ private String keyword;
182
+ private Integer status;
137
183
 
138
- // 单条数据
139
- @GetMapping("/{id}")
140
- public XxxVO getById(@PathVariable Long id) { ... }
184
+ @Min(value = 1)
185
+ private Integer pageNum = 1;
141
186
 
142
- // 新增返回 ID / 修改删除返回 void
143
- @PostMapping("/add")
144
- public Long add(@RequestBody LeRequest<XxxDTO> request) { ... }
187
+ @Min(value = 1) @Max(value = 100)
188
+ private Integer pageSize = 10;
189
+ }
145
190
  ```
146
191
 
147
192
  ---
148
193
 
149
194
  ## 常见场景
150
195
 
151
- ### 带 Redisson 分布式锁的导入
196
+ ### 带分布式锁的导入
152
197
 
153
198
  ```java
154
- @PostMapping("/import-excel")
155
- @ApiOperation(value = "Excel导入")
156
- public void importExcel(@RequestParam(value = "file") MultipartFile file) {
157
- if (Objects.isNull(file) || file.isEmpty()) {
158
- throw new LeException("文件不能为空");
159
- }
160
- RLock lock = redissonClient.getLock("import:lock:" + TenantContextHolder.getTenantId());
161
- if (!lock.tryLock(5, 60, TimeUnit.SECONDS)) {
162
- throw new LeException("正在处理中,请稍后再试");
199
+ @PostMapping("/import")
200
+ public Result<Void> importExcel(@RequestPart("file") MultipartFile file) {
201
+ if (file == null || file.isEmpty()) {
202
+ throw new [你的异常类]("文件不能为空");
163
203
  }
204
+ RLock lock = redissonClient.getLock("import:lock:" + getCurrentTenantId());
164
205
  try {
165
- xxxService.importExcel(file);
166
- } finally {
167
- if (lock.isLocked() && lock.isHeldByCurrentThread()) {
168
- lock.unlock();
206
+ if (!lock.tryLock(5, 60, TimeUnit.SECONDS)) {
207
+ throw new [你的异常类]("正在处理中,请稍后再试");
208
+ }
209
+ try {
210
+ xxxService.importExcel(file);
211
+ } finally {
212
+ if (lock.isLocked() && lock.isHeldByCurrentThread()) {
213
+ lock.unlock();
214
+ }
169
215
  }
216
+ } catch (InterruptedException e) {
217
+ Thread.currentThread().interrupt();
218
+ throw new [你的异常类]("导入被中断");
170
219
  }
220
+ return Result.ok();
171
221
  }
172
222
  ```
173
223
 
174
224
  ### 批量删除
175
225
 
176
226
  ```java
177
- @RequestMapping(value = "/batch/delete", method = {RequestMethod.POST, RequestMethod.PUT})
178
- @ApiOperation(value = "批量删除")
179
- public void batchDelete(@RequestBody LeRequest<List<Long>> request) {
180
- if (CollUtil.isEmpty(request.getContent())) {
181
- throw new LeException("ID列表不能为空");
227
+ @DeleteMapping("/{ids}")
228
+ public Result<Void> delete(@PathVariable List<Long> ids) {
229
+ if (ids == null || ids.isEmpty()) {
230
+ throw new [你的异常类]("ID列表不能为空");
182
231
  }
183
- xxxService.batchDelete(request.getContent());
232
+ xxxService.deleteByIds(ids);
233
+ return Result.ok();
184
234
  }
185
235
  ```
186
236
 
187
- ### 带合计行的分页查询
237
+ ### 文件上传
188
238
 
189
239
  ```java
190
- @PostMapping("/query")
191
- @ApiOperation(value = "分页查询(带合计)")
192
- public ReportBaseTotalVO<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
193
- ReportBaseTotalVO<XxxVO> result = new ReportBaseTotalVO<>();
194
- result.setTotalLine(xxxService.getSummaryTotal(request.getContent()));
195
- result.setResultPage(PageVO.of(xxxService.pageList(request.getContent())));
196
- return result;
240
+ @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
241
+ public Result<UploadResult> upload(@RequestPart("file") MultipartFile file) {
242
+ return Result.ok(ossService.upload(file));
197
243
  }
198
244
  ```
199
245
 
200
246
  ---
201
247
 
202
- ## Swagger 注解
248
+ ## API 文档注解
249
+
250
+ ### Swagger / SpringDoc 注解
203
251
 
204
252
  ```java
205
- @Api(value = "模块/功能", tags = "模块/功能") // Controller 类
206
- @ApiOperation(value = "功能描述-新增") // 方法
207
- @ApiModel("功能描述DTO") // DTO/VO 类
208
- @ApiModelProperty(value = "主键ID", required = true) // 字段
253
+ // SpringDoc (OpenAPI 3.0, 推荐)
254
+ @Tag(name = "用户管理") // Controller 类
255
+ @Operation(summary = "新增用户") // 方法
256
+ @Schema(description = "用户DTO") // DTO/VO 类
257
+ @Schema(description = "主键ID", requiredMode = REQUIRED) // 字段
258
+
259
+ // Swagger 2 (旧项目)
260
+ @Api(value = "用户管理", tags = "用户管理")
261
+ @ApiOperation(value = "新增用户")
262
+ @ApiModel("用户DTO")
263
+ @ApiModelProperty(value = "主键ID", required = true)
209
264
  ```
210
265
 
211
266
  ---
212
267
 
213
- ## 检查清单
268
+ ## 全局异常处理
214
269
 
215
- - [ ] 认证注解 `@RequiresAuthentication`
216
- - [ ] API 文档注解 `@ApiOperation`
217
- - [ ] 参数校验 `@Validated` + 分组
218
- - [ ] 返回值类型正确(分页用 `Page<VO>`)
219
- - [ ] 使用 `LeRequest<T>` 封装请求
220
- - [ ] 敏感操作加分布式锁
270
+ ```java
271
+ @RestControllerAdvice
272
+ public class GlobalExceptionHandler {
221
273
 
222
- ---
274
+ @ExceptionHandler([你的异常类].class)
275
+ public Result<Void> handleBusinessException([你的异常类] e) {
276
+ return Result.fail(e.getMessage());
277
+ }
223
278
 
224
- ## 多项目对比
279
+ @ExceptionHandler(MethodArgumentNotValidException.class)
280
+ public Result<Void> handleValidException(MethodArgumentNotValidException e) {
281
+ String message = e.getBindingResult().getFieldErrors().stream()
282
+ .map(FieldError::getDefaultMessage)
283
+ .collect(Collectors.joining(", "));
284
+ return Result.fail(message);
285
+ }
225
286
 
226
- | 特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
227
- |-----|----------------|-------------------|
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()` |
287
+ @ExceptionHandler(Exception.class)
288
+ public Result<Void> handleException(Exception e) {
289
+ log.error("系统异常", e);
290
+ return Result.fail("系统繁忙,请稍后再试");
291
+ }
292
+ }
293
+ ```
236
294
 
237
295
  ---
238
296
 
239
- ## 错误对比
297
+ ## 检查清单
240
298
 
241
- ```java
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());
252
- }
253
- import jakarta.validation.constraints.NotNull;
254
- ```
299
+ - [ ] 认证注解(`@PreAuthorize` / `[你的认证注解]`)
300
+ - [ ] API 文档注解(`@Operation` / `@ApiOperation`)
301
+ - [ ] 参数校验 `@Validated` + 分组
302
+ - [ ] 统一响应包装 `Result<T>`
303
+ - [ ] 敏感操作加分布式锁
304
+ - [ ] 全局异常处理器已配置
255
305
 
256
306
  ---
257
307
 
@@ -259,8 +309,7 @@ import jakarta.validation.constraints.NotNull;
259
309
 
260
310
  | 需要了解 | Skill |
261
311
  |---------|-------|
262
- | Service 层 | `java-service` |
263
- | Controller 详细 | `java-controller` |
264
312
  | 异常处理 | `error-handler` |
265
- | 参数校验 | `java-entity` |
266
313
  | 数据库设计 | `database-ops` |
314
+ | 缓存 | `redis-cache` |
315
+ | 文件上传 | `file-oss-management` |