ai-engineering-init 1.3.4 → 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.
Files changed (226) hide show
  1. package/.claude/hooks/skill-forced-eval.js +2 -0
  2. package/.claude/settings.json +3 -3
  3. package/.claude/skills/add-skill/SKILL.md +79 -32
  4. package/.claude/skills/api-development/SKILL.md +83 -377
  5. package/.claude/skills/architecture-design/SKILL.md +138 -632
  6. package/.claude/skills/backend-annotations/SKILL.md +134 -506
  7. package/.claude/skills/banana-image/SKILL.md +10 -3
  8. package/.claude/skills/brainstorm/SKILL.md +103 -535
  9. package/.claude/skills/bug-detective/SKILL.md +147 -1097
  10. package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
  11. package/.claude/skills/code-patterns/SKILL.md +116 -426
  12. package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  13. package/.claude/skills/crud-development/SKILL.md +64 -304
  14. package/.claude/skills/data-permission/SKILL.md +105 -412
  15. package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
  16. package/.claude/skills/file-oss-management/SKILL.md +106 -714
  17. package/.claude/skills/file-oss-management/references/entities.md +105 -0
  18. package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
  19. package/.claude/skills/leniu-api-development/SKILL.md +142 -626
  20. package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
  21. package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
  22. package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
  23. package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
  24. package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  25. package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
  26. package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
  27. package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
  28. package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
  29. package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
  30. package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
  31. package/.claude/skills/leniu-java-export/SKILL.md +94 -379
  32. package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
  33. package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
  34. package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  35. package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
  36. package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  37. package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
  38. package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
  39. package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
  40. package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  41. package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  42. package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
  43. package/.claude/skills/mysql-debug/SKILL.md +364 -0
  44. package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
  45. package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
  46. package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  47. package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
  48. package/.claude/skills/openspec-explore/SKILL.md +10 -1
  49. package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
  50. package/.claude/skills/openspec-new-change/SKILL.md +9 -1
  51. package/.claude/skills/openspec-onboard/SKILL.md +15 -130
  52. package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
  53. package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
  54. package/.claude/skills/performance-doctor/SKILL.md +110 -434
  55. package/.claude/skills/redis-cache/SKILL.md +89 -595
  56. package/.claude/skills/redis-cache/references/listeners.md +23 -0
  57. package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
  58. package/.claude/skills/security-guard/SKILL.md +137 -532
  59. package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
  60. package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
  61. package/.claude/skills/sms-mail/SKILL.md +116 -574
  62. package/.claude/skills/sms-mail/references/mail-config.md +88 -0
  63. package/.claude/skills/sms-mail/references/sms-config.md +74 -0
  64. package/.claude/skills/social-login/SKILL.md +112 -514
  65. package/.claude/skills/social-login/references/provider-configs.md +118 -0
  66. package/.claude/skills/tenant-management/SKILL.md +129 -444
  67. package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
  68. package/.claude/skills/test-development/SKILL.md +86 -540
  69. package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
  70. package/.claude/skills/utils-toolkit/SKILL.md +52 -305
  71. package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  72. package/.claude/skills/websocket-sse/SKILL.md +105 -550
  73. package/.claude/skills/workflow-engine/SKILL.md +147 -502
  74. package/.codex/skills/add-skill/SKILL.md +79 -32
  75. package/.codex/skills/api-development/SKILL.md +172 -599
  76. package/.codex/skills/architecture-design/SKILL.md +138 -504
  77. package/.codex/skills/backend-annotations/SKILL.md +134 -496
  78. package/.codex/skills/banana-image/SKILL.md +10 -3
  79. package/.codex/skills/brainstorm/SKILL.md +103 -535
  80. package/.codex/skills/bug-detective/SKILL.md +147 -1097
  81. package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
  82. package/.codex/skills/code-patterns/SKILL.md +120 -282
  83. package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  84. package/.codex/skills/crud-development/SKILL.md +64 -292
  85. package/.codex/skills/data-permission/SKILL.md +108 -407
  86. package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
  87. package/.codex/skills/database-ops/SKILL.md +8 -154
  88. package/.codex/skills/error-handler/SKILL.md +10 -0
  89. package/.codex/skills/file-oss-management/SKILL.md +106 -714
  90. package/.codex/skills/file-oss-management/references/entities.md +105 -0
  91. package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
  92. package/.codex/skills/git-workflow/SKILL.md +27 -5
  93. package/.codex/skills/leniu-api-development/SKILL.md +142 -626
  94. package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
  95. package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
  96. package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
  97. package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
  98. package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  99. package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
  100. package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
  101. package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
  102. package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
  103. package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
  104. package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
  105. package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
  106. package/.codex/skills/leniu-java-export/SKILL.md +94 -379
  107. package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
  108. package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
  109. package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  110. package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
  111. package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  112. package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
  113. package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
  114. package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
  115. package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  116. package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  117. package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
  118. package/.codex/skills/mysql-debug/SKILL.md +364 -0
  119. package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
  120. package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
  121. package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  122. package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
  123. package/.codex/skills/openspec-explore/SKILL.md +10 -1
  124. package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
  125. package/.codex/skills/openspec-new-change/SKILL.md +9 -1
  126. package/.codex/skills/openspec-onboard/SKILL.md +15 -130
  127. package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
  128. package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
  129. package/.codex/skills/performance-doctor/SKILL.md +110 -434
  130. package/.codex/skills/project-navigator/SKILL.md +20 -1
  131. package/.codex/skills/redis-cache/SKILL.md +93 -589
  132. package/.codex/skills/redis-cache/references/listeners.md +23 -0
  133. package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
  134. package/.codex/skills/security-guard/SKILL.md +141 -527
  135. package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
  136. package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
  137. package/.codex/skills/sms-mail/SKILL.md +116 -574
  138. package/.codex/skills/sms-mail/references/mail-config.md +88 -0
  139. package/.codex/skills/sms-mail/references/sms-config.md +74 -0
  140. package/.codex/skills/social-login/SKILL.md +112 -514
  141. package/.codex/skills/social-login/references/provider-configs.md +118 -0
  142. package/.codex/skills/store-pc/SKILL.md +258 -383
  143. package/.codex/skills/tenant-management/SKILL.md +129 -444
  144. package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
  145. package/.codex/skills/test-development/SKILL.md +86 -540
  146. package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
  147. package/.codex/skills/ui-pc/SKILL.md +350 -387
  148. package/.codex/skills/utils-toolkit/SKILL.md +52 -283
  149. package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  150. package/.codex/skills/websocket-sse/SKILL.md +105 -550
  151. package/.codex/skills/workflow-engine/SKILL.md +147 -502
  152. package/.cursor/hooks.json +3 -3
  153. package/.cursor/skills/add-skill/SKILL.md +79 -32
  154. package/.cursor/skills/api-development/SKILL.md +83 -377
  155. package/.cursor/skills/architecture-design/SKILL.md +138 -632
  156. package/.cursor/skills/backend-annotations/SKILL.md +134 -506
  157. package/.cursor/skills/banana-image/SKILL.md +10 -3
  158. package/.cursor/skills/brainstorm/SKILL.md +103 -535
  159. package/.cursor/skills/bug-detective/SKILL.md +147 -1097
  160. package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
  161. package/.cursor/skills/code-patterns/SKILL.md +116 -426
  162. package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  163. package/.cursor/skills/crud-development/SKILL.md +64 -304
  164. package/.cursor/skills/data-permission/SKILL.md +105 -412
  165. package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
  166. package/.cursor/skills/file-oss-management/SKILL.md +106 -714
  167. package/.cursor/skills/file-oss-management/references/entities.md +105 -0
  168. package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
  169. package/.cursor/skills/git-workflow/SKILL.md +27 -5
  170. package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
  171. package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
  172. package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
  173. package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
  174. package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
  175. package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  176. package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
  177. package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
  178. package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
  179. package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
  180. package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
  181. package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
  182. package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
  183. package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
  184. package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
  185. package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
  186. package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  187. package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
  188. package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  189. package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
  190. package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
  191. package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
  192. package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  193. package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  194. package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
  195. package/.cursor/skills/mysql-debug/SKILL.md +364 -0
  196. package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
  197. package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
  198. package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  199. package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
  200. package/.cursor/skills/openspec-explore/SKILL.md +10 -1
  201. package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
  202. package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
  203. package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
  204. package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
  205. package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
  206. package/.cursor/skills/performance-doctor/SKILL.md +110 -434
  207. package/.cursor/skills/redis-cache/SKILL.md +89 -595
  208. package/.cursor/skills/redis-cache/references/listeners.md +23 -0
  209. package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
  210. package/.cursor/skills/security-guard/SKILL.md +137 -532
  211. package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
  212. package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
  213. package/.cursor/skills/sms-mail/SKILL.md +116 -574
  214. package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
  215. package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
  216. package/.cursor/skills/social-login/SKILL.md +112 -514
  217. package/.cursor/skills/social-login/references/provider-configs.md +118 -0
  218. package/.cursor/skills/tenant-management/SKILL.md +129 -444
  219. package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
  220. package/.cursor/skills/test-development/SKILL.md +86 -540
  221. package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
  222. package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
  223. package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  224. package/.cursor/skills/websocket-sse/SKILL.md +105 -550
  225. package/.cursor/skills/workflow-engine/SKILL.md +147 -502
  226. package/package.json +1 -1
