kra-new/internal/data
Yvan 001e39da50 优化结构 2026-08-25 16:38:51 +08:00
..
integration 优化结构 2026-08-25 00:20:29 +08:00
payment 优化结构 2026-08-23 00:38:33 +08:00
system 优化结构 2026-08-24 21:50:33 +08:00
task 优化结构 2026-08-22 22:34:33 +08:00
README.md 优化结构 2026-08-23 00:38:33 +08:00
config_helpers.go 优化结构 2026-08-25 00:20:29 +08:00
config_store.go 优化结构 2026-08-25 16:38:51 +08:00
data.go 优化结构 2026-08-25 16:38:51 +08:00
data_scope.go 优化结构 2026-08-22 12:13:16 +08:00
data_scope_audit.go 优化结构 2026-08-21 10:29:14 +08:00
data_scope_audit_test.go 优化结构 2026-08-21 10:29:14 +08:00
data_scope_record.go 优化结构 2026-08-22 20:14:29 +08:00
data_scope_test.go 优化结构 2026-08-24 21:50:33 +08:00
database.go 优化结构 2026-08-24 21:50:33 +08:00
gorm_logger_test.go 优化结构 2026-08-21 10:29:14 +08:00
initialization_backend.go 优化结构 2026-08-25 16:38:51 +08:00
initialization_backend_test.go 优化结构 2026-08-24 13:56:06 +08:00
integration_config.go 优化结构 2026-08-24 13:25:16 +08:00
integration_config_test.go 优化结构 2026-08-25 00:20:29 +08:00
integration_runtime.go 优化结构 2026-08-22 20:14:29 +08:00
migrations.go 优化结构 2026-08-22 21:39:39 +08:00
migrations_test.go 优化结构 2026-08-24 21:50:33 +08:00
mongo.go 优化结构 2026-08-24 13:25:16 +08:00
runtime_clients.go 优化结构 2026-08-24 21:50:33 +08:00

README.md

Data Layer

data owns database clients, persistence models, migrations, configuration watching, and repository implementations.

  • system/: system repositories and system table persistence
  • task/: timed-task tables and task persistence
  • integration/: sys_integration_configs and integration configuration persistence
  • payment/: payment-order persistence
  • each subpackage owns its Wire ProviderSet; the root package only binds the shared Data infrastructure and aggregates those sets, mirroring biz
  • root files: shared database lifecycle, runtime clients, configuration orchestration, data-scope auditing, and migration orchestration

新增数据模块时创建 internal/data/<module>,提供 ProviderSetMigrations(),再在 internal/modules/<module>/definition.go 注册迁移与 管理面,最后在根 data.ProviderSet 中注册该模块。根 data 不应直接 拥有业务表 PO也不应让一个模块引用另一个模块的私有 PO。

Root files intentionally stay in one package because they share Data state and reload locks. Do not split them into packages only to reduce file count.

当前内置数据模块为 systemintegrationtaskpayment。其中:

  • system 只拥有 sys_* 系统表、系统仓储、种子和系统维护清理;
  • integration 唯一拥有 sys_integration_configs 表模型、配置仓储和通信默认值;
  • task 只拥有定时任务与任务日志表;
  • payment 只拥有 pay_orders 等支付持久化,通过 biz/integration.PaymentConfigReader 读取支付配置,不感知 integration 的 PO 或表结构。

配置文件迁移、数据库切换、Redis/Mongo/对象存储重载仍属于根 data 的生命周期编排, 不等同于某个业务模块的表仓储。