后端 DDD 分层架构规范

SKILL开发

原名 DDD架构规范 · 标识 yudream-ddd-architecture

开发 未标注权限 许可证不明确
安装这个技能

在修改 Java 后端代码、新增系统模块或重构控制器、应用服务、领域聚合等场景下,按项目既定的 DDD 分层与架构约定约束代码组织,减少分层混乱。

一句话选型结论

按资料字段整理

后端 DDD 分层架构规范是开发类的 Agent Skill,安装方式未标注,权限级别未标注,许可证不明确,有可直接复制的安装命令。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式未标注 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 未标注 仓库 未标注
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

未标注
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
skillhub install user_50429d75/yudream-ddd-architecture
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    执行上面的命令安装;也可以把仓库里的 SKILL.md 手动放进客户端的 skills 目录。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方user_50429d75仓库 未标注 · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式未标注安装包 community
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验2026-11-06上游最后核验时间 · 数据更新 2026-11-06
正文体量7.4 KBSKILL.md 原文大小,越大说明说明书写得越细

能做什么

0 项能力
上游给出的能力概览与适用场景
重构控制器与服务新增系统模块分层审查领域层代码

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有可直接复制的安装命令,不用自己翻文档找入口。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
后端 DDD 分层架构规范当前 未标注权限 未标注 未标注 未标注 有
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

7.4 KB
模型实际读到的说明书原文,来自技能仓库

YuDream DDD Architecture

Mandatory First Steps

  1. Read this skill before backend edits in this repository.
  2. If the task touches a specific bounded context, inspect the matching packages in all four modules before editing:
    - yudream-domain/src/main/java/online/yudream/base/domain/...
    - yudream-application/src/main/java/online/yudream/base/application/...
    - yudream-infrastructure/src/main/java/online/yudream/base/infra/...
    - yudream-interfaces/src/main/java/online/yudream/base/interfaces/...
  3. Prefer the system/user package as the baseline pattern. It is the reference for aggregate, value object, repository, application command/query/DTO/service, infra data object/mapper/impl/service, and interface controller/assembler/request/res layout.
  4. Read references/knowledge.json when a task involves a repeated pitfall, known utility, or tool usage. Append durable lessons with scripts/add_knowledge.py when the user corrects the same issue, when a bug pattern is important, or when a reusable utility is discovered.

Layer Contract

Domain Layer

Use domain for business meaning and invariants.

Required package roles:
- aggregate: aggregate roots and entities such as User, Role, Dept.
- valobj: identity/value objects such as RoleID, DeptID, UserDept.
- enumerate: domain enums such as status, type, source.
- repo: repository interfaces only. No persistence implementation.
- service: domain services for cross-aggregate domain rules.

Rules:
- Keep framework/web classes out of domain.
- Put invariants and state transitions on aggregates when they belong to the aggregate.
- Use value objects for typed identifiers and meaningful compound values.
- Throw domain/business exceptions with normal Chinese text, not Unicode escapes or mojibake.

Application Layer

Use application for use cases and orchestration.

Required package roles:
- cmd: write-use-case input objects, for example create/update/assign commands.
- query: read-use-case query objects.
- dto: application output DTOs.
- assembler: application-layer conversions between domain aggregates and application DTOs.
- service: application services. They orchestrate repositories, domain services, transactions, validation, and authorization-sensitive use cases.

Rules:
- Application services may construct aggregates and call aggregate methods.
- Application services must not return interface res objects and must not accept interface request objects.
- Do not bury large toDTO, toDomain, or row-mapping methods inside services. Move conversion to application assembler when it is not trivial.
- Keep persistence-specific query construction out of application.

Infrastructure Layer

Use infrastructure for technical adapters.

Required package roles:
- dataobj: persistence objects such as Mongo DOs.
- mapper: DO/domain conversion.
- impl: repository implementations.
- service: external technical services and gateways.
- Additional adapter folders are allowed when they are explicit, for example bootstrap, context, scanner/config packages.

Rules:
- Repository implementations implement domain repo interfaces.
- Data objects never leak to application or interface layers.
- Mapper methods belong in infra mapper, not controller or application service.
- External systems (S3, Redis, Sa-Token gateway details, mail) live here behind domain/application contracts.

