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