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,462 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: leniu-error-handler
|
|
3
|
+
description: |
|
|
4
|
+
leniu-yunshitang-core 项目异常处理规范。包含 LeException 用法、全局异常处理器、参数校验、日志规范、错误码设计、国际化。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 抛出业务异常(LeException)
|
|
8
|
+
- 全局异常处理器配置
|
|
9
|
+
- 参数校验异常处理
|
|
10
|
+
- 日志记录规范
|
|
11
|
+
- 错误码设计与国际化
|
|
12
|
+
- 事务异常处理
|
|
13
|
+
|
|
14
|
+
适用项目:leniu-tengyun-core(云食堂项目)
|
|
15
|
+
|
|
16
|
+
触发词:leniu-异常、leniu-LeException、leniu-throw、leniu-错误处理、leniu-全局异常、leniu-@Validated、leniu-参数校验、leniu-日志、leniu-log、leniu-错误码、leniu-事务、leniu-I18n、net.xnzn、leniu-yunshitang、云食堂异常
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# leniu-yunshitang-core 异常处理指南
|
|
20
|
+
|
|
21
|
+
> 本文档专注于 leniu-tengyun-core 项目的 Java 后端异常处理规范。
|
|
22
|
+
|
|
23
|
+
## 快速索引
|
|
24
|
+
|
|
25
|
+
| 场景 | 推荐方式 |
|
|
26
|
+
|------|---------|
|
|
27
|
+
| 业务异常 | `throw new LeException("msg")` |
|
|
28
|
+
| 带参数异常 | `throw new LeException("用户 {} 不存在", userId)` |
|
|
29
|
+
| 参数校验 | `@Validated(InsertGroup.class)` |
|
|
30
|
+
| 日志记录 | `log.error("msg: {}", e.getMessage(), e)` |
|
|
31
|
+
| 国际化消息 | `throw new LeException(I18n.getMessage("key"))` |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 1. 业务异常 - LeException
|
|
36
|
+
|
|
37
|
+
### 基本用法
|
|
38
|
+
|
|
39
|
+
```java
|
|
40
|
+
import com.pig4cloud.pigx.common.core.exception.LeException;
|
|
41
|
+
|
|
42
|
+
// ✅ 基本用法:抛出业务异常
|
|
43
|
+
throw new LeException("用户不存在");
|
|
44
|
+
|
|
45
|
+
// ✅ 带占位符(支持 {} 占位符)
|
|
46
|
+
throw new LeException("用户 {} 不存在", userId);
|
|
47
|
+
throw new LeException("订单 {} 状态 {} 无法支付", orderId, status);
|
|
48
|
+
|
|
49
|
+
// ✅ 条件抛出(手动检查)
|
|
50
|
+
if (ObjectUtil.isNull(user)) {
|
|
51
|
+
throw new LeException("用户不存在");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ✅ 参数校验
|
|
55
|
+
if (StrUtil.isBlank(bo.getName())) {
|
|
56
|
+
throw new LeException("名称不能为空");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ✅ 集合判空
|
|
60
|
+
if (CollUtil.isEmpty(list)) {
|
|
61
|
+
throw new LeException("列表不能为空");
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 2. 国际化 - I18n
|
|
68
|
+
|
|
69
|
+
### 国际化消息使用
|
|
70
|
+
|
|
71
|
+
```java
|
|
72
|
+
import net.xnzn.core.common.i18n.I18n;
|
|
73
|
+
|
|
74
|
+
// 获取国际化消息
|
|
75
|
+
String message = I18n.getMessage("user.not.exists");
|
|
76
|
+
|
|
77
|
+
// 带参数的国际化消息
|
|
78
|
+
String message = I18n.getMessage("user.password.retry.limit.exceed", maxRetryCount);
|
|
79
|
+
|
|
80
|
+
// 在异常中使用
|
|
81
|
+
throw new LeException(I18n.getMessage("user.not.exists"));
|
|
82
|
+
throw new LeException(I18n.getMessage("order.status.invalid", orderStatus));
|
|
83
|
+
|
|
84
|
+
// 带占位符的国际化
|
|
85
|
+
throw new LeException(I18n.getMessage("user.not.found", userId));
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 3. 参数校验
|
|
91
|
+
|
|
92
|
+
### 使用 @Validated 自动校验
|
|
93
|
+
|
|
94
|
+
```java
|
|
95
|
+
import jakarta.validation.Valid;
|
|
96
|
+
import jakarta.validation.constraints.*;
|
|
97
|
+
|
|
98
|
+
// Controller 层校验
|
|
99
|
+
@PostMapping("/add")
|
|
100
|
+
public Long add(@Validated(InsertGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
101
|
+
// 参数校验失败会自动抛出异常
|
|
102
|
+
return xxxService.add(request.getContent());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@PostMapping("/update")
|
|
106
|
+
public void update(@Validated(UpdateGroup.class) @RequestBody LeRequest<XxxDTO> request) {
|
|
107
|
+
xxxService.update(request.getContent());
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### DTO 类校验注解
|
|
112
|
+
|
|
113
|
+
```java
|
|
114
|
+
@Data
|
|
115
|
+
@ApiModel("XXX DTO")
|
|
116
|
+
public class XxxDTO implements Serializable {
|
|
117
|
+
|
|
118
|
+
@ApiModelProperty(value = "主键ID")
|
|
119
|
+
@NotNull(message = "主键ID不能为空", groups = {UpdateGroup.class})
|
|
120
|
+
private Long id;
|
|
121
|
+
|
|
122
|
+
@ApiModelProperty(value = "名称", required = true)
|
|
123
|
+
@NotBlank(message = "名称不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
124
|
+
@Size(max = 100, message = "名称长度不能超过100个字符")
|
|
125
|
+
private String name;
|
|
126
|
+
|
|
127
|
+
@ApiModelProperty(value = "邮箱")
|
|
128
|
+
@Email(message = "邮箱格式不正确")
|
|
129
|
+
private String email;
|
|
130
|
+
|
|
131
|
+
@ApiModelProperty(value = "手机号")
|
|
132
|
+
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
|
133
|
+
private String phone;
|
|
134
|
+
|
|
135
|
+
@ApiModelProperty(value = "数量")
|
|
136
|
+
@Min(value = 0, message = "数量不能小于0")
|
|
137
|
+
@Max(value = 9999, message = "数量不能大于9999")
|
|
138
|
+
private Integer count;
|
|
139
|
+
|
|
140
|
+
@ApiModelProperty(value = "开始时间", required = true)
|
|
141
|
+
@NotNull(message = "开始时间不能为空", groups = {InsertGroup.class, UpdateGroup.class})
|
|
142
|
+
private Date startTime;
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 分组校验定义
|
|
147
|
+
|
|
148
|
+
```java
|
|
149
|
+
// InsertGroup.java
|
|
150
|
+
public interface InsertGroup {}
|
|
151
|
+
|
|
152
|
+
// UpdateGroup.java
|
|
153
|
+
public interface UpdateGroup {}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 4. 日志规范
|
|
159
|
+
|
|
160
|
+
### 日志级别
|
|
161
|
+
|
|
162
|
+
| 级别 | 使用场景 | 示例 |
|
|
163
|
+
|------|---------|------|
|
|
164
|
+
| ERROR | 系统错误、业务异常 | 数据库连接失败、第三方接口超时 |
|
|
165
|
+
| WARN | 警告信息、潜在问题 | 缓存未命中、重试操作 |
|
|
166
|
+
| INFO | 重要业务流程、操作记录 | 用户登录、订单创建 |
|
|
167
|
+
| DEBUG | 开发调试信息 | 方法入参、中间变量 |
|
|
168
|
+
|
|
169
|
+
### 日志最佳实践
|
|
170
|
+
|
|
171
|
+
```java
|
|
172
|
+
import lombok.extern.slf4j.Slf4j;
|
|
173
|
+
import cn.hutool.core.util.ObjectUtil;
|
|
174
|
+
|
|
175
|
+
@Slf4j
|
|
176
|
+
@Service
|
|
177
|
+
public class XxxServiceImpl implements XxxService {
|
|
178
|
+
|
|
179
|
+
@Resource
|
|
180
|
+
private XxxMapper xxxMapper;
|
|
181
|
+
|
|
182
|
+
// ✅ 好的:使用占位符(性能更好)
|
|
183
|
+
@Override
|
|
184
|
+
public Long add(XxxDTO dto) {
|
|
185
|
+
log.info("开始新增XXX,名称: {}", dto.getName());
|
|
186
|
+
|
|
187
|
+
// 业务逻辑
|
|
188
|
+
XxxEntity entity = BeanUtil.copyProperties(dto, XxxEntity.class);
|
|
189
|
+
xxxMapper.insert(entity);
|
|
190
|
+
|
|
191
|
+
log.info("新增XXX成功,ID: {}", entity.getId());
|
|
192
|
+
return entity.getId();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ❌ 不好:字符串拼接(每次都会拼接,即使日志级别不输出)
|
|
196
|
+
@Override
|
|
197
|
+
public Long addBad(XxxDTO dto) {
|
|
198
|
+
log.info("开始新增XXX,名称: " + dto.getName()); // ❌
|
|
199
|
+
// ...
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ✅ 好的:异常日志带堆栈(第三个参数传异常对象)
|
|
203
|
+
@Override
|
|
204
|
+
public XxxVO getById(Long id) {
|
|
205
|
+
try {
|
|
206
|
+
XxxEntity entity = xxxMapper.selectById(id);
|
|
207
|
+
if (ObjectUtil.isNull(entity)) {
|
|
208
|
+
throw new LeException("记录不存在");
|
|
209
|
+
}
|
|
210
|
+
return BeanUtil.copyProperties(entity, XxxVO.class);
|
|
211
|
+
} catch (Exception e) {
|
|
212
|
+
log.error("查询失败: {}", e.getMessage(), e); // ✅
|
|
213
|
+
throw new LeException("查询失败");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ❌ 不好:只记录消息,丢失堆栈
|
|
218
|
+
@Override
|
|
219
|
+
public void bad() {
|
|
220
|
+
try {
|
|
221
|
+
// ...
|
|
222
|
+
} catch (Exception e) {
|
|
223
|
+
log.error("处理失败: {}", e.getMessage()); // ❌
|
|
224
|
+
throw new LeException("处理失败");
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ✅ 好的:判断日志级别(避免不必要的序列化开销)
|
|
229
|
+
@Override
|
|
230
|
+
public void debugMethod(XxxDTO dto) {
|
|
231
|
+
if (log.isDebugEnabled()) {
|
|
232
|
+
log.debug("详细数据: {}", JacksonUtil.writeValueAsString(dto));
|
|
233
|
+
}
|
|
234
|
+
// ...
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 5. Service 层完整示例
|
|
242
|
+
|
|
243
|
+
```java
|
|
244
|
+
import com.pig4cloud.pigx.common.core.exception.LeException;
|
|
245
|
+
import com.pig4cloud.pigx.common.core.util.LeRequest;
|
|
246
|
+
import cn.hutool.core.bean.BeanUtil;
|
|
247
|
+
import cn.hutool.core.util.ObjectUtil;
|
|
248
|
+
import cn.hutool.core.util.StrUtil;
|
|
249
|
+
import cn.hutool.core.collection.CollUtil;
|
|
250
|
+
import lombok.extern.slf4j.Slf4j;
|
|
251
|
+
import net.xnzn.core.common.i18n.I18n;
|
|
252
|
+
import net.xnzn.core.xxx.dto.XxxDTO;
|
|
253
|
+
import net.xnzn.core.xxx.mapper.XxxMapper;
|
|
254
|
+
import net.xnzn.core.xxx.model.XxxEntity;
|
|
255
|
+
import net.xnzn.core.xxx.vo.XxxVO;
|
|
256
|
+
|
|
257
|
+
import javax.annotation.Resource;
|
|
258
|
+
import java.util.List;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* XXX 服务实现
|
|
262
|
+
*/
|
|
263
|
+
@Slf4j
|
|
264
|
+
@Service
|
|
265
|
+
public class XxxServiceImpl implements XxxService {
|
|
266
|
+
|
|
267
|
+
@Resource
|
|
268
|
+
private XxxMapper xxxMapper;
|
|
269
|
+
|
|
270
|
+
@Override
|
|
271
|
+
public Long add(XxxDTO dto) {
|
|
272
|
+
log.info("开始新增XXX,类型: {}", dto.getXXXType());
|
|
273
|
+
|
|
274
|
+
// 参数校验
|
|
275
|
+
if (StrUtil.isBlank(dto.getName())) {
|
|
276
|
+
throw new LeException(I18n.getMessage("name.required"));
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// 业务校验
|
|
280
|
+
if (dto.getStartTime().after(dto.getEndTime())) {
|
|
281
|
+
throw new LeException(I18n.getMessage("time.invalid"));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// 转换并保存
|
|
285
|
+
XxxEntity entity = BeanUtil.copyProperties(dto, XxxEntity.class);
|
|
286
|
+
entity.setDelFlag(2); // 正常状态
|
|
287
|
+
|
|
288
|
+
xxxMapper.insert(entity);
|
|
289
|
+
|
|
290
|
+
log.info("新增XXX成功,ID: {}", entity.getId());
|
|
291
|
+
return entity.getId();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
@Override
|
|
295
|
+
public void update(XxxDTO dto) {
|
|
296
|
+
if (ObjectUtil.isNull(dto.getId())) {
|
|
297
|
+
throw new LeException(I18n.getMessage("id.required"));
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
XxxEntity exist = xxxMapper.selectById(dto.getId());
|
|
301
|
+
if (ObjectUtil.isNull(exist)) {
|
|
302
|
+
throw new LeException(I18n.getMessage("record.not.exists"));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
XxxEntity entity = BeanUtil.copyProperties(dto, XxxEntity.class);
|
|
306
|
+
xxxMapper.updateById(entity);
|
|
307
|
+
|
|
308
|
+
log.info("更新XXX成功,ID: {}", dto.getId());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
@Override
|
|
312
|
+
public void delete(Long id) {
|
|
313
|
+
if (ObjectUtil.isNull(id)) {
|
|
314
|
+
throw new LeException(I18n.getMessage("id.required"));
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
int rows = xxxMapper.deleteById(id);
|
|
318
|
+
if (rows == 0) {
|
|
319
|
+
throw new LeException(I18n.getMessage("delete.failed"));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
log.info("删除XXX成功,ID: {}", id);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## 6. 用户友好提示
|
|
330
|
+
|
|
331
|
+
### 错误提示规范
|
|
332
|
+
|
|
333
|
+
```java
|
|
334
|
+
// ✅ 好的:用户友好提示
|
|
335
|
+
throw new LeException("订单已发货,无法取消");
|
|
336
|
+
throw new LeException("库存不足,请减少购买数量");
|
|
337
|
+
throw new LeException("验证码已过期,请重新获取");
|
|
338
|
+
throw new LeException("该用户名已被注册,请换一个试试");
|
|
339
|
+
|
|
340
|
+
// ❌ 不好:技术术语
|
|
341
|
+
throw new LeException("order.status.invalid");
|
|
342
|
+
throw new LeException("NullPointerException at line 123");
|
|
343
|
+
throw new LeException("数据库连接失败");
|
|
344
|
+
throw new LeException("Duplicate entry for key 'uk_username'");
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 7. 常见错误对比
|
|
350
|
+
|
|
351
|
+
### ❌ 错误写法
|
|
352
|
+
|
|
353
|
+
```java
|
|
354
|
+
// 错误 1: 使用 RuoYi 的 ServiceException
|
|
355
|
+
throw new ServiceException("用户不存在"); // ❌ 应该用 LeException
|
|
356
|
+
|
|
357
|
+
// 错误 2: 使用 RuoYi 的 MessageUtils
|
|
358
|
+
throw new ServiceException(MessageUtils.message("user.not.exists")); // ❌ 应该用 I18n.getMessage()
|
|
359
|
+
|
|
360
|
+
// 错误 3: 使用 javax.validation(JDK 21 应用 jakarta.validation)
|
|
361
|
+
import javax.validation.Valid; // ❌ 错误
|
|
362
|
+
|
|
363
|
+
// 错误 4: 使用 RuoYi 的 AddGroup/EditGroup
|
|
364
|
+
@Validated(AddGroup.class) // ❌ 应该用 InsertGroup.class
|
|
365
|
+
|
|
366
|
+
// 错误 5: 使用 RuoYi 的 StringUtils
|
|
367
|
+
StringUtils.isBlank(str); // ❌ 应该用 StrUtil.isBlank()
|
|
368
|
+
|
|
369
|
+
// 错误 6: 使用 RuoYi 的 CollUtil
|
|
370
|
+
CollUtil.isEmpty(list); // ❌ 应该用 CollUtil.isEmpty()(Hutool)
|
|
371
|
+
|
|
372
|
+
// 错误 7: 日志不带堆栈
|
|
373
|
+
log.error("处理失败: {}", e.getMessage()); // ❌
|
|
374
|
+
|
|
375
|
+
// 错误 8: 字符串拼接日志
|
|
376
|
+
log.info("处理用户: " + userId); // ❌
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### ✅ 正确写法
|
|
380
|
+
|
|
381
|
+
```java
|
|
382
|
+
// 正确 1: 使用 leniu 的 LeException
|
|
383
|
+
throw new LeException("用户不存在"); // ✅
|
|
384
|
+
|
|
385
|
+
// 正确 2: 使用 leniu 的 I18n
|
|
386
|
+
throw new LeException(I18n.getMessage("user.not.exists")); // ✅
|
|
387
|
+
|
|
388
|
+
// 正确 3: 使用 Jakarta Validation
|
|
389
|
+
import jakarta.validation.Valid; // ✅
|
|
390
|
+
|
|
391
|
+
// 正确 4: 使用 leniu 的 InsertGroup/UpdateGroup
|
|
392
|
+
@Validated(InsertGroup.class) // ✅
|
|
393
|
+
|
|
394
|
+
// 正确 5: 使用 Hutool 的 StrUtil
|
|
395
|
+
StrUtil.isBlank(str); // ✅
|
|
396
|
+
|
|
397
|
+
// 正确 6: 使用 Hutool 的 CollUtil
|
|
398
|
+
CollUtil.isEmpty(list); // ✅
|
|
399
|
+
|
|
400
|
+
// 正确 7: 日志带堆栈
|
|
401
|
+
log.error("处理失败: {}", e.getMessage(), e); // ✅
|
|
402
|
+
|
|
403
|
+
// 正确 8: 日志使用占位符
|
|
404
|
+
log.info("处理用户: {}", userId); // ✅
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## 8. 工具类选择
|
|
410
|
+
|
|
411
|
+
| 场景 | RuoYi-Vue-Plus | leniu-tengyun-core |
|
|
412
|
+
|------|----------------|-------------------|
|
|
413
|
+
| **异常类** | `ServiceException` | `LeException` |
|
|
414
|
+
| **国际化** | `MessageUtils.message(key)` | `I18n.getMessage(key)` |
|
|
415
|
+
| **静态工厂** | 无(必须 `new`) | 无(必须 `new`) |
|
|
416
|
+
| **对象判空** | `ObjectUtil.isNull()` | `ObjectUtil.isNull()` |
|
|
417
|
+
| **集合判空** | `CollUtil.isEmpty()` | `CollUtil.isEmpty()` |
|
|
418
|
+
| **字符串判空** | `StringUtils.isBlank()` | `StrUtil.isBlank()` |
|
|
419
|
+
| **日志框架** | `@Slf4j` | `@Slf4j` |
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## 9. 检查清单
|
|
424
|
+
|
|
425
|
+
使用异常处理前必须检查:
|
|
426
|
+
|
|
427
|
+
- [ ] **业务异常使用 `new LeException()`**?
|
|
428
|
+
- [ ] **条件判断使用 `if + ObjectUtil.isNull()`**?
|
|
429
|
+
- [ ] **参数校验使用 `@Validated(InsertGroup.class)`**?
|
|
430
|
+
- [ ] **异常消息是否使用国际化**(`I18n.getMessage()`)?
|
|
431
|
+
- [ ] **日志记录异常堆栈**(`log.error("msg: {}", e.getMessage(), e)`)?
|
|
432
|
+
- [ ] **日志使用占位符 `{}`**,不使用字符串拼接?
|
|
433
|
+
- [ ] **重要操作记录 INFO 日志**?
|
|
434
|
+
- [ ] **错误提示使用用户友好语言**?
|
|
435
|
+
- [ ] **是否使用 Jakarta Validation**?
|
|
436
|
+
- [ ] **分组是否正确**(InsertGroup/UpdateGroup)?
|
|
437
|
+
- [ ] **是否使用正确的工具类**(StrUtil/CollUtil)?
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## 10. 快速对照表
|
|
442
|
+
|
|
443
|
+
| ❌ 错误写法 | ✅ 正确写法 |
|
|
444
|
+
|-----------|-----------|
|
|
445
|
+
| `throw new ServiceException("msg")` | `throw new LeException("msg")` |
|
|
446
|
+
| `MessageUtils.message("key")` | `I18n.getMessage("key")` |
|
|
447
|
+
| `import javax.validation.Valid` | `import jakarta.validation.Valid` |
|
|
448
|
+
| `@Validated(AddGroup.class)` | `@Validated(InsertGroup.class)` |
|
|
449
|
+
| `StringUtils.isBlank(str)` | `StrUtil.isBlank(str)` |
|
|
450
|
+
| `log.error("失败: " + e.getMessage())` | `log.error("失败: {}", e.getMessage(), e)` |
|
|
451
|
+
| `log.info("用户: " + userId)` | `log.info("用户: {}", userId)` |
|
|
452
|
+
| `throw new LeException("DB error")` | `throw new LeException("数据保存失败,请重试")` |
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
## 参考代码位置
|
|
457
|
+
|
|
458
|
+
| 类型 | 路径 |
|
|
459
|
+
|------|------|
|
|
460
|
+
| Service 示例 | `core-attendance/.../service/impl/AttendanceLeaveInfoServiceImpl.java` |
|
|
461
|
+
|
|
462
|
+
**项目路径**:`/Users/xujiajun/Developer/gongsi_proj/leniu-api/leniu-tengyun-core`
|