@@ -13,7 +13,7 @@ description: |
13
13
  触发词:API、接口、RESTful、Controller、GetMapping、PostMapping、权限注解、日志注解、分页查询、接口规范
14
14
 
15
15
  注意:
16
- - 本项目是三层架构:Controller Service Mapper
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
- | **统一入口** | 所有接口使用 POST 或 RESTful 风格 |
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
- ## Controller 类模板
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
- ### 1. 请求参数封装
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
- XxxQueryParam param = request.getContent(); // 获取实际参数
101
- return xxxService.pageList(param);
93
+ return xxxService.pageList(request.getContent());
102
94
  }
103
95
  ```
104
96
 
105
- ### 2. 分页参数
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
- ### 3. 分组校验
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
- ### 1. 分页响应
131
+ ## 响应格式
154
132
 
155
133
  ```java
156
- // 使用 MyBatis-Plus 的 Page 对象
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 void add(@RequestBody LeRequest<XxxDTO> request) {
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
- ## API 文档注解
149
+ ## 常见场景
259
150
 
260
- ### Swagger 注解使用
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
- ### 2. 批量删除
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
- ### 3. 带合计行的分页查询
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
- // 错误 1: 缺少认证注解
378
- @RestController
379
- public class XxxController { }
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
- | 需要了解 | 激活 Skill |
419
- |---------|-----------|
420
- | Service 层规范 | `java-service` |
421
- | Controller 详细规范 | `java-controller` |
422
- | 异常处理 | `java-exception` / `error-handler` |
423
- | 参数校验详细 | `java-entity` |
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
- | **JDK 版本** | 17 | 21 |
435
- | **包名前缀** | `org.dromara.*` | `net.xnzn.core.*` |
436
- | **请求封装** | 直接使用 BO | `LeRequest<T>` 包装 |
437
- | **响应封装** | `R<T>`, `TableDataInfo<T>` | `Page<T>`, `void` |
438
- | **分组校验** | `AddGroup`, `EditGroup` | `InsertGroup`, `UpdateGroup` |
439
- | **认证注解** | `@SaCheckPermission` | `@RequiresAuthentication` |
440
- | **异常类** | `ServiceException` | `LeException` |
441
- | **国际化** | `MessageUtils.message()` | `I18n.getMessage()` |
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
- ```java
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
- @RequestMapping(value = "/batch/delete", method = {RequestMethod.POST, RequestMethod.PUT})
522
- @ApiOperation(value = "批量删除")
523
- public void batchDelete(@RequestBody LeRequest<List<Long>> request) {
524
- // 使用 Hutool CollUtil 进行判空
525
- if (CollUtil.isEmpty(request.getContent())) {
526
- throw new LeException("ID列表不能为空");
527
- }
528
- xxxService.batchDelete(request.getContent());
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
- // 2. 分页查询
555
- Page<XxxVO> page = xxxService.pageList(request.getContent());
556
- result.setResultPage(PageVO.of(page));
258
+ ## 相关技能
557
259
 
558
- return result;
559
- }
560
- ```
260
+ | 需要了解 | Skill |
261
+ |---------|-------|
262
+ | Service 层 | `java-service` |
263
+ | Controller 详细 | `java-controller` |
264
+ | 异常处理 | `error-handler` |
265
+ | 参数校验 | `java-entity` |
266
+ | 数据库设计 | `database-ops` |