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.
- package/.claude/agents/code-reviewer.md +3 -130
- package/.claude/hooks/skill-forced-eval.js +46 -60
- package/.claude/hooks/stop.js +24 -1
- package/.claude/settings.json +10 -1
- package/.claude/skills/api-development/SKILL.md +179 -130
- package/.claude/skills/architecture-design/SKILL.md +102 -212
- package/.claude/skills/backend-annotations/SKILL.md +166 -220
- package/.claude/skills/bug-detective/SKILL.md +225 -186
- package/.claude/skills/code-patterns/SKILL.md +127 -244
- package/.claude/skills/codex-code-review/SKILL.md +327 -0
- package/.claude/skills/collaborating-with-codex/SKILL.md +96 -113
- package/.claude/skills/crud-development/SKILL.md +226 -307
- package/.claude/skills/data-permission/SKILL.md +131 -202
- package/.claude/skills/database-ops/SKILL.md +158 -355
- package/.claude/skills/error-handler/SKILL.md +224 -285
- package/.claude/skills/file-oss-management/SKILL.md +174 -169
- package/.claude/skills/git-workflow/SKILL.md +123 -341
- package/.claude/skills/json-serialization/SKILL.md +121 -137
- package/.claude/skills/leniu-report-customization/SKILL.md +82 -2
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +65 -2
- package/.claude/skills/loki-log-query/SKILL.md +400 -0
- package/.claude/skills/mysql-debug/SKILL.md +58 -22
- package/.claude/skills/performance-doctor/SKILL.md +83 -89
- package/.claude/skills/redis-cache/SKILL.md +134 -185
- package/.claude/skills/scheduled-jobs/SKILL.md +187 -224
- package/.claude/skills/security-guard/SKILL.md +168 -276
- package/.claude/skills/sms-mail/SKILL.md +266 -228
- package/.claude/skills/social-login/SKILL.md +257 -195
- package/.claude/skills/sync-back-merge/SKILL.md +66 -0
- package/.claude/skills/tenant-management/SKILL.md +172 -188
- package/.claude/skills/utils-toolkit/SKILL.md +214 -222
- package/.claude/skills/websocket-sse/SKILL.md +251 -172
- package/.claude/skills/workflow-engine/SKILL.md +178 -250
- package/.claude/skills/yunxiao-task-management/SKILL.md +489 -0
- package/.codex/skills/api-development/SKILL.md +179 -130
- package/.codex/skills/architecture-design/SKILL.md +102 -212
- package/.codex/skills/backend-annotations/SKILL.md +166 -220
- package/.codex/skills/bug-detective/SKILL.md +225 -186
- package/.codex/skills/code-patterns/SKILL.md +127 -244
- package/.codex/skills/collaborating-with-codex/SKILL.md +96 -113
- package/.codex/skills/crud-development/SKILL.md +226 -307
- package/.codex/skills/data-permission/SKILL.md +131 -202
- package/.codex/skills/database-ops/SKILL.md +158 -355
- package/.codex/skills/error-handler/SKILL.md +224 -285
- package/.codex/skills/file-oss-management/SKILL.md +174 -169
- package/.codex/skills/git-workflow/SKILL.md +123 -341
- package/.codex/skills/json-serialization/SKILL.md +121 -137
- package/.codex/skills/leniu-report-customization/SKILL.md +82 -2
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +65 -2
- package/.codex/skills/loki-log-query/SKILL.md +400 -0
- package/.codex/skills/loki-log-query/environments.json +45 -0
- package/.codex/skills/mysql-debug/SKILL.md +58 -22
- package/.codex/skills/performance-doctor/SKILL.md +83 -89
- package/.codex/skills/redis-cache/SKILL.md +134 -185
- package/.codex/skills/scheduled-jobs/SKILL.md +187 -224
- package/.codex/skills/security-guard/SKILL.md +168 -276
- package/.codex/skills/skill-creator/LICENSE.txt +202 -0
- package/.codex/skills/skill-creator/SKILL.md +479 -0
- package/.codex/skills/skill-creator/agents/analyzer.md +274 -0
- package/.codex/skills/skill-creator/agents/comparator.md +202 -0
- package/.codex/skills/skill-creator/agents/grader.md +223 -0
- package/.codex/skills/skill-creator/assets/eval_review.html +146 -0
- package/.codex/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/.codex/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/.codex/skills/skill-creator/references/schemas.md +430 -0
- package/.codex/skills/skill-creator/scripts/__init__.py +0 -0
- package/.codex/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/.codex/skills/skill-creator/scripts/generate_report.py +326 -0
- package/.codex/skills/skill-creator/scripts/improve_description.py +248 -0
- package/.codex/skills/skill-creator/scripts/package_skill.py +136 -0
- package/.codex/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/.codex/skills/skill-creator/scripts/run_eval.py +310 -0
- package/.codex/skills/skill-creator/scripts/run_loop.py +332 -0
- package/.codex/skills/skill-creator/scripts/utils.py +47 -0
- package/.codex/skills/sms-mail/SKILL.md +266 -228
- package/.codex/skills/social-login/SKILL.md +257 -195
- package/.codex/skills/sync-back-merge/SKILL.md +66 -0
- package/.codex/skills/tenant-management/SKILL.md +172 -188
- package/.codex/skills/utils-toolkit/SKILL.md +214 -222
- package/.codex/skills/websocket-sse/SKILL.md +251 -172
- package/.codex/skills/workflow-engine/SKILL.md +178 -250
- package/.codex/skills/yunxiao-task-management/SKILL.md +489 -0
- package/.cursor/hooks/cursor-skill-eval.js +66 -6
- package/.cursor/hooks/stop.js +23 -1
- package/.cursor/skills/api-development/SKILL.md +179 -130
- package/.cursor/skills/architecture-design/SKILL.md +102 -212
- package/.cursor/skills/backend-annotations/SKILL.md +166 -220
- package/.cursor/skills/bug-detective/SKILL.md +225 -186
- package/.cursor/skills/code-patterns/SKILL.md +127 -244
- package/.cursor/skills/collaborating-with-codex/SKILL.md +96 -113
- package/.cursor/skills/crud-development/SKILL.md +226 -307
- package/.cursor/skills/data-permission/SKILL.md +131 -202
- package/.cursor/skills/database-ops/SKILL.md +158 -355
- package/.cursor/skills/error-handler/SKILL.md +224 -285
- package/.cursor/skills/file-oss-management/SKILL.md +174 -169
- package/.cursor/skills/git-workflow/SKILL.md +123 -341
- package/.cursor/skills/json-serialization/SKILL.md +121 -137
- package/.cursor/skills/leniu-report-customization/SKILL.md +82 -2
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +65 -2
- package/.cursor/skills/loki-log-query/SKILL.md +400 -0
- package/.cursor/skills/loki-log-query/environments.json +45 -0
- package/.cursor/skills/mysql-debug/SKILL.md +58 -22
- package/.cursor/skills/performance-doctor/SKILL.md +83 -89
- package/.cursor/skills/redis-cache/SKILL.md +134 -185
- package/.cursor/skills/scheduled-jobs/SKILL.md +187 -224
- package/.cursor/skills/security-guard/SKILL.md +168 -276
- package/.cursor/skills/skill-creator/LICENSE.txt +202 -0
- package/.cursor/skills/skill-creator/SKILL.md +479 -0
- package/.cursor/skills/skill-creator/agents/analyzer.md +274 -0
- package/.cursor/skills/skill-creator/agents/comparator.md +202 -0
- package/.cursor/skills/skill-creator/agents/grader.md +223 -0
- package/.cursor/skills/skill-creator/assets/eval_review.html +146 -0
- package/.cursor/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/.cursor/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/.cursor/skills/skill-creator/references/schemas.md +430 -0
- package/.cursor/skills/skill-creator/scripts/__init__.py +0 -0
- package/.cursor/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/.cursor/skills/skill-creator/scripts/generate_report.py +326 -0
- package/.cursor/skills/skill-creator/scripts/improve_description.py +248 -0
- package/.cursor/skills/skill-creator/scripts/package_skill.py +136 -0
- package/.cursor/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/.cursor/skills/skill-creator/scripts/run_eval.py +310 -0
- package/.cursor/skills/skill-creator/scripts/run_loop.py +332 -0
- package/.cursor/skills/skill-creator/scripts/utils.py +47 -0
- package/.cursor/skills/sms-mail/SKILL.md +266 -228
- package/.cursor/skills/social-login/SKILL.md +257 -195
- package/.cursor/skills/sync-back-merge/SKILL.md +66 -0
- package/.cursor/skills/tenant-management/SKILL.md +172 -188
- package/.cursor/skills/utils-toolkit/SKILL.md +214 -222
- package/.cursor/skills/websocket-sse/SKILL.md +251 -172
- package/.cursor/skills/workflow-engine/SKILL.md +178 -250
- package/.cursor/skills/yunxiao-task-management/SKILL.md +489 -0
- package/AGENTS.md +49 -540
- package/CLAUDE.md +73 -119
- package/README.md +37 -6
- package/bin/index.js +611 -25
- package/package.json +1 -1
- package/src/platform-map.json +4 -0
- package/src/skills/api-development/SKILL.md +179 -130
- package/src/skills/architecture-design/SKILL.md +102 -212
- package/src/skills/backend-annotations/SKILL.md +166 -220
- package/src/skills/bug-detective/SKILL.md +225 -186
- package/src/skills/code-patterns/SKILL.md +127 -244
- package/src/skills/codex-code-review/SKILL.md +261 -69
- package/src/skills/collaborating-with-codex/SKILL.md +96 -113
- package/src/skills/crud-development/SKILL.md +226 -307
- package/src/skills/data-permission/SKILL.md +131 -202
- package/src/skills/database-ops/SKILL.md +158 -355
- package/src/skills/error-handler/SKILL.md +224 -285
- package/src/skills/file-oss-management/SKILL.md +174 -169
- package/src/skills/git-workflow/SKILL.md +123 -341
- package/src/skills/json-serialization/SKILL.md +121 -137
- package/src/skills/leniu-report-customization/SKILL.md +82 -2
- package/src/skills/leniu-report-standard-customization/SKILL.md +65 -2
- package/src/skills/loki-log-query/SKILL.md +400 -0
- package/src/skills/loki-log-query/environments.json +45 -0
- package/src/skills/mysql-debug/SKILL.md +58 -22
- package/src/skills/performance-doctor/SKILL.md +83 -89
- package/src/skills/redis-cache/SKILL.md +134 -185
- package/src/skills/scheduled-jobs/SKILL.md +187 -224
- package/src/skills/security-guard/SKILL.md +168 -276
- package/src/skills/skill-creator/LICENSE.txt +202 -0
- package/src/skills/skill-creator/SKILL.md +479 -0
- package/src/skills/skill-creator/agents/analyzer.md +274 -0
- package/src/skills/skill-creator/agents/comparator.md +202 -0
- package/src/skills/skill-creator/agents/grader.md +223 -0
- package/src/skills/skill-creator/assets/eval_review.html +146 -0
- package/src/skills/skill-creator/eval-viewer/generate_review.py +471 -0
- package/src/skills/skill-creator/eval-viewer/viewer.html +1325 -0
- package/src/skills/skill-creator/references/schemas.md +430 -0
- package/src/skills/skill-creator/scripts/__init__.py +0 -0
- package/src/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
- package/src/skills/skill-creator/scripts/generate_report.py +326 -0
- package/src/skills/skill-creator/scripts/improve_description.py +248 -0
- package/src/skills/skill-creator/scripts/package_skill.py +136 -0
- package/src/skills/skill-creator/scripts/quick_validate.py +103 -0
- package/src/skills/skill-creator/scripts/run_eval.py +310 -0
- package/src/skills/skill-creator/scripts/run_loop.py +332 -0
- package/src/skills/skill-creator/scripts/utils.py +47 -0
- package/src/skills/sms-mail/SKILL.md +266 -228
- package/src/skills/social-login/SKILL.md +257 -195
- package/src/skills/sync-back-merge/SKILL.md +66 -0
- package/src/skills/tenant-management/SKILL.md +172 -188
- package/src/skills/utils-toolkit/SKILL.md +214 -222
- package/src/skills/websocket-sse/SKILL.md +251 -172
- package/src/skills/workflow-engine/SKILL.md +178 -250
- 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
|
|
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
|
-
-
|
|
17
|
-
- 参考 java-controller 技能获取更详细的 Controller 层规范
|
|
16
|
+
- 参考项目实际架构层次选择合适的分层模式
|
|
18
17
|
---
|
|
19
18
|
|
|
20
19
|
# API 接口设计规范
|
|
@@ -23,22 +22,22 @@ description: |
|
|
|
23
22
|
|
|
24
23
|
| 原则 | 说明 |
|
|
25
24
|
|------|------|
|
|
26
|
-
|
|
|
25
|
+
| RESTful 风格 | 使用标准 HTTP 方法表达语义 |
|
|
27
26
|
| 认证保护 | 所有业务接口必须添加认证注解 |
|
|
28
27
|
| 参数校验 | 使用分组校验区分新增/修改场景 |
|
|
29
28
|
| 统一响应 | 使用统一的响应格式包装返回数据 |
|
|
30
29
|
|
|
31
30
|
### HTTP 方法规范
|
|
32
31
|
|
|
33
|
-
| 操作 | 方法 |
|
|
34
|
-
|
|
35
|
-
| 列表查询 |
|
|
36
|
-
| 获取详情 |
|
|
37
|
-
| 新增 | POST | `/add` |
|
|
38
|
-
| 修改 |
|
|
39
|
-
| 删除 |
|
|
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
|
|
40
|
+
| 导入 | POST | `/import` |
|
|
42
41
|
|
|
43
42
|
---
|
|
44
43
|
|
|
@@ -47,65 +46,106 @@ description: |
|
|
|
47
46
|
```java
|
|
48
47
|
@Slf4j
|
|
49
48
|
@RestController
|
|
50
|
-
@
|
|
51
|
-
@RequestMapping("/
|
|
52
|
-
@Api(value = "模块/功能", tags = "模块/功能")
|
|
49
|
+
@RequiredArgsConstructor
|
|
50
|
+
@RequestMapping("/api/v1/[模块]/[功能]")
|
|
53
51
|
public class XxxController {
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
private XxxService xxxService;
|
|
53
|
+
private final XxxService xxxService;
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
###
|
|
103
|
+
### Result 包装类(通用模式)
|
|
89
104
|
|
|
90
105
|
```java
|
|
91
|
-
@
|
|
92
|
-
public
|
|
93
|
-
|
|
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
|
|
102
|
-
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
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
|
|
124
|
-
public Long add(@Validated(InsertGroup.class) @RequestBody
|
|
125
|
-
```
|
|
167
|
+
@PostMapping
|
|
168
|
+
public Result<Long> add(@Validated(InsertGroup.class) @RequestBody XxxDTO dto) { ... }
|
|
126
169
|
|
|
127
|
-
|
|
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
|
-
|
|
136
|
-
|
|
179
|
+
@Data
|
|
180
|
+
public class XxxQueryDTO {
|
|
181
|
+
private String keyword;
|
|
182
|
+
private Integer status;
|
|
137
183
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
public XxxVO getById(@PathVariable Long id) { ... }
|
|
184
|
+
@Min(value = 1)
|
|
185
|
+
private Integer pageNum = 1;
|
|
141
186
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
###
|
|
196
|
+
### 带分布式锁的导入
|
|
152
197
|
|
|
153
198
|
```java
|
|
154
|
-
@PostMapping("/import
|
|
155
|
-
@
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
@
|
|
178
|
-
@
|
|
179
|
-
|
|
180
|
-
|
|
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.
|
|
232
|
+
xxxService.deleteByIds(ids);
|
|
233
|
+
return Result.ok();
|
|
184
234
|
}
|
|
185
235
|
```
|
|
186
236
|
|
|
187
|
-
###
|
|
237
|
+
### 文件上传
|
|
188
238
|
|
|
189
239
|
```java
|
|
190
|
-
@PostMapping("/
|
|
191
|
-
@
|
|
192
|
-
|
|
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
|
-
##
|
|
248
|
+
## API 文档注解
|
|
249
|
+
|
|
250
|
+
### Swagger / SpringDoc 注解
|
|
203
251
|
|
|
204
252
|
```java
|
|
205
|
-
|
|
206
|
-
@
|
|
207
|
-
@
|
|
208
|
-
@
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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` |
|