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,280 +1,163 @@
1
1
  ---
2
2
  name: code-patterns
3
3
  description: |
4
- 后端代码禁令和编码规范速查。本项目是纯后端项目,前端代码在分离的项目中开发。
5
-
6
- 触发场景:
7
- - 查看项目禁止事项(后端代码)
8
- - 命名规范速查
9
- - Git 提交规范
10
- - 代码风格检查
11
- - 避免过度工程
12
-
13
- 触发词:规范、禁止、命名、Git提交、代码风格、不能用、不允许、包名、架构
14
-
15
- 注意:后端 CRUD 开发规范请激活 crud-development,API 开发规范请激活 api-development,数据库设计规范请激活 database-ops。
4
+ 通用编码规范指南。涵盖 RESTful API 设计、命名规范、Git 提交规范、代码风格等。
5
+ 触发场景:代码审查、规范检查、命名讨论、API 设计。
6
+ 触发词:编码规范、代码风格、命名规范、RESTful、Git 提交。
7
+ 注意:如果项目有专属技能(如 `leniu-code-patterns`),优先使用专属版本。
16
8
  ---
17
9
 
18
- # 代码规范速查
19
-
20
- ## 后端禁令速查表
21
-
22
- | # | 禁止项 | 错误写法 | 正确写法 |
23
- |---|--------|---------|---------|
24
- | 1 | 包名 | `com.ruoyi.*` / `plus.ruoyi.*` | `org.dromara.*` |
25
- | 2 | 完整引用 | `org.dromara.xxx.Xxx` 内联 | `import` + 短类名 |
26
- | 3 | 数据返回 | `Map<String, Object>` | 创建 VO 类 |
27
- | 4 | Service设计 | `extends ServiceImpl<>` | `implements IXxxService` |
28
- | 5 | 查询构建 | Controller 层 | **Service 层** `buildQueryWrapper()` |
29
- | 6 | 接口路径 | `/pageXxxs`, `/getXxx/{id}` | `/list`, `/{id}`, `/` |
30
- | 7 | 对象转换 | `BeanUtil.copyProperties()` | `MapstructUtils.convert()` |
31
- | 8 | 主键 | `AUTO_INCREMENT` | 雪花ID(不指定type) |
32
- | 9 | R.ok(string) | `R.ok(token)` | `R.ok(null, token)` |
33
- | 10 | Entity基类 | 无基类 | `extends TenantEntity` / `BaseEntity` |
34
- | 11 | @Cacheable | 返回 `List.of()`/`Set.of()` | `new ArrayList<>(List.of())` |
35
- | 12 | Mapper注解 | 单目标用 `@AutoMappers` | 单目标用 `@AutoMapper` |
36
- | 13 | 注释语言 | 英文注释 | **中文注释** |
37
- | 14 | SQL COMMENT | `COMMENT 'user name'` | `COMMENT '用户名'` |
38
-
39
- ---
40
-
41
- ## 禁令详解
42
-
43
- ### 1-2. 包名与引用
44
-
45
- ```java
46
- // ✅
47
- package org.dromara.system.service;
48
- import org.dromara.common.core.domain.R;
49
- public R<XxxVo> getXxx(Long id) { ... }
50
-
51
- // ❌
52
- package com.ruoyi.system.service;
53
- public org.dromara.common.core.domain.R<XxxVo> getXxx(Long id) { ... }
54
- ```
55
-
56
- ### 3. 禁止 Map 传业务数据
10
+ # 编码规范指南
57
11
 
58
- ```java
59
- // ✅ 创建 VO 类
60
- public XxxVo getXxx(Long id) {
61
- return MapstructUtils.convert(entity, XxxVo.class);
62
- }
12
+ > 通用模板。如果项目有专属技能(如 `leniu-code-patterns`),优先使用。
63
13
 
64
- //
65
- public Map<String, Object> getXxx(Long id) { ... }
66
- ```
14
+ ## 核心规范
67
15
 
68
- ### 4-5. Service 架构
16
+ ### RESTful API 设计
69
17
 
