解决多租户架构中user-module-mt、auth-module-mt、file-module-mt三个包的循环依赖问题,通过合并为单一@d8d/core-module-mt包,在包内保持三个模块的独立目录结构,同时消除循环依赖。
合并后包结构:
@d8d/core-module-mt/
├── src/
│ ├── modules/ # 模块层
│ │ ├── user/ # 用户模块(原user-module-mt)
│ │ │ ├── entities/
│ │ │ │ ├── user.entity.mt.ts
│ │ │ │ ├── role.entity.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── services/
│ │ │ │ ├── user.service.mt.ts
│ │ │ │ ├── role.service.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── schemas/
│ │ │ │ ├── user.schema.mt.ts
│ │ │ │ ├── role.schema.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── routes/
│ │ │ │ ├── user.routes.mt.ts
│ │ │ │ ├── role.routes.mt.ts
│ │ │ │ ├── custom.routes.mt.ts
│ │ │ │ └── index.ts
│ │ │ └── index.ts
│ │ ├── auth/ # 认证模块(原auth-module-mt)
│ │ │ ├── services/
│ │ │ │ ├── auth.service.mt.ts
│ │ │ │ ├── mini-auth.service.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── schemas/
│ │ │ │ ├── auth.schema.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── routes/
│ │ │ │ ├── login.route.mt.ts
│ │ │ │ ├── register.route.mt.ts
│ │ │ │ ├── mini-login.route.mt.ts
│ │ │ │ └── ...
│ │ │ ├── middleware/
│ │ │ │ ├── auth.middleware.mt.ts
│ │ │ │ └── index.ts
│ │ │ └── index.ts
│ │ ├── file/ # 文件模块(原file-module-mt)
│ │ │ ├── entities/
│ │ │ │ ├── file.entity.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── services/
│ │ │ │ ├── file.service.mt.ts
│ │ │ │ ├── minio.service.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── schemas/
│ │ │ │ ├── file.schema.mt.ts
│ │ │ │ └── index.ts
│ │ │ ├── routes/
│ │ │ │ ├── upload-policy/
│ │ │ │ ├── multipart-policy/
│ │ │ │ ├── [id]/
│ │ │ │ └── index.ts
│ │ │ └── index.ts
│ │ └── index.ts
│ ├── shared/ # 共享层
│ │ ├── middleware/
│ │ │ ├── auth.middleware.mt.ts
│ │ │ └── index.ts
│ │ └── index.ts
│ └── index.ts # 包入口
适配器包设计:
# 原来的user-module-mt包(现在作为适配器)
@d8d/user-module-mt/
├── package.json
│ └── dependencies: { "@d8d/core-module-mt": "workspace:*" }
└── src/
└── index.ts
├── export { UserEntityMt } from '@d8d/core-module-mt/modules/user/entities'
├── export { UserServiceMt } from '@d8d/core-module-mt/modules/user/services'
├── export { UserSchemaMt } from '@d8d/core-module-mt/modules/user/schemas'
└── export { authMiddleware } from '@d8d/core-module-mt/shared/middleware'
# 其他包完全不需要修改
@d8d/goods-module-mt/
└── package.json
└── dependencies: { "@d8d/user-module-mt": "workspace:*" } # 保持不变
成功标准:
Story Manager Handoff:
"请为这个棕地epic开发详细的用户故事。关键考虑:
该epic应在保持系统完整性的同时交付解决循环依赖问题的目标。"