ai-engineering-init 1.7.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 (118) hide show
  1. package/.claude/hooks/skill-forced-eval.js +46 -62
  2. package/.claude/settings.json +10 -1
  3. package/.claude/skills/api-development/SKILL.md +179 -130
  4. package/.claude/skills/architecture-design/SKILL.md +102 -212
  5. package/.claude/skills/backend-annotations/SKILL.md +166 -220
  6. package/.claude/skills/bug-detective/SKILL.md +225 -186
  7. package/.claude/skills/code-patterns/SKILL.md +127 -244
  8. package/.claude/skills/collaborating-with-codex/SKILL.md +96 -113
  9. package/.claude/skills/crud-development/SKILL.md +226 -307
  10. package/.claude/skills/data-permission/SKILL.md +131 -202
  11. package/.claude/skills/database-ops/SKILL.md +158 -355
  12. package/.claude/skills/error-handler/SKILL.md +224 -285
  13. package/.claude/skills/file-oss-management/SKILL.md +174 -169
  14. package/.claude/skills/git-workflow/SKILL.md +123 -341
  15. package/.claude/skills/json-serialization/SKILL.md +121 -137
  16. package/.claude/skills/performance-doctor/SKILL.md +83 -89
  17. package/.claude/skills/redis-cache/SKILL.md +134 -185
  18. package/.claude/skills/scheduled-jobs/SKILL.md +187 -224
  19. package/.claude/skills/security-guard/SKILL.md +168 -276
  20. package/.claude/skills/sms-mail/SKILL.md +266 -228
  21. package/.claude/skills/social-login/SKILL.md +257 -195
  22. package/.claude/skills/tenant-management/SKILL.md +172 -188
  23. package/.claude/skills/utils-toolkit/SKILL.md +214 -222
  24. package/.claude/skills/websocket-sse/SKILL.md +251 -172
  25. package/.claude/skills/workflow-engine/SKILL.md +178 -250
  26. package/.codex/skills/api-development/SKILL.md +179 -130
  27. package/.codex/skills/architecture-design/SKILL.md +102 -212
  28. package/.codex/skills/backend-annotations/SKILL.md +166 -220
  29. package/.codex/skills/bug-detective/SKILL.md +225 -186
  30. package/.codex/skills/code-patterns/SKILL.md +127 -244
  31. package/.codex/skills/collaborating-with-codex/SKILL.md +96 -113
  32. package/.codex/skills/crud-development/SKILL.md +226 -307
  33. package/.codex/skills/data-permission/SKILL.md +131 -202
  34. package/.codex/skills/database-ops/SKILL.md +158 -355
  35. package/.codex/skills/error-handler/SKILL.md +224 -285
  36. package/.codex/skills/file-oss-management/SKILL.md +174 -169
  37. package/.codex/skills/git-workflow/SKILL.md +123 -341
  38. package/.codex/skills/json-serialization/SKILL.md +121 -137
  39. package/.codex/skills/performance-doctor/SKILL.md +83 -89
  40. package/.codex/skills/redis-cache/SKILL.md +134 -185
  41. package/.codex/skills/scheduled-jobs/SKILL.md +187 -224
  42. package/.codex/skills/security-guard/SKILL.md +168 -276
  43. package/.codex/skills/sms-mail/SKILL.md +266 -228
  44. package/.codex/skills/social-login/SKILL.md +257 -195
  45. package/.codex/skills/tenant-management/SKILL.md +172 -188
  46. package/.codex/skills/utils-toolkit/SKILL.md +214 -222
  47. package/.codex/skills/websocket-sse/SKILL.md +251 -172
  48. package/.codex/skills/workflow-engine/SKILL.md +178 -250
  49. package/.cursor/hooks/cursor-skill-eval.js +66 -6
  50. package/.cursor/skills/api-development/SKILL.md +179 -130
  51. package/.cursor/skills/architecture-design/SKILL.md +102 -212
  52. package/.cursor/skills/backend-annotations/SKILL.md +166 -220
  53. package/.cursor/skills/bug-detective/SKILL.md +225 -186
  54. package/.cursor/skills/code-patterns/SKILL.md +127 -244
  55. package/.cursor/skills/collaborating-with-codex/SKILL.md +96 -113
  56. package/.cursor/skills/crud-development/SKILL.md +226 -307
  57. package/.cursor/skills/data-permission/SKILL.md +131 -202
  58. package/.cursor/skills/database-ops/SKILL.md +158 -355
  59. package/.cursor/skills/error-handler/SKILL.md +224 -285
  60. package/.cursor/skills/file-oss-management/SKILL.md +174 -169
  61. package/.cursor/skills/git-workflow/SKILL.md +123 -341
  62. package/.cursor/skills/json-serialization/SKILL.md +121 -137
  63. package/.cursor/skills/performance-doctor/SKILL.md +83 -89
  64. package/.cursor/skills/redis-cache/SKILL.md +134 -185
  65. package/.cursor/skills/scheduled-jobs/SKILL.md +187 -224
  66. package/.cursor/skills/security-guard/SKILL.md +168 -276
  67. package/.cursor/skills/sms-mail/SKILL.md +266 -228
  68. package/.cursor/skills/social-login/SKILL.md +257 -195
  69. package/.cursor/skills/tenant-management/SKILL.md +172 -188
  70. package/.cursor/skills/utils-toolkit/SKILL.md +214 -222
  71. package/.cursor/skills/websocket-sse/SKILL.md +251 -172
  72. package/.cursor/skills/workflow-engine/SKILL.md +178 -250
  73. package/AGENTS.md +49 -540
  74. package/CLAUDE.md +73 -119
  75. package/README.md +37 -6
  76. package/bin/index.js +5 -1
  77. package/package.json +1 -1
  78. package/src/skills/api-development/SKILL.md +179 -130
  79. package/src/skills/architecture-design/SKILL.md +102 -212
  80. package/src/skills/backend-annotations/SKILL.md +166 -220
  81. package/src/skills/bug-detective/SKILL.md +225 -186
  82. package/src/skills/code-patterns/SKILL.md +127 -244
  83. package/src/skills/collaborating-with-codex/SKILL.md +96 -113
  84. package/src/skills/crud-development/SKILL.md +226 -307
  85. package/src/skills/data-permission/SKILL.md +131 -202
  86. package/src/skills/database-ops/SKILL.md +158 -355
  87. package/src/skills/error-handler/SKILL.md +224 -285
  88. package/src/skills/file-oss-management/SKILL.md +174 -169
  89. package/src/skills/git-workflow/SKILL.md +123 -341
  90. package/src/skills/json-serialization/SKILL.md +121 -137
  91. package/src/skills/performance-doctor/SKILL.md +83 -89
  92. package/src/skills/redis-cache/SKILL.md +134 -185
  93. package/src/skills/scheduled-jobs/SKILL.md +187 -224
  94. package/src/skills/security-guard/SKILL.md +168 -276
  95. package/src/skills/sms-mail/SKILL.md +266 -228
  96. package/src/skills/social-login/SKILL.md +257 -195
  97. package/src/skills/tenant-management/SKILL.md +172 -188
  98. package/src/skills/utils-toolkit/SKILL.md +214 -222
  99. package/src/skills/websocket-sse/SKILL.md +251 -172
  100. package/src/skills/workflow-engine/SKILL.md +178 -250
  101. package/.claude/skills/skill-creator/LICENSE.txt +0 -202
  102. package/.claude/skills/skill-creator/SKILL.md +0 -479
  103. package/.claude/skills/skill-creator/agents/analyzer.md +0 -274
  104. package/.claude/skills/skill-creator/agents/comparator.md +0 -202
  105. package/.claude/skills/skill-creator/agents/grader.md +0 -223
  106. package/.claude/skills/skill-creator/assets/eval_review.html +0 -146
  107. package/.claude/skills/skill-creator/eval-viewer/generate_review.py +0 -471
  108. package/.claude/skills/skill-creator/eval-viewer/viewer.html +0 -1325
  109. package/.claude/skills/skill-creator/references/schemas.md +0 -430
  110. package/.claude/skills/skill-creator/scripts/__init__.py +0 -0
  111. package/.claude/skills/skill-creator/scripts/aggregate_benchmark.py +0 -401
  112. package/.claude/skills/skill-creator/scripts/generate_report.py +0 -326
  113. package/.claude/skills/skill-creator/scripts/improve_description.py +0 -248
  114. package/.claude/skills/skill-creator/scripts/package_skill.py +0 -136
  115. package/.claude/skills/skill-creator/scripts/quick_validate.py +0 -103
  116. package/.claude/skills/skill-creator/scripts/run_eval.py +0 -310
  117. package/.claude/skills/skill-creator/scripts/run_loop.py +0 -332
  118. package/.claude/skills/skill-creator/scripts/utils.py +0 -47
@@ -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` |