Ready for Review
As a 系统管理员, I want 在多租户核心包中创建系统配置模块,实现系统配置实体、Schema定义,并复用共享CRUD包自动获得完整CRUD功能, so that 可以为小程序登录、支付等场景提供租户隔离的系统配置管理
packages/core-module-mt/system-config-module-mt/)packages/core-module-mt/system-config-module-mt/ 目录src/entities/system-config.entity.mt.ts [参考: packages/core-module-mt/file-module-mt/src/entities/file.entity.ts]src/schemas/system-config.schema.mt.ts [参考: packages/core-module-mt/file-module-mt/src/schemas/file.schema.mt.ts]src/services/system-config.service.mt.ts [参考: packages/core-module-mt/file-module-mt/src/services/file.service.mt.ts]src/routes/system-config.routes.mt.ts [参考: packages/core-module-mt/file-module-mt/src/routes/index.mt.ts][x] 创建模块导出 (AC: 1)
src/index.mt.ts 导出实体、服务、路由[x] 实现系统配置测试 (AC: 6)
tests/integration/system-config.routes.integration.test.ts [参考: packages/core-module-mt/file-module-mt/tests/integration/file.routes.integration.test.ts][x] 验证现有功能 (AC: 6)
packages/core-module-mt/system-config-module-mt/src/entities/ - 实体定义 (使用 .mt.ts 后缀)src/schemas/ - Zod Schema定义 (使用 .mt.ts 后缀)src/services/ - 服务实现 (使用 .mt.ts 后缀)src/routes/ - API路由 (使用 .mt.ts 后缀)tests/ - 测试文件auth-module-mt/ - 认证模块user-module-mt/ - 用户模块file-module-mt/ - 文件模块GenericCrudService<T> 抽象类tenantOptions 配置租户隔离userTracking 配置用户跟踪getList(), getById(), create(), update(), delete()createCrudRoutes() 函数@Entity('system_config')
export class SystemConfig {
@PrimaryGeneratedColumn()
id!: number;
@Column()
tenantId!: number; // 自动通过共享CRUD的tenantOptions设置
@Column()
configKey!: string;
@Column('text')
configValue!: string;
@Column()
description?: string;
// 自动通过共享CRUD的userTracking设置
@Column()
createdBy?: number;
@Column()
updatedBy?: number;
@Column()
createdAt!: Date;
@Column()
updatedAt!: Date;
}
export class SystemConfigService extends GenericCrudService<SystemConfig> {
constructor(dataSource: DataSource) {
super(dataSource, SystemConfig, {
tenantOptions: {
enabled: true,
tenantIdField: 'tenantId',
autoExtractFromContext: true
},
userTracking: {
createdByField: 'createdBy',
updatedByField: 'updatedBy'
}
});
}
}
const systemConfigRoutes = createCrudRoutes({
entity: SystemConfig,
createSchema: CreateSystemConfigSchema,
updateSchema: UpdateSystemConfigSchema,
getSchema: SystemConfigSchema,
listSchema: SystemConfigSchema,
tenantOptions: { enabled: true }
});
packages/core-module-mt/system-config-module-mt/tests/tests/unit/ - 单元测试
system-config.service.test.ts - 服务单元测试system-config.entity.test.ts - 实体单元测试tests/integration/ - 集成测试
system-config.routes.integration.test.ts - 路由集成测试packages/core-module-mt/auth-module-mt/packages/core-module-mt/user-module-mt/packages/core-module-mt/file-module-mt/.mt.ts 后缀,遵循多租户包命名规范| Date | Version | Description | Author |
|---|---|---|---|
| 2025-11-19 | 1.0 | 初始故事创建 | Bob (Scrum Master) |
| 2025-11-19 | 1.1 | 调整模块位置到core-module-mt包内 | Bob (Scrum Master) |
pnpm typecheckpnpm test tests/integration/system-config.routes.integration.test.ts初始实施阶段:按照故事需求创建完整的系统配置模块
packages/core-module-mt/system-config-module-mt/用户反馈修正:
packages/core-module-mt/tsconfig.json测试修复阶段:
tests/utils/integration-test-db.ts最终验证:
测试用例中文化:
packages/core-module-mt/system-config-module-mt/src/entities/system-config.entity.mt.ts - 系统配置实体packages/core-module-mt/system-config-module-mt/src/schemas/system-config.schema.mt.ts - Zod Schema定义packages/core-module-mt/system-config-module-mt/src/services/system-config.service.mt.ts - 系统配置服务packages/core-module-mt/system-config-module-mt/src/routes/system-config.routes.mt.ts - CRUD路由packages/core-module-mt/system-config-module-mt/src/index.mt.ts - 模块导出packages/core-module-mt/system-config-module-mt/tests/integration/system-config.routes.integration.test.ts - 集成测试packages/core-module-mt/system-config-module-mt/tests/utils/integration-test-db.ts - 测试工具packages/core-module-mt/tsconfig.json - 更新包含系统配置模块路径packages/core-module-mt/vitest.config.ts - 更新包含系统配置模块测试路径