70
- ```java
71
- // ✅ 三层架构:不继承 ServiceImpl,直接注入 Mapper
72
- @Service
73
- public class XxxServiceImpl implements IXxxService {
74
- private final XxxMapper baseMapper;
75
-
76
- private LambdaQueryWrapper<Xxx> buildQueryWrapper(XxxBo bo) {
77
- LambdaQueryWrapper<Xxx> lqw = Wrappers.lambdaQuery();
78
- lqw.eq(bo.getStatus() != null, Xxx::getStatus, bo.getStatus());
79
- lqw.like(StringUtils.isNotBlank(bo.getName()), Xxx::getName, bo.getName());
80
- return lqw;
81
- }
82
- }
18
+ | 操作 | HTTP 方法 | URL 示例 | 说明 |
19
+ |------|----------|---------|------|
20
+ | 创建 | POST | `/api/v1/orders` | 请求体传参 |
21
+ | 查询列表 | GET | `/api/v1/orders` | Query 参数分页 |
22
+ | 查询详情 | GET | `/api/v1/orders/{id}` | 路径参数 |
23
+ | 全量更新 | PUT | `/api/v1/orders/{id}` | 请求体传参 |
24
+ | 部分更新 | PATCH | `/api/v1/orders/{id}` | 请求体传参 |
25
+ | 删除 | DELETE | `/api/v1/orders/{id}` | 路径参数 |
83
26
 
84
- //
85
- public class XxxServiceImpl extends ServiceImpl<XxxMapper, Xxx> { }
86
- ```
27
+ **URL 规范**:
28
+ - 使用名词复数:`/orders` 而非 `/order`
29
+ - 使用小写连字符:`/order-items` 而非 `/orderItems`
30
+ - 版本号放 URL 前缀:`/api/v1/`
31
+ - 嵌套资源不超过两层:`/orders/{id}/items`
87
32
 
88
- ### 6. RESTful 路径
33
+ ### 命名规范
89
34
 
90
- ```java
91
- // ✅
92
- @GetMapping("/list") @GetMapping("/{id}")
93
- @PostMapping @PutMapping
94
- @DeleteMapping("/{ids}") @PostMapping("/export")
95
-
96
- //
97
- @GetMapping("/pageAds") @GetMapping("/getAd/{id}")
98
- @PostMapping("/addAd") @PutMapping("/updateAd")
99
- ```
100
-
101
- ### 7. 对象转换
102
-
103
- ```java
104
- // ✅ MapstructUtils
105
- XxxVo vo = MapstructUtils.convert(entity, XxxVo.class);
106
- List<XxxVo> voList = MapstructUtils.convert(entityList, XxxVo.class);
107
-
108
- // ❌ BeanUtil
109
- BeanUtil.copyProperties(entity, vo);
110
- ```
35
+ | 类型 | 风格 | 示例 |
36
+ |------|------|------|
37
+ | 类名 | UpperCamelCase | `OrderService`, `UserController` |
38
+ | 方法名 | lowerCamelCase | `createOrder()`, `getUserById()` |
39
+ | 变量名 | lowerCamelCase | `orderNo`, `userName` |
40
+ | 常量 | UPPER_SNAKE_CASE | `MAX_RETRY_COUNT`, `DEFAULT_PAGE_SIZE` |
41
+ | 包名 | 全小写 | `com.example.order` |
42
+ | 数据库表/字段 | lower_snake_case | `t_order`, `order_no` |
111
43
 
112
- ### 8. 主键策略
44
+ **类命名约定**:
113
45
 
114
- ```sql
115
- -- ✅ 雪花ID
116
- id BIGINT(20) NOT NULL COMMENT '主键ID'
46
+ | 后缀 | 用途 | 示例 |
47
+ |------|------|------|
48
+ | `Controller` | 控制器 | `OrderController` |
49
+ | `Service` / `ServiceImpl` | 服务层 | `OrderServiceImpl` |
50
+ | `Mapper` / `Repository` | 数据访问 | `OrderMapper` |
51
+ | `DTO` | 请求参数 | `OrderCreateDTO` |
52
+ | `VO` | 响应对象 | `OrderVO` |
53
+ | `Enum` | 枚举 | `OrderStatusEnum` |
54
+ | `Config` | 配置类 | `RedisConfig` |
55
+ | `Handler` | 处理器 | `GlobalExceptionHandler` |
56
+ | `Interceptor` | 拦截器 | `AuthInterceptor` |
57
+ | `Utils` / `Helper` | 工具类 | `DateUtils` |
58
+
59
+ ### 方法命名约定
60
+
61
+ | 前缀 | 含义 | 示例 |
62
+ |------|------|------|
63
+ | `create` / `add` | 创建 | `createOrder()` |
64
+ | `update` / `modify` | 更新 | `updateStatus()` |
65
+ | `delete` / `remove` | 删除 | `deleteById()` |
66
+ | `get` / `find` / `query` | 查询 | `getById()`, `findByName()` |
67
+ | `list` | 查询列表 | `listByStatus()` |
68
+ | `page` | 分页查询 | `pageQuery()` |
69
+ | `count` | 计数 | `countByStatus()` |
70
+ | `is` / `has` / `can` | 布尔判断 | `isValid()`, `hasPermission()` |
71
+ | `check` / `validate` | 校验 | `checkDuplicate()` |
72
+ | `convert` / `to` | 转换 | `convertToVO()`, `toDTO()` |
73
+
74
+ ### Git 提交规范(Conventional Commits)
117
75
 
118
- -- ❌
119
- id BIGINT(20) AUTO_INCREMENT
120
76
  ```
