在多租户核心包中创建系统配置多租户模块,为小程序登录、支付等场景提供租户隔离的系统配置管理,支持在管理后台进行配置,并通过Redis缓存提高访问性能。
Current relevant functionality:
Technology stack:
Integration points:
What's being added/changed:
How it integrates:
Success criteria:
✅ Story 1: 创建系统配置多租户模块包 - 实现系统配置实体、Schema定义,复用共享CRUD包自动获得完整CRUD功能
✅ Story 2: 实现系统配置Redis缓存 - 添加Redis缓存支持,优化配置访问性能
In操作符使用问题,确保批量查询正确工作✅ Story 3: 集成系统配置到认证和支付模块 - 修改小程序登录和支付功能使用系统配置
02b448f)Story 4: 创建系统配置UI包并集成到管理后台 - 开发系统配置管理界面
Primary Risk: 系统配置模块可能影响现有认证和支付功能的稳定性
Mitigation: 分阶段实施,先创建独立模块,再逐步集成到现有功能
Rollback Plan: 如果出现问题,可以回退到使用环境变量的方式,系统配置模块作为可选功能
@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;
}
// 服务实现 - 继承GenericCrudService(参考文件模块模式)
export class SystemConfigService extends GenericCrudService<SystemConfig> {
constructor(dataSource: DataSource) {
super(dataSource, SystemConfig, {
tenantOptions: {
enabled: true,
tenantIdField: 'tenantId',
autoExtractFromContext: true
},
userTracking: {
createdByField: 'createdBy',
updatedByField: 'updatedBy'
}
});
}
// 可添加自定义方法,如Redis缓存相关方法
async getConfigByKey(tenantId: number, key: string): Promise<string | null> {
// Redis缓存逻辑
}
}
// 路由生成 - 一行代码获得完整CRUD API
const systemConfigRoutes = createCrudRoutes({
entity: SystemConfig,
createSchema: CreateSystemConfigSchema,
updateSchema: UpdateSystemConfigSchema,
getSchema: SystemConfigSchema,
listSchema: SystemConfigSchema,
tenantOptions: { enabled: true }
});
system_config:{tenantId}:{configKey}Story Manager Handoff:
"请为这个棕地史诗开发详细的用户故事。关键考虑因素:
该史诗应在保持系统完整性的同时交付多租户系统配置管理功能。"