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,210 @@
|
|
|
1
|
+
# /check - 后端代码规范检查
|
|
2
|
+
|
|
3
|
+
作为代码规范检查助手,自动检测项目代码是否符合 leniu-tengyun-core(云食堂)后端规范。
|
|
4
|
+
|
|
5
|
+
## 检查范围
|
|
6
|
+
|
|
7
|
+
支持三种模式:
|
|
8
|
+
|
|
9
|
+
1. **全量检查**:`/check` - 检查所有业务模块
|
|
10
|
+
2. **模块检查**:`/check canteen` - 检查指定模块
|
|
11
|
+
3. **文件检查**:`/check XxxServiceImpl.java` - 检查指定文件
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 检查清单总览
|
|
16
|
+
|
|
17
|
+
| 检查项 | 级别 | 说明 |
|
|
18
|
+
|--------|------|------|
|
|
19
|
+
| 包名规范 | 🔴 严重 | 必须是 `net.xnzn.core.*` |
|
|
20
|
+
| 禁用旧工具类 | 🔴 严重 | 禁止 MapstructUtils、ServiceException |
|
|
21
|
+
| 审计字段命名 | 🔴 严重 | 必须用 crby/crtime/upby/uptime |
|
|
22
|
+
| del_flag 语义 | 🔴 严重 | 2=正常,1=删除(不是 0=正常) |
|
|
23
|
+
| 不含 tenant_id | 🔴 严重 | 双库物理隔离,Entity 无需此字段 |
|
|
24
|
+
| 禁止 Map 传业务数据 | 🔴 严重 | 必须用 VO/DTO |
|
|
25
|
+
| 认证注解 | 🟡 警告 | 接口应有 @RequiresAuthentication 或 @RequiresGuest |
|
|
26
|
+
| 请求封装 | 🟡 警告 | POST 请求应使用 LeRequest<T> |
|
|
27
|
+
| 事务注解 | 🟡 警告 | 写操作应加 @Transactional(rollbackFor = Exception.class) |
|
|
28
|
+
| 国际化异常 | 🟢 建议 | LeException 建议配合 I18n.getMessage() |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 检查详情
|
|
33
|
+
|
|
34
|
+
### 1. 包名规范 [🔴 严重]
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
Grep pattern: "package org\.dromara\." path: [目标目录] glob: "*.java" # ❌ 必须为 0 个
|
|
38
|
+
Grep pattern: "package com\.ruoyi\." path: [目标目录] glob: "*.java" # ❌ 必须为 0 个
|
|
39
|
+
Grep pattern: "package net\.xnzn\.core\." path: [目标目录] glob: "*.java" # ✅ 应有结果
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```java
|
|
43
|
+
// ❌ 错误
|
|
44
|
+
package org.dromara.system.service;
|
|
45
|
+
|
|
46
|
+
// ✅ 正确
|
|
47
|
+
package net.xnzn.core.canteen.order.service;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. 禁止使用 RuoYi 工具类 [🔴 严重]
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
Grep pattern: "MapstructUtils" path: [目标目录] glob: "*.java"
|
|
54
|
+
Grep pattern: "ServiceException" path: [目标目录] glob: "*.java"
|
|
55
|
+
Grep pattern: "import javax\.validation" path: [目标目录] glob: "*.java"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
| 错误写法 | 正确写法 |
|
|
59
|
+
|---------|---------|
|
|
60
|
+
| `MapstructUtils.convert()` | `BeanUtil.copyProperties()` |
|
|
61
|
+
| `throw new ServiceException()` | `throw new LeException()` |
|
|
62
|
+
| `import javax.validation.*` | `import jakarta.validation.*` |
|
|
63
|
+
|
|
64
|
+
### 3. 审计字段命名 [🔴 严重]
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
Grep pattern: "private.*createBy\|private.*updateBy\|private.*createTime\|private.*updateTime" path: [目标目录] glob: "*.java"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
| 错误写法 | 正确写法 | 填充时机 |
|
|
71
|
+
|---------|---------|---------|
|
|
72
|
+
| `createBy` | `crby` | INSERT |
|
|
73
|
+
| `createTime` | `crtime` | INSERT |
|
|
74
|
+
| `updateBy` | `upby` | INSERT_UPDATE |
|
|
75
|
+
| `updateTime` | `uptime` | INSERT_UPDATE |
|
|
76
|
+
|
|
77
|
+
### 4. del_flag 值语义 [🔴 严重]
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
Grep pattern: "delFlag.*=.*0\|del_flag.*=.*0" path: [目标目录] glob: "*.java"
|
|
81
|
+
Grep pattern: "DelFlag.*NORMAL.*0\|del_flag.*DEFAULT.*0" path: [目标目录]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
- ❌ `delFlag = 0`(RuoYi 的正常值,leniu 中是错误的)
|
|
85
|
+
- ✅ `delFlag = 2`(leniu 的正常值,`1=删除,2=正常`)
|
|
86
|
+
|
|
87
|
+
### 5. Entity 不含 tenant_id [🔴 严重]
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
Grep pattern: "tenantId\|tenant_id" path: [目标目录] glob: "*.java"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- ❌ Entity 中有 `tenantId` 字段(双库物理隔离,无需此字段)
|
|
94
|
+
- ✅ 通过 `TenantContextHolder.getTenantId()` 获取当前租户
|
|
95
|
+
|
|
96
|
+
### 6. 禁止 Map 传递业务数据 [🔴 严重]
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
Grep pattern: "Map<String,\s*Object>" path: [目标目录] glob: "*.java"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- ❌ 返回 `Map<String, Object>` 封装业务数据
|
|
103
|
+
- ✅ 创建专属 VO 类返回
|
|
104
|
+
|
|
105
|
+
### 7. 认证注解 [🟡 警告]
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
Grep pattern: "@RequiresAuthentication\|@RequiresGuest" path: [目标目录] glob: "*Controller.java"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Controller 中每个接口应有 `@RequiresAuthentication` 或 `@RequiresGuest` 注解
|
|
112
|
+
|
|
113
|
+
### 8. 请求封装 [🟡 警告]
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
Grep pattern: "@RequestBody [^L]" path: [目标目录] glob: "*Controller.java"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- POST/PUT 请求体建议统一用 `@RequestBody LeRequest<T>` 封装
|
|
120
|
+
- `request.getContent()` 获取实际参数
|
|
121
|
+
|
|
122
|
+
### 9. 事务注解 [🟡 警告]
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
Grep pattern: "@Transactional" path: [目标目录] glob: "*ServiceImpl.java"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- 写操作(insert/update/delete)应加 `@Transactional(rollbackFor = Exception.class)`
|
|
129
|
+
- 查询方法不需要加事务
|
|
130
|
+
|
|
131
|
+
### 10. 国际化异常 [🟢 建议]
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
Grep pattern: "new LeException\(\"[^\"]*[\u4e00-\u9fa5]" path: [目标目录] glob: "*.java"
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- 建议将硬编码中文消息迁移到 `I18n.getMessage("xxx.key")` 国际化
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 输出格式
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
# 代码审查报告
|
|
145
|
+
|
|
146
|
+
审查范围: [文件/模块]
|
|
147
|
+
审查时间: YYYY-MM-DD HH:mm
|
|
148
|
+
|
|
149
|
+
## 严重问题(X 项)
|
|
150
|
+
|
|
151
|
+
1. [问题类型]
|
|
152
|
+
文件: path/to/file.java:行号
|
|
153
|
+
问题: 描述
|
|
154
|
+
修复: 代码示例
|
|
155
|
+
|
|
156
|
+
## 警告问题(X 项)
|
|
157
|
+
...
|
|
158
|
+
|
|
159
|
+
## 通过项
|
|
160
|
+
- [x] 包名规范 (net.xnzn.core.*)
|
|
161
|
+
- [x] 使用 LeException
|
|
162
|
+
- [x] 审计字段正确 (crby/crtime/upby/uptime)
|
|
163
|
+
- [x] del_flag 语义正确 (2=正常)
|
|
164
|
+
- [x] 无 tenant_id 字段
|
|
165
|
+
...
|
|
166
|
+
|
|
167
|
+
结论: ✅ 通过 / ⚠️ 需修复 / ❌ 不通过
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 检查优先级
|
|
173
|
+
|
|
174
|
+
### 开发完成后必查(阻塞提交)
|
|
175
|
+
|
|
176
|
+
1. 包名是否是 `net.xnzn.core.*`
|
|
177
|
+
2. 审计字段是否正确(crby/crtime/upby/uptime)
|
|
178
|
+
3. del_flag 值是否正确(2=正常,1=删除)
|
|
179
|
+
4. 是否有 `tenantId` 字段(不应存在)
|
|
180
|
+
5. 对象转换是否使用 `BeanUtil.copyProperties()`
|
|
181
|
+
|
|
182
|
+
### 代码审查建议查
|
|
183
|
+
|
|
184
|
+
1. 所有 POST 接口是否使用 `LeRequest<T>`
|
|
185
|
+
2. 认证注解是否完整
|
|
186
|
+
3. 写操作是否有 `@Transactional`
|
|
187
|
+
4. 是否有硬编码中文异常消息
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 快速修复指南
|
|
192
|
+
|
|
193
|
+
| 问题 | 修复方式 |
|
|
194
|
+
|------|---------|
|
|
195
|
+
| 包名错误 | 全局替换 `org.dromara` → `net.xnzn.core` |
|
|
196
|
+
| 审计字段错误 | 全局替换 createBy→crby、createTime→crtime、updateBy→upby、updateTime→uptime |
|
|
197
|
+
| del_flag=0 | 替换为 del_flag=2 |
|
|
198
|
+
| MapstructUtils | 替换为 `BeanUtil.copyProperties(source, Target.class)` |
|
|
199
|
+
| ServiceException | 替换为 `LeException` |
|
|
200
|
+
| javax.validation | 替换为 `jakarta.validation` |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 参考代码
|
|
205
|
+
|
|
206
|
+
| 类型 | 路径 |
|
|
207
|
+
|------|------|
|
|
208
|
+
| Controller 示例 | `sys-canteen/.../order/web/controller/OrderInfoWebController.java` |
|
|
209
|
+
| Service 示例 | `sys-canteen/.../order/common/service/impl/OrderInfoService.java` |
|
|
210
|
+
| Entity 示例 | `sys-canteen/.../order/common/model/OrderInfo.java` |
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
# /crud - 快速生成 CRUD 代码
|
|
2
|
+
|
|
3
|
+
作为 CRUD 代码生成助手,基于已存在的数据库表快速生成 leniu-tengyun-core 标准后端代码。
|
|
4
|
+
|
|
5
|
+
## 适用场景
|
|
6
|
+
|
|
7
|
+
- ✅ **数据库表已存在** - 表结构已设计完毕
|
|
8
|
+
- ✅ **快速生成四层代码** - Entity / DTO / VO / Mapper / Service / Business / Controller
|
|
9
|
+
- ✅ **标准 CRUD** - 增删改查、分页列表
|
|
10
|
+
|
|
11
|
+
不适合:
|
|
12
|
+
- ❌ 表结构尚未设计 → 使用 `/dev` 命令
|
|
13
|
+
- ❌ 需要复杂业务逻辑 → 使用 `/dev` 后手动增强
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 执行流程
|
|
18
|
+
|
|
19
|
+
### 第一步:获取表信息
|
|
20
|
+
|
|
21
|
+
询问用户:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
请提供以下信息:
|
|
25
|
+
|
|
26
|
+
1. 表名?(如:canteen_order_info)
|
|
27
|
+
2. 所属模块?(sys-canteen / sys-kitchen / sys-drp / sys-common)
|
|
28
|
+
3. 功能名称(中文)?(如:订单管理)
|
|
29
|
+
4. 端类型?(web / mobile / android,默认 web)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
#### 1.1 查看表结构
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# 查看表结构(用户提供连接信息,或从配置文件读取)
|
|
36
|
+
SHOW CREATE TABLE [表名];
|
|
37
|
+
DESC [表名];
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### 1.2 字段类型映射
|
|
41
|
+
|
|
42
|
+
| 数据库类型 | Java 类型 | 说明 |
|
|
43
|
+
|-----------|---------|------|
|
|
44
|
+
| BIGINT | Long | 主键、外键、金额(分)|
|
|
45
|
+
| INT / TINYINT | Integer | 状态、类型 |
|
|
46
|
+
| VARCHAR / CHAR | String | 字符串 |
|
|
47
|
+
| TEXT / LONGTEXT | String | 长文本 |
|
|
48
|
+
| DATETIME / TIMESTAMP | LocalDateTime | 时间 |
|
|
49
|
+
| DECIMAL | BigDecimal | 高精度数值 |
|
|
50
|
+
|
|
51
|
+
#### 1.3 输出表结构分析
|
|
52
|
+
|
|
53
|
+
```markdown
|
|
54
|
+
## 表结构分析
|
|
55
|
+
|
|
56
|
+
**表名**:canteen_order_info
|
|
57
|
+
**功能名称**:订单管理
|
|
58
|
+
**包名**:net.xnzn.core.canteen.order
|
|
59
|
+
|
|
60
|
+
**字段列表**:
|
|
61
|
+
| 字段 | 类型 | 注释 | 是否审计 |
|
|
62
|
+
|------|------|------|---------|
|
|
63
|
+
| id | BIGINT | 主键 | - |
|
|
64
|
+
| order_no | VARCHAR(32) | 订单号 | - |
|
|
65
|
+
| total_amount | BIGINT | 订单金额(分)| - |
|
|
66
|
+
| status | TINYINT | 订单状态 | - |
|
|
67
|
+
| crby | VARCHAR(64) | 创建人 | ✅ |
|
|
68
|
+
| crtime | DATETIME | 创建时间 | ✅ |
|
|
69
|
+
| upby | VARCHAR(64) | 更新人 | ✅ |
|
|
70
|
+
| uptime | DATETIME | 更新时间 | ✅ |
|
|
71
|
+
| del_flag | TINYINT | 删除标识(1删除,2正常) | ✅ |
|
|
72
|
+
|
|
73
|
+
**审计字段**:✅ 完整(crby/crtime/upby/uptime/del_flag)
|
|
74
|
+
**逻辑删除**:✅ del_flag(2=正常,1=删除)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### 第二步:生成代码清单确认
|
|
80
|
+
|
|
81
|
+
```markdown
|
|
82
|
+
## 代码生成方案
|
|
83
|
+
|
|
84
|
+
**功能名称**:订单管理
|
|
85
|
+
**Java 类名前缀**:OrderInfo
|
|
86
|
+
**包名**:net.xnzn.core.canteen.order
|
|
87
|
+
**路由**:/api/v2/web/canteen/order
|
|
88
|
+
|
|
89
|
+
**将生成 7 个文件**:
|
|
90
|
+
|
|
91
|
+
| 层 | 文件 |
|
|
92
|
+
|----|------|
|
|
93
|
+
| Controller | web/controller/OrderInfoWebController.java |
|
|
94
|
+
| Business | web/business/impl/OrderInfoWebBusiness.java |
|
|
95
|
+
| Service | common/service/impl/OrderInfoService.java |
|
|
96
|
+
| Mapper | common/mapper/OrderInfoMapper.java + OrderInfoMapper.xml |
|
|
97
|
+
| Entity | common/model/OrderInfo.java |
|
|
98
|
+
| DTO | web/dto/OrderInfoDTO.java |
|
|
99
|
+
| VO | web/vo/OrderInfoVO.java |
|
|
100
|
+
|
|
101
|
+
确认开始生成?
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### 第三步:生成所有文件
|
|
107
|
+
|
|
108
|
+
#### Entity 实体类
|
|
109
|
+
|
|
110
|
+
根据表字段逐一映射,**注意**:
|
|
111
|
+
- 审计字段使用 `@TableField(fill = FieldFill.INSERT)` 自动填充
|
|
112
|
+
- `delFlag` 字段不加自动填充(手动设置)
|
|
113
|
+
- 不生成 `tenantId` 字段
|
|
114
|
+
|
|
115
|
+
```java
|
|
116
|
+
package net.xnzn.core.[模块].[功能].common.model;
|
|
117
|
+
|
|
118
|
+
import com.baomidou.mybatisplus.annotation.*;
|
|
119
|
+
import io.swagger.annotations.ApiModel;
|
|
120
|
+
import io.swagger.annotations.ApiModelProperty;
|
|
121
|
+
import lombok.Data;
|
|
122
|
+
import lombok.experimental.Accessors;
|
|
123
|
+
import java.io.Serializable;
|
|
124
|
+
import java.time.LocalDateTime;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* [功能名称] 实体
|
|
128
|
+
*/
|
|
129
|
+
@Data
|
|
130
|
+
@Accessors(chain = true)
|
|
131
|
+
@TableName("[表名]")
|
|
132
|
+
@ApiModel("[功能名称]")
|
|
133
|
+
public class [实体名] implements Serializable {
|
|
134
|
+
|
|
135
|
+
@ApiModelProperty("主键ID")
|
|
136
|
+
@TableId(value = "id", type = IdType.INPUT)
|
|
137
|
+
private Long id;
|
|
138
|
+
|
|
139
|
+
// === 业务字段(从表结构逐一映射)===
|
|
140
|
+
|
|
141
|
+
@ApiModelProperty("删除标识(1删除,2正常)")
|
|
142
|
+
@TableField("del_flag")
|
|
143
|
+
private Integer delFlag;
|
|
144
|
+
|
|
145
|
+
@TableField(value = "crby", fill = FieldFill.INSERT)
|
|
146
|
+
private String crby;
|
|
147
|
+
|
|
148
|
+
@TableField(value = "crtime", fill = FieldFill.INSERT)
|
|
149
|
+
private LocalDateTime crtime;
|
|
150
|
+
|
|
151
|
+
@TableField(value = "upby", fill = FieldFill.INSERT_UPDATE)
|
|
152
|
+
private String upby;
|
|
153
|
+
|
|
154
|
+
@TableField(value = "uptime", fill = FieldFill.INSERT_UPDATE)
|
|
155
|
+
private LocalDateTime uptime;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### DTO 请求参数
|
|
160
|
+
|
|
161
|
+
根据业务字段生成,审计字段不放入 DTO:
|
|
162
|
+
|
|
163
|
+
```java
|
|
164
|
+
package net.xnzn.core.[模块].[功能].web.dto;
|
|
165
|
+
|
|
166
|
+
import io.swagger.annotations.ApiModel;
|
|
167
|
+
import io.swagger.annotations.ApiModelProperty;
|
|
168
|
+
import lombok.Data;
|
|
169
|
+
import jakarta.validation.constraints.*;
|
|
170
|
+
import java.io.Serializable;
|
|
171
|
+
|
|
172
|
+
@Data
|
|
173
|
+
@ApiModel("[功能名称] 请求参数")
|
|
174
|
+
public class [实体名]DTO implements Serializable {
|
|
175
|
+
|
|
176
|
+
@ApiModelProperty("主键ID(修改必填)")
|
|
177
|
+
@NotNull(message = "ID不能为空", groups = {UpdateGroup.class})
|
|
178
|
+
private Long id;
|
|
179
|
+
|
|
180
|
+
// === 业务字段 ===
|
|
181
|
+
|
|
182
|
+
// 分页参数
|
|
183
|
+
private Integer pageNum = 1;
|
|
184
|
+
private Integer pageSize = 10;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### VO 返回对象
|
|
189
|
+
|
|
190
|
+
```java
|
|
191
|
+
package net.xnzn.core.[模块].[功能].web.vo;
|
|
192
|
+
|
|
193
|
+
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
194
|
+
import io.swagger.annotations.ApiModel;
|
|
195
|
+
import io.swagger.annotations.ApiModelProperty;
|
|
196
|
+
import lombok.Data;
|
|
197
|
+
import java.io.Serializable;
|
|
198
|
+
import java.time.LocalDateTime;
|
|
199
|
+
|
|
200
|
+
@Data
|
|
201
|
+
@ApiModel("[功能名称] 返回对象")
|
|
202
|
+
public class [实体名]VO implements Serializable {
|
|
203
|
+
|
|
204
|
+
@ApiModelProperty("主键ID")
|
|
205
|
+
private Long id;
|
|
206
|
+
|
|
207
|
+
// === 业务字段 ===
|
|
208
|
+
|
|
209
|
+
@ApiModelProperty("创建时间")
|
|
210
|
+
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
211
|
+
private LocalDateTime crtime;
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### Mapper 接口
|
|
216
|
+
|
|
217
|
+
```java
|
|
218
|
+
package net.xnzn.core.[模块].[功能].common.mapper;
|
|
219
|
+
|
|
220
|
+
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
221
|
+
import net.xnzn.core.[模块].[功能].common.model.[实体名];
|
|
222
|
+
import org.apache.ibatis.annotations.Mapper;
|
|
223
|
+
|
|
224
|
+
@Mapper
|
|
225
|
+
public interface [实体名]Mapper extends BaseMapper<[实体名]> {
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### Mapper XML(与 Java 同目录)
|
|
230
|
+
|
|
231
|
+
```xml
|
|
232
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
233
|
+
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
234
|
+
<mapper namespace="net.xnzn.core.[模块].[功能].common.mapper.[实体名]Mapper">
|
|
235
|
+
|
|
236
|
+
</mapper>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Service 实现
|
|
240
|
+
|
|
241
|
+
```java
|
|
242
|
+
package net.xnzn.core.[模块].[功能].common.service.impl;
|
|
243
|
+
|
|
244
|
+
import cn.hutool.core.bean.BeanUtil;
|
|
245
|
+
import cn.hutool.core.collection.CollUtil;
|
|
246
|
+
import cn.hutool.core.util.ObjectUtil;
|
|
247
|
+
import cn.hutool.core.util.StrUtil;
|
|
248
|
+
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
249
|
+
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
250
|
+
import com.pig4cloud.pigx.common.core.exception.LeException;
|
|
251
|
+
import lombok.extern.slf4j.Slf4j;
|
|
252
|
+
import net.xnzn.core.[模块].[功能].web.dto.[实体名]DTO;
|
|
253
|
+
import net.xnzn.core.[模块].[功能].common.mapper.[实体名]Mapper;
|
|
254
|
+
import net.xnzn.core.[模块].[功能].common.model.[实体名];
|
|
255
|
+
import net.xnzn.core.[模块].[功能].web.vo.[实体名]VO;
|
|
256
|
+
import net.xnzn.framework.id.Id;
|
|
257
|
+
import org.springframework.stereotype.Service;
|
|
258
|
+
import org.springframework.transaction.annotation.Transactional;
|
|
259
|
+
|
|
260
|
+
import javax.annotation.Resource;
|
|
261
|
+
import java.util.Collections;
|
|
262
|
+
import java.util.List;
|
|
263
|
+
import java.util.Optional;
|
|
264
|
+
|
|
265
|
+
@Slf4j
|
|
266
|
+
@Service
|
|
267
|
+
public class [实体名]Service {
|
|
268
|
+
|
|
269
|
+
@Resource
|
|
270
|
+
private [实体名]Mapper mapper;
|
|
271
|
+
|
|
272
|
+
@Transactional(rollbackFor = Exception.class)
|
|
273
|
+
public Long add([实体名]DTO dto) {
|
|
274
|
+
[实体名] entity = BeanUtil.copyProperties(dto, [实体名].class);
|
|
275
|
+
entity.setId(Id.next()).setDelFlag(2);
|
|
276
|
+
mapper.insert(entity);
|
|
277
|
+
return entity.getId();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
@Transactional(rollbackFor = Exception.class)
|
|
281
|
+
public void update([实体名]DTO dto) {
|
|
282
|
+
Optional.ofNullable(mapper.selectById(dto.getId()))
|
|
283
|
+
.orElseThrow(() -> new LeException("记录不存在"));
|
|
284
|
+
mapper.updateById(BeanUtil.copyProperties(dto, [实体名].class));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@Transactional(rollbackFor = Exception.class)
|
|
288
|
+
public void delete(Long id) {
|
|
289
|
+
Optional.ofNullable(mapper.selectById(id))
|
|
290
|
+
.orElseThrow(() -> new LeException("记录不存在"));
|
|
291
|
+
mapper.updateById(new [实体名]().setId(id).setDelFlag(1));
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public [实体名]VO getById(Long id) {
|
|
295
|
+
return BeanUtil.copyProperties(
|
|
296
|
+
Optional.ofNullable(mapper.selectById(id))
|
|
297
|
+
.orElseThrow(() -> new LeException("记录不存在")),
|
|
298
|
+
[实体名]VO.class
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public List<[实体名]VO> list([实体名]DTO dto) {
|
|
303
|
+
List<[实体名]> list = mapper.selectList(buildWrapper(dto));
|
|
304
|
+
if (CollUtil.isEmpty(list)) return Collections.emptyList();
|
|
305
|
+
return BeanUtil.copyToList(list, [实体名]VO.class);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
private LambdaQueryWrapper<[实体名]> buildWrapper([实体名]DTO dto) {
|
|
309
|
+
return Wrappers.<[实体名]>lambdaQuery()
|
|
310
|
+
.eq([实体名]::getDelFlag, 2)
|
|
311
|
+
// 根据业务字段追加查询条件
|
|
312
|
+
// .like(StrUtil.isNotBlank(dto.getXxxName()), [实体名]::getXxxName, dto.getXxxName())
|
|
313
|
+
.orderByDesc([实体名]::getCrtime);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
#### Business 业务层
|
|
319
|
+
|
|
320
|
+
```java
|
|
321
|
+
package net.xnzn.core.[模块].[功能].web.business.impl;
|
|
322
|
+
|
|
323
|
+
import com.github.pagehelper.page.PageMethod;
|
|
324
|
+
import lombok.extern.slf4j.Slf4j;
|
|
325
|
+
import net.xnzn.core.[模块].[功能].web.dto.[实体名]DTO;
|
|
326
|
+
import net.xnzn.core.[模块].[功能].common.service.impl.[实体名]Service;
|
|
327
|
+
import net.xnzn.core.[模块].[功能].web.vo.[实体名]VO;
|
|
328
|
+
import org.springframework.stereotype.Service;
|
|
329
|
+
|
|
330
|
+
import javax.annotation.Resource;
|
|
331
|
+
import java.util.List;
|
|
332
|
+
|
|
333
|
+
@Slf4j
|
|
334
|
+
@Service
|
|
335
|
+
public class [实体名]WebBusiness {
|
|
336
|
+
|
|
337
|
+
@Resource
|
|
338
|
+
private [实体名]Service service;
|
|
339
|
+
|
|
340
|
+
public Long add([实体名]DTO dto) { return service.add(dto); }
|
|
341
|
+
public void update([实体名]DTO dto) { service.update(dto); }
|
|
342
|
+
public void delete(Long id) { service.delete(id); }
|
|
343
|
+
|
|
344
|
+
public [实体名]VO getById(Long id) { return service.getById(id); }
|
|
345
|
+
|
|
346
|
+
public List<[实体名]VO> page([实体名]DTO dto) {
|
|
347
|
+
PageMethod.startPage(dto.getPageNum(), dto.getPageSize());
|
|
348
|
+
return service.list(dto);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### Controller 接口层
|
|
354
|
+
|
|
355
|
+
```java
|
|
356
|
+
package net.xnzn.core.[模块].[功能].web.controller;
|
|
357
|
+
|
|
358
|
+
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
359
|
+
import io.swagger.annotations.Api;
|
|
360
|
+
import io.swagger.annotations.ApiOperation;
|
|
361
|
+
import lombok.extern.slf4j.Slf4j;
|
|
362
|
+
import net.xnzn.core.[模块].[功能].web.business.impl.[实体名]WebBusiness;
|
|
363
|
+
import net.xnzn.core.[模块].[功能].web.dto.[实体名]DTO;
|
|
364
|
+
import net.xnzn.core.[模块].[功能].web.vo.[实体名]VO;
|
|
365
|
+
import net.xnzn.framework.secure.filter.annotation.RequiresAuthentication;
|
|
366
|
+
import org.springframework.validation.annotation.Validated;
|
|
367
|
+
import org.springframework.web.bind.annotation.*;
|
|
368
|
+
|
|
369
|
+
import javax.annotation.Resource;
|
|
370
|
+
import java.util.List;
|
|
371
|
+
|
|
372
|
+
@Slf4j
|
|
373
|
+
@RestController
|
|
374
|
+
@RequestMapping("/api/v2/web/[模块]/[功能]")
|
|
375
|
+
@Api(tags = "[功能名称]管理")
|
|
376
|
+
public class [实体名]WebController {
|
|
377
|
+
|
|
378
|
+
@Resource
|
|
379
|
+
private [实体名]WebBusiness business;
|
|
380
|
+
|
|
381
|
+
@PostMapping("/add")
|
|
382
|
+
@ApiOperation("新增")
|
|
383
|
+
@RequiresAuthentication
|
|
384
|
+
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<[实体名]DTO> request) {
|
|
385
|
+
return business.add(request.getContent());
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
@PostMapping("/update")
|
|
389
|
+
@ApiOperation("修改")
|
|
390
|
+
@RequiresAuthentication
|
|
391
|
+
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<[实体名]DTO> request) {
|
|
392
|
+
business.update(request.getContent());
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
@PostMapping("/delete")
|
|
396
|
+
@ApiOperation("删除")
|
|
397
|
+
@RequiresAuthentication
|
|
398
|
+
public void delete(@RequestBody LeRequest<Long> request) {
|
|
399
|
+
business.delete(request.getContent());
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
@GetMapping("/get/{id}")
|
|
403
|
+
@ApiOperation("获取详情")
|
|
404
|
+
@RequiresAuthentication
|
|
405
|
+
public [实体名]VO getById(@PathVariable Long id) {
|
|
406
|
+
return business.getById(id);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@PostMapping("/page")
|
|
410
|
+
@ApiOperation("分页查询")
|
|
411
|
+
@RequiresAuthentication
|
|
412
|
+
public List<[实体名]VO> page(@RequestBody LeRequest<[实体名]DTO> request) {
|
|
413
|
+
return business.page(request.getContent());
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
### 第四步:输出清单
|
|
421
|
+
|
|
422
|
+
```markdown
|
|
423
|
+
## CRUD 代码生成完成!
|
|
424
|
+
|
|
425
|
+
### 已生成文件(8 个)
|
|
426
|
+
|
|
427
|
+
| 文件 | 状态 |
|
|
428
|
+
|------|------|
|
|
429
|
+
| common/model/[实体名].java | ✅ |
|
|
430
|
+
| web/dto/[实体名]DTO.java | ✅ |
|
|
431
|
+
| web/vo/[实体名]VO.java | ✅ |
|
|
432
|
+
| common/mapper/[实体名]Mapper.java | ✅ |
|
|
433
|
+
| common/mapper/[实体名]Mapper.xml | ✅ |
|
|
434
|
+
| common/service/impl/[实体名]Service.java | ✅ |
|
|
435
|
+
| web/business/impl/[实体名]WebBusiness.java | ✅ |
|
|
436
|
+
| web/controller/[实体名]WebController.java | ✅ |
|
|
437
|
+
|
|
438
|
+
### 下一步
|
|
439
|
+
|
|
440
|
+
1. 完善 DTO 查询条件字段
|
|
441
|
+
2. 完善 Service buildWrapper 查询逻辑
|
|
442
|
+
3. 根据业务在 Business 层增加复杂编排
|
|
443
|
+
4. 运行 /check 检查代码规范
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## 与 /dev 的区别
|
|
449
|
+
|
|
450
|
+
| 对比 | `/crud` | `/dev` |
|
|
451
|
+
|------|---------|--------|
|
|
452
|
+
| **适用** | 表已存在 | 从零设计 |
|
|
453
|
+
| **建表 SQL** | ❌ 跳过 | ✅ 引导设计 |
|
|
454
|
+
| **代码生成** | ✅ 快速 | ✅ 完整 |
|