ai-engineering-init 1.3.3 → 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.
- package/.claude/hooks/skill-forced-eval.js +4 -1
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +252 -116
- package/.claude/skills/api-development/SKILL.md +83 -377
- package/.claude/skills/architecture-design/SKILL.md +138 -632
- package/.claude/skills/backend-annotations/SKILL.md +134 -506
- package/.claude/skills/banana-image/SKILL.md +10 -3
- package/.claude/skills/brainstorm/SKILL.md +103 -535
- package/.claude/skills/bug-detective/SKILL.md +147 -1097
- package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
- package/.claude/skills/code-patterns/SKILL.md +116 -426
- package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.claude/skills/crud-development/SKILL.md +64 -304
- package/.claude/skills/data-permission/SKILL.md +105 -412
- package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.claude/skills/file-oss-management/SKILL.md +106 -714
- package/.claude/skills/file-oss-management/references/entities.md +105 -0
- package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
- package/.claude/skills/leniu-api-development/SKILL.md +142 -626
- package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
- package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
- package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
- package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
- package/.claude/skills/leniu-java-export/SKILL.md +94 -379
- package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
- package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.claude/skills/leniu-report-customization/SKILL.md +111 -325
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +328 -0
- package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
- package/.claude/skills/mysql-debug/SKILL.md +364 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
- package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
- package/.claude/skills/openspec-explore/SKILL.md +10 -1
- package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
- package/.claude/skills/openspec-new-change/SKILL.md +9 -1
- package/.claude/skills/openspec-onboard/SKILL.md +15 -130
- package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
- package/.claude/skills/performance-doctor/SKILL.md +110 -434
- package/.claude/skills/redis-cache/SKILL.md +89 -595
- package/.claude/skills/redis-cache/references/listeners.md +23 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
- package/.claude/skills/security-guard/SKILL.md +137 -532
- package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
- package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.claude/skills/sms-mail/SKILL.md +116 -574
- package/.claude/skills/sms-mail/references/mail-config.md +88 -0
- package/.claude/skills/sms-mail/references/sms-config.md +74 -0
- package/.claude/skills/social-login/SKILL.md +112 -514
- package/.claude/skills/social-login/references/provider-configs.md +118 -0
- package/.claude/skills/tenant-management/SKILL.md +129 -444
- package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.claude/skills/test-development/SKILL.md +86 -540
- package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
- package/.claude/skills/utils-toolkit/SKILL.md +52 -305
- package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.claude/skills/websocket-sse/SKILL.md +105 -550
- package/.claude/skills/workflow-engine/SKILL.md +147 -502
- package/.codex/skills/add-skill/SKILL.md +252 -116
- package/.codex/skills/api-development/SKILL.md +172 -599
- package/.codex/skills/architecture-design/SKILL.md +138 -504
- package/.codex/skills/backend-annotations/SKILL.md +134 -496
- package/.codex/skills/banana-image/SKILL.md +10 -3
- package/.codex/skills/brainstorm/SKILL.md +103 -535
- package/.codex/skills/bug-detective/SKILL.md +147 -1097
- package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
- package/.codex/skills/code-patterns/SKILL.md +120 -282
- package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.codex/skills/crud-development/SKILL.md +64 -292
- package/.codex/skills/data-permission/SKILL.md +108 -407
- package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.codex/skills/database-ops/SKILL.md +8 -154
- package/.codex/skills/error-handler/SKILL.md +10 -0
- package/.codex/skills/file-oss-management/SKILL.md +106 -714
- package/.codex/skills/file-oss-management/references/entities.md +105 -0
- package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
- package/.codex/skills/git-workflow/SKILL.md +27 -5
- package/.codex/skills/leniu-api-development/SKILL.md +142 -626
- package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
- package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
- package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
- package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
- package/.codex/skills/leniu-java-export/SKILL.md +94 -379
- package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
- package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.codex/skills/leniu-report-customization/SKILL.md +111 -325
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +328 -0
- package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
- package/.codex/skills/mysql-debug/SKILL.md +364 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
- package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
- package/.codex/skills/openspec-explore/SKILL.md +10 -1
- package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
- package/.codex/skills/openspec-new-change/SKILL.md +9 -1
- package/.codex/skills/openspec-onboard/SKILL.md +15 -130
- package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
- package/.codex/skills/performance-doctor/SKILL.md +110 -434
- package/.codex/skills/project-navigator/SKILL.md +20 -1
- package/.codex/skills/redis-cache/SKILL.md +93 -589
- package/.codex/skills/redis-cache/references/listeners.md +23 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
- package/.codex/skills/security-guard/SKILL.md +141 -527
- package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
- package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.codex/skills/sms-mail/SKILL.md +116 -574
- package/.codex/skills/sms-mail/references/mail-config.md +88 -0
- package/.codex/skills/sms-mail/references/sms-config.md +74 -0
- package/.codex/skills/social-login/SKILL.md +112 -514
- package/.codex/skills/social-login/references/provider-configs.md +118 -0
- package/.codex/skills/store-pc/SKILL.md +258 -383
- package/.codex/skills/tenant-management/SKILL.md +129 -444
- package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.codex/skills/test-development/SKILL.md +86 -540
- package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
- package/.codex/skills/ui-pc/SKILL.md +350 -387
- package/.codex/skills/utils-toolkit/SKILL.md +52 -283
- package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.codex/skills/websocket-sse/SKILL.md +105 -550
- package/.codex/skills/workflow-engine/SKILL.md +147 -502
- package/.cursor/hooks.json +3 -3
- package/.cursor/rules/skill-activation.mdc +2 -0
- package/.cursor/skills/add-skill/SKILL.md +252 -116
- package/.cursor/skills/api-development/SKILL.md +83 -377
- package/.cursor/skills/architecture-design/SKILL.md +138 -632
- package/.cursor/skills/backend-annotations/SKILL.md +134 -506
- package/.cursor/skills/banana-image/SKILL.md +10 -3
- package/.cursor/skills/brainstorm/SKILL.md +103 -535
- package/.cursor/skills/bug-detective/SKILL.md +147 -1097
- package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
- package/.cursor/skills/code-patterns/SKILL.md +116 -426
- package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.cursor/skills/crud-development/SKILL.md +64 -304
- package/.cursor/skills/data-permission/SKILL.md +105 -412
- package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.cursor/skills/file-oss-management/SKILL.md +106 -714
- package/.cursor/skills/file-oss-management/references/entities.md +105 -0
- package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
- package/.cursor/skills/git-workflow/SKILL.md +27 -5
- package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
- package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
- package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
- package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
- package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
- package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
- package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.cursor/skills/leniu-report-customization/SKILL.md +111 -325
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +328 -0
- package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
- package/.cursor/skills/mysql-debug/SKILL.md +364 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
- package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-explore/SKILL.md +10 -1
- package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
- package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
- package/.cursor/skills/performance-doctor/SKILL.md +110 -434
- package/.cursor/skills/redis-cache/SKILL.md +89 -595
- package/.cursor/skills/redis-cache/references/listeners.md +23 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
- package/.cursor/skills/security-guard/SKILL.md +137 -532
- package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
- package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.cursor/skills/sms-mail/SKILL.md +116 -574
- package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
- package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
- package/.cursor/skills/social-login/SKILL.md +112 -514
- package/.cursor/skills/social-login/references/provider-configs.md +118 -0
- package/.cursor/skills/tenant-management/SKILL.md +129 -444
- package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.cursor/skills/test-development/SKILL.md +86 -540
- package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
- package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.cursor/skills/websocket-sse/SKILL.md +105 -550
- package/.cursor/skills/workflow-engine/SKILL.md +147 -502
- package/AGENTS.md +1 -0
- package/package.json +1 -1
|
@@ -1,137 +1,72 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: leniu-api-development
|
|
3
3
|
description: |
|
|
4
|
-
|
|
4
|
+
leniu-yunshitang-core 项目 API 接口开发规范。基于四层架构的 API 开发指南。
|
|
5
5
|
|
|
6
6
|
触发场景:
|
|
7
|
-
- 设计 leniu 项目
|
|
7
|
+
- 设计 leniu 项目 API 接口
|
|
8
8
|
- 编写 leniu Controller 层代码
|
|
9
|
-
-
|
|
9
|
+
- 配置接口权限和参数校验
|
|
10
10
|
- 接口返回值类型选择
|
|
11
|
-
-
|
|
11
|
+
- 多端路由规划(Web/Mobile/Android)
|
|
12
12
|
|
|
13
13
|
适用项目:leniu-tengyun-core(云食堂项目)
|
|
14
14
|
|
|
15
|
-
触发词:API接口、Controller、
|
|
15
|
+
触发词:API接口、Controller、LeResult、LeResponse、LeRequest、接口开发、路由前缀、分页查询、接口权限
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
#
|
|
18
|
+
# leniu API 接口开发规范
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## HTTP 方法与路径规范
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
|
25
|
-
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| 特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
34
|
-
|-----|----------------|-------------------|
|
|
35
|
-
| **JDK 版本** | 17 | 21 |
|
|
36
|
-
| **包名前缀** | `org.dromara.*` | `net.xnzn.core.*` |
|
|
37
|
-
| **请求封装** | 直接使用 BO | `LeRequest<T>` 包装 |
|
|
38
|
-
| **响应封装** | `R<T>`, `TableDataInfo<T>` | `Page<T>`, `LeResponse<T>`, `void` |
|
|
39
|
-
| **分组校验** | `AddGroup`, `EditGroup` | `InsertGroup`, `UpdateGroup` |
|
|
40
|
-
| **认证注解** | `@SaCheckPermission` | `@RequiresAuthentication`, `@RequiresGuest` |
|
|
41
|
-
| **异常类** | `ServiceException` | `LeException` |
|
|
42
|
-
| **审计字段** | `create_by/create_time/update_by/update_time` | `crby/crtime/upby/uptime` |
|
|
43
|
-
| **主键策略** | 雪花ID (`IdType.ASSIGN_ID`) | 自增ID (`IdType.AUTO`) |
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## 核心规范
|
|
48
|
-
|
|
49
|
-
### 1. 接口定义原则
|
|
50
|
-
|
|
51
|
-
| 原则 | 说明 |
|
|
52
|
-
|------|------|
|
|
53
|
-
| **统一入口** | 所有接口使用 POST 或 RESTful 风格 |
|
|
54
|
-
| **认证保护** | 业务接口使用 `@RequiresAuthentication`,部分使用 `@RequiresGuest` |
|
|
55
|
-
| **参数校验** | 使用分组校验区分新增/修改场景 |
|
|
56
|
-
| **统一响应** | 分页用 `Page<T>`,单数据用 `LeResponse<T>` 或直接返回 VO |
|
|
57
|
-
| **请求封装** | 使用 `LeRequest<T>` 包装请求参数 |
|
|
58
|
-
|
|
59
|
-
### 2. HTTP 方法规范
|
|
60
|
-
|
|
61
|
-
| 操作 | HTTP 方法 | 路径 | 说明 |
|
|
62
|
-
|------|---------|------|------|
|
|
63
|
-
| **列表查询** | POST | `/query` 或 `/page-*` | 分页查询列表 |
|
|
64
|
-
| **获取详情** | GET/POST | `/{id}` 或 `/get-*` | 根据 ID 查询 |
|
|
65
|
-
| **新增** | POST | `/add` | 创建新数据 |
|
|
66
|
-
| **修改** | POST/PUT | `/update` 或 `/modify-*` | 更新数据 |
|
|
67
|
-
| **删除** | DELETE/POST | `/delete` 或 `/batch/delete` | 删除数据 |
|
|
68
|
-
| **导出** | POST | `/export` | 导出数据到 Excel |
|
|
69
|
-
| **导入** | POST | `/import-excel` | 从 Excel 导入数据 |
|
|
22
|
+
| 操作 | HTTP 方法 | 路径示例 | 返回类型 |
|
|
23
|
+
|------|---------|---------|---------|
|
|
24
|
+
| 分页查询 | POST | `/query`, `/page-*` | `Page<VO>` / `PageVO<VO>` |
|
|
25
|
+
| 获取详情 | POST/GET | `/{id}`, `/get-*`, `/info` | VO |
|
|
26
|
+
| 新增 | POST | `/add` | `void` |
|
|
27
|
+
| 修改 | POST/PUT | `/update`, `/modify-*` | `void` |
|
|
28
|
+
| 删除 | DELETE/POST | `/delete`, `/batch/delete` | `void` |
|
|
29
|
+
| 列表(不分页) | POST | `/list-all`, `/type-list` | `List<VO>` |
|
|
30
|
+
| 导出 | POST | `/export`, `/export-async/*` | `void` |
|
|
31
|
+
| 导入 | POST | `/import-excel` | `void` |
|
|
32
|
+
| 树形查询 | POST | `/tree` | `List<Tree<Long>>` |
|
|
70
33
|
|
|
71
34
|
---
|
|
72
35
|
|
|
73
|
-
## Controller
|
|
74
|
-
|
|
75
|
-
### 标准模板(带参数校验)
|
|
36
|
+
## Controller 标准模板
|
|
76
37
|
|
|
77
38
|
```java
|
|
78
39
|
@Api(tags = "模块-功能描述")
|
|
79
40
|
@RestController
|
|
80
41
|
@RequiresAuthentication
|
|
81
|
-
@RequestMapping("/module
|
|
82
|
-
public class
|
|
42
|
+
@RequestMapping("/api/v2/web/module")
|
|
43
|
+
public class XxxWebController {
|
|
83
44
|
|
|
84
45
|
@Autowired
|
|
85
|
-
private
|
|
46
|
+
private XxxBusiness xxxBusiness;
|
|
86
47
|
|
|
87
48
|
@PostMapping("/add")
|
|
88
|
-
@ApiOperation(value = "
|
|
49
|
+
@ApiOperation(value = "功能-新增")
|
|
89
50
|
public void add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
90
|
-
|
|
51
|
+
xxxBusiness.add(request.getContent());
|
|
91
52
|
}
|
|
92
53
|
|
|
93
54
|
@PostMapping("/update")
|
|
94
|
-
@ApiOperation(value = "
|
|
55
|
+
@ApiOperation(value = "功能-修改")
|
|
95
56
|
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
96
|
-
|
|
57
|
+
xxxBusiness.update(request.getContent());
|
|
97
58
|
}
|
|
98
59
|
|
|
99
60
|
@PostMapping("/query")
|
|
100
|
-
@ApiOperation(value = "
|
|
61
|
+
@ApiOperation(value = "功能-分页查询")
|
|
101
62
|
public Page<XxxVO> query(@Validated @RequestBody LeRequest<XxxQueryParam> request) {
|
|
102
|
-
return
|
|
63
|
+
return xxxBusiness.page(request.getContent());
|
|
103
64
|
}
|
|
104
65
|
|
|
105
66
|
@PostMapping("/delete")
|
|
106
|
-
@ApiOperation(value = "
|
|
67
|
+
@ApiOperation(value = "功能-删除")
|
|
107
68
|
public void delete(@RequestBody LeRequest<Long> request) {
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### 简化模板(无分组校验)
|
|
114
|
-
|
|
115
|
-
```java
|
|
116
|
-
@Api(tags = "模块-功能描述")
|
|
117
|
-
@RestController
|
|
118
|
-
@RequiresAuthentication
|
|
119
|
-
@RequestMapping("/module/feature")
|
|
120
|
-
public class XxxController {
|
|
121
|
-
|
|
122
|
-
@Autowired
|
|
123
|
-
private XxxService xxxService;
|
|
124
|
-
|
|
125
|
-
@PostMapping("/add")
|
|
126
|
-
@ApiOperation(value = "功能描述-新增")
|
|
127
|
-
public void add(@RequestBody LeRequest<XxxDTO> request) {
|
|
128
|
-
xxxService.add(request.getContent());
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
@PostMapping("/query")
|
|
132
|
-
@ApiOperation(value = "功能描述-分页查询")
|
|
133
|
-
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
134
|
-
return xxxService.page(request.getContent());
|
|
69
|
+
xxxBusiness.delete(request.getContent());
|
|
135
70
|
}
|
|
136
71
|
}
|
|
137
72
|
```
|
|
@@ -140,206 +75,107 @@ public class XxxController {
|
|
|
140
75
|
|
|
141
76
|
## 请求/响应封装
|
|
142
77
|
|
|
143
|
-
###
|
|
144
|
-
|
|
145
|
-
```java
|
|
146
|
-
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
147
|
-
|
|
148
|
-
@PostMapping("/query")
|
|
149
|
-
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
150
|
-
XxxQueryParam param = request.getContent(); // 获取实际参数
|
|
151
|
-
return xxxService.page(param);
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### 2. 响应类型
|
|
78
|
+
### 请求:LeRequest<T>
|
|
156
79
|
|
|
157
|
-
|
|
80
|
+
所有接口入参统一用 `LeRequest<T>` 包装,通过 `request.getContent()` 获取实际参数。
|
|
158
81
|
|
|
159
82
|
```java
|
|
160
|
-
// 使用 MyBatis-Plus 的 Page 对象
|
|
161
83
|
@PostMapping("/query")
|
|
162
|
-
@ApiOperation(value = "分页查询")
|
|
163
84
|
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
164
85
|
return xxxService.page(request.getContent());
|
|
165
86
|
}
|
|
166
87
|
```
|
|
167
88
|
|
|
168
|
-
|
|
89
|
+
### 响应类型选择
|
|
169
90
|
|
|
170
|
-
|
|
171
|
-
|
|
91
|
+
| 场景 | 返回类型 | 示例 |
|
|
92
|
+
|------|---------|------|
|
|
93
|
+
| 分页 | `Page<VO>` / `PageVO<VO>` | `return xxxService.page(param);` |
|
|
94
|
+
| 单值包装 | `LeResponse<T>` | `return LeResponse.succ(value);` |
|
|
95
|
+
| 复杂对象 | 直接返回 VO | `return xxxService.getDetail(id);` |
|
|
96
|
+
| 报表+合计行 | `ReportBaseTotalVO<VO>` | `return service.pageSummary(param);` |
|
|
97
|
+
| 写操作 | `void` | 无返回值 |
|
|
172
98
|
|
|
99
|
+
```java
|
|
100
|
+
// LeResponse 用法
|
|
173
101
|
@PostMapping("/get-config")
|
|
174
|
-
@ApiOperation(value = "查询配置")
|
|
175
102
|
public LeResponse<String> getConfig(@RequestBody LeRequest<Long> request) {
|
|
176
103
|
return LeResponse.succ(xxxService.getConfig(request.getContent()));
|
|
177
104
|
}
|
|
178
105
|
```
|
|
179
106
|
|
|
180
|
-
|
|
107
|
+
---
|
|
181
108
|
|
|
182
|
-
|
|
183
|
-
@PostMapping("/get-detail")
|
|
184
|
-
@ApiOperation(value = "查询详情(聚合)")
|
|
185
|
-
public XxxDetailVO getDetail(@RequestBody LeRequest<Long> request) {
|
|
186
|
-
return xxxService.getDetail(request.getContent());
|
|
187
|
-
}
|
|
188
|
-
```
|
|
109
|
+
## 参数校验
|
|
189
110
|
|
|
190
|
-
|
|
111
|
+
### 分组校验(新增/修改区分)
|
|
191
112
|
|
|
192
113
|
```java
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
public
|
|
196
|
-
xxxService.add(request.getContent());
|
|
197
|
-
}
|
|
198
|
-
```
|
|
114
|
+
// 分组接口定义
|
|
115
|
+
public interface InsertGroup {}
|
|
116
|
+
public interface UpdateGroup {}
|
|
199
117
|
|
|
200
|
-
|
|
118
|
+
// Controller 使用
|
|
119
|
+
@PostMapping("/add")
|
|
120
|
+
public void add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {}
|
|
201
121
|
|
|
202
|
-
|
|
122
|
+
@PostMapping("/update")
|
|
123
|
+
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request) {}
|
|
124
|
+
```
|
|
203
125
|
|
|
204
|
-
###
|
|
126
|
+
### DTO 校验示例
|
|
205
127
|
|
|
206
128
|
```java
|
|
207
|
-
|
|
208
|
-
import jakarta.validation.constraints
|
|
209
|
-
import jakarta.validation.constraints.NotBlank;
|
|
210
|
-
import jakarta.validation.constraints.NotEmpty;
|
|
211
|
-
import jakarta.validation.constraints.Size;
|
|
212
|
-
import jakarta.validation.constraints.Pattern;
|
|
213
|
-
import jakarta.validation.constraints.Min;
|
|
214
|
-
import jakarta.validation.constraints.Max;
|
|
129
|
+
// 必须用 jakarta.validation(JDK 21)
|
|
130
|
+
import jakarta.validation.constraints.*;
|
|
215
131
|
|
|
216
132
|
@Data
|
|
217
133
|
public class XxxDTO {
|
|
218
|
-
|
|
219
134
|
@NotNull(message = "ID不能为空", groups = {UpdateGroup.class})
|
|
220
135
|
private Long id;
|
|
221
136
|
|
|
222
137
|
@NotBlank(message = "名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
223
138
|
@Size(max = 100, message = "名称长度不能超过100个字符")
|
|
224
139
|
private String name;
|
|
225
|
-
|
|
226
|
-
@Min(value = 0, message = "数量不能小于0")
|
|
227
|
-
@Max(value = 9999, message = "数量不能大于9999")
|
|
228
|
-
private Integer count;
|
|
229
|
-
|
|
230
|
-
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
|
231
|
-
private String phone;
|
|
232
140
|
}
|
|
233
141
|
```
|
|
234
142
|
|
|
235
|
-
###
|
|
236
|
-
|
|
237
|
-
```java
|
|
238
|
-
// 定义校验分组
|
|
239
|
-
public interface InsertGroup {}
|
|
240
|
-
public interface UpdateGroup {}
|
|
241
|
-
|
|
242
|
-
// Controller 中应用分组
|
|
243
|
-
@PostMapping("/add")
|
|
244
|
-
public void add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request)
|
|
245
|
-
|
|
246
|
-
@PostMapping("/update")
|
|
247
|
-
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request)
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### 3. 简单校验(无分组)
|
|
143
|
+
### 简单校验(无分组)
|
|
251
144
|
|
|
252
145
|
```java
|
|
253
|
-
// 直接使用 @Valid 或在方法上加 @Validated
|
|
254
146
|
@PostMapping("/query")
|
|
255
|
-
public Page<XxxVO> query(@Validated @RequestBody LeRequest<XxxQueryParam> request)
|
|
147
|
+
public Page<XxxVO> query(@Validated @RequestBody LeRequest<XxxQueryParam> request) {}
|
|
256
148
|
|
|
257
149
|
@PostMapping("/check")
|
|
258
|
-
public LeResponse<Boolean> check(@Valid @RequestBody LeRequest<XxxDTO> request)
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## 认证注解规范
|
|
264
|
-
|
|
265
|
-
| 注解 | 用途 | 使用场景 |
|
|
266
|
-
|------|------|---------|
|
|
267
|
-
| `@RequiresAuthentication` | 需要登录认证 | 大部分业务接口 |
|
|
268
|
-
| `@RequiresGuest` | 允许游客访问 | 不需要登录的接口 |
|
|
269
|
-
|
|
270
|
-
```java
|
|
271
|
-
// 需要登录
|
|
272
|
-
@RequiresAuthentication
|
|
273
|
-
@PostMapping("/query")
|
|
274
|
-
public Page<XxxVO> query(@RequestBody LeRequest<XxxQueryParam> request) { }
|
|
275
|
-
|
|
276
|
-
// 允许游客访问
|
|
277
|
-
@RequiresGuest
|
|
278
|
-
@PostMapping("/public")
|
|
279
|
-
public void publicApi(@RequestBody LeRequest<XxxDTO> request) { }
|
|
150
|
+
public LeResponse<Boolean> check(@Valid @RequestBody LeRequest<XxxDTO> request) {}
|
|
280
151
|
```
|
|
281
152
|
|
|
282
153
|
---
|
|
283
154
|
|
|
284
|
-
##
|
|
285
|
-
|
|
286
|
-
leiu-tengyun-core 项目使用以下审计字段:
|
|
287
|
-
|
|
288
|
-
| 字段 | 类型 | 说明 | MyBatis-Plus 注解 |
|
|
289
|
-
|------|------|------|------------------|
|
|
290
|
-
| `crby` | String | 创建人 | `@TableField(fill = FieldFill.INSERT)` |
|
|
291
|
-
| `crtime` | LocalDateTime | 创建时间 | `@TableField(fill = FieldFill.INSERT)` |
|
|
292
|
-
| `upby` | String | 更新人 | `@TableField(fill = FieldFill.INSERT_UPDATE)` |
|
|
293
|
-
| `uptime` | LocalDateTime | 更新时间 | `@TableField(fill = FieldFill.INSERT_UPDATE)` |
|
|
155
|
+
## 认证注解
|
|
294
156
|
|
|
295
|
-
|
|
157
|
+
| 注解 | 用途 | 包路径 |
|
|
158
|
+
|------|------|--------|
|
|
159
|
+
| `@RequiresAuthentication` | 需要登录(类/方法级) | `net.xnzn.framework.secure.filter.annotation` |
|
|
160
|
+
| `@RequiresGuest` | 允许游客访问(方法级覆盖) | `net.xnzn.framework.secure.filter.annotation` |
|
|
296
161
|
|
|
297
162
|
```java
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
@Data
|
|
302
|
-
@TableName("xxx_table")
|
|
303
|
-
public class XxxEntity implements Serializable {
|
|
304
|
-
|
|
305
|
-
// 主键(自增)
|
|
306
|
-
@ApiModelProperty("主键ID")
|
|
307
|
-
@TableId(value = "id", type = IdType.AUTO)
|
|
308
|
-
private Long id;
|
|
309
|
-
|
|
310
|
-
// 审计字段
|
|
311
|
-
@ApiModelProperty("创建人")
|
|
312
|
-
@TableField(fill = FieldFill.INSERT)
|
|
313
|
-
private String crby;
|
|
314
|
-
|
|
315
|
-
@ApiModelProperty("创建时间")
|
|
316
|
-
@TableField(fill = FieldFill.INSERT)
|
|
317
|
-
private LocalDateTime crtime;
|
|
318
|
-
|
|
319
|
-
@ApiModelProperty("更新人")
|
|
320
|
-
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
321
|
-
private String upby;
|
|
163
|
+
@RequiresAuthentication // 类级别:所有方法默认需登录
|
|
164
|
+
public class XxxController {
|
|
322
165
|
|
|
323
|
-
@
|
|
324
|
-
@
|
|
325
|
-
|
|
166
|
+
@RequiresGuest // 方法级别覆盖:此接口游客可访问
|
|
167
|
+
@PostMapping("/public-list")
|
|
168
|
+
public List<XxxVO> publicList() {}
|
|
326
169
|
}
|
|
327
170
|
```
|
|
328
171
|
|
|
329
172
|
---
|
|
330
173
|
|
|
331
|
-
##
|
|
174
|
+
## 常见场景
|
|
332
175
|
|
|
333
|
-
###
|
|
176
|
+
### 带 Redisson 分布式锁的导入
|
|
334
177
|
|
|
335
178
|
```java
|
|
336
|
-
import org.redisson.api.RLock;
|
|
337
|
-
import org.redisson.api.RedissonClient;
|
|
338
|
-
import java.util.concurrent.TimeUnit;
|
|
339
|
-
|
|
340
|
-
@Autowired
|
|
341
|
-
private RedissonClient redissonClient;
|
|
342
|
-
|
|
343
179
|
@PostMapping("/import-excel")
|
|
344
180
|
@ApiOperation(value = "Excel导入")
|
|
345
181
|
public void importExcel(@RequestParam(value = "file") MultipartFile file) {
|
|
@@ -357,7 +193,7 @@ public void importExcel(@RequestParam(value = "file") MultipartFile file) {
|
|
|
357
193
|
}
|
|
358
194
|
```
|
|
359
195
|
|
|
360
|
-
###
|
|
196
|
+
### 批量删除
|
|
361
197
|
|
|
362
198
|
```java
|
|
363
199
|
@PutMapping("/batch/delete")
|
|
@@ -367,11 +203,9 @@ public void batchDelete(@RequestBody LeRequest<List<Long>> request) {
|
|
|
367
203
|
}
|
|
368
204
|
```
|
|
369
205
|
|
|
370
|
-
###
|
|
206
|
+
### 树形结构查询
|
|
371
207
|
|
|
372
208
|
```java
|
|
373
|
-
import cn.hutool.core.lang.tree.Tree;
|
|
374
|
-
|
|
375
209
|
@PostMapping("/tree")
|
|
376
210
|
@ApiOperation(value = "树形结构查询")
|
|
377
211
|
public List<Tree<Long>> getTree(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
@@ -379,425 +213,107 @@ public List<Tree<Long>> getTree(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
|
379
213
|
}
|
|
380
214
|
```
|
|
381
215
|
|
|
382
|
-
###
|
|
383
|
-
|
|
384
|
-
```java
|
|
385
|
-
@PostMapping("/list-all")
|
|
386
|
-
@ApiOperation(value = "查询所有列表")
|
|
387
|
-
public List<XxxVO> listAll(@RequestBody LeRequest<XxxQueryParam> request) {
|
|
388
|
-
return xxxService.listAll(request.getContent());
|
|
389
|
-
}
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
---
|
|
393
|
-
|
|
394
|
-
## 真实代码示例(来自 order/report 模块)
|
|
395
|
-
|
|
396
|
-
### 示例0:ReportAnalysisController(报表模块典型 Controller)
|
|
397
|
-
|
|
398
|
-
```java
|
|
399
|
-
@RestController
|
|
400
|
-
@RequestMapping("/summary/analysis")
|
|
401
|
-
@Api(value = "报表中心/经营分析", tags = "报表/经营分析-新")
|
|
402
|
-
public class ReportAnalysisController {
|
|
403
|
-
|
|
404
|
-
@Autowired
|
|
405
|
-
@Lazy
|
|
406
|
-
protected ExportApi exportApi; // 跨模块依赖用 @Lazy 避免循环依赖
|
|
407
|
-
@Autowired
|
|
408
|
-
private ReportAnalysisTurnoverService reportAnalysisTurnoverService;
|
|
409
|
-
|
|
410
|
-
// 报表查询:返回直接 VO 对象
|
|
411
|
-
@ApiOperation(value = "营业分析-总营业额")
|
|
412
|
-
@PostMapping("/turnover/total")
|
|
413
|
-
public ReportTurnoverPO getTurnoverTotal(@RequestBody LeRequest<ReportAnalysisTurnoverParam> request) {
|
|
414
|
-
return reportAnalysisTurnoverService.getTurnoverTotal(request.getContent());
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// 报表分页:返回 ReportBaseTotalVO(含合计行)
|
|
418
|
-
@ApiOperation(value = "营业分析-营业额报表")
|
|
419
|
-
@PostMapping("/turnover/detail")
|
|
420
|
-
public ReportBaseTotalVO<ReportAnalysisTurnoverDetailVO> getTurnoverDetail(
|
|
421
|
-
@RequestBody LeRequest<ReportAnalysisTurnoverParam> request) {
|
|
422
|
-
return reportAnalysisTurnoverService.getTurnoverDetail(request.getContent());
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// 同步导出(小数据量)
|
|
426
|
-
@SneakyThrows
|
|
427
|
-
@ApiOperation(value = "食堂满意度统计导出")
|
|
428
|
-
@PostMapping("/evaluate/export")
|
|
429
|
-
public void exportEvaluateSummary(@RequestBody LeRequest<ReportAnalysisEvaluateParam> request,
|
|
430
|
-
HttpServletResponse response) {
|
|
431
|
-
ReportAnalysisEvaluateParam param = request.getContent();
|
|
432
|
-
ReportBaseTotalVO<ReportAnalysisEvaluateVO> result = reportAnalysisEvaluateService.pageSummary(param);
|
|
433
|
-
List<ReportAnalysisEvaluateVO> list = (List<ReportAnalysisEvaluateVO>)
|
|
434
|
-
CollUtil.addAll(result.getResultPage().getRecords(), result.getTotalLine());
|
|
435
|
-
EasyExcelUtil.writeExcelByDownLoadIncludeWrite(response, "文件",
|
|
436
|
-
ReportAnalysisEvaluateVO.class, ReportConstant.REPORT_TITLE_DETAILS, list, param.getExportCols());
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// 异步导出(大数据量)
|
|
440
|
-
@ApiOperation(value = "异步导出菜品销售排行")
|
|
441
|
-
@PostMapping("/export-async/dishes/sale/export")
|
|
442
|
-
public void exportDishesSaleSummary(@RequestBody LeRequest<ReportAnalysisDishesSaleParam> request) {
|
|
443
|
-
ReportAnalysisDishesSaleParam param = request.getContent();
|
|
444
|
-
ReportBaseTotalVO<ReportAnalysisDishesSaleVO> result = reportAnalysisDishesSaleService.pageSummary(param);
|
|
445
|
-
List<ReportAnalysisDishesSaleVO> list = (List<ReportAnalysisDishesSaleVO>)
|
|
446
|
-
CollUtil.addAll(result.getResultPage().getRecords(), result.getTotalLine());
|
|
447
|
-
exportApi.startExcelExportTaskByPage(
|
|
448
|
-
"菜品销售排行",
|
|
449
|
-
I18n.getMessage(ReportConstant.REPORT_TITLE_DETAILS),
|
|
450
|
-
ReportAnalysisDishesSaleVO.class,
|
|
451
|
-
param.getExportCols(),
|
|
452
|
-
param.getPage(),
|
|
453
|
-
null,
|
|
454
|
-
() -> PageVO.of(list));
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
```
|
|
458
|
-
|
|
459
|
-
### 示例0b:OrderInfoExportWebController(订单导出 Controller)
|
|
216
|
+
### 同步导出
|
|
460
217
|
|
|
461
218
|
```java
|
|
462
|
-
|
|
463
|
-
@
|
|
464
|
-
@
|
|
465
|
-
@
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
protected OrderWebBusiness orderWebBusiness;
|
|
471
|
-
@Autowired
|
|
472
|
-
@Lazy
|
|
473
|
-
protected OrderClients orderClients;
|
|
474
|
-
|
|
475
|
-
// 使用 orderClients.export() 启动异步导出(通过 client 代理)
|
|
476
|
-
@PostMapping(value = "/detail")
|
|
477
|
-
public void exportOrderDetail(@RequestBody LeRequest<OrderDetailWebDTO> request) {
|
|
478
|
-
OrderDetailWebDTO orderDetailDTO = request.getContent();
|
|
479
|
-
orderClients.export().startExcelExportTaskByPage(
|
|
480
|
-
I18n.getMessage("order.title.order-detail"), // 文件名(国际化)
|
|
481
|
-
orderSheetName(), // 工作表名
|
|
482
|
-
OrderListWebVO.class, // 数据类
|
|
483
|
-
orderDetailDTO.getExportCols(), // 导出列
|
|
484
|
-
orderDetailDTO, // 分页参数(Param 直接实现 PageDTO)
|
|
485
|
-
null, // 合计行(可选)
|
|
486
|
-
() -> orderWebBusiness.queryOrderInfoWebByPage(orderDetailDTO, orderDetailDTO));
|
|
487
|
-
}
|
|
219
|
+
@SneakyThrows
|
|
220
|
+
@PostMapping("/export")
|
|
221
|
+
@ApiOperation(value = "导出")
|
|
222
|
+
public void export(@RequestBody LeRequest<XxxParam> request, HttpServletResponse response) {
|
|
223
|
+
XxxParam param = request.getContent();
|
|
224
|
+
List<XxxVO> list = xxxService.listAll(param);
|
|
225
|
+
EasyExcelUtil.writeExcelByDownLoadIncludeWrite(response, "文件名",
|
|
226
|
+
XxxVO.class, "标题", list, param.getExportCols());
|
|
488
227
|
}
|
|
489
228
|
```
|
|
490
229
|
|
|
491
|
-
###
|
|
230
|
+
### 异步导出(大数据量)
|
|
492
231
|
|
|
493
232
|
```java
|
|
494
|
-
@
|
|
495
|
-
@
|
|
496
|
-
@
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
// GET 详情:直接 @PostMapping 加 @Valid 校验
|
|
503
|
-
@PostMapping(value = "/info")
|
|
504
|
-
public OrderInfoWebVO info(@Valid @RequestBody LeRequest<OrderInfoWebDTO> request) {
|
|
505
|
-
return orderWebBusiness.getOrderInfo(request.getContent().getOrderId());
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
// 分页查询:返回 PageVO
|
|
509
|
-
@PostMapping(value = "/page/detail")
|
|
510
|
-
public PageVO<OrderListWebVO> pageOrderDetail(@RequestBody LeRequest<OrderDetailWebDTO> request) {
|
|
511
|
-
OrderDetailWebDTO content = request.getContent();
|
|
512
|
-
return orderWebBusiness.queryOrderInfoWebByPage(PageDTO.of(content.getCurrent(), content.getSize()), content);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// 抛出 LeException 明确告知失败原因
|
|
516
|
-
@PostMapping(value = "/refund")
|
|
517
|
-
public OrderRefundResultVO orderRefundWeb(@RequestBody LeRequest<OrderRefundSubmitWebDTO> request) throws LeCheckedException {
|
|
518
|
-
OrderRefundResultVO result = orderRefundBusiness.orderRefund(
|
|
519
|
-
request.getContent().convertToOrderRefundParam(), OrderRefundBizEnum.WEB);
|
|
520
|
-
if (!result.ifSuccess()) {
|
|
521
|
-
throw new LeException(result.getResultCode(), result.getResultMsg());
|
|
522
|
-
}
|
|
523
|
-
return result;
|
|
524
|
-
}
|
|
233
|
+
@PostMapping("/export-async/xxx")
|
|
234
|
+
@ApiOperation(value = "异步导出")
|
|
235
|
+
public void exportAsync(@RequestBody LeRequest<XxxParam> request) {
|
|
236
|
+
XxxParam param = request.getContent();
|
|
237
|
+
exportApi.startExcelExportTaskByPage(
|
|
238
|
+
"文件名", I18n.getMessage("title.key"),
|
|
239
|
+
XxxVO.class, param.getExportCols(), param.getPage(), null,
|
|
240
|
+
() -> PageVO.of(xxxService.listAll(param)));
|
|
525
241
|
}
|
|
526
242
|
```
|
|
527
243
|
|
|
528
244
|
---
|
|
529
245
|
|
|
530
|
-
##
|
|
246
|
+
## 路径命名规范
|
|
531
247
|
|
|
532
248
|
| 模式 | 示例 | 说明 |
|
|
533
249
|
|------|------|------|
|
|
534
|
-
|
|
|
535
|
-
| 报表前缀 | `/summary/xxx` |
|
|
536
|
-
| 查询接口 | `/page/detail`, `/
|
|
537
|
-
| 枚举接口 | `/
|
|
538
|
-
| 导出接口 | `/export`, `/export-async/xxx` |
|
|
539
|
-
|
|
|
540
|
-
|
|
541
|
-
---
|
|
542
|
-
|
|
543
|
-
## 真实代码示例
|
|
544
|
-
|
|
545
|
-
### 示例1:AttendanceLeaveInfoController
|
|
546
|
-
|
|
547
|
-
```java
|
|
548
|
-
package net.xnzn.core.attendance.leave.controller;
|
|
549
|
-
|
|
550
|
-
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
551
|
-
import com.pig4cloud.pigx.common.core.exception.LeException;
|
|
552
|
-
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
553
|
-
import io.swagger.annotations.Api;
|
|
554
|
-
import io.swagger.annotations.ApiOperation;
|
|
555
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
556
|
-
import org.springframework.web.bind.annotation.*;
|
|
557
|
-
|
|
558
|
-
import java.util.List;
|
|
559
|
-
|
|
560
|
-
@Api(tags = "zjl-考勤-请假信息")
|
|
561
|
-
@RestController
|
|
562
|
-
@RequiresAuthentication
|
|
563
|
-
@RequestMapping("/attendance/leave-info")
|
|
564
|
-
public class AttendanceLeaveInfoController {
|
|
565
|
-
|
|
566
|
-
@Autowired
|
|
567
|
-
AttendanceLeaveInfoService attendanceLeaveInfoService;
|
|
568
|
-
@Autowired
|
|
569
|
-
RedissonClient redissonClient;
|
|
570
|
-
|
|
571
|
-
@PostMapping("/add")
|
|
572
|
-
@ApiOperation(value = "请假信息-新增")
|
|
573
|
-
public void add(@RequestBody LeRequest<AddOrUpdateAttendanceLeaveInfoDTO> request) {
|
|
574
|
-
attendanceLeaveInfoService.add(request.getContent());
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
@PutMapping("/batch/delete")
|
|
578
|
-
@ApiOperation(value = "请假信息-批量删除")
|
|
579
|
-
public void batchDelete(@RequestBody LeRequest<List<Long>> request) {
|
|
580
|
-
attendanceLeaveInfoService.batchDelete(request.getContent());
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
@PutMapping("/update")
|
|
584
|
-
@ApiOperation(value = "请假信息-修改")
|
|
585
|
-
public void update(@RequestBody LeRequest<AddOrUpdateAttendanceLeaveInfoDTO> request) {
|
|
586
|
-
attendanceLeaveInfoService.update(request.getContent());
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
@PostMapping("/query")
|
|
590
|
-
@ApiOperation(value = "请假信息-分页查询")
|
|
591
|
-
public Page<QueryAttendanceLeaveInfoVO> query(@RequestBody LeRequest<QueryAttendanceLeaveInfoDTO> request) {
|
|
592
|
-
return attendanceLeaveInfoService.page(request.getContent());
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
@PostMapping("/import-excel")
|
|
596
|
-
@ApiOperation(value = "请假信息-excel导入")
|
|
597
|
-
public void importExcel(@RequestParam(value = "leaveInfoExcel") MultipartFile leaveInfoExcel) throws Exception {
|
|
598
|
-
RLock lock = redissonClient.getLock("import:lock:" + TenantContextHolder.getTenantId());
|
|
599
|
-
if (!lock.tryLock(5, TimeUnit.SECONDS)) {
|
|
600
|
-
throw new LeException("考勤-请假数据导入中,请等待...");
|
|
601
|
-
}
|
|
602
|
-
try {
|
|
603
|
-
attendanceLeaveInfoService.importExcel(new ImportLeaveInfoExcelDTO().setLeaveInfoExcel(leaveInfoExcel));
|
|
604
|
-
} finally {
|
|
605
|
-
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
|
|
606
|
-
lock.unlock();
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
### 示例2:AllocCanteenController
|
|
614
|
-
|
|
615
|
-
```java
|
|
616
|
-
package net.xnzn.core.allocation.canteen.controller;
|
|
617
|
-
|
|
618
|
-
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
619
|
-
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
620
|
-
import com.pig4cloud.pigx.common.core.util.LeResponse;
|
|
621
|
-
import io.swagger.annotations.Api;
|
|
622
|
-
import io.swagger.annotations.ApiOperation;
|
|
623
|
-
import net.xnzn.framework.secure.filter.annotation.RequiresGuest;
|
|
624
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
625
|
-
import org.springframework.context.annotation.Lazy;
|
|
626
|
-
import org.springframework.web.bind.annotation.*;
|
|
627
|
-
|
|
628
|
-
import jakarta.validation.Valid;
|
|
629
|
-
import java.util.List;
|
|
630
|
-
|
|
631
|
-
@Slf4j
|
|
632
|
-
@RestController
|
|
633
|
-
@RequestMapping("/api/v2/alloc/canteen")
|
|
634
|
-
@Api(tags = "lsh_食堂档口相关控制器")
|
|
635
|
-
public class AllocCanteenController {
|
|
636
|
-
|
|
637
|
-
@Autowired
|
|
638
|
-
@Lazy
|
|
639
|
-
private AllocCanteenService allocCanteenService;
|
|
640
|
-
|
|
641
|
-
@ApiOperation("分页查询食堂列表")
|
|
642
|
-
@PostMapping("/page-canteen")
|
|
643
|
-
public Page<AllocCanteenVO> pageCanteen(@RequestBody LeRequest<AllocCanteenStallPageParam> request) {
|
|
644
|
-
return allocCanteenService.pageCanteen(request.getContent());
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
@ApiOperation("查询区域食堂档口餐线编号")
|
|
648
|
-
@PostMapping("/get-canteen-num")
|
|
649
|
-
public LeResponse<String> getCanteenNum(@Valid @RequestBody LeRequest<AllocCanteenNumParam> request) {
|
|
650
|
-
return LeResponse.succ(allocCanteenBusiness.getCanteenNum(request.getContent()));
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
@ApiOperation("新增食堂")
|
|
654
|
-
@PostMapping("/add-canteen")
|
|
655
|
-
@RequiresGuest
|
|
656
|
-
public void addCanteen(@Valid @RequestBody LeRequest<AllocCanteenModel> request) {
|
|
657
|
-
allocCanteenBusiness.addCanteen(request.getContent());
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
@ApiOperation("删除食堂")
|
|
661
|
-
@PostMapping("/remove-canteen")
|
|
662
|
-
public void removeCanteen(@Valid @RequestBody LeRequest<Long> request) {
|
|
663
|
-
allocCanteenBusiness.removeCanteen(request.getContent());
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
```
|
|
667
|
-
|
|
668
|
-
### 示例3:MgrMenuController
|
|
669
|
-
|
|
670
|
-
```java
|
|
671
|
-
package net.xnzn.core.auth.menu.controller;
|
|
672
|
-
|
|
673
|
-
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
674
|
-
import io.swagger.annotations.Api;
|
|
675
|
-
import io.swagger.annotations.ApiOperation;
|
|
676
|
-
import net.xnzn.framework.secure.filter.annotation.RequiresAuthentication;
|
|
677
|
-
import net.xnzn.framework.secure.filter.annotation.RequiresGuest;
|
|
678
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
|
679
|
-
import org.springframework.web.bind.annotation.*;
|
|
680
|
-
|
|
681
|
-
import jakarta.validation.Valid;
|
|
682
|
-
import java.util.List;
|
|
683
|
-
|
|
684
|
-
@RestController
|
|
685
|
-
@RequestMapping("/api/v1/mgrmenu")
|
|
686
|
-
@Api(value = "mgrmenu", tags = "菜单权限表管理")
|
|
687
|
-
public class MgrMenuController {
|
|
688
|
-
|
|
689
|
-
@Autowired
|
|
690
|
-
private MgrMenuService mgrMenuService;
|
|
691
|
-
|
|
692
|
-
@ApiOperation(value = "新增菜单")
|
|
693
|
-
@PostMapping("/add")
|
|
694
|
-
@RequiresAuthentication
|
|
695
|
-
public void saveMenu(@Valid @RequestBody LeRequest<MgrMenuVO> request) {
|
|
696
|
-
MgrMenuVO mgrMenuVO = request.getContent();
|
|
697
|
-
mgrMenuService.saveMenu(mgrMenuVO);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
@ApiOperation(value = "更新菜单")
|
|
701
|
-
@PostMapping("/update")
|
|
702
|
-
@RequiresAuthentication
|
|
703
|
-
public boolean updateMenu(@Valid @RequestBody LeRequest<MgrMenuVO> request) {
|
|
704
|
-
MgrMenuVO mgrMenuVO = request.getContent();
|
|
705
|
-
return mgrMenuService.updateMenu(mgrMenuVO);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
@ApiOperation(value = "删除菜单")
|
|
709
|
-
@DeleteMapping("/{id}")
|
|
710
|
-
@RequiresGuest
|
|
711
|
-
public boolean removeById(@PathVariable Long id) {
|
|
712
|
-
return mgrMenuService.removeById(id);
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
```
|
|
250
|
+
| 标准前缀 | `/api/v2/web/module` | 按端区分 |
|
|
251
|
+
| 报表前缀 | `/summary/xxx` | 报表/统计类 |
|
|
252
|
+
| 查询接口 | `/page/detail`, `/query` | 分页查询 |
|
|
253
|
+
| 枚举接口 | `/type-list`, `/state-list` | 枚举数据 |
|
|
254
|
+
| 导出接口 | `/export`, `/export-async/xxx` | 同步/异步 |
|
|
255
|
+
| 导出 Controller 独立 | `XxxExportWebController` | 与查询分离 |
|
|
716
256
|
|
|
717
257
|
---
|
|
718
258
|
|
|
719
259
|
## 检查清单
|
|
720
260
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
- [ ]
|
|
724
|
-
- [ ]
|
|
725
|
-
- [ ]
|
|
726
|
-
- [ ]
|
|
727
|
-
- [ ]
|
|
728
|
-
- [ ]
|
|
729
|
-
- [ ] **路径命名是否规范**?(`/add`, `/update`, `/query`, `/delete`)
|
|
730
|
-
- [ ] **是否使用中文注释和错误提示**?
|
|
731
|
-
- [ ] **敏感操作是否加了分布式锁**?
|
|
732
|
-
- [ ] **审计字段是否正确配置**?(crby/crtime/upby/uptime)
|
|
261
|
+
- [ ] 认证注解:`@RequiresAuthentication` 或 `@RequiresGuest`
|
|
262
|
+
- [ ] 文档注解:`@Api` + `@ApiOperation`
|
|
263
|
+
- [ ] 参数校验:`@Validated(InsertGroup/UpdateGroup.class)` 或 `@Valid`
|
|
264
|
+
- [ ] 请求封装:`LeRequest<T>`
|
|
265
|
+
- [ ] 返回类型:分页 `Page<VO>`、单值 `LeResponse<T>`、写操作 `void`
|
|
266
|
+
- [ ] 路径命名:`/add`、`/update`、`/query`、`/delete`
|
|
267
|
+
- [ ] 敏感操作加分布式锁
|
|
268
|
+
- [ ] 跨模块依赖用 `@Lazy` 避免循环依赖
|
|
733
269
|
|
|
734
270
|
---
|
|
735
271
|
|
|
736
272
|
## 错误对比
|
|
737
273
|
|
|
738
|
-
### ❌ 不要做
|
|
739
|
-
|
|
740
274
|
```java
|
|
741
|
-
//
|
|
742
|
-
@
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
public
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
//
|
|
754
|
-
import
|
|
755
|
-
|
|
756
|
-
// 错误 5: 审计字段使用 RuoYi 命名
|
|
757
|
-
private String createBy; // ❌ 应该用 crby
|
|
758
|
-
|
|
759
|
-
// 错误 6: 主键策略错误
|
|
760
|
-
@TableId(type = IdType.ASSIGN_ID) // ❌ leniu 使用自增
|
|
761
|
-
// 应该用
|
|
762
|
-
@TableId(value = "id", type = IdType.AUTO)
|
|
763
|
-
```
|
|
764
|
-
|
|
765
|
-
### ✅ 正确做法
|
|
275
|
+
// ❌ 不使用参数封装
|
|
276
|
+
public Long add(@RequestBody XxxDTO dto) {}
|
|
277
|
+
// ✅ 使用 LeRequest
|
|
278
|
+
public void add(@RequestBody LeRequest<XxxDTO> request) { xxxService.add(request.getContent()); }
|
|
279
|
+
|
|
280
|
+
// ❌ 不使用分组校验
|
|
281
|
+
public void add(@Valid @RequestBody LeRequest<XxxDTO> request) {}
|
|
282
|
+
// ✅ 使用分组
|
|
283
|
+
public void add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {}
|
|
284
|
+
|
|
285
|
+
// ❌ javax.validation(JDK 21 必须 jakarta)
|
|
286
|
+
import javax.validation.constraints.NotNull;
|
|
287
|
+
// ✅
|
|
288
|
+
import jakarta.validation.constraints.NotNull;
|
|
766
289
|
|
|
767
|
-
|
|
768
|
-
// 正确 1: 添加认证注解
|
|
290
|
+
// ❌ 缺少认证注解
|
|
769
291
|
@RestController
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
public void add(@RequestBody LeRequest<XxxDTO> request) {
|
|
776
|
-
xxxService.add(request.getContent());
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// 正确 3: 使用分组校验
|
|
780
|
-
@Validated(InsertGroup.class)
|
|
292
|
+
public class XxxController {}
|
|
293
|
+
// ✅
|
|
294
|
+
@RestController @RequiresAuthentication
|
|
295
|
+
public class XxxController {}
|
|
296
|
+
```
|
|
781
297
|
|
|
782
|
-
|
|
783
|
-
import jakarta.validation.constraints.NotNull; // ✅ 正确
|
|
298
|
+
---
|
|
784
299
|
|
|
785
|
-
|
|
786
|
-
@TableField(fill = FieldFill.INSERT)
|
|
787
|
-
private String crby;
|
|
300
|
+
## 真实代码示例
|
|
788
301
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
302
|
+
详见 `references/real-examples.md`,包含:
|
|
303
|
+
- ReportAnalysisController(报表模块)
|
|
304
|
+
- OrderInfoExportWebController(订单导出)
|
|
305
|
+
- OrderInfoWebController(订单查询)
|
|
306
|
+
- AttendanceLeaveInfoController(考勤请假)
|
|
307
|
+
- AllocCanteenController(食堂档口)
|
|
308
|
+
- MgrMenuController(菜单权限)
|
|
793
309
|
|
|
794
310
|
---
|
|
795
311
|
|
|
796
312
|
## 相关技能
|
|
797
313
|
|
|
798
|
-
| 需要了解 |
|
|
799
|
-
|
|
800
|
-
| Service
|
|
801
|
-
| Entity
|
|
802
|
-
| 数据库设计 | `leniu-database-
|
|
803
|
-
|
|
|
314
|
+
| 需要了解 | Skill |
|
|
315
|
+
|---------|-------|
|
|
316
|
+
| Service 层 | `leniu-service-development` |
|
|
317
|
+
| Entity 设计 | `leniu-entity-design` |
|
|
318
|
+
| 数据库设计 | `leniu-database-ops` |
|
|
319
|
+
| CRUD 开发 | `leniu-crud-development` |
|