77
+ <type>(<scope>): <subject>
121
78
 
122
- ### 9. R.ok() 返回 String 陷阱
123
-
124
- ```java
125
- // ❌ 匹配 R.ok(String msg),字符串进入 msg 而非 data
126
- return R.ok(token); // {code:200, msg:"xxx", data:null}
79
+ <body>
127
80
 
128
- // ✅ 明确指定
129
- return R.ok(null, token); // data=token, msg=null
130
- return R.ok("获取成功", token); // 都有值
81
+ <footer>
131
82
  ```
132
83
 
133
- ### 10. Entity 基类
134
-
135
- ```java
136
- // 业务表(需多租户隔离)
137
- public class Xxx extends TenantEntity {
138
- @TableId(value = "id")
139
- private Long id;
140
- }
141
-
142
- // 系统表(不需多租户)
143
- public class SysClient extends BaseEntity { }
144
-
145
- // ❌ 不继承基类
146
- public class Xxx { }
84
+ | type | 说明 |
85
+ |------|------|
86
+ | `feat` | 新功能 |
87
+ | `fix` | 修复 Bug |
88
+ | `docs` | 文档变更 |
89
+ | `style` | 代码格式(不影响逻辑) |
90
+ | `refactor` | 重构(非新功能、非修复) |
91
+ | `perf` | 性能优化 |
92
+ | `test` | 测试相关 |
93
+ | `chore` | 构建/工具变更 |
94
+
95
+ **示例**:
147
96
  ```
97
+ feat(order): 新增订单导出功能
148
98
 
149
- ### 11. @Cacheable 不可变集合
99
+ 支持按时间范围导出订单数据为 Excel 格式。
150
100
 
151
- ```java
152
- // ❌ Redis 反序列化失败
153
- @Cacheable(value = "xxx")
154
- public List<String> listXxx() { return List.of("1", "2"); }
155
-
156
- // ✅ 可变集合包装
157
- @Cacheable(value = "xxx")
158
- public List<String> listXxx() { return new ArrayList<>(List.of("1", "2")); }
101
+ Closes #123
159
102
  ```
160
103
 
161
- > **原因**:Jackson DefaultTyping.NON_FINAL 会为 `ImmutableCollections$List12` 添加类型信息,反序列化时导致 `ClassNotFoundException`。
104
+ ## 代码示例
162
105
 
163
- ### 12. BO 映射注解
106
+ ### 统一响应格式
164
107
 
