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,560 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: leniu-java-export
|
|
3
|
+
description: |
|
|
4
|
+
leniu-tengyun-core / leniu-yunshitang 项目数据导出规范。当实现数据导出功能时使用此skill,包括Excel异步导出和分页导出方案。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 实现Excel数据导出(exportApi.startExcelExportTaskByPage)
|
|
8
|
+
- 实现异步导出(数据量大时)
|
|
9
|
+
- 实现分页导出(防内存溢出)
|
|
10
|
+
- 导出API接口设计(@PostMapping("/export"))
|
|
11
|
+
|
|
12
|
+
适用项目:
|
|
13
|
+
- leniu-tengyun-core:/Users/xujiajun/Developer/gongsi_proj/leniu-api/leniu-tengyun-core
|
|
14
|
+
- leniu-yunshitang:/Users/xujiajun/Developer/gongsi_proj/leniu-api/leniu-tengyun/leniu-yunshitang
|
|
15
|
+
|
|
16
|
+
触发词:导出、Export、Excel导出、异步导出、分页导出、@ExcelProperty、exportApi、数据导出、导出接口、leniu导出、leniu-yunshitang导出、net.xnzn导出
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# leniu-tengyun-core 数据导出规范
|
|
20
|
+
|
|
21
|
+
## 项目特征
|
|
22
|
+
|
|
23
|
+
| 特征 | 说明 |
|
|
24
|
+
|------|------|
|
|
25
|
+
| 包名 | `net.xnzn.*` |
|
|
26
|
+
| 异常类 | `LeException` |
|
|
27
|
+
| 导出工具 | `ExportApi.startExcelExportTaskByPage()` |
|
|
28
|
+
| 国际化 | `I18n.getMessage()` |
|
|
29
|
+
| 工具类 | Hutool(CollUtil、BeanUtil 等) |
|
|
30
|
+
| 请求包装 | `LeRequest<T>` |
|
|
31
|
+
|
|
32
|
+
## 核心组件
|
|
33
|
+
|
|
34
|
+
- **ExportApi**: 导出API接口
|
|
35
|
+
- **EasyExcelUtil**: 同步导出工具(报表 Controller 直接使用)
|
|
36
|
+
- **I18n**: 国际化工具
|
|
37
|
+
- **PageDTO**: 分页参数
|
|
38
|
+
- **ReportConstant**: 报表常量(工作表名称等)
|
|
39
|
+
|
|
40
|
+
## 两种导出模式
|
|
41
|
+
|
|
42
|
+
| 模式 | 工具 | 适用场景 |
|
|
43
|
+
|------|------|---------|
|
|
44
|
+
| **同步导出** | `EasyExcelUtil.writeExcelByDownLoadIncludeWrite()` | 报表 Controller 直接返回文件流,数据量不大 |
|
|
45
|
+
| **异步分页导出** | `exportApi.startExcelExportTaskByPage()` | 大数据量,任务队列方式 |
|
|
46
|
+
| **异步分页导出(Feign)** | `orderClients.export().startExcelExportTaskByPage()` | 跨模块导出,通过 Feign 客户端 |
|
|
47
|
+
|
|
48
|
+
## 同步导出(EasyExcelUtil)
|
|
49
|
+
|
|
50
|
+
```java
|
|
51
|
+
@ApiOperation(value = "流水汇总-同步导出")
|
|
52
|
+
@PostMapping("/export")
|
|
53
|
+
@SneakyThrows
|
|
54
|
+
public void export(@RequestBody LeRequest<ReportAnalysisTurnoverParam> request,
|
|
55
|
+
HttpServletResponse response) {
|
|
56
|
+
ReportAnalysisTurnoverParam param = request.getContent();
|
|
57
|
+
|
|
58
|
+
// 1. 查询数据
|
|
59
|
+
ReportBaseTotalVO<TurnoverVO> result = reportService.pageSummary(param);
|
|
60
|
+
|
|
61
|
+
// 2. 将列表 + 合计行合并(合计行追加到列表末尾)
|
|
62
|
+
List<TurnoverVO> records = result.getResultPage().getRecords();
|
|
63
|
+
CollUtil.addAll(records, result.getTotalLine()); // 合计行是单个 VO 或 List
|
|
64
|
+
|
|
65
|
+
// 3. 直接写出文件流
|
|
66
|
+
EasyExcelUtil.writeExcelByDownLoadIncludeWrite(
|
|
67
|
+
response,
|
|
68
|
+
I18n.getMessage("report.turnover.title"), // 文件名(国际化)
|
|
69
|
+
TurnoverVO.class, // VO 类型
|
|
70
|
+
I18n.getMessage(ReportConstant.REPORT_TITLE_DETAILS), // 工作表名
|
|
71
|
+
records, // 数据列表(含合计行)
|
|
72
|
+
param.getExportCols() // 导出列
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**注意事项**:
|
|
78
|
+
- 方法签名必须加 `@SneakyThrows`(`EasyExcelUtil` 抛出受检异常)
|
|
79
|
+
- `HttpServletResponse response` 作为方法参数接收
|
|
80
|
+
- 合计行用 `CollUtil.addAll(records, totalLine)` 追加到列表末尾
|
|
81
|
+
- 若合计行是单个 VO:`records.add(totalLine)` 即可
|
|
82
|
+
|
|
83
|
+
## 异步分页导出
|
|
84
|
+
|
|
85
|
+
### 基础导出模板
|
|
86
|
+
|
|
87
|
+
```java
|
|
88
|
+
@ApiOperation(value = "xxx导出")
|
|
89
|
+
@PostMapping("/export")
|
|
90
|
+
public void export(@RequestBody LeRequest<XxxPageParam> request) {
|
|
91
|
+
XxxPageParam param = request.getContent();
|
|
92
|
+
|
|
93
|
+
// 获取合计行(可选)
|
|
94
|
+
XxxVO totalLine = xxxService.getSummaryTotal(param);
|
|
95
|
+
|
|
96
|
+
// 启动异步导出任务
|
|
97
|
+
exportApi.startExcelExportTaskByPage(
|
|
98
|
+
I18n.getMessage("report.xxx.title"), // 文件名(国际化)
|
|
99
|
+
I18n.getMessage(ReportConstant.REPORT_TITLE_DETAILS), // 工作表名
|
|
100
|
+
XxxVO.class, // 数据类型
|
|
101
|
+
param.getExportCols(), // 导出列
|
|
102
|
+
param.getPage(), // 分页参数
|
|
103
|
+
totalLine, // 合计行(可为null)
|
|
104
|
+
() -> xxxService.pageList(param).getResultPage() // 数据提供者
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 实际项目示例
|
|
110
|
+
|
|
111
|
+
```java
|
|
112
|
+
@PostMapping("/purchase/order/export")
|
|
113
|
+
@ApiOperation(value = "采购-采购订单汇总-导出")
|
|
114
|
+
public void exportPurchaseOrder(@RequestBody LeRequest<MonitorPageParam> param) {
|
|
115
|
+
MonitorPageParam content = param.getContent();
|
|
116
|
+
|
|
117
|
+
// 1. 获取合计行
|
|
118
|
+
PurchaseOrderSummaryVO totalLine = monitorSafetyPurchaseService.getPurchaseOrderSummaryTotal(content);
|
|
119
|
+
|
|
120
|
+
// 2. 启动导出任务
|
|
121
|
+
exportApi.startExcelExportTaskByPage(
|
|
122
|
+
I18n.getMessage("school.purchase-order-summary"), // 文件名(国际化)
|
|
123
|
+
I18n.getMessage(ReportConstant.REPORT_TITLE_DETAILS), // 工作表名
|
|
124
|
+
PurchaseOrderSummaryVO.class, // VO类型
|
|
125
|
+
content.getExportCols(), // 导出列
|
|
126
|
+
content.getPage(), // 分页参数
|
|
127
|
+
totalLine, // 合计行
|
|
128
|
+
() -> monitorSafetyPurchaseService.getPurchaseOrderSummary(content).getResultPage()
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## 异步分页导出(Feign 客户端模式)
|
|
134
|
+
|
|
135
|
+
跨模块导出时,通过 Feign 客户端调用目标模块的导出接口。订单模块导出是典型示例:
|
|
136
|
+
|
|
137
|
+
```java
|
|
138
|
+
/**
|
|
139
|
+
* 订单导出 Controller(独立拆分,避免与主 Controller 耦合)
|
|
140
|
+
*/
|
|
141
|
+
@Slf4j
|
|
142
|
+
@Api(tags = "订单导出")
|
|
143
|
+
@RestController
|
|
144
|
+
@RequestMapping("/web/order/export")
|
|
145
|
+
public class OrderInfoExportWebController {
|
|
146
|
+
|
|
147
|
+
// ✅ 跨模块依赖:通过 Feign 客户端调用,@Lazy 避免循环依赖
|
|
148
|
+
@Autowired
|
|
149
|
+
@Lazy
|
|
150
|
+
private OrderClients orderClients;
|
|
151
|
+
|
|
152
|
+
@ApiOperation(value = "订单导出")
|
|
153
|
+
@PostMapping("/start")
|
|
154
|
+
public void export(@RequestBody LeRequest<OrderDetailWebDTO> request) {
|
|
155
|
+
OrderDetailWebDTO dto = request.getContent();
|
|
156
|
+
|
|
157
|
+
// 转换为内部查询参数
|
|
158
|
+
OrderSearchParam searchParam = dto.convertToOrderSearchParam();
|
|
159
|
+
|
|
160
|
+
// 通过 Feign 客户端启动异步导出任务
|
|
161
|
+
orderClients.export().startExcelExportTaskByPage(
|
|
162
|
+
I18n.getMessage("order.export.title"), // 文件名
|
|
163
|
+
I18n.getMessage(ReportConstant.REPORT_TITLE_DETAILS), // 工作表名
|
|
164
|
+
OrderDetailVO.class, // VO 类型
|
|
165
|
+
dto.getExportCols(), // 导出列
|
|
166
|
+
dto.getPage(), // 分页参数
|
|
167
|
+
null, // 无合计行
|
|
168
|
+
() -> orderClients.order().pageOrder(searchParam) // Lambda 提供数据
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**独立 Export Controller 的优点**:
|
|
175
|
+
- 将导出逻辑与查询逻辑解耦
|
|
176
|
+
- 避免单个 Controller 过于庞大
|
|
177
|
+
- `@Autowired @Lazy` 防止 Spring 循环依赖
|
|
178
|
+
|
|
179
|
+
## VO类导出注解
|
|
180
|
+
|
|
181
|
+
### 使用@ExcelProperty
|
|
182
|
+
|
|
183
|
+
```java
|
|
184
|
+
@Data
|
|
185
|
+
@ApiModel("xxx导出VO")
|
|
186
|
+
public class XxxVO {
|
|
187
|
+
|
|
188
|
+
@ExcelProperty(value = "ID", index = 0)
|
|
189
|
+
@ApiModelProperty("ID")
|
|
190
|
+
private Long id;
|
|
191
|
+
|
|
192
|
+
@ExcelProperty(value = "名称", index = 1)
|
|
193
|
+
@ApiModelProperty("名称")
|
|
194
|
+
private String name;
|
|
195
|
+
|
|
196
|
+
@ExcelProperty(value = "状态", index = 2)
|
|
197
|
+
@ApiModelProperty("状态")
|
|
198
|
+
private String statusDesc;
|
|
199
|
+
|
|
200
|
+
@ExcelProperty(value = "金额(元)", index = 3)
|
|
201
|
+
@ApiModelProperty("金额(元)")
|
|
202
|
+
@NumberFormat("#,##0.00")
|
|
203
|
+
private BigDecimal amount;
|
|
204
|
+
|
|
205
|
+
@ExcelProperty(value = "创建时间", index = 4)
|
|
206
|
+
@ApiModelProperty("创建时间")
|
|
207
|
+
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
|
208
|
+
private LocalDateTime createTime;
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 导出参数类
|
|
213
|
+
|
|
214
|
+
### PageParam包含导出列
|
|
215
|
+
|
|
216
|
+
```java
|
|
217
|
+
@Data
|
|
218
|
+
@ApiModel("xxx分页查询参数")
|
|
219
|
+
public class XxxPageParam extends ReportBaseParam {
|
|
220
|
+
|
|
221
|
+
@ApiModelProperty(value = "查询条件")
|
|
222
|
+
private String keyword;
|
|
223
|
+
|
|
224
|
+
// 其他查询条件...
|
|
225
|
+
// 导出列 exportCols 和分页 page 已在 ReportBaseParam 基类中定义
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Service层导出逻辑
|
|
230
|
+
|
|
231
|
+
### 导出时不分页
|
|
232
|
+
|
|
233
|
+
```java
|
|
234
|
+
public PageVO<XxxVO> pageList(XxxPageParam param) {
|
|
235
|
+
// 导出时不分页,查询全部数据
|
|
236
|
+
if (CollUtil.isNotEmpty(param.getExportCols())) {
|
|
237
|
+
// 不调用 PageMethod.startPage()
|
|
238
|
+
List<XxxEntity> records = mapper.selectList(param);
|
|
239
|
+
List<XxxVO> voList = BeanUtil.copyToList(records, XxxVO.class);
|
|
240
|
+
return PageVO.of(voList);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// 正常分页查询
|
|
244
|
+
PageMethod.startPage(param);
|
|
245
|
+
List<XxxEntity> records = mapper.pageList(param);
|
|
246
|
+
List<XxxVO> voList = BeanUtil.copyToList(records, XxxVO.class);
|
|
247
|
+
return PageVO.of(voList);
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### 带合计行的导出
|
|
252
|
+
|
|
253
|
+
```java
|
|
254
|
+
public ReportBaseTotalVO<XxxVO> pageWithTotal(XxxPageParam param) {
|
|
255
|
+
return Executors.readInSystem(() -> {
|
|
256
|
+
ReportBaseTotalVO<XxxVO> result = new ReportBaseTotalVO<>();
|
|
257
|
+
|
|
258
|
+
// 1. 导出时不查询合计行(避免不必要的性能开销)
|
|
259
|
+
if (CollUtil.isEmpty(param.getExportCols())) {
|
|
260
|
+
XxxVO totalLine = mapper.getSummaryTotal(param);
|
|
261
|
+
result.setTotalLine(totalLine);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 2. 导出时不分页
|
|
265
|
+
if (CollUtil.isNotEmpty(param.getExportCols())) {
|
|
266
|
+
List<XxxVO> list = mapper.getSummaryList(param);
|
|
267
|
+
result.setResultPage(PageVO.of(list));
|
|
268
|
+
} else {
|
|
269
|
+
// 正常分页查询
|
|
270
|
+
PageMethod.startPage(param);
|
|
271
|
+
List<XxxVO> list = mapper.getSummaryList(param);
|
|
272
|
+
result.setResultPage(PageVO.of(list));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return result;
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## 导出文件名国际化
|
|
281
|
+
|
|
282
|
+
### 使用I18n
|
|
283
|
+
|
|
284
|
+
```java
|
|
285
|
+
// 在 resources/message_zh.properties 中定义
|
|
286
|
+
report.order.title=订单报表
|
|
287
|
+
report.order.sheet=订单明细
|
|
288
|
+
|
|
289
|
+
// 在 resources/message_en.properties 中定义
|
|
290
|
+
report.order.title=Order Report
|
|
291
|
+
report.order.sheet=Order Details
|
|
292
|
+
|
|
293
|
+
// 在代码中使用
|
|
294
|
+
exportApi.startExcelExportTaskByPage(
|
|
295
|
+
I18n.getMessage("report.order.title"), // 订单报表
|
|
296
|
+
I18n.getMessage("report.order.sheet"), // 订单明细
|
|
297
|
+
OrderVO.class,
|
|
298
|
+
param.getExportCols(),
|
|
299
|
+
param.getPage(),
|
|
300
|
+
totalLine,
|
|
301
|
+
() -> orderService.pageList(param).getResultPage()
|
|
302
|
+
);
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## 导出列控制
|
|
306
|
+
|
|
307
|
+
### 前端传递导出列
|
|
308
|
+
|
|
309
|
+
```json
|
|
310
|
+
{
|
|
311
|
+
"page": {
|
|
312
|
+
"current": 1,
|
|
313
|
+
"size": 10
|
|
314
|
+
},
|
|
315
|
+
"exportCols": ["id", "name", "status", "amount", "createTime"],
|
|
316
|
+
"keyword": "test"
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 后端处理导出列
|
|
321
|
+
|
|
322
|
+
```java
|
|
323
|
+
@PostMapping("/export")
|
|
324
|
+
public void export(@RequestBody LeRequest<XxxPageParam> request) {
|
|
325
|
+
XxxPageParam param = request.getContent();
|
|
326
|
+
|
|
327
|
+
// 校验导出列
|
|
328
|
+
if (CollUtil.isEmpty(param.getExportCols())) {
|
|
329
|
+
throw new LeException("导出列不能为空");
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// 启动导出任务
|
|
333
|
+
exportApi.startExcelExportTaskByPage(
|
|
334
|
+
I18n.getMessage("report.xxx.title"),
|
|
335
|
+
I18n.getMessage("report.xxx.sheet"),
|
|
336
|
+
XxxVO.class,
|
|
337
|
+
param.getExportCols(), // 传递导出列
|
|
338
|
+
param.getPage(),
|
|
339
|
+
null,
|
|
340
|
+
() -> xxxService.pageList(param).getResultPage()
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## 导出数据转换
|
|
346
|
+
|
|
347
|
+
### 状态码转换为描述(使用BeanUtil)
|
|
348
|
+
|
|
349
|
+
```java
|
|
350
|
+
public PageVO<XxxVO> pageList(XxxPageParam param) {
|
|
351
|
+
PageMethod.startPage(param);
|
|
352
|
+
List<XxxEntity> records = mapper.pageList(param);
|
|
353
|
+
|
|
354
|
+
// 转换为VO并处理状态描述(leniu 使用 BeanUtil,不用 MapstructUtils)
|
|
355
|
+
List<XxxVO> voList = records.stream()
|
|
356
|
+
.map(entity -> {
|
|
357
|
+
XxxVO vo = new XxxVO();
|
|
358
|
+
BeanUtil.copyProperties(entity, vo);
|
|
359
|
+
|
|
360
|
+
// 状态码转换为描述
|
|
361
|
+
vo.setStatusDesc(StatusEnum.getByCode(entity.getStatus()).getDesc());
|
|
362
|
+
|
|
363
|
+
return vo;
|
|
364
|
+
})
|
|
365
|
+
.collect(Collectors.toList());
|
|
366
|
+
|
|
367
|
+
return PageVO.of(voList);
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
## 常见场景
|
|
372
|
+
|
|
373
|
+
### 场景1:订单导出
|
|
374
|
+
|
|
375
|
+
```java
|
|
376
|
+
@ApiOperation(value = "订单导出")
|
|
377
|
+
@PostMapping("/export")
|
|
378
|
+
public void export(@RequestBody LeRequest<OrderPageParam> request) {
|
|
379
|
+
OrderPageParam param = request.getContent();
|
|
380
|
+
|
|
381
|
+
log.info("【导出】订单导出,条件:{}", param);
|
|
382
|
+
|
|
383
|
+
// 获取合计行
|
|
384
|
+
OrderVO totalLine = orderService.getSummaryTotal(param);
|
|
385
|
+
|
|
386
|
+
// 启动导出任务
|
|
387
|
+
exportApi.startExcelExportTaskByPage(
|
|
388
|
+
I18n.getMessage("report.order.title"),
|
|
389
|
+
I18n.getMessage("report.order.sheet"),
|
|
390
|
+
OrderVO.class,
|
|
391
|
+
param.getExportCols(),
|
|
392
|
+
param.getPage(),
|
|
393
|
+
totalLine,
|
|
394
|
+
() -> orderService.pageList(param).getResultPage()
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### 场景2:报表导出
|
|
400
|
+
|
|
401
|
+
```java
|
|
402
|
+
@ApiOperation(value = "销售报表导出")
|
|
403
|
+
@PostMapping("/export")
|
|
404
|
+
public void export(@RequestBody LeRequest<SalesReportParam> request) {
|
|
405
|
+
SalesReportParam param = request.getContent();
|
|
406
|
+
|
|
407
|
+
log.info("【导出】销售报表导出,日期范围:{} - {}",
|
|
408
|
+
param.getStartDate(), param.getEndDate());
|
|
409
|
+
|
|
410
|
+
// 获取合计行
|
|
411
|
+
SalesReportVO totalLine = reportService.getSummaryTotal(param);
|
|
412
|
+
|
|
413
|
+
// 启动导出任务
|
|
414
|
+
exportApi.startExcelExportTaskByPage(
|
|
415
|
+
I18n.getMessage("report.sales.title"),
|
|
416
|
+
I18n.getMessage("report.sales.sheet"),
|
|
417
|
+
SalesReportVO.class,
|
|
418
|
+
param.getExportCols(),
|
|
419
|
+
param.getPage(),
|
|
420
|
+
totalLine,
|
|
421
|
+
() -> reportService.getSummary(param).getResultPage()
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### 场景3:带权限过滤的导出
|
|
427
|
+
|
|
428
|
+
```java
|
|
429
|
+
@ApiOperation(value = "数据导出")
|
|
430
|
+
@PostMapping("/export")
|
|
431
|
+
public void export(@RequestBody LeRequest<DataPageParam> request) {
|
|
432
|
+
DataPageParam param = request.getContent();
|
|
433
|
+
|
|
434
|
+
// 获取用户权限
|
|
435
|
+
MgrUserAuthPO authPO = mgrAuthApi.getUserAuthPO();
|
|
436
|
+
ReportDataPermissionParam dataPermission =
|
|
437
|
+
reportDataPermissionService.getDataPermission(authPO);
|
|
438
|
+
|
|
439
|
+
log.info("【导出】数据导出,用户:{}, 权限范围:{}",
|
|
440
|
+
authPO.getUserId(), dataPermission.getCanteenIds());
|
|
441
|
+
|
|
442
|
+
// 启动导出任务(权限过滤在Service层处理)
|
|
443
|
+
exportApi.startExcelExportTaskByPage(
|
|
444
|
+
I18n.getMessage("report.data.title"),
|
|
445
|
+
I18n.getMessage("report.data.sheet"),
|
|
446
|
+
DataVO.class,
|
|
447
|
+
param.getExportCols(),
|
|
448
|
+
param.getPage(),
|
|
449
|
+
null,
|
|
450
|
+
() -> dataService.pageList(param).getResultPage()
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## 导出性能优化
|
|
456
|
+
|
|
457
|
+
### 1. 限制导出数量
|
|
458
|
+
|
|
459
|
+
```java
|
|
460
|
+
@PostMapping("/export")
|
|
461
|
+
public void export(@RequestBody LeRequest<XxxPageParam> request) {
|
|
462
|
+
XxxPageParam param = request.getContent();
|
|
463
|
+
|
|
464
|
+
// 查询总数
|
|
465
|
+
long total = xxxService.count(param);
|
|
466
|
+
|
|
467
|
+
// 限制导出数量
|
|
468
|
+
if (total > 100000) {
|
|
469
|
+
throw new LeException("导出数据量过大,请缩小查询范围");
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
// 启动导出任务
|
|
473
|
+
exportApi.startExcelExportTaskByPage(
|
|
474
|
+
I18n.getMessage("report.xxx.title"),
|
|
475
|
+
I18n.getMessage("report.xxx.sheet"),
|
|
476
|
+
XxxVO.class,
|
|
477
|
+
param.getExportCols(),
|
|
478
|
+
param.getPage(),
|
|
479
|
+
null,
|
|
480
|
+
() -> xxxService.pageList(param).getResultPage()
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### 2. 导出数据脱敏
|
|
486
|
+
|
|
487
|
+
```java
|
|
488
|
+
public PageVO<UserVO> pageList(UserPageParam param) {
|
|
489
|
+
PageMethod.startPage(param);
|
|
490
|
+
List<User> records = mapper.pageList(param);
|
|
491
|
+
|
|
492
|
+
List<UserVO> voList = records.stream()
|
|
493
|
+
.map(user -> {
|
|
494
|
+
UserVO vo = new UserVO();
|
|
495
|
+
BeanUtil.copyProperties(user, vo);
|
|
496
|
+
|
|
497
|
+
// 导出时脱敏
|
|
498
|
+
if (CollUtil.isNotEmpty(param.getExportCols())) {
|
|
499
|
+
vo.setMobile(maskMobile(user.getMobile()));
|
|
500
|
+
vo.setIdCard(maskIdCard(user.getIdCard()));
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return vo;
|
|
504
|
+
})
|
|
505
|
+
.collect(Collectors.toList());
|
|
506
|
+
|
|
507
|
+
return PageVO.of(voList);
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
## 最佳实践
|
|
512
|
+
|
|
513
|
+
### 1. 导出日志
|
|
514
|
+
|
|
515
|
+
```java
|
|
516
|
+
@PostMapping("/export")
|
|
517
|
+
public void export(@RequestBody LeRequest<XxxPageParam> request) {
|
|
518
|
+
XxxPageParam param = request.getContent();
|
|
519
|
+
|
|
520
|
+
log.info("【导出】开始导出,文件名:{}, 条件:{}",
|
|
521
|
+
I18n.getMessage("report.xxx.title"), param);
|
|
522
|
+
|
|
523
|
+
exportApi.startExcelExportTaskByPage(
|
|
524
|
+
I18n.getMessage("report.xxx.title"),
|
|
525
|
+
I18n.getMessage("report.xxx.sheet"),
|
|
526
|
+
XxxVO.class,
|
|
527
|
+
param.getExportCols(),
|
|
528
|
+
param.getPage(),
|
|
529
|
+
null,
|
|
530
|
+
() -> xxxService.pageList(param).getResultPage()
|
|
531
|
+
);
|
|
532
|
+
|
|
533
|
+
log.info("【导出】导出任务已启动");
|
|
534
|
+
}
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### 2. 导出权限校验
|
|
538
|
+
|
|
539
|
+
```java
|
|
540
|
+
@PostMapping("/export")
|
|
541
|
+
public void export(@RequestBody LeRequest<XxxPageParam> request) {
|
|
542
|
+
// 校验导出权限
|
|
543
|
+
if (!hasExportPermission()) {
|
|
544
|
+
throw new LeException("无导出权限");
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// 启动导出任务
|
|
548
|
+
exportApi.startExcelExportTaskByPage(...);
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
## 常见错误
|
|
553
|
+
|
|
554
|
+
| 错误写法 | 正确写法 | 说明 |
|
|
555
|
+
|---------|---------|------|
|
|
556
|
+
| `throw new ServiceException("msg")` | `throw new LeException("msg")` | leniu 项目异常类 |
|
|
557
|
+
| `MapstructUtils.convert(a, B.class)` | `BeanUtil.copyProperties(a, b)` | leniu 使用 Hutool |
|
|
558
|
+
| `@RequestParam` 接收请求 | `@RequestBody LeRequest<T>` | leniu 接口使用 LeRequest 包装 |
|
|
559
|
+
| `import javax.validation.*` | `import jakarta.validation.*` | JDK 21 + Spring Boot 3.x |
|
|
560
|
+
| 不写导出日志 | 写 log.info 记录导出参数 | 便于排查导出问题 |
|