优化结构

This commit is contained in:
Yvan
2026-08-23 00:38:33 +08:00
parent 64459574b2
commit 4e5071ee65
22 changed files with 301 additions and 127 deletions
+7 -7
View File
@@ -9,8 +9,8 @@
```text
internal/
app/ # 组合根、模块 catalog 和运行时组合
modules/system/ # system 模块定义
app/ # 运行时组合根
modules/ # 静态 catalog 和模块定义
modules/payment/ # payment 模块定义
biz/ # DO、usecase、repo interface
conf/ # 配置 proto/runtime
@@ -40,12 +40,12 @@ internal/
独立边界时不继续拆分。
- 删除只转发 `pkg/protoutil` 的 `utils/configutil`。
## `internal/app` 为什么只保留组合代码
## `internal/app` 为什么只保留运行时组合
`app/catalog.go` 是有意保留的组合根,负责组装模块、任务注册与运行时。
system 自身的迁移、管理面和默认定时任务位于
`modules/system/definition.go`,由模块包声明后再被 catalog 汇总。这样模块
定义不再和应用组合逻辑混在一起,也不能误并入 `biz`、`service` 或 `data`。
`modules/catalog.go` 是静态模块注册点,负责按依赖顺序汇总各模块
`Definition()`;`app/runtime.go` 只负责任务注册和依赖注入后的运行时路由组合。
这样模块定义不再和应用组合逻辑混在一起,也不能误并入 `biz`、`service` 或
`data`。
Catalog 只能自动汇总静态模块贡献;新增模块若提供运行时路由或依赖型任务,仍需
在 cmd/Wire 中显式注册,直到统一的 runtime contribution 协议落地。