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,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
|
-
|
|
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
|
-
###
|
|
16
|
+
### RESTful API 设计
|
|
69
17
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
86
|
-
|
|
27
|
+
**URL 规范**:
|
|
28
|
+
- 使用名词复数:`/orders` 而非 `/order`
|
|
29
|
+
- 使用小写连字符:`/order-items` 而非 `/orderItems`
|
|
30
|
+
- 版本号放 URL 前缀:`/api/v1/`
|
|
31
|
+
- 嵌套资源不超过两层:`/orders/{id}/items`
|
|
87
32
|
|
|
88
|
-
###
|
|
33
|
+
### 命名规范
|
|
89
34
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
44
|
+
**类命名约定**:
|
|
113
45
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
99
|
+
支持按时间范围导出订单数据为 Excel 格式。
|
|
150
100
|
|
|
151
|
-
|
|
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
|
-
|
|
104
|
+
## 代码示例
|
|
162
105
|
|
|
163
|
-
###
|
|
106
|
+
### 统一响应格式
|
|
164
107
|
|
|
165
108
|
```java
|
|
166
|
-
|
|
167
|
-
@
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
|
|
|
276
|
-
|
|
277
|
-
|
|
|
278
|
-
|
|
|
279
|
-
|
|
|
280
|
-
|
|
|
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` |
|