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,649 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: crud-development
|
|
3
|
+
description: |
|
|
4
|
+
后端 CRUD 开发规范。基于 RuoYi-Vue-Plus 三层架构(Controller → Service → Mapper),无独立 DAO 层。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 新建业务模块的 CRUD 功能
|
|
8
|
+
- 创建 Entity、BO、VO、Service、Mapper、Controller
|
|
9
|
+
- 分页查询、新增、修改、删除、导出
|
|
10
|
+
- 查询条件构建(buildQueryWrapper)
|
|
11
|
+
|
|
12
|
+
触发词:CRUD、增删改查、新建模块、Entity、BO、VO、Service、Mapper、Controller、分页查询、buildQueryWrapper、@AutoMapper、BaseMapperPlus、TenantEntity
|
|
13
|
+
|
|
14
|
+
注意:
|
|
15
|
+
- 本项目是三层架构,Service 直接注入 Mapper,无 DAO 层。
|
|
16
|
+
- 查询条件在 Service 层构建(buildQueryWrapper)。
|
|
17
|
+
- 使用 @AutoMapper(单数)而非 @AutoMappers。
|
|
18
|
+
- API 路径使用标准 RESTful 格式(/list、/{id})。
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# CRUD 全栈开发规范(RuoYi-Vue-Plus 三层架构版)
|
|
22
|
+
|
|
23
|
+
> **⚠️ 重要声明**: 本项目是 **RuoYi-Vue-Plus 纯后端项目**,采用三层架构!
|
|
24
|
+
> 不同于其他四层架构项目,本项目 **无独立 DAO 层**,Service 直接调用 Mapper。
|
|
25
|
+
|
|
26
|
+
## 核心架构特征
|
|
27
|
+
|
|
28
|
+
| 对比项 | 本项目 (RuoYi-Vue-Plus) |
|
|
29
|
+
|--------|----------------------|
|
|
30
|
+
| **包名前缀** | `org.dromara.*` |
|
|
31
|
+
| **架构** | 三层:Controller → Service → Mapper |
|
|
32
|
+
| **DAO 层** | ❌ 不存在,Service 直接注入 Mapper |
|
|
33
|
+
| **查询构建** | Service 层 `buildQueryWrapper()` |
|
|
34
|
+
| **Mapper 继承** | `BaseMapperPlus<Entity, VO>` |
|
|
35
|
+
| **对象转换** | `MapstructUtils.convert()` |
|
|
36
|
+
| **Entity 基类** | `TenantEntity`(多租户) |
|
|
37
|
+
| **BO 映射** | `@AutoMapper` 注解(单数) |
|
|
38
|
+
| **API 路径** | 标准 RESTful:`/list`、`/{id}` |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 1. Entity 实体类(继承 TenantEntity)
|
|
43
|
+
|
|
44
|
+
```java
|
|
45
|
+
package org.dromara.demo.domain;
|
|
46
|
+
|
|
47
|
+
import org.dromara.common.tenant.core.TenantEntity;
|
|
48
|
+
import com.baomidou.mybatisplus.annotation.*;
|
|
49
|
+
import lombok.Data;
|
|
50
|
+
import lombok.EqualsAndHashCode;
|
|
51
|
+
import java.io.Serial;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* XXX 对象
|
|
55
|
+
*
|
|
56
|
+
* @author Lion Li
|
|
57
|
+
*/
|
|
58
|
+
@Data
|
|
59
|
+
@EqualsAndHashCode(callSuper = true)
|
|
60
|
+
@TableName("test_xxx")
|
|
61
|
+
public class Xxx extends TenantEntity { // ✅ 继承 TenantEntity(多租户)
|
|
62
|
+
|
|
63
|
+
@Serial
|
|
64
|
+
private static final long serialVersionUID = 1L;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 主键 ID
|
|
68
|
+
*/
|
|
69
|
+
@TableId(value = "id")
|
|
70
|
+
private Long id;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 名称
|
|
74
|
+
*/
|
|
75
|
+
private String xxxName;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 状态(0正常 1停用)
|
|
79
|
+
*/
|
|
80
|
+
private String status;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 删除标志
|
|
84
|
+
*/
|
|
85
|
+
@TableLogic
|
|
86
|
+
private Long delFlag;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 2. BO 业务对象(@AutoMapper 映射)
|
|
93
|
+
|
|
94
|
+
```java
|
|
95
|
+
package org.dromara.demo.domain.bo;
|
|
96
|
+
|
|
97
|
+
import io.github.linpeilie.annotations.AutoMapper;
|
|
98
|
+
import org.dromara.demo.domain.Xxx;
|
|
99
|
+
import org.dromara.demo.domain.vo.XxxVo;
|
|
100
|
+
import org.dromara.common.core.validate.AddGroup;
|
|
101
|
+
import org.dromara.common.core.validate.EditGroup;
|
|
102
|
+
import lombok.Data;
|
|
103
|
+
import lombok.EqualsAndHashCode;
|
|
104
|
+
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
105
|
+
import jakarta.validation.constraints.*;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* XXX 业务对象
|
|
109
|
+
*/
|
|
110
|
+
@Data
|
|
111
|
+
@EqualsAndHashCode(callSuper = true)
|
|
112
|
+
@AutoMapper(target = Xxx.class, reverseConvertGenerate = false) // ✅ 映射到 Entity
|
|
113
|
+
public class XxxBo extends BaseEntity {
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 主键 ID
|
|
117
|
+
*/
|
|
118
|
+
@NotNull(message = "主键 ID 不能为空", groups = {EditGroup.class})
|
|
119
|
+
private Long id;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 名称
|
|
123
|
+
*/
|
|
124
|
+
@NotBlank(message = "名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
|
125
|
+
private String xxxName;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 状态
|
|
129
|
+
*/
|
|
130
|
+
private String status;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 3. VO 视图对象(@AutoMapper 映射)
|
|
137
|
+
|
|
138
|
+
```java
|
|
139
|
+
package org.dromara.demo.domain.vo;
|
|
140
|
+
|
|
141
|
+
import io.github.linpeilie.annotations.AutoMapper;
|
|
142
|
+
import org.dromara.demo.domain.Xxx;
|
|
143
|
+
import org.dromara.demo.domain.bo.XxxBo;
|
|
144
|
+
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
|
145
|
+
import cn.idev.excel.annotation.ExcelProperty;
|
|
146
|
+
import lombok.Data;
|
|
147
|
+
import java.io.Serial;
|
|
148
|
+
import java.io.Serializable;
|
|
149
|
+
import java.util.Date;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* XXX 视图对象
|
|
153
|
+
*/
|
|
154
|
+
@Data
|
|
155
|
+
@ExcelIgnoreUnannotated
|
|
156
|
+
@AutoMapper(target = Xxx.class) // ✅ VO 也使用 @AutoMapper
|
|
157
|
+
public class XxxVo implements Serializable {
|
|
158
|
+
|
|
159
|
+
@Serial
|
|
160
|
+
private static final long serialVersionUID = 1L;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 主键 ID
|
|
164
|
+
*/
|
|
165
|
+
@ExcelProperty(value = "主键 ID")
|
|
166
|
+
private Long id;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 名称
|
|
170
|
+
*/
|
|
171
|
+
@ExcelProperty(value = "名称")
|
|
172
|
+
private String xxxName;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 状态
|
|
176
|
+
*/
|
|
177
|
+
@ExcelProperty(value = "状态")
|
|
178
|
+
private String status;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 创建时间
|
|
182
|
+
*/
|
|
183
|
+
@ExcelProperty(value = "创建时间")
|
|
184
|
+
private Date createTime;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 4. Service 接口
|
|
191
|
+
|
|
192
|
+
```java
|
|
193
|
+
package org.dromara.demo.service;
|
|
194
|
+
|
|
195
|
+
import org.dromara.demo.domain.bo.XxxBo;
|
|
196
|
+
import org.dromara.demo.domain.vo.XxxVo;
|
|
197
|
+
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
198
|
+
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
199
|
+
import java.util.Collection;
|
|
200
|
+
import java.util.List;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* XXX 服务接口
|
|
204
|
+
*/
|
|
205
|
+
public interface IXxxService {
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 根据 ID 查询
|
|
209
|
+
*/
|
|
210
|
+
XxxVo queryById(Long id);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* 查询列表
|
|
214
|
+
*/
|
|
215
|
+
List<XxxVo> queryList(XxxBo bo);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* 分页查询
|
|
219
|
+
*/
|
|
220
|
+
TableDataInfo<XxxVo> queryPageList(XxxBo bo, PageQuery pageQuery);
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 新增
|
|
224
|
+
*/
|
|
225
|
+
Boolean insertByBo(XxxBo bo);
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 修改
|
|
229
|
+
*/
|
|
230
|
+
Boolean updateByBo(XxxBo bo);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 删除
|
|
234
|
+
*/
|
|
235
|
+
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 5. Service 实现类(⭐ 核心:三层架构,NO DAO 层)
|
|
242
|
+
|
|
243
|
+
```java
|
|
244
|
+
package org.dromara.demo.service.impl;
|
|
245
|
+
|
|
246
|
+
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
247
|
+
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
248
|
+
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
249
|
+
import lombok.RequiredArgsConstructor;
|
|
250
|
+
import org.springframework.stereotype.Service;
|
|
251
|
+
import org.dromara.common.core.exception.ServiceException;
|
|
252
|
+
import org.dromara.common.core.utils.MapstructUtils;
|
|
253
|
+
import org.dromara.common.core.utils.StringUtils;
|
|
254
|
+
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
255
|
+
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
256
|
+
import org.dromara.demo.domain.Xxx;
|
|
257
|
+
import org.dromara.demo.domain.bo.XxxBo;
|
|
258
|
+
import org.dromara.demo.domain.vo.XxxVo;
|
|
259
|
+
import org.dromara.demo.mapper.XxxMapper;
|
|
260
|
+
import org.dromara.demo.service.IXxxService;
|
|
261
|
+
import java.util.Collection;
|
|
262
|
+
import java.util.List;
|
|
263
|
+
import java.util.Map;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* XXX 服务实现
|
|
267
|
+
*
|
|
268
|
+
* @author Lion Li
|
|
269
|
+
*/
|
|
270
|
+
@Service
|
|
271
|
+
@RequiredArgsConstructor
|
|
272
|
+
public class XxxServiceImpl implements IXxxService {
|
|
273
|
+
|
|
274
|
+
private final XxxMapper baseMapper; // ✅ 直接注入 Mapper(NO DAO!)
|
|
275
|
+
|
|
276
|
+
@Override
|
|
277
|
+
public XxxVo queryById(Long id) {
|
|
278
|
+
return baseMapper.selectVoById(id);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
@Override
|
|
282
|
+
public List<XxxVo> queryList(XxxBo bo) {
|
|
283
|
+
return baseMapper.selectVoList(buildQueryWrapper(bo));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
@Override
|
|
287
|
+
public TableDataInfo<XxxVo> queryPageList(XxxBo bo, PageQuery pageQuery) {
|
|
288
|
+
LambdaQueryWrapper<Xxx> lqw = buildQueryWrapper(bo); // ✅ Service 层构建查询
|
|
289
|
+
Page<XxxVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
290
|
+
return TableDataInfo.build(result);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@Override
|
|
294
|
+
public Boolean insertByBo(XxxBo bo) {
|
|
295
|
+
Xxx add = MapstructUtils.convert(bo, Xxx.class); // ✅ MapstructUtils 转换
|
|
296
|
+
validEntityBeforeSave(add);
|
|
297
|
+
return baseMapper.insert(add) > 0;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@Override
|
|
301
|
+
public Boolean updateByBo(XxxBo bo) {
|
|
302
|
+
Xxx update = MapstructUtils.convert(bo, Xxx.class);
|
|
303
|
+
validEntityBeforeSave(update);
|
|
304
|
+
return baseMapper.updateById(update) > 0;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@Override
|
|
308
|
+
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
309
|
+
if (isValid) {
|
|
310
|
+
List<Xxx> list = baseMapper.selectByIds(ids);
|
|
311
|
+
if (list.size() != ids.size()) {
|
|
312
|
+
throw new ServiceException("您没有删除权限!");
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return baseMapper.deleteByIds(ids) > 0;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 构建查询条件
|
|
320
|
+
* ✅ Service 层直接构建(不是 DAO 层)
|
|
321
|
+
*/
|
|
322
|
+
private LambdaQueryWrapper<Xxx> buildQueryWrapper(XxxBo bo) {
|
|
323
|
+
Map<String, Object> params = bo.getParams();
|
|
324
|
+
LambdaQueryWrapper<Xxx> lqw = Wrappers.lambdaQuery();
|
|
325
|
+
|
|
326
|
+
// ✅ 精确匹配
|
|
327
|
+
lqw.eq(bo.getId() != null, Xxx::getId, bo.getId());
|
|
328
|
+
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), Xxx::getStatus, bo.getStatus());
|
|
329
|
+
|
|
330
|
+
// ✅ 模糊匹配
|
|
331
|
+
lqw.like(StringUtils.isNotBlank(bo.getXxxName()), Xxx::getXxxName, bo.getXxxName());
|
|
332
|
+
|
|
333
|
+
// ✅ 时间范围
|
|
334
|
+
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
|
335
|
+
Xxx::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
|
336
|
+
|
|
337
|
+
// ✅ 排序
|
|
338
|
+
lqw.orderByAsc(Xxx::getId);
|
|
339
|
+
return lqw;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* 保存前验证
|
|
344
|
+
*/
|
|
345
|
+
private void validEntityBeforeSave(Xxx entity) {
|
|
346
|
+
// TODO 做一些数据校验,如唯一约束
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 6. Mapper 接口(继承 BaseMapperPlus)
|
|
354
|
+
|
|
355
|
+
```java
|
|
356
|
+
package org.dromara.demo.mapper;
|
|
357
|
+
|
|
358
|
+
import org.dromara.demo.domain.Xxx;
|
|
359
|
+
import org.dromara.demo.domain.vo.XxxVo;
|
|
360
|
+
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* XXX Mapper 接口
|
|
364
|
+
*/
|
|
365
|
+
public interface XxxMapper extends BaseMapperPlus<Xxx, XxxVo> {
|
|
366
|
+
// ✅ 继承 BaseMapperPlus,已提供 selectVoById、selectVoPage、selectVoList 等方法
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## 7. Controller 控制器(标准 RESTful 路径)
|
|
373
|
+
|
|
374
|
+
```java
|
|
375
|
+
package org.dromara.demo.controller;
|
|
376
|
+
|
|
377
|
+
import java.util.Arrays;
|
|
378
|
+
import java.util.List;
|
|
379
|
+
import lombok.RequiredArgsConstructor;
|
|
380
|
+
import jakarta.servlet.http.HttpServletResponse;
|
|
381
|
+
import jakarta.validation.constraints.*;
|
|
382
|
+
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
383
|
+
import org.springframework.web.bind.annotation.*;
|
|
384
|
+
import org.springframework.validation.annotation.Validated;
|
|
385
|
+
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
386
|
+
import org.dromara.common.log.annotation.Log;
|
|
387
|
+
import org.dromara.common.log.enums.BusinessType;
|
|
388
|
+
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
389
|
+
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
390
|
+
import org.dromara.common.web.core.BaseController;
|
|
391
|
+
import org.dromara.common.core.domain.R;
|
|
392
|
+
import org.dromara.common.core.validate.AddGroup;
|
|
393
|
+
import org.dromara.common.core.validate.EditGroup;
|
|
394
|
+
import org.dromara.common.excel.utils.ExcelUtil;
|
|
395
|
+
import org.dromara.demo.domain.vo.XxxVo;
|
|
396
|
+
import org.dromara.demo.domain.bo.XxxBo;
|
|
397
|
+
import org.dromara.demo.service.IXxxService;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* XXX 管理控制器
|
|
401
|
+
*/
|
|
402
|
+
@Validated
|
|
403
|
+
@RequiredArgsConstructor
|
|
404
|
+
@RestController
|
|
405
|
+
@RequestMapping("/demo/xxx")
|
|
406
|
+
public class XxxController extends BaseController { // ✅ 继承 BaseController
|
|
407
|
+
|
|
408
|
+
private final IXxxService xxxService;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* 查询列表
|
|
412
|
+
* ✅ RESTful 路径:/list(不是 /pageXxxs)
|
|
413
|
+
*/
|
|
414
|
+
@SaCheckPermission("demo:xxx:list")
|
|
415
|
+
@GetMapping("/list")
|
|
416
|
+
public TableDataInfo<XxxVo> list(XxxBo bo, PageQuery pageQuery) {
|
|
417
|
+
return xxxService.queryPageList(bo, pageQuery);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* 获取详情
|
|
422
|
+
* ✅ RESTful 路径:/{id}(不是 /getXxx/{id})
|
|
423
|
+
*/
|
|
424
|
+
@SaCheckPermission("demo:xxx:query")
|
|
425
|
+
@GetMapping("/{id}")
|
|
426
|
+
public R<XxxVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
|
|
427
|
+
return R.ok(xxxService.queryById(id));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* 新增
|
|
432
|
+
* ✅ POST 空路径
|
|
433
|
+
*/
|
|
434
|
+
@SaCheckPermission("demo:xxx:add")
|
|
435
|
+
@Log(title = "XXX管理", businessType = BusinessType.INSERT)
|
|
436
|
+
@RepeatSubmit()
|
|
437
|
+
@PostMapping()
|
|
438
|
+
public R<Void> add(@Validated(AddGroup.class) @RequestBody XxxBo bo) {
|
|
439
|
+
return toAjax(xxxService.insertByBo(bo));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* 修改
|
|
444
|
+
* ✅ PUT 空路径
|
|
445
|
+
*/
|
|
446
|
+
@SaCheckPermission("demo:xxx:edit")
|
|
447
|
+
@Log(title = "XXX管理", businessType = BusinessType.UPDATE)
|
|
448
|
+
@RepeatSubmit()
|
|
449
|
+
@PutMapping()
|
|
450
|
+
public R<Void> edit(@Validated(EditGroup.class) @RequestBody XxxBo bo) {
|
|
451
|
+
return toAjax(xxxService.updateByBo(bo));
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* 删除
|
|
456
|
+
* ✅ DELETE /{ids}
|
|
457
|
+
*/
|
|
458
|
+
@SaCheckPermission("demo:xxx:remove")
|
|
459
|
+
@Log(title = "XXX管理", businessType = BusinessType.DELETE)
|
|
460
|
+
@DeleteMapping("/{ids}")
|
|
461
|
+
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] ids) {
|
|
462
|
+
return toAjax(xxxService.deleteWithValidByIds(Arrays.asList(ids), true));
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* 导出
|
|
467
|
+
*/
|
|
468
|
+
@SaCheckPermission("demo:xxx:export")
|
|
469
|
+
@Log(title = "XXX管理", businessType = BusinessType.EXPORT)
|
|
470
|
+
@PostMapping("/export")
|
|
471
|
+
public void export(@Validated XxxBo bo, HttpServletResponse response) {
|
|
472
|
+
List<XxxVo> list = xxxService.queryList(bo);
|
|
473
|
+
ExcelUtil.exportExcel(list, "XXX数据", XxxVo.class, response);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
## 8. 数据库建表(SQL)
|
|
481
|
+
|
|
482
|
+
```sql
|
|
483
|
+
-- 表前缀:demo_(根据模块选择:sys_/demo_/workflow_ 等)
|
|
484
|
+
CREATE TABLE demo_xxx (
|
|
485
|
+
id BIGINT(20) NOT NULL COMMENT '主键 ID', -- ✅ 雪花 ID,不用 AUTO_INCREMENT
|
|
486
|
+
tenant_id VARCHAR(20) DEFAULT '000000' COMMENT '租户 ID',
|
|
487
|
+
|
|
488
|
+
-- 业务字段
|
|
489
|
+
xxx_name VARCHAR(100) NOT NULL COMMENT '名称',
|
|
490
|
+
status CHAR(1) DEFAULT '0' COMMENT '状态(0正常 1停用)',
|
|
491
|
+
|
|
492
|
+
-- 审计字段(必须)
|
|
493
|
+
create_dept BIGINT(20) DEFAULT NULL COMMENT '创建部门',
|
|
494
|
+
create_by BIGINT(20) DEFAULT NULL COMMENT '创建人',
|
|
495
|
+
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
496
|
+
update_by BIGINT(20) DEFAULT NULL COMMENT '更新人',
|
|
497
|
+
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
498
|
+
remark VARCHAR(255) DEFAULT NULL COMMENT '备注',
|
|
499
|
+
del_flag BIGINT(20) DEFAULT 0 COMMENT '删除标志(0正常 1已删除)',
|
|
500
|
+
|
|
501
|
+
PRIMARY KEY (id)
|
|
502
|
+
) ENGINE=InnoDB COMMENT='XXX表';
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
## 架构对比
|
|
508
|
+
|
|
509
|
+
### 三层架构流程图
|
|
510
|
+
|
|
511
|
+
```
|
|
512
|
+
请求到达
|
|
513
|
+
↓
|
|
514
|
+
Controller (路由转发 + 权限检查 + 参数校验)
|
|
515
|
+
↓
|
|
516
|
+
Service (业务逻辑 + 查询构建 + 对象转换)
|
|
517
|
+
↓
|
|
518
|
+
Mapper (数据持久化)
|
|
519
|
+
↓
|
|
520
|
+
数据库
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### 关键差异
|
|
524
|
+
|
|
525
|
+
| 环节 | 操作 | 位置 |
|
|
526
|
+
|------|------|------|
|
|
527
|
+
| **查询构建** | `buildQueryWrapper()` | **Service 层** ✅ |
|
|
528
|
+
| **Mapper 注入** | 在 Service 中注入 | ✅ 直接注入 baseMapper |
|
|
529
|
+
| **DAO 层** | 是否存在 | ❌ **不存在** |
|
|
530
|
+
| **对象转换** | `MapstructUtils.convert()` | Service 层 |
|
|
531
|
+
| **权限注解** | `@DataPermission` | Mapper 接口方法 |
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
## 常见错误速查
|
|
536
|
+
|
|
537
|
+
### ❌ 不要做
|
|
538
|
+
|
|
539
|
+
```java
|
|
540
|
+
// 错误 1: 在 Service 层注入 DAO
|
|
541
|
+
@Service
|
|
542
|
+
public class XxxServiceImpl {
|
|
543
|
+
private final IXxxDao xxxDao; // ❌ 本项目没有 DAO 层!
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// 错误 2: 使用 BeanUtil
|
|
547
|
+
BeanUtil.copyProperties(bo, entity); // ❌ 必须用 MapstructUtils.convert()
|
|
548
|
+
|
|
549
|
+
// 错误 3: Service 继承基类
|
|
550
|
+
public class XxxServiceImpl extends ServiceImpl<XxxMapper, Xxx> { // ❌ 不继承!
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// 错误 4: 使用 @AutoMappers(复数)
|
|
554
|
+
@AutoMappers({ // ❌ 本项目用单数 @AutoMapper
|
|
555
|
+
@AutoMapper(target = Xxx.class)
|
|
556
|
+
})
|
|
557
|
+
public class XxxBo { }
|
|
558
|
+
|
|
559
|
+
// 错误 5: 包名错误
|
|
560
|
+
package org.dromara.xxx; // ❌ 必须是 org.dromara.xxx
|
|
561
|
+
|
|
562
|
+
// 错误 6: 使用错误的路径格式
|
|
563
|
+
@GetMapping("/pageXxxs") // ❌ 应该是 /list
|
|
564
|
+
@GetMapping("/getXxx/{id}") // ❌ 应该是 /{id}
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### ✅ 正确做法
|
|
568
|
+
|
|
569
|
+
```java
|
|
570
|
+
// 正确 1: 直接在 Service 中注入 Mapper
|
|
571
|
+
@Service
|
|
572
|
+
@RequiredArgsConstructor
|
|
573
|
+
public class XxxServiceImpl implements IXxxService {
|
|
574
|
+
private final XxxMapper baseMapper; // ✅ 直接注入 Mapper
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// 正确 2: 使用 MapstructUtils
|
|
578
|
+
Xxx entity = MapstructUtils.convert(bo, Xxx.class); // ✅
|
|
579
|
+
|
|
580
|
+
// 正确 3: Service 只实现接口
|
|
581
|
+
public class XxxServiceImpl implements IXxxService { // ✅
|
|
582
|
+
|
|
583
|
+
// 正确 4: 使用 @AutoMapper(单数)
|
|
584
|
+
@AutoMapper(target = Xxx.class) // ✅
|
|
585
|
+
public class XxxBo { }
|
|
586
|
+
|
|
587
|
+
// 正确 5: 使用 org.dromara 包名
|
|
588
|
+
package org.dromara.demo.service; // ✅
|
|
589
|
+
|
|
590
|
+
// 正确 6: 使用标准 RESTful 路径
|
|
591
|
+
@GetMapping("/list") // ✅
|
|
592
|
+
@GetMapping("/{id}") // ✅
|
|
593
|
+
@PostMapping
|
|
594
|
+
@PutMapping
|
|
595
|
+
@DeleteMapping("/{ids}")
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## 检查清单
|
|
601
|
+
|
|
602
|
+
生成代码前必须检查:
|
|
603
|
+
|
|
604
|
+
- [ ] **包名是否是 `org.dromara.*`**?
|
|
605
|
+
- [ ] **Service 是否只实现接口,不继承任何基类**?
|
|
606
|
+
- [ ] **Service 是否直接注入 Mapper(无 DAO 层)**?
|
|
607
|
+
- [ ] **buildQueryWrapper() 是否在 Service 层实现**?
|
|
608
|
+
- [ ] **Entity 是否继承 `TenantEntity`**?
|
|
609
|
+
- [ ] **BO 是否使用 `@AutoMapper`(单数)映射到 Entity**?
|
|
610
|
+
- [ ] **VO 是否使用 `@AutoMapper` 映射**?
|
|
611
|
+
- [ ] **是否使用 `MapstructUtils.convert()` 转换对象**?
|
|
612
|
+
- [ ] **是否所有类型都先 import 再使用短类名**?
|
|
613
|
+
- [ ] **Mapper 是否继承 `BaseMapperPlus<Entity, VO>`**?
|
|
614
|
+
- [ ] **Controller 是否使用标准 RESTful 路径(/list、/{id} 等)**?
|
|
615
|
+
- [ ] **是否使用了 `@DataPermission` 进行行级权限控制**?
|
|
616
|
+
- [ ] **SQL 是否使用了 `del_flag`(非 `is_deleted`)**?
|
|
617
|
+
- [ ] **主键是否使用雪花 ID(无 AUTO_INCREMENT)**?
|
|
618
|
+
- [ ] **所有代码注释是否使用中文**?(Javadoc、行内注释、SQL 注释)
|
|
619
|
+
- [ ] **SQL COMMENT 是否使用中文**?(禁止英文 COMMENT)
|
|
620
|
+
|
|
621
|
+
---
|
|
622
|
+
|
|
623
|
+
## 参考实现
|
|
624
|
+
|
|
625
|
+
查看已有的完整实现:
|
|
626
|
+
|
|
627
|
+
- **Entity 参考**: `org.dromara.demo.domain.TestDemo`
|
|
628
|
+
- **BO 参考**: `org.dromara.demo.domain.bo.TestDemoBo`
|
|
629
|
+
- **VO 参考**: `org.dromara.demo.domain.vo.TestDemoVo`
|
|
630
|
+
- **Service 参考**: `org.dromara.demo.service.impl.TestDemoServiceImpl`
|
|
631
|
+
- **Mapper 参考**: `org.dromara.demo.mapper.TestDemoMapper`
|
|
632
|
+
- **Controller 参考**: `org.dromara.demo.controller.TestDemoController`
|
|
633
|
+
|
|
634
|
+
**特别注意**:上述参考代码是本项目的标准实现,严格遵循三层架构(Service 直接调用 Mapper,无 DAO 层)。
|
|
635
|
+
|
|
636
|
+
---
|
|
637
|
+
|
|
638
|
+
## 参考实现
|
|
639
|
+
|
|
640
|
+
查看已有的完整实现:
|
|
641
|
+
|
|
642
|
+
- **Entity 参考**: `org.dromara.demo.domain.TestDemo`
|
|
643
|
+
- **BO 参考**: `org.dromara.demo.domain.bo.TestDemoBo`
|
|
644
|
+
- **VO 参考**: `org.dromara.demo.domain.vo.TestDemoVo`
|
|
645
|
+
- **Service 参考**: `org.dromara.demo.service.impl.TestDemoServiceImpl`
|
|
646
|
+
- **Mapper 参考**: `org.dromara.demo.mapper.TestDemoMapper`
|
|
647
|
+
- **Controller 参考**: `org.dromara.demo.controller.TestDemoController`
|
|
648
|
+
|
|
649
|
+
**特别注意**:上述参考代码是本项目的标准实现,严格遵循三层架构(Service 直接调用 Mapper,无 DAO 层)。
|