Interface Layer

Use interface for HTTP/API boundary only.

Required package roles:
- controller: HTTP routing, auth annotations, validation trigger, app-service calls, response wrapping.
- assembler: request/res/Excel row/web boundary conversion.
- request: inbound request bodies.
- res: outbound response bodies.
- row: Excel/import-export row models when needed.
- vo: allowed only for UI-specific view objects already established by the project; prefer res for HTTP responses.

Controller hard rules:
- No new XxxCmd, new XxxRes, new XxxExcelRow, or response builder() in controllers.
- No private toXxx, parseXxx, templateXxx, rowToXxx, or Excel template construction in controllers.
- No stream mapping from request rows to commands in controllers. Wrap that in an assembler method.
- No business invariants in controllers. Delegate to application/domain.
- Controller is allowed to set page/size limits, call auth/session helpers, pass app-service return values through an assembler, and return Result.

Assembler hard rules:
- Interface assembler converts request -> cmd, domain/app DTO -> res, Excel row -> cmd, DTO -> Excel row, and template rows.
- Application assembler converts domain -> application DTO and similar application-internal transformations.
- Infrastructure mapper converts domain <-> dataobj.

Excel / Import Export

  • Use EasyExcel for .xlsx import/export.
  • Put HTTP file writing/reading helpers in support classes such as ExcelHttpSupport.
  • Put row mapping and template row creation in interface assemblers.
  • Export endpoints return blob responses from the frontend; frontend utilities should use saveExcelResponse, pickExcelFile, excelForm, and importResultMessage from src/utils/excel.ts.
  • Add matching permissions to menu seed enum when adding v-auth buttons.

UTF-8 / Chinese Text

  • Do not convert Chinese strings to \uXXXX escapes.
  • Do not change files merely because PowerShell prints mojibake.
  • Do fix actual source text that contains mojibake such as 鐢ㄦ埛, 绯荤粺, 鍒犻櫎, 鏄?, 涓嶅瓨鍦?.
  • Prefer normal Chinese in source files when existing project files are already UTF-8.
  • Keep generated frontend display text localized in Chinese.

Review Checklist

Before finishing backend work, run targeted scans:

rg -n "private .*to[A-Z]|new .*Cmd|new .*ExcelRow|\\.builder\\(\\)" yudream-interfaces/src/main/java/online/yudream/base/interfaces -g "*Controller.java"
rg -n "鐢ㄦ埛|绯荤粺|鍒犻櫎|鏄\\?|涓嶅瓨鍦|\\\\u[0-9a-fA-F]{4}" yudream-*/src/main/java -g "*.java"

Then verify:

$env:JAVA_HOME='C:/Users/SiberianHusky/.jdks/ms-21.0.10'; $env:Path="$env:JAVA_HOME/bin;$env:Path"; mvn -pl yudream-bootstrap -am -DskipTests compile

For frontend changes:

pnpm --config.engine-strict=false --filter @fantastic-admin/core-arco-design-vue exec vue-tsc --noEmit --pretty false --skipLibCheck --ignoreDeprecations 6.0

Incremental Knowledge

Use references/knowledge.json for project-specific lessons, utilities, and recurring corrections. Add entries when:
- the user repeatedly corrects a style or architecture issue;
- a bug has a reusable diagnosis/fix;
- a utility, endpoint, or component is useful enough to reuse;
- a rule is important but too detailed for the core SKILL.md.

Append with:

python .codex/skills/yudream-ddd-architecture/scripts/add_knowledge.py rule controller-no-mapping "Controller must not create Cmd/Res/ExcelRow; put conversions in interface assembler."

常见问题

5 问
答案由本站依据条目字段整理
后端 DDD 分层架构规范怎么安装?

在支持 Skills 的客户端里执行:skillhub install user_50429d75/yudream-ddd-architecture。安装方式为未标注。装完刷新技能列表或重开客户端。

后端 DDD 分层架构规范支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

后端 DDD 分层架构规范权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

后端 DDD 分层架构规范收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

后端 DDD 分层架构规范用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 2026-11-06。