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,590 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-patterns
|
|
3
|
+
description: |
|
|
4
|
+
后端代码禁令和编码规范速查。本项目是纯后端项目,前端代码在分离的项目中开发。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 查看项目禁止事项(后端代码)
|
|
8
|
+
- 命名规范速查
|
|
9
|
+
- Git 提交规范
|
|
10
|
+
- 避免过度工程
|
|
11
|
+
- 代码风格检查
|
|
12
|
+
|
|
13
|
+
触发词:规范、禁止、命名、Git提交、代码风格、不能用、不允许、包名、架构
|
|
14
|
+
|
|
15
|
+
注意:后端 CRUD 开发规范请激活 crud-development,API 开发规范请激活 api-development,数据库设计规范请激活 database-ops。
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
# 代码规范速查
|
|
19
|
+
|
|
20
|
+
## 🚫 后端禁令速查表
|
|
21
|
+
|
|
22
|
+
> **快速查表**:一眼定位所有后端代码禁止写法
|
|
23
|
+
|
|
24
|
+
| 禁止项 | ❌ 禁止写法 | ✅ 正确写法 | 原因 |
|
|
25
|
+
|--------|-----------|-----------|------|
|
|
26
|
+
| 包名规范 | `com.ruoyi.*` 或 `plus.ruoyi.*` | `org.dromara.*` | 包名统一标准 |
|
|
27
|
+
| 完整引用 | `org.dromara.xxx.Xxx` (内联全限定名) | `import` + 短类名 | 代码整洁 |
|
|
28
|
+
| 数据返回 | `Map<String, Object>` 返回业务数据 | 创建 VO 类 | 类型安全 |
|
|
29
|
+
| Service设计 | `extends ServiceImpl<>` | `implements IXxxService` | 三层架构 |
|
|
30
|
+
| 查询构建 | 在 Controller 层构建 | **Service 层** `buildQueryWrapper()` | 职责分离 |
|
|
31
|
+
| 接口路径 | `/pageXxxs`, `/getXxx/{id}` | `/list`, `/{id}`, `/` | RESTful 规范 |
|
|
32
|
+
| 对象转换 | `BeanUtil.copyProperties()` | `MapstructUtils.convert()` | 项目统一规范 |
|
|
33
|
+
| 主键策略 | `AUTO_INCREMENT` | 雪花ID(不指定type) | 主键策略规范 |
|
|
34
|
+
| 返回String陷阱 | `R.ok(stringValue)` 返回字符串到data | `R.ok(null, stringValue)` | 方法重载陷阱 |
|
|
35
|
+
| Entity基类 | 无基类继承 | `extends TenantEntity`(业务表)或 `extends BaseEntity`(系统表) | 多租户支持 |
|
|
36
|
+
| Redis缓存 | `@Cacheable` 返回 `List.of()`/`Set.of()` | `new ArrayList<>(List.of())` | Redis 反序列化失败 |
|
|
37
|
+
| Mapper注解 | 单目标用 `@AutoMappers`(复数) | 单目标用 `@AutoMapper`(单数) | 多目标时可用复数 |
|
|
38
|
+
| Bash命令 | `> nul` | `> /dev/null 2>&1` | Windows 会创建 nul 文件 |
|
|
39
|
+
| 注释语言 | 英文注释 `// get user name` | 中文注释 `// 获取用户名` | 项目统一中文 |
|
|
40
|
+
| SQL COMMENT | `COMMENT 'user name'` | `COMMENT '用户名'` | 项目统一中文 |
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🚫 后端禁令(14 条)
|
|
45
|
+
|
|
46
|
+
### 1. 包名必须是 `org.dromara.*`
|
|
47
|
+
|
|
48
|
+
```java
|
|
49
|
+
// ✅ 正确
|
|
50
|
+
package org.dromara.system.service;
|
|
51
|
+
package org.dromara.demo.controller;
|
|
52
|
+
|
|
53
|
+
// ❌ 错误
|
|
54
|
+
package com.ruoyi.system.service;
|
|
55
|
+
package plus.ruoyi.business.service;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. 禁止使用完整类型引用
|
|
59
|
+
|
|
60
|
+
```java
|
|
61
|
+
// ✅ 正确:先 import 再使用
|
|
62
|
+
import org.dromara.common.core.domain.R;
|
|
63
|
+
public R<XxxVo> getXxx(Long id) { ... }
|
|
64
|
+
|
|
65
|
+
// ❌ 错误:直接使用完整包名
|
|
66
|
+
public org.dromara.common.core.domain.R<XxxVo> getXxx(Long id) { ... }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. 禁止使用 Map 封装业务数据
|
|
70
|
+
|
|
71
|
+
```java
|
|
72
|
+
// ✅ 正确:创建 VO 类
|
|
73
|
+
public XxxVo getXxx(Long id) {
|
|
74
|
+
return MapstructUtils.convert(entity, XxxVo.class);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ❌ 错误:使用 Map
|
|
78
|
+
public Map<String, Object> getXxx(Long id) {
|
|
79
|
+
Map<String, Object> result = new HashMap<>();
|
|
80
|
+
result.put("id", entity.getId());
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. Service 禁止继承 ServiceImpl 基类
|
|
86
|
+
|
|
87
|
+
```java
|
|
88
|
+
// ✅ 正确:不继承任何基类,直接注入 Mapper
|
|
89
|
+
@Service
|
|
90
|
+
public class XxxServiceImpl implements IXxxService {
|
|
91
|
+
private final XxxMapper baseMapper; // 直接注入 Mapper
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ❌ 错误:继承 ServiceImpl
|
|
95
|
+
public class XxxServiceImpl extends ServiceImpl<XxxMapper, Xxx> {
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 5. 查询条件必须在 Service 层构建
|
|
100
|
+
|
|
101
|
+
> **本项目是三层架构(无 DAO 层)**,`buildQueryWrapper()` 在 **Service 实现类**中。
|
|
102
|
+
|
|
103
|
+
```java
|
|
104
|
+
// ✅ 正确:在 Service 层构建查询条件
|
|
105
|
+
@Service
|
|
106
|
+
public class XxxServiceImpl implements IXxxService {
|
|
107
|
+
|
|
108
|
+
private final XxxMapper baseMapper;
|
|
109
|
+
|
|
110
|
+
private LambdaQueryWrapper<Xxx> buildQueryWrapper(XxxBo bo) {
|
|
111
|
+
LambdaQueryWrapper<Xxx> lqw = Wrappers.lambdaQuery();
|
|
112
|
+
lqw.eq(bo.getStatus() != null, Xxx::getStatus, bo.getStatus());
|
|
113
|
+
lqw.like(StringUtils.isNotBlank(bo.getName()), Xxx::getName, bo.getName());
|
|
114
|
+
return lqw;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public TableDataInfo<XxxVo> queryPageList(XxxBo bo, PageQuery pageQuery) {
|
|
119
|
+
LambdaQueryWrapper<Xxx> lqw = buildQueryWrapper(bo);
|
|
120
|
+
Page<XxxVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
121
|
+
return TableDataInfo.build(result);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// ❌ 错误:在 Controller 层构建查询条件
|
|
126
|
+
@RestController
|
|
127
|
+
public class XxxController {
|
|
128
|
+
@GetMapping("/list")
|
|
129
|
+
public R<List<XxxVo>> list(XxxBo bo) {
|
|
130
|
+
LambdaQueryWrapper<Xxx> wrapper = new LambdaQueryWrapper<>(); // 禁止!
|
|
131
|
+
wrapper.eq(Xxx::getStatus, bo.getStatus());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 6. 接口路径必须使用标准 RESTful 格式
|
|
137
|
+
|
|
138
|
+
```java
|
|
139
|
+
// ✅ 正确:标准 RESTful 路径
|
|
140
|
+
@GetMapping("/list") // 分页/列表查询
|
|
141
|
+
@GetMapping("/{id}") // 获取详情
|
|
142
|
+
@PostMapping // 新增(空路径)
|
|
143
|
+
@PutMapping // 修改(空路径)
|
|
144
|
+
@DeleteMapping("/{ids}") // 删除
|
|
145
|
+
@PostMapping("/export") // 导出
|
|
146
|
+
|
|
147
|
+
// ❌ 错误:包含动词或实体名
|
|
148
|
+
@GetMapping("/pageAds")
|
|
149
|
+
@GetMapping("/getAd/{id}")
|
|
150
|
+
@PostMapping("/addAd")
|
|
151
|
+
@PutMapping("/updateAd")
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 7. 禁止使用 BeanUtil 进行对象转换
|
|
155
|
+
|
|
156
|
+
```java
|
|
157
|
+
// ✅ 正确:使用 MapstructUtils
|
|
158
|
+
XxxVo vo = MapstructUtils.convert(entity, XxxVo.class);
|
|
159
|
+
List<XxxVo> voList = MapstructUtils.convert(entityList, XxxVo.class);
|
|
160
|
+
|
|
161
|
+
// ❌ 错误:使用 BeanUtil
|
|
162
|
+
BeanUtil.copyProperties(entity, vo); // 禁止!
|
|
163
|
+
BeanUtils.copyProperties(entity, vo); // 禁止!
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 8. 禁止使用 AUTO_INCREMENT
|
|
167
|
+
|
|
168
|
+
```sql
|
|
169
|
+
-- ✅ 正确:不指定自增,使用雪花ID(MyBatis-Plus 全局配置)
|
|
170
|
+
id BIGINT(20) NOT NULL COMMENT '主键ID'
|
|
171
|
+
|
|
172
|
+
-- ❌ 错误:使用自增
|
|
173
|
+
id BIGINT(20) AUTO_INCREMENT -- 禁止!
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### 9. R.ok() 返回 String 类型的陷阱
|
|
177
|
+
|
|
178
|
+
```java
|
|
179
|
+
// 场景:Controller 返回 R<String>,想把字符串放到 data 中
|
|
180
|
+
|
|
181
|
+
// ❌ 错误:会匹配 R.ok(String msg),字符串进入 msg 而非 data
|
|
182
|
+
return R.ok(token); // 结果:{code:200, msg:"xxx", data:null}
|
|
183
|
+
|
|
184
|
+
// ✅ 正确:明确指定 msg 和 data
|
|
185
|
+
return R.ok(null, token); // data 有值,msg 为 null
|
|
186
|
+
return R.ok("获取成功", token); // msg 和 data 都有值
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 10. Entity 必须继承合适的基类
|
|
190
|
+
|
|
191
|
+
```java
|
|
192
|
+
// ✅ 正确:业务表(需要多租户隔离)继承 TenantEntity
|
|
193
|
+
@Data
|
|
194
|
+
@EqualsAndHashCode(callSuper = true)
|
|
195
|
+
@TableName("xxx_table")
|
|
196
|
+
public class Xxx extends TenantEntity { // ✅ 业务表推荐
|
|
197
|
+
@TableId(value = "id")
|
|
198
|
+
private Long id;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ✅ 正确:系统级/工具级表(不需要多租户)继承 BaseEntity
|
|
202
|
+
// 例如:SysClient(OAuth2客户端)、GenTable(代码生成)
|
|
203
|
+
@Data
|
|
204
|
+
@EqualsAndHashCode(callSuper = true)
|
|
205
|
+
@TableName("sys_client")
|
|
206
|
+
public class SysClient extends BaseEntity { // ✅ 系统表可用
|
|
207
|
+
@TableId(value = "id")
|
|
208
|
+
private Long id;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ❌ 错误:不继承任何基类
|
|
212
|
+
public class Xxx { // 禁止!缺少审计字段
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 11. @Cacheable 禁止返回不可变集合
|
|
217
|
+
|
|
218
|
+
```java
|
|
219
|
+
// ❌ 错误:List.of()/Set.of()/Map.of() 返回不可变集合
|
|
220
|
+
// 会导致 Redis 反序列化失败(Jackson DefaultTyping 无法正确处理)
|
|
221
|
+
@Cacheable(value = "xxx")
|
|
222
|
+
public List<String> listXxx() {
|
|
223
|
+
return List.of("1", "2"); // 禁止!第二次请求会报错
|
|
224
|
+
return Set.of("a", "b"); // 禁止!
|
|
225
|
+
return Map.of("k", "v"); // 禁止!
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ✅ 正确:使用可变集合包装
|
|
229
|
+
@Cacheable(value = "xxx")
|
|
230
|
+
public List<String> listXxx() {
|
|
231
|
+
return new ArrayList<>(List.of("1", "2")); // ✅
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@Cacheable(value = "xxx")
|
|
235
|
+
public Set<String> setXxx() {
|
|
236
|
+
return new HashSet<>(Set.of("a", "b")); // ✅
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@Cacheable(value = "xxx")
|
|
240
|
+
public Map<String, String> mapXxx() {
|
|
241
|
+
return new HashMap<>(Map.of("k", "v")); // ✅
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**原因**:本项目 Redis 使用 `Jackson DefaultTyping.NON_FINAL`,会为非 final 类添加类型信息。`List.of()` 返回的 `ImmutableCollections$List12` 是非 final 类,序列化后反序列化时会将内层元素误判为类型数组,导致 `ClassNotFoundException`。
|
|
246
|
+
|
|
247
|
+
### 12. BO 映射注解规范
|
|
248
|
+
|
|
249
|
+
```java
|
|
250
|
+
// ✅ 正确:单目标映射使用 @AutoMapper(单数)
|
|
251
|
+
@Data
|
|
252
|
+
@AutoMapper(target = Xxx.class, reverseConvertGenerate = false)
|
|
253
|
+
public class XxxBo {
|
|
254
|
+
// ...
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ✅ 正确:多目标映射使用 @AutoMappers(复数)
|
|
258
|
+
// 例如 SysOperLogBo 需要映射到 SysOperLog 和 OperLogEvent 两个目标
|
|
259
|
+
@AutoMappers({
|
|
260
|
+
@AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false),
|
|
261
|
+
@AutoMapper(target = OperLogEvent.class)
|
|
262
|
+
})
|
|
263
|
+
public class SysOperLogBo {
|
|
264
|
+
// ...
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// ❌ 错误:单目标时使用 @AutoMappers 包装(冗余)
|
|
268
|
+
@AutoMappers({
|
|
269
|
+
@AutoMapper(target = Xxx.class)
|
|
270
|
+
})
|
|
271
|
+
public class XxxBo {
|
|
272
|
+
// ...
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### 13. 代码注释必须使用中文
|
|
277
|
+
|
|
278
|
+
> **⚠️ 高频问题**:Codex/Gemini 协作时经常输出英文注释,必须检查并修正。
|
|
279
|
+
|
|
280
|
+
```java
|
|
281
|
+
// ✅ 正确:中文注释
|
|
282
|
+
/**
|
|
283
|
+
* 根据 ID 查询用户信息
|
|
284
|
+
*
|
|
285
|
+
* @param id 用户 ID
|
|
286
|
+
* @return 用户视图对象
|
|
287
|
+
*/
|
|
288
|
+
public SysUserVo queryById(Long id) {
|
|
289
|
+
// 查询用户基本信息
|
|
290
|
+
return baseMapper.selectVoById(id);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// ❌ 错误:英文注释
|
|
294
|
+
/**
|
|
295
|
+
* Query user info by ID
|
|
296
|
+
*
|
|
297
|
+
* @param id user ID
|
|
298
|
+
* @return user view object
|
|
299
|
+
*/
|
|
300
|
+
public SysUserVo queryById(Long id) {
|
|
301
|
+
// query user basic info
|
|
302
|
+
return baseMapper.selectVoById(id);
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**适用范围**:
|
|
307
|
+
- Javadoc 注释(`/** */`)
|
|
308
|
+
- 行内注释(`//`)
|
|
309
|
+
- 块注释(`/* */`)
|
|
310
|
+
- `@param`、`@return`、`@throws` 的描述文本
|
|
311
|
+
- SQL 注释(`--`)
|
|
312
|
+
|
|
313
|
+
**不适用**(保持英文):
|
|
314
|
+
- 变量名、方法名、类名(遵循 Java 命名规范)
|
|
315
|
+
- 注解属性值(如 `@TableName("sys_user")`)
|
|
316
|
+
- 日志中的英文关键词(如 `log.error("Failed to...")`,但建议也用中文)
|
|
317
|
+
|
|
318
|
+
### 14. SQL COMMENT 必须使用中文
|
|
319
|
+
|
|
320
|
+
```sql
|
|
321
|
+
-- ✅ 正确:中文 COMMENT
|
|
322
|
+
`user_name` VARCHAR(50) NOT NULL COMMENT '用户名',
|
|
323
|
+
`status` CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
|
|
324
|
+
) ENGINE=InnoDB COMMENT='用户信息表';
|
|
325
|
+
|
|
326
|
+
-- ❌ 错误:英文 COMMENT(⚠️ Codex 高频错误)
|
|
327
|
+
`user_name` VARCHAR(50) NOT NULL COMMENT 'user name',
|
|
328
|
+
`status` CHAR(1) DEFAULT '0' COMMENT 'status(0=normal 1=disabled)',
|
|
329
|
+
) ENGINE=InnoDB COMMENT='user info table';
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## 📝 命名规范速查
|
|
335
|
+
|
|
336
|
+
### 后端命名
|
|
337
|
+
|
|
338
|
+
| 类型 | 规范 | 示例 |
|
|
339
|
+
|------|------|------|
|
|
340
|
+
| 包名 | 小写,点分隔 | `org.dromara.system` |
|
|
341
|
+
| 类名 | 大驼峰 | `SysUserServiceImpl` |
|
|
342
|
+
| 方法名 | 小驼峰 | `queryPageList`, `selectById` |
|
|
343
|
+
| 变量名 | 小驼峰 | `userName`, `createTime` |
|
|
344
|
+
| 常量 | 全大写下划线 | `MAX_PAGE_SIZE` |
|
|
345
|
+
| 表名 | 小写下划线 | `sys_user`, `test_demo` |
|
|
346
|
+
| 字段名 | 小写下划线 | `user_name`, `create_time` |
|
|
347
|
+
|
|
348
|
+
### 类命名后缀
|
|
349
|
+
|
|
350
|
+
| 类型 | 后缀 | 示例 |
|
|
351
|
+
|------|------|------|
|
|
352
|
+
| 实体类 | 无/Sys前缀 | `SysUser`, `TestDemo` |
|
|
353
|
+
| 业务对象 | Bo | `SysUserBo`, `TestDemoBo` |
|
|
354
|
+
| 视图对象 | Vo | `SysUserVo`, `TestDemoVo` |
|
|
355
|
+
| 服务接口 | IXxxService | `ISysUserService` |
|
|
356
|
+
| 服务实现 | XxxServiceImpl | `SysUserServiceImpl` |
|
|
357
|
+
| 控制器 | XxxController | `SysUserController` |
|
|
358
|
+
| Mapper | XxxMapper | `SysUserMapper` |
|
|
359
|
+
|
|
360
|
+
> **注意**:本项目是三层架构,没有 DAO 层。Service 直接注入 Mapper。
|
|
361
|
+
|
|
362
|
+
### 方法命名
|
|
363
|
+
|
|
364
|
+
| 操作 | Service 方法 | Controller URL |
|
|
365
|
+
|------|-------------|----------------|
|
|
366
|
+
| 分页查询 | `queryPageList(bo, pageQuery)` | `GET /list` |
|
|
367
|
+
| 查询单个 | `queryById(id)` | `GET /{id}` |
|
|
368
|
+
| 新增 | `insertByBo(bo)` | `POST /` |
|
|
369
|
+
| 修改 | `updateByBo(bo)` | `PUT /` |
|
|
370
|
+
| 删除 | `deleteWithValidByIds(ids)` | `DELETE /{ids}` |
|
|
371
|
+
| 导出 | `queryList(bo)` + ExcelUtil | `POST /export` |
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## ✅ 避免过度工程
|
|
376
|
+
|
|
377
|
+
### 不要做的事
|
|
378
|
+
|
|
379
|
+
1. **不要创建不必要的抽象**
|
|
380
|
+
- 只有一处使用的代码不需要抽取
|
|
381
|
+
- 三处以上相同代码才考虑抽取
|
|
382
|
+
|
|
383
|
+
2. **不要添加不需要的功能**
|
|
384
|
+
- 只实现当前需求
|
|
385
|
+
- 不要"以防万一"添加功能
|
|
386
|
+
|
|
387
|
+
3. **不要过早优化**
|
|
388
|
+
- 优先使用简单直接的方案
|
|
389
|
+
- 复杂方案需要有明确理由
|
|
390
|
+
|
|
391
|
+
4. **不要添加无用注释**
|
|
392
|
+
- 不要给显而易见的代码加注释
|
|
393
|
+
- 只在逻辑复杂处添加注释
|
|
394
|
+
|
|
395
|
+
5. **不要保留废弃代码**
|
|
396
|
+
- 删除不用的代码,不要注释保留
|
|
397
|
+
- Git 有历史记录
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 📦 Git 提交规范
|
|
402
|
+
|
|
403
|
+
### 格式
|
|
404
|
+
|
|
405
|
+
```
|
|
406
|
+
<type>(<scope>): <description>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### 类型
|
|
410
|
+
|
|
411
|
+
| type | 说明 |
|
|
412
|
+
|------|------|
|
|
413
|
+
| `feat` | 新功能 |
|
|
414
|
+
| `fix` | 修复 Bug |
|
|
415
|
+
| `docs` | 文档更新 |
|
|
416
|
+
| `style` | 代码格式(不影响逻辑) |
|
|
417
|
+
| `refactor` | 重构(不是新功能或修复) |
|
|
418
|
+
| `perf` | 性能优化 |
|
|
419
|
+
| `test` | 测试 |
|
|
420
|
+
| `chore` | 构建/工具 |
|
|
421
|
+
|
|
422
|
+
### 示例
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
feat(system): 新增用户反馈功能
|
|
426
|
+
fix(demo): 修复订单状态显示错误
|
|
427
|
+
docs(readme): 更新安装说明
|
|
428
|
+
refactor(common): 重构分页查询工具类
|
|
429
|
+
perf(system): 优化用户列表查询性能
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## 🔗 相关 Skill
|
|
435
|
+
|
|
436
|
+
| 需要了解 | 激活 Skill |
|
|
437
|
+
|---------|-----------|
|
|
438
|
+
| 后端 CRUD 开发规范 | `crud-development` |
|
|
439
|
+
| API 开发规范 | `api-development` |
|
|
440
|
+
| 数据库设计规范 | `database-ops` |
|
|
441
|
+
| 系统架构设计 | `architecture-design` |
|
|
442
|
+
| 技术方案决策 | `tech-decision` |
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## 多项目适配说明
|
|
447
|
+
|
|
448
|
+
### 不同项目代码模式对比
|
|
449
|
+
|
|
450
|
+
| 项目特征 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
451
|
+
|---------|----------------|-------------------|
|
|
452
|
+
| **包名前缀** | `org.dromara.*` | `net.xnzn.core.*` |
|
|
453
|
+
| **JDK 版本** | 17 | 21 |
|
|
454
|
+
| **Validation** | `jakarta.validation.*` | `jakarta.validation.*` |
|
|
455
|
+
| **工具库** | 自定义工具类 | Hutool (CollUtil, ObjectUtil, BeanUtil) |
|
|
456
|
+
| **分页** | `TableDataInfo<T>` | `Page<T>` |
|
|
457
|
+
| **对象转换** | `MapstructUtils.convert()` | `BeanUtil.copyProperties()` |
|
|
458
|
+
|
|
459
|
+
### 通用代码规范
|
|
460
|
+
|
|
461
|
+
无论使用哪种项目架构,以下规范都是通用的:
|
|
462
|
+
|
|
463
|
+
1. **禁止使用 `SELECT *`**:明确指定字段
|
|
464
|
+
2. **使用参数化查询**:`#{}` 而非 `${}`
|
|
465
|
+
3. **异常必须处理**:不能吞掉异常
|
|
466
|
+
4. **日志使用占位符**:`log.info("msg: {}", value)`
|
|
467
|
+
5. **敏感信息脱敏**:不记录密码、身份证等
|
|
468
|
+
6. **集合判空**:使用 `CollUtil.isEmpty()` 或类似方法
|
|
469
|
+
7. **空指针防护**:使用 `Optional` 或 `ObjectUtil.isNull()`
|
|
470
|
+
|
|
471
|
+
### Hutool 工具类速查
|
|
472
|
+
|
|
473
|
+
```java
|
|
474
|
+
// 集合判空
|
|
475
|
+
if (CollUtil.isEmpty(list)) { }
|
|
476
|
+
if (CollUtil.isNotEmpty(list)) { }
|
|
477
|
+
|
|
478
|
+
// 对象判空
|
|
479
|
+
if (ObjectUtil.isNull(obj)) { }
|
|
480
|
+
if (ObjectUtil.isNotNull(obj)) { }
|
|
481
|
+
|
|
482
|
+
// 字符串判空
|
|
483
|
+
if (StrUtil.isBlank(str)) { }
|
|
484
|
+
if (StrUtil.isNotBlank(str)) { }
|
|
485
|
+
|
|
486
|
+
// 对象拷贝
|
|
487
|
+
Target target = BeanUtil.copyProperties(source, Target.class);
|
|
488
|
+
List<Target> targets = BeanUtil.copyToList(sources, Target.class);
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
## leniu-tengyun-core 代码模式
|
|
494
|
+
|
|
495
|
+
### Hutool 工具类完整用法
|
|
496
|
+
|
|
497
|
+
```java
|
|
498
|
+
import cn.hutool.core.collection.CollUtil;
|
|
499
|
+
import cn.hutool.core.util.ObjectUtil;
|
|
500
|
+
import cn.hutool.core.util.StrUtil;
|
|
501
|
+
import cn.hutool.core.bean.BeanUtil;
|
|
502
|
+
|
|
503
|
+
// 1. 集合操作
|
|
504
|
+
if (CollUtil.isEmpty(list)) {
|
|
505
|
+
throw new LeException("列表不能为空");
|
|
506
|
+
}
|
|
507
|
+
if (CollUtil.isNotEmpty(list)) {
|
|
508
|
+
// 处理列表
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// 2. 对象判空
|
|
512
|
+
if (ObjectUtil.isNull(user)) {
|
|
513
|
+
throw new LeException("用户不存在");
|
|
514
|
+
}
|
|
515
|
+
if (ObjectUtil.isNotNull(user)) {
|
|
516
|
+
// 处理用户
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// 3. 字符串操作
|
|
520
|
+
if (StrUtil.isBlank(name)) {
|
|
521
|
+
throw new LeException("名称不能为空");
|
|
522
|
+
}
|
|
523
|
+
String trimmed = StrUtil.trim(name);
|
|
524
|
+
String joined = StrUtil.join(",", list);
|
|
525
|
+
|
|
526
|
+
// 4. 对象拷贝
|
|
527
|
+
TargetDTO target = BeanUtil.copyProperties(source, TargetDTO.class);
|
|
528
|
+
List<TargetDTO> targets = BeanUtil.copyToList(sources, TargetDTO.class);
|
|
529
|
+
|
|
530
|
+
// 5. 集合创建
|
|
531
|
+
List<String> list = CollUtil.newArrayList("a", "b", "c");
|
|
532
|
+
Map<String, Object> map = CollUtil.newHashMap();
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
### 国际化消息
|
|
536
|
+
|
|
537
|
+
```java
|
|
538
|
+
import net.xnzn.core.common.i18n.I18n;
|
|
539
|
+
|
|
540
|
+
// RuoYi-Vue-Plus 风格
|
|
541
|
+
throw new ServiceException(MessageUtils.message("user.not.exists"));
|
|
542
|
+
|
|
543
|
+
// leniu-tengyun-core 风格
|
|
544
|
+
throw new LeException(I18n.getMessage("user.not.exists"));
|
|
545
|
+
|
|
546
|
+
// 带参数的国际化
|
|
547
|
+
throw new LeException(I18n.getMessage("user.password.retry.limit.exceed", maxRetryCount));
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### 租户上下文
|
|
551
|
+
|
|
552
|
+
```java
|
|
553
|
+
import net.xnzn.core.context.TenantContextHolder;
|
|
554
|
+
|
|
555
|
+
// 获取当前租户ID
|
|
556
|
+
Long tenantId = TenantContextHolder.getTenantId();
|
|
557
|
+
|
|
558
|
+
// 设置租户ID
|
|
559
|
+
TenantContextHolder.setTenantId(tenantId);
|
|
560
|
+
|
|
561
|
+
// 清除租户上下文
|
|
562
|
+
TenantContextHolder.clear();
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
### 分页参数处理
|
|
566
|
+
|
|
567
|
+
```java
|
|
568
|
+
// leniu-tengyun-core 风格
|
|
569
|
+
@Data
|
|
570
|
+
public class XxxQueryParam implements Serializable {
|
|
571
|
+
@ApiModelProperty(value = "分页参数", required = true)
|
|
572
|
+
@NotNull(message = "分页参数不能为空")
|
|
573
|
+
private PageDTO page;
|
|
574
|
+
|
|
575
|
+
@ApiModelProperty("关键字")
|
|
576
|
+
private String keyword;
|
|
577
|
+
|
|
578
|
+
@ApiModelProperty("状态")
|
|
579
|
+
private Integer status;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
// Service 层处理
|
|
583
|
+
public Page<XxxVO> pageList(XxxQueryParam param) {
|
|
584
|
+
// 使用 PageHelper 分页
|
|
585
|
+
PageMethod.startPage(param.getPage().getPageNum(), param.getPage().getPageSize());
|
|
586
|
+
|
|
587
|
+
List<XxxEntity> list = xxxMapper.selectList(buildWrapper(param));
|
|
588
|
+
return new Page<>(list);
|
|
589
|
+
}
|
|
590
|
+
```
|