165
108
  ```java
166
- // ✅ 单目标:@AutoMapper
167
- @AutoMapper(target = Xxx.class, reverseConvertGenerate = false)
168
- public class XxxBo { }
169
-
170
- // 多目标:@AutoMappers
171
- @AutoMappers({
172
- @AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false),
173
- @AutoMapper(target = OperLogEvent.class)
174
- })
175
- public class SysOperLogBo { }
176
- ```
177
-
178
- ### 13-14. 中文注释与 SQL COMMENT
109
+ @Data
110
+ @AllArgsConstructor
111
+ @NoArgsConstructor
112
+ public class Result<T> {
113
+ private int code;
114
+ private String message;
115
+ private T data;
116
+
117
+ public static <T> Result<T> ok(T data) {
118
+ return new Result<>(200, "success", data);
119
+ }
179
120
 
180
- ```java
181
- // 中文注释
182
- /** 根据 ID 查询用户信息 */
183
- public SysUserVo queryById(Long id) {
184
- // 查询用户基本信息
185
- return baseMapper.selectVoById(id);
121
+ public static <T> Result<T> fail(int code, String message) {
122
+ return new Result<>(code, message, null);
123
+ }
186
124
  }
187
-
188
- // ❌ 英文注释
189
- /** Query user info by ID */
190
- ```
191
-
192
- ```sql
193
- -- ✅
194
- `user_name` VARCHAR(50) NOT NULL COMMENT '用户名',
195
- ) ENGINE=InnoDB COMMENT='用户信息表';
196
-
197
- -- ❌
198
- `user_name` VARCHAR(50) NOT NULL COMMENT 'user name',
199
125
  ```
200
126
 
201
- ---
202
-
203
- ## 命名后缀规范
204
-
205
- | 类型 | 后缀 | 示例 |
206
- |------|------|------|
207
- | 实体类 | 无/Sys前缀 | `SysUser`, `TestDemo` |
208
- | 业务对象 | Bo | `SysUserBo` |
209
- | 视图对象 | Vo | `SysUserVo` |
210
- | 服务接口 | IXxxService | `ISysUserService` |
211
- | 服务实现 | XxxServiceImpl | `SysUserServiceImpl` |
212
- | 控制器 | XxxController | `SysUserController` |
213
- | Mapper | XxxMapper | `SysUserMapper` |
214
-
215
- > 本项目是三层架构,没有 DAO 层。Service 直接注入 Mapper。
216
-
217
- ## 方法命名
218
-
219
- | 操作 | Service 方法 | Controller URL |
220
- |------|-------------|----------------|
221
- | 分页查询 | `queryPageList(bo, pageQuery)` | `GET /list` |
222
- | 查询单个 | `queryById(id)` | `GET /{id}` |
223
- | 新增 | `insertByBo(bo)` | `POST /` |
224
- | 修改 | `updateByBo(bo)` | `PUT /` |
225
- | 删除 | `deleteWithValidByIds(ids)` | `DELETE /{ids}` |
226
- | 导出 | `queryList(bo)` + ExcelUtil | `POST /export` |
227
-
228
- ---
229
-
230
- ## Git 提交规范
231
-
232
- ```
233
- <type>(<scope>): <description>
234
- ```
235
-
236
- | type | 说明 | 示例 |
237
- |------|------|------|
238
- | `feat` | 新功能 | `feat(system): 新增用户反馈功能` |
239
- | `fix` | 修复 | `fix(demo): 修复订单状态显示错误` |
240
- | `refactor` | 重构 | `refactor(common): 重构分页查询工具类` |
241
- | `perf` | 性能 | `perf(system): 优化用户列表查询性能` |
242
- | `docs` | 文档 | `docs(readme): 更新安装说明` |
243
- | `style` | 格式 | `chore` 构建/工具 | `test` 测试 |
244
-
245
- ---
246
-
247
- ## 多项目适配
248
-
249
- | 特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
250
- |------|----------------|-------------------|
251
- | 包名 | `org.dromara.*` | `net.xnzn.core.*` |
252
- | JDK | 17 | 21 |
253
- | 对象转换 | `MapstructUtils.convert()` | `BeanUtil.copyProperties()` |
254
- | 分页 | `TableDataInfo<T>` | `Page<T>` |
255
- | 异常 | `ServiceException` | `LeException` |
256
- | 工具库 | 自定义工具类 | Hutool |
257
-
258
- ### leniu-tengyun-core 专用
127
+ ### 枚举定义规范
259
128
 
260
129
  ```java
261
- // 国际化
262
- throw new LeException(I18n.getMessage("user.not.exists"));
263
-
264
- // 租户上下文
265
- Long tenantId = TenantContextHolder.getTenantId();
266
-
267
- // 分页
268
- PageMethod.startPage(param.getPage().getPageNum(), param.getPage().getPageSize());
130
+ @Getter
131
+ @AllArgsConstructor
132
+ public enum OrderStatusEnum {
133
+
134
+ PENDING(0, "待处理"),
135
+ COMPLETED(1, "已完成"),
136
+ CANCELLED(2, "已取消");
137
+
138
+ private final int code;
139
+ private final String desc;
140
+
141
+ public static OrderStatusEnum of(int code) {
142
+ for (OrderStatusEnum status : values()) {
143
+ if (status.code == code) {
144
+ return status;
145
+ }
146
+ }
147
+ throw new IllegalArgumentException("未知状态码: " + code);
148
+ }
149
+ }
269
150
  ```
270
151
 
271
- ---
272
-
273
- ## 相关 Skill
274
-
275
- | 需要了解 | 激活 Skill |
276
- |---------|-----------|
277
- | 后端 CRUD 开发 | `crud-development` |
278
- | API 开发 | `api-development` |
279
- | 数据库设计 | `database-ops` |
280
- | 系统架构 | `architecture-design` |
152
+ ## 常见错误
153
+
154
+ | 错误 | 正确做法 |
155
+ |------|---------|
156
+ | URL 用动词:`/getOrder` | 用名词 + HTTP 方法:`GET /orders/{id}` |
157
+ | 方法名含义不清:`process()` | 明确动作:`calculateTotalAmount()` |
158
+ | 魔法数字:`if (status == 1)` | 用枚举或常量 |
159
+ | 一个方法超过 80 | 拆分为多个私有方法 |
160
+ | 注释描述"做了什么" | 注释描述"为什么这样做" |
161
+ | Git 提交信息写"fix bug" | 写清楚修了什么:`fix(order): 修复金额计算精度丢失` |
162
+ | Boolean 变量名:`flag` | 有意义的名字:`isActive`, `hasPermission` |
163
+ | 缩写命名:`usr`, `mgr` | 完整命名:`user`, `manager` |