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,111 +1,60 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: leniu-backend-annotations
|
|
3
3
|
description: |
|
|
4
|
-
leniu-yunshitang-core
|
|
4
|
+
leniu-yunshitang-core 项目后端注解速查指南。包含认证、校验、Swagger、MyBatis-Plus、审计字段等注解的正确用法。
|
|
5
5
|
|
|
6
6
|
触发场景:
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
- 配置 Swagger 文档注解(@Api, @ApiOperation
|
|
10
|
-
-
|
|
7
|
+
- 配置 leniu 认证注解(@RequiresAuthentication, @RequiresGuest)
|
|
8
|
+
- 配置参数校验和分组校验(InsertGroup, UpdateGroup)
|
|
9
|
+
- 配置 Swagger 文档注解(@Api, @ApiOperation)
|
|
10
|
+
- 配置 Entity 审计字段注解
|
|
11
|
+
- 排查注解使用错误(javax vs jakarta、AddGroup vs InsertGroup)
|
|
11
12
|
|
|
12
|
-
适用项目:
|
|
13
|
-
- leniu-tengyun-core:/Users/xujiajun/Developer/gongsi_proj/leniu-api/leniu-tengyun-core
|
|
14
|
-
- leniu-yunshitang:/Users/xujiajun/Developer/gongsi_proj/leniu-api/leniu-tengyun/leniu-yunshitang
|
|
13
|
+
适用项目:leniu-tengyun-core(云食堂项目)
|
|
15
14
|
|
|
16
|
-
触发词:@RequiresAuthentication、@RequiresGuest、@Validated、@NotNull、@Api、@ApiOperation
|
|
15
|
+
触发词:@RequiresAuthentication、@RequiresGuest、@Validated、@NotNull、@Api、@ApiOperation、InsertGroup、UpdateGroup、注解用法、审计字段注解
|
|
17
16
|
---
|
|
18
17
|
|
|
19
|
-
# leniu
|
|
18
|
+
# leniu 后端注解速查
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
## 注解总览
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
|
26
|
-
|
|
27
|
-
| `@
|
|
28
|
-
| `@
|
|
29
|
-
| `@
|
|
30
|
-
| `@
|
|
31
|
-
| `@
|
|
32
|
-
| `@
|
|
33
|
-
| `@
|
|
22
|
+
| 注解 | 作用层 | 包路径 | 场景 |
|
|
23
|
+
|------|--------|--------|------|
|
|
24
|
+
| `@RequiresAuthentication` | Controller 类/方法 | `net.xnzn.framework.secure.filter.annotation` | 需要登录 |
|
|
25
|
+
| `@RequiresGuest` | Controller 类/方法 | `net.xnzn.framework.secure.filter.annotation` | 允许游客 |
|
|
26
|
+
| `@Validated` | Controller 方法参数 | `org.springframework.validation.annotation` | 分组校验 |
|
|
27
|
+
| `@Valid` | Controller 方法参数 | `jakarta.validation` | 简单校验 |
|
|
28
|
+
| `@Api` | Controller 类 | `io.swagger.annotations` | Swagger 类文档 |
|
|
29
|
+
| `@ApiOperation` | Controller 方法 | `io.swagger.annotations` | Swagger 方法文档 |
|
|
30
|
+
| `@ApiModelProperty` | DTO/VO/Entity 字段 | `io.swagger.annotations` | Swagger 字段文档 |
|
|
31
|
+
| `@TableName` | Entity 类 | `com.baomidou.mybatisplus.annotation` | 表名映射 |
|
|
32
|
+
| `@TableId` | Entity 主键字段 | `com.baomidou.mybatisplus.annotation` | 主键策略 |
|
|
33
|
+
| `@TableField` | Entity 字段 | `com.baomidou.mybatisplus.annotation` | 字段映射/自动填充 |
|
|
34
34
|
|
|
35
35
|
---
|
|
36
36
|
|
|
37
37
|
## 1. 认证注解
|
|
38
38
|
|
|
39
|
-
### @RequiresAuthentication - 需要登录
|
|
40
|
-
|
|
41
39
|
```java
|
|
42
40
|
import net.xnzn.framework.secure.filter.annotation.RequiresAuthentication;
|
|
43
|
-
|
|
44
|
-
@RestController
|
|
45
|
-
@RequestMapping("/api/xxx")
|
|
46
|
-
@Api(tags = "XXX管理")
|
|
47
|
-
@RequiresAuthentication // 类级别:所有方法都需要登录
|
|
48
|
-
public class XxxController {
|
|
49
|
-
|
|
50
|
-
@Resource
|
|
51
|
-
private XxxService xxxService;
|
|
52
|
-
|
|
53
|
-
@PostMapping("/add")
|
|
54
|
-
@ApiOperation(value = "XXX-新增")
|
|
55
|
-
public Long add(@Valid @RequestBody LeRequest<XxxDTO> request) {
|
|
56
|
-
return xxxService.add(request.getContent());
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@PostMapping("/delete")
|
|
60
|
-
@ApiOperation(value = "XXX-删除")
|
|
61
|
-
public void delete(@RequestBody LeRequest<Long> request) {
|
|
62
|
-
xxxService.delete(request.getContent());
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### @RequiresGuest - 允许游客访问
|
|
68
|
-
|
|
69
|
-
```java
|
|
70
41
|
import net.xnzn.framework.secure.filter.annotation.RequiresGuest;
|
|
71
42
|
|
|
72
43
|
@RestController
|
|
73
|
-
@
|
|
74
|
-
@
|
|
75
|
-
public class PublicController {
|
|
76
|
-
|
|
77
|
-
@Resource
|
|
78
|
-
private PublicService publicService;
|
|
79
|
-
|
|
80
|
-
@RequiresGuest
|
|
81
|
-
@GetMapping("/config")
|
|
82
|
-
@ApiOperation(value = "获取配置")
|
|
83
|
-
public LeResponse<ConfigVO> getConfig() {
|
|
84
|
-
return LeResponse.succ(publicService.getConfig());
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### 混合使用
|
|
90
|
-
|
|
91
|
-
```java
|
|
92
|
-
@RestController
|
|
93
|
-
@RequestMapping("/api/xxx")
|
|
44
|
+
@RequiresAuthentication // 类级别:所有方法默认需登录
|
|
45
|
+
@RequestMapping("/api/v2/web/xxx")
|
|
94
46
|
@Api(tags = "XXX管理")
|
|
95
|
-
@RequiresAuthentication // 类级别默认需要登录
|
|
96
47
|
public class XxxController {
|
|
97
48
|
|
|
98
|
-
//
|
|
99
|
-
@PostMapping("/add")
|
|
49
|
+
@PostMapping("/add") // 继承类级别:需要登录
|
|
100
50
|
@ApiOperation(value = "XXX-新增")
|
|
101
|
-
public
|
|
102
|
-
|
|
51
|
+
public void add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
52
|
+
xxxService.add(request.getContent());
|
|
103
53
|
}
|
|
104
54
|
|
|
105
|
-
//
|
|
106
|
-
@RequiresGuest
|
|
55
|
+
@RequiresGuest // 方法级别覆盖:允许游客
|
|
107
56
|
@GetMapping("/list")
|
|
108
|
-
@ApiOperation(value = "XXX
|
|
57
|
+
@ApiOperation(value = "XXX-公开列表")
|
|
109
58
|
public List<XxxVO> list() {
|
|
110
59
|
return xxxService.list();
|
|
111
60
|
}
|
|
@@ -116,166 +65,97 @@ public class XxxController {
|
|
|
116
65
|
|
|
117
66
|
## 2. 参数校验注解
|
|
118
67
|
|
|
119
|
-
###
|
|
68
|
+
### 分组校验(新增/修改场景区分)
|
|
120
69
|
|
|
121
70
|
```java
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
71
|
+
// 分组接口
|
|
72
|
+
public interface InsertGroup {}
|
|
73
|
+
public interface UpdateGroup {}
|
|
125
74
|
|
|
126
|
-
|
|
127
|
-
@
|
|
128
|
-
public class
|
|
75
|
+
// Controller 中使用分组
|
|
76
|
+
@PostMapping("/add")
|
|
77
|
+
public void add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {}
|
|
129
78
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
@ApiOperation(value = "XXX-新增")
|
|
133
|
-
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
134
|
-
return xxxService.add(request.getContent());
|
|
135
|
-
}
|
|
79
|
+
@PostMapping("/update")
|
|
80
|
+
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request) {}
|
|
136
81
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
public void update(@Valid @RequestBody LeRequest<XxxDTO> request) {
|
|
141
|
-
xxxService.update(request.getContent());
|
|
142
|
-
}
|
|
143
|
-
}
|
|
82
|
+
// 不需要分组时用 @Valid 或 @Validated(不带参数)
|
|
83
|
+
@PostMapping("/query")
|
|
84
|
+
public Page<XxxVO> query(@Valid @RequestBody LeRequest<XxxQueryParam> request) {}
|
|
144
85
|
```
|
|
145
86
|
|
|
146
|
-
### DTO
|
|
87
|
+
### DTO 校验字段
|
|
147
88
|
|
|
148
89
|
```java
|
|
149
|
-
import jakarta.validation.constraints.*;
|
|
150
|
-
import io.swagger.annotations.ApiModel;
|
|
151
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
152
|
-
import lombok.Data;
|
|
153
|
-
import java.io.Serializable;
|
|
90
|
+
import jakarta.validation.constraints.*; // JDK 21 必须 jakarta
|
|
154
91
|
|
|
155
|
-
/**
|
|
156
|
-
* XXX DTO
|
|
157
|
-
*/
|
|
158
92
|
@Data
|
|
159
93
|
@ApiModel("XXX DTO")
|
|
160
94
|
public class XxxDTO implements Serializable {
|
|
161
95
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
@ApiModelProperty(value = "主键ID")
|
|
165
|
-
@NotNull(message = "主键ID不能为空", groups = {UpdateGroup.class})
|
|
96
|
+
@NotNull(message = "ID不能为空", groups = {UpdateGroup.class})
|
|
97
|
+
@ApiModelProperty("主键ID")
|
|
166
98
|
private Long id;
|
|
167
99
|
|
|
168
|
-
@ApiModelProperty(value = "名称", required = true)
|
|
169
100
|
@NotBlank(message = "名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
170
101
|
@Size(max = 100, message = "名称长度不能超过100个字符")
|
|
102
|
+
@ApiModelProperty(value = "名称", required = true)
|
|
171
103
|
private String name;
|
|
172
104
|
|
|
173
|
-
@ApiModelProperty(value = "状态")
|
|
174
105
|
@Min(value = 0, message = "状态不能小于0")
|
|
175
106
|
@Max(value = 1, message = "状态不能大于1")
|
|
107
|
+
@ApiModelProperty("状态")
|
|
176
108
|
private Integer status;
|
|
177
109
|
|
|
178
|
-
@ApiModelProperty(value = "邮箱")
|
|
179
|
-
@Email(message = "邮箱格式不正确")
|
|
180
|
-
private String email;
|
|
181
|
-
|
|
182
|
-
@ApiModelProperty(value = "手机号")
|
|
183
110
|
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
|
111
|
+
@ApiModelProperty("手机号")
|
|
184
112
|
private String phone;
|
|
185
113
|
|
|
186
|
-
@
|
|
187
|
-
@
|
|
188
|
-
private String
|
|
189
|
-
|
|
190
|
-
@ApiModelProperty(value = "URL")
|
|
191
|
-
@Pattern(regexp = "^https?://.+", message = "URL格式不正确")
|
|
192
|
-
private String url;
|
|
114
|
+
@Email(message = "邮箱格式不正确")
|
|
115
|
+
@ApiModelProperty("邮箱")
|
|
116
|
+
private String email;
|
|
193
117
|
|
|
194
|
-
@ApiModelProperty(value = "开始时间", required = true)
|
|
195
118
|
@NotNull(message = "开始时间不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
119
|
+
@ApiModelProperty(value = "开始时间", required = true)
|
|
196
120
|
private Date startTime;
|
|
197
121
|
|
|
198
|
-
@ApiModelProperty(value = "结束时间", required = true)
|
|
199
|
-
@NotNull(message = "结束时间不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
200
|
-
private Date endTime;
|
|
201
|
-
|
|
202
|
-
@ApiModelProperty(value = "备注")
|
|
203
122
|
@Size(max = 500, message = "备注长度不能超过500个字符")
|
|
123
|
+
@ApiModelProperty("备注")
|
|
204
124
|
private String remark;
|
|
205
125
|
}
|
|
206
126
|
```
|
|
207
127
|
|
|
208
|
-
### 分组校验
|
|
209
|
-
|
|
210
|
-
```java
|
|
211
|
-
// InsertGroup.java - 新增分组
|
|
212
|
-
public interface InsertGroup {}
|
|
213
|
-
|
|
214
|
-
// UpdateGroup.java - 修改分组
|
|
215
|
-
public interface UpdateGroup {}
|
|
216
|
-
```
|
|
217
|
-
|
|
218
128
|
---
|
|
219
129
|
|
|
220
130
|
## 3. Swagger 文档注解
|
|
221
131
|
|
|
222
|
-
### @Api - 类级别
|
|
223
|
-
|
|
224
132
|
```java
|
|
225
133
|
import io.swagger.annotations.Api;
|
|
226
|
-
|
|
227
|
-
@RestController
|
|
228
|
-
@RequestMapping("/api/xxx")
|
|
229
|
-
@Api(value = "XXX管理", tags = "XXX管理")
|
|
230
|
-
@RequiresAuthentication
|
|
231
|
-
public class XxxController {
|
|
232
|
-
// ...
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### @ApiOperation - 方法级别
|
|
237
|
-
|
|
238
|
-
```java
|
|
239
134
|
import io.swagger.annotations.ApiOperation;
|
|
135
|
+
import io.swagger.annotations.ApiModelProperty;
|
|
136
|
+
import io.swagger.annotations.ApiParam;
|
|
240
137
|
|
|
241
|
-
|
|
242
|
-
@
|
|
243
|
-
public
|
|
244
|
-
return xxxService.add(request.getContent());
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
@PostMapping("/update")
|
|
248
|
-
@ApiOperation(value = "XXX-修改")
|
|
249
|
-
public void update(@Valid @RequestBody LeRequest<XxxDTO> request) {
|
|
250
|
-
xxxService.update(request.getContent());
|
|
251
|
-
}
|
|
138
|
+
// 类级别
|
|
139
|
+
@Api(value = "XXX管理", tags = "XXX管理")
|
|
140
|
+
public class XxxController {}
|
|
252
141
|
|
|
253
|
-
|
|
254
|
-
@ApiOperation(value = "XXX
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
142
|
+
// 方法级别
|
|
143
|
+
@ApiOperation(value = "XXX-分页查询")
|
|
144
|
+
@PostMapping("/page")
|
|
145
|
+
public Page<XxxVO> page(@Valid @RequestBody LeRequest<XxxDTO> request) {}
|
|
258
146
|
|
|
147
|
+
// 路径参数
|
|
259
148
|
@GetMapping("/get/{id}")
|
|
260
|
-
@
|
|
261
|
-
public XxxVO getById(@PathVariable Long id) {
|
|
262
|
-
return xxxService.getById(id);
|
|
263
|
-
}
|
|
149
|
+
public XxxVO getById(@ApiParam(value = "主键ID", required = true) @PathVariable Long id) {}
|
|
264
150
|
|
|
265
|
-
|
|
266
|
-
@
|
|
267
|
-
public
|
|
268
|
-
return xxxService.page(request.getContent());
|
|
269
|
-
}
|
|
151
|
+
// 查询参数
|
|
152
|
+
@PostMapping("/search")
|
|
153
|
+
public List<XxxVO> search(@ApiParam(value = "搜索关键词") @RequestParam(required = false) String keyword) {}
|
|
270
154
|
```
|
|
271
155
|
|
|
272
|
-
###
|
|
156
|
+
### VO 字段文档
|
|
273
157
|
|
|
274
158
|
```java
|
|
275
|
-
import io.swagger.annotations.ApiModel;
|
|
276
|
-
import io.swagger.annotations.ApiModelProperty;
|
|
277
|
-
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
278
|
-
|
|
279
159
|
@Data
|
|
280
160
|
@ApiModel("XXX VO")
|
|
281
161
|
public class XxxVO implements Serializable {
|
|
@@ -286,370 +166,105 @@ public class XxxVO implements Serializable {
|
|
|
286
166
|
@ApiModelProperty("名称")
|
|
287
167
|
private String name;
|
|
288
168
|
|
|
289
|
-
@ApiModelProperty("
|
|
290
|
-
private String status;
|
|
291
|
-
|
|
292
|
-
@ApiModelProperty("状态描述")
|
|
293
|
-
private String statusDesc;
|
|
294
|
-
|
|
295
|
-
@ApiModelProperty(value = "创建时间")
|
|
169
|
+
@ApiModelProperty("创建时间")
|
|
296
170
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
297
171
|
private Date crtime;
|
|
298
|
-
|
|
299
|
-
@ApiModelProperty(value = "更新时间")
|
|
300
|
-
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
301
|
-
private Date uptime;
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### @ApiParam - 参数级别
|
|
306
|
-
|
|
307
|
-
```java
|
|
308
|
-
import io.swagger.annotations.ApiParam;
|
|
309
|
-
|
|
310
|
-
@GetMapping("/get/{id}")
|
|
311
|
-
@ApiOperation(value = "XXX-获取详情")
|
|
312
|
-
public XxxVO getById(
|
|
313
|
-
@ApiParam(value = "主键ID", required = true)
|
|
314
|
-
@PathVariable Long id
|
|
315
|
-
) {
|
|
316
|
-
return xxxService.getById(id);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
@PostMapping("/search")
|
|
320
|
-
@ApiOperation(value = "XXX-搜索")
|
|
321
|
-
public List<XxxVO> search(
|
|
322
|
-
@ApiParam(value = "搜索关键词")
|
|
323
|
-
@RequestParam(required = false) String keyword
|
|
324
|
-
) {
|
|
325
|
-
return xxxService.search(keyword);
|
|
326
|
-
}
|
|
327
|
-
```
|
|
328
|
-
|
|
329
|
-
---
|
|
330
|
-
|
|
331
|
-
## 4. MyBatis 注解
|
|
332
|
-
|
|
333
|
-
### @Mapper - Mapper 接口
|
|
334
|
-
|
|
335
|
-
```java
|
|
336
|
-
import org.apache.ibatis.annotations.Mapper;
|
|
337
|
-
|
|
338
|
-
@Mapper
|
|
339
|
-
public interface XxxMapper extends BaseMapper<XxxEntity> {
|
|
340
|
-
// ...
|
|
341
|
-
}
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### @TableName - 实体类
|
|
345
|
-
|
|
346
|
-
```java
|
|
347
|
-
import com.baomidou.mybatisplus.annotation.TableName;
|
|
348
|
-
|
|
349
|
-
@TableName("xxx_table")
|
|
350
|
-
public class XxxEntity {
|
|
351
|
-
// ...
|
|
352
172
|
}
|
|
353
173
|
```
|
|
354
174
|
|
|
355
|
-
### @TableId - 主键
|
|
356
|
-
|
|
357
|
-
```java
|
|
358
|
-
import com.baomidou.mybatisplus.annotation.TableId;
|
|
359
|
-
import com.baomidou.mybatisplus.annotation.IdType;
|
|
360
|
-
|
|
361
|
-
@TableId(value = "id", type = IdType.AUTO)
|
|
362
|
-
private Long id;
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### @TableField - 字段映射
|
|
366
|
-
|
|
367
|
-
```java
|
|
368
|
-
import com.baomidou.mybatisplus.annotation.TableField;
|
|
369
|
-
import com.baomidou.mybatisplus.annotation.FieldFill;
|
|
370
|
-
|
|
371
|
-
@TableField("name")
|
|
372
|
-
private String name;
|
|
373
|
-
|
|
374
|
-
@TableField(value = "crby", fill = FieldFill.INSERT)
|
|
375
|
-
private String crby;
|
|
376
|
-
|
|
377
|
-
@TableField(value = "crtime", fill = FieldFill.INSERT)
|
|
378
|
-
private Date crtime;
|
|
379
|
-
|
|
380
|
-
@TableField(value = "upby", fill = FieldFill.INSERT_UPDATE)
|
|
381
|
-
private String upby;
|
|
382
|
-
|
|
383
|
-
@TableField(value = "uptime", fill = FieldFill.INSERT_UPDATE)
|
|
384
|
-
private Date uptime;
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
---
|
|
388
|
-
|
|
389
|
-
## 5. JSON 序列化注解
|
|
390
|
-
|
|
391
|
-
### @JsonFormat - 日期格式化
|
|
392
|
-
|
|
393
|
-
```java
|
|
394
|
-
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
395
|
-
|
|
396
|
-
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
397
|
-
private Date crtime;
|
|
398
|
-
|
|
399
|
-
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
400
|
-
private Date date;
|
|
401
|
-
```
|
|
402
|
-
|
|
403
175
|
---
|
|
404
176
|
|
|
405
|
-
##
|
|
406
|
-
|
|
407
|
-
### @Data - 实体类
|
|
177
|
+
## 4. Entity 注解(MyBatis-Plus + 审计字段)
|
|
408
178
|
|
|
409
179
|
```java
|
|
410
|
-
import
|
|
180
|
+
import com.baomidou.mybatisplus.annotation.*;
|
|
411
181
|
|
|
412
182
|
@Data
|
|
413
183
|
@TableName("xxx_table")
|
|
414
|
-
public class XxxEntity {
|
|
415
|
-
private Long id;
|
|
416
|
-
private String name;
|
|
417
|
-
}
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
### @Accessors(chain = true) - 链式调用
|
|
184
|
+
public class XxxEntity implements Serializable {
|
|
421
185
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
import lombok.experimental.Accessors;
|
|
425
|
-
|
|
426
|
-
@Data
|
|
427
|
-
@Accessors(chain = true)
|
|
428
|
-
public class XxxEntity {
|
|
186
|
+
@ApiModelProperty("主键ID")
|
|
187
|
+
@TableId(value = "id", type = IdType.AUTO)
|
|
429
188
|
private Long id;
|
|
430
|
-
private String name;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// 使用
|
|
434
|
-
XxxEntity entity = new XxxEntity()
|
|
435
|
-
.setId(1L)
|
|
436
|
-
.setName("test");
|
|
437
|
-
```
|
|
438
189
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
```java
|
|
444
|
-
package net.xnzn.core.xxx.controller;
|
|
445
|
-
|
|
446
|
-
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
447
|
-
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
448
|
-
import io.swagger.annotations.Api;
|
|
449
|
-
import io.swagger.annotations.ApiOperation;
|
|
450
|
-
import io.swagger.annotations.ApiParam;
|
|
451
|
-
import lombok.extern.slf4j.Slf4j;
|
|
452
|
-
import net.xnzn.core.xxx.dto.XxxDTO;
|
|
453
|
-
import net.xnzn.core.xxx.service.XxxService;
|
|
454
|
-
import net.xnzn.core.xxx.vo.XxxVO;
|
|
455
|
-
import net.xnzn.framework.secure.filter.annotation.RequiresAuthentication;
|
|
456
|
-
import net.xnzn.framework.secure.filter.annotation.RequiresGuest;
|
|
457
|
-
|
|
458
|
-
import org.springframework.web.bind.annotation.*;
|
|
459
|
-
|
|
460
|
-
import jakarta.validation.Valid;
|
|
461
|
-
import java.util.List;
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* XXX 管理控制器
|
|
465
|
-
*/
|
|
466
|
-
@Slf4j
|
|
467
|
-
@RestController
|
|
468
|
-
@RequestMapping("/api/xxx")
|
|
469
|
-
@Api(value = "XXX管理", tags = "XXX管理")
|
|
470
|
-
@RequiresAuthentication
|
|
471
|
-
public class XxxController {
|
|
472
|
-
|
|
473
|
-
@Resource
|
|
474
|
-
private XxxService xxxService;
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* 新增
|
|
478
|
-
*/
|
|
479
|
-
@PostMapping("/add")
|
|
480
|
-
@ApiOperation(value = "XXX-新增")
|
|
481
|
-
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
482
|
-
log.info("新增XXX,参数: {}", request.getContent());
|
|
483
|
-
return xxxService.add(request.getContent());
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
/**
|
|
487
|
-
* 修改
|
|
488
|
-
*/
|
|
489
|
-
@PostMapping("/update")
|
|
490
|
-
@ApiOperation(value = "XXX-修改")
|
|
491
|
-
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
492
|
-
log.info("修改XXX,参数: {}", request.getContent());
|
|
493
|
-
xxxService.update(request.getContent());
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* 删除
|
|
498
|
-
*/
|
|
499
|
-
@PostMapping("/delete")
|
|
500
|
-
@ApiOperation(value = "XXX-删除")
|
|
501
|
-
public void delete(@RequestBody LeRequest<Long> request) {
|
|
502
|
-
log.info("删除XXX,参数: {}", request.getContent());
|
|
503
|
-
xxxService.delete(request.getContent());
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* 获取详情
|
|
508
|
-
*/
|
|
509
|
-
@GetMapping("/get/{id}")
|
|
510
|
-
@ApiOperation(value = "XXX-获取详情")
|
|
511
|
-
@RequiresGuest
|
|
512
|
-
public XxxVO getById(
|
|
513
|
-
@ApiParam(value = "主键ID", required = true)
|
|
514
|
-
@PathVariable Long id
|
|
515
|
-
) {
|
|
516
|
-
return xxxService.getById(id);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* 分页查询
|
|
521
|
-
*/
|
|
522
|
-
@PostMapping("/page")
|
|
523
|
-
@ApiOperation(value = "XXX-分页查询")
|
|
524
|
-
public Page<XxxVO> page(@Valid @RequestBody LeRequest<XxxDTO> request) {
|
|
525
|
-
log.info("分页查询XXX,参数: {}", request.getContent());
|
|
526
|
-
return xxxService.page(request.getContent());
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* 查询列表
|
|
531
|
-
*/
|
|
532
|
-
@PostMapping("/list")
|
|
533
|
-
@ApiOperation(value = "XXX-查询列表")
|
|
534
|
-
@RequiresGuest
|
|
535
|
-
public List<XxxVO> list(@Valid @RequestBody LeRequest<XxxDTO> request) {
|
|
536
|
-
return xxxService.list(request.getContent());
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
---
|
|
542
|
-
|
|
543
|
-
## 8. 常见错误对比
|
|
544
|
-
|
|
545
|
-
### ❌ 错误写法
|
|
190
|
+
@ApiModelProperty("名称")
|
|
191
|
+
@TableField("name")
|
|
192
|
+
private String name;
|
|
546
193
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
@
|
|
194
|
+
// ===== 审计字段(leniu 标准) =====
|
|
195
|
+
@ApiModelProperty("创建人")
|
|
196
|
+
@TableField(value = "crby", fill = FieldFill.INSERT)
|
|
197
|
+
private String crby;
|
|
550
198
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
199
|
+
@ApiModelProperty("创建时间")
|
|
200
|
+
@TableField(value = "crtime", fill = FieldFill.INSERT)
|
|
201
|
+
private LocalDateTime crtime;
|
|
554
202
|
|
|
555
|
-
|
|
556
|
-
@
|
|
203
|
+
@ApiModelProperty("更新人")
|
|
204
|
+
@TableField(value = "upby", fill = FieldFill.INSERT_UPDATE)
|
|
205
|
+
private String upby;
|
|
557
206
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
import io.swagger.annotations.*; // ✅ Swagger 2.0
|
|
207
|
+
@ApiModelProperty("更新时间")
|
|
208
|
+
@TableField(value = "uptime", fill = FieldFill.INSERT_UPDATE)
|
|
209
|
+
private LocalDateTime uptime;
|
|
562
210
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
public class XxxController { // ❌ 缺少 @Api
|
|
566
|
-
@PostMapping("/add")
|
|
567
|
-
public Long add(@RequestBody LeRequest<XxxDTO> request) { // ❌ 缺少 @ApiOperation
|
|
568
|
-
return xxxService.add(request.getContent());
|
|
569
|
-
}
|
|
211
|
+
@ApiModelProperty("删除标识(1-删除,2-正常)")
|
|
212
|
+
private Integer delFlag;
|
|
570
213
|
}
|
|
571
|
-
|
|
572
|
-
// 错误 6: 审计字段注解错误
|
|
573
|
-
@TableField("create_by") // ❌ 应该用 crby
|
|
574
|
-
@TableField("create_time") // ❌ 应该用 crtime
|
|
575
214
|
```
|
|
576
215
|
|
|
577
|
-
###
|
|
216
|
+
### Mapper 接口
|
|
578
217
|
|
|
579
218
|
```java
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
@RequiresGuest // ✅
|
|
583
|
-
|
|
584
|
-
// 正确 2: 使用 Jakarta Validation
|
|
585
|
-
import jakarta.validation.Valid; // ✅
|
|
586
|
-
import jakarta.validation.constraints.NotNull; // ✅
|
|
587
|
-
|
|
588
|
-
// 正确 3: 使用 leniu 的分组
|
|
589
|
-
@Validated(InsertGroup.class) // ✅
|
|
590
|
-
|
|
591
|
-
// 正确 4: Swagger 注解包正确
|
|
592
|
-
import io.swagger.annotations.Api; // ✅
|
|
593
|
-
import io.swagger.annotations.ApiOperation; // ✅
|
|
594
|
-
|
|
595
|
-
// 正确 5: Swagger 文档注解完整
|
|
596
|
-
@RestController
|
|
597
|
-
@Api(value = "XXX管理", tags = "XXX管理") // ✅
|
|
598
|
-
public class XxxController {
|
|
599
|
-
@PostMapping("/add")
|
|
600
|
-
@ApiOperation(value = "XXX-新增") // ✅
|
|
601
|
-
public Long add(@RequestBody LeRequest<XxxDTO> request) {
|
|
602
|
-
return xxxService.add(request.getContent());
|
|
603
|
-
}
|
|
604
|
-
}
|
|
219
|
+
import org.apache.ibatis.annotations.Mapper;
|
|
220
|
+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
605
221
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
@TableField(value = "crtime", fill = FieldFill.INSERT) // ✅
|
|
222
|
+
@Mapper
|
|
223
|
+
public interface XxxMapper extends BaseMapper<XxxEntity> {}
|
|
609
224
|
```
|
|
610
225
|
|
|
611
226
|
---
|
|
612
227
|
|
|
613
|
-
##
|
|
614
|
-
|
|
615
|
-
使用注解前必须检查:
|
|
228
|
+
## 5. 注解组合速查
|
|
616
229
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
- [ ] **审计字段是否配置 `FieldFill`**?
|
|
230
|
+
| 层级 | 标准注解组合 |
|
|
231
|
+
|------|-------------|
|
|
232
|
+
| Controller 类 | `@Api` + `@RestController` + `@RequiresAuthentication` + `@RequestMapping` |
|
|
233
|
+
| 写操作方法 | `@ApiOperation` + `@PostMapping` + `@Validated(InsertGroup/UpdateGroup.class)` |
|
|
234
|
+
| 查询方法 | `@ApiOperation` + `@PostMapping` + `@Valid` 或 `@Validated` |
|
|
235
|
+
| DTO 字段 | `@ApiModelProperty` + `@NotNull/@NotBlank` + `(groups = {InsertGroup.class})` |
|
|
236
|
+
| Entity 类 | `@Data` + `@TableName` |
|
|
237
|
+
| Entity 主键 | `@ApiModelProperty` + `@TableId(type = IdType.AUTO)` |
|
|
238
|
+
| 审计字段 | `@ApiModelProperty` + `@TableField(fill = FieldFill.INSERT/INSERT_UPDATE)` |
|
|
627
239
|
|
|
628
240
|
---
|
|
629
241
|
|
|
630
|
-
##
|
|
242
|
+
## 6. 错误对比
|
|
631
243
|
|
|
632
|
-
|
|
244
|
+
| 错误写法 | 正确写法 | 说明 |
|
|
245
|
+
|---------|---------|------|
|
|
246
|
+
| `@SaCheckPermission("xxx")` | `@RequiresAuthentication` | leniu 不用 Sa-Token 细粒度权限 |
|
|
247
|
+
| `import javax.validation.*` | `import jakarta.validation.*` | JDK 21 必须 jakarta |
|
|
248
|
+
| `@Validated(AddGroup.class)` | `@Validated(InsertGroup.class)` | leniu 分组名为 InsertGroup |
|
|
249
|
+
| `import io.swagger.v3.oas.*` | `import io.swagger.annotations.*` | leniu 用 Swagger 2.0 |
|
|
250
|
+
| `@TableField("create_by")` | `@TableField(value = "crby", fill = FieldFill.INSERT)` | leniu 审计字段 |
|
|
251
|
+
| `@TableField("create_time")` | `@TableField(value = "crtime", fill = FieldFill.INSERT)` | leniu 审计字段 |
|
|
252
|
+
| `@TableId(type = IdType.ASSIGN_ID)` | `@TableId(type = IdType.AUTO)` | leniu 用自增主键 |
|
|
253
|
+
| Controller 缺 `@Api` | 必须加 `@Api(tags = "模块名")` | Swagger 文档要求 |
|
|
254
|
+
| 方法缺 `@ApiOperation` | 必须加 `@ApiOperation(value = "描述")` | Swagger 文档要求 |
|
|
633
255
|
|
|
634
|
-
|
|
635
|
-
@RequiresAuthentication → 需要登录认证
|
|
636
|
-
@RequiresGuest → 允许游客访问
|
|
637
|
-
@Validated → 参数校验(支持分组)
|
|
638
|
-
@Valid → 参数校验(不支持分组)
|
|
639
|
-
@Api → Swagger 文档(类级别)
|
|
640
|
-
@ApiOperation → Swagger 文档(方法级别)
|
|
641
|
-
@ApiModelProperty → Swagger 文档(字段级别)
|
|
642
|
-
@ApiParam → Swagger 文档(参数级别)
|
|
643
|
-
```
|
|
256
|
+
---
|
|
644
257
|
|
|
645
|
-
|
|
258
|
+
## 检查清单
|
|
646
259
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
260
|
+
- [ ] 认证注解:`@RequiresAuthentication` 或 `@RequiresGuest`
|
|
261
|
+
- [ ] 校验包:`jakarta.validation`(非 `javax.validation`)
|
|
262
|
+
- [ ] 分组名:`InsertGroup` / `UpdateGroup`(非 `AddGroup` / `EditGroup`)
|
|
263
|
+
- [ ] Swagger 包:`io.swagger.annotations`(非 `io.swagger.v3.oas`)
|
|
264
|
+
- [ ] Controller 有 `@Api`,方法有 `@ApiOperation`
|
|
265
|
+
- [ ] DTO/VO 字段有 `@ApiModelProperty`
|
|
266
|
+
- [ ] Entity 主键:`@TableId(type = IdType.AUTO)`
|
|
267
|
+
- [ ] 审计字段:`crby/crtime/upby/uptime` + 正确的 `FieldFill`
|
|
653
268
|
|
|
654
269
|
---
|
|
655
270
|
|
|
@@ -657,8 +272,6 @@ Entity Field: @TableField + @ApiModelProperty
|
|
|
657
272
|
|
|
658
273
|
| 类型 | 路径 |
|
|
659
274
|
|------|------|
|
|
660
|
-
| Controller 示例 | `
|
|
661
|
-
| DTO 示例 | `
|
|
662
|
-
| Entity 示例 | `
|
|
663
|
-
|
|
664
|
-
**项目路径**:`/Users/xujiajun/Developer/gongsi_proj/leniu-api/leniu-tengyun-core`
|
|
275
|
+
| Controller 示例 | `sys-canteen/.../order/web/controller/OrderInfoWebController.java` |
|
|
276
|
+
| DTO 示例 | `sys-kitchen/.../attendance/.../dto/` |
|
|
277
|
+
| Entity 示例 | `sys-canteen/.../order/common/model/OrderInfo.java` |
|