feat: 实现服务层核心功能与文档更新
refactor(ProductService): 修复createProduct方法和其他方法错误 fix(InventoryAgingService): 修复AGING_THRESHOLD_DAYS引用问题 fix(InventoryService): 修复predictSKUDemand方法 refactor(ChatBotController): 从tsoa风格改为Express风格 fix(CommandCenterController): 修复类型问题 fix(AdAutoService): 修复stock可能为undefined的问题 docs: 更新SERVICE_MAP、DOMAIN_MODEL等架构文档 chore: 启动前端服务(运行在http://localhost:8000)
This commit is contained in:
@@ -6,6 +6,10 @@ export interface AppConfig {
|
||||
value: any;
|
||||
description?: string;
|
||||
isEnabled: boolean;
|
||||
version?: number;
|
||||
tenantId?: string;
|
||||
created_at?: Date;
|
||||
updated_at?: Date;
|
||||
}
|
||||
|
||||
export class ConfigService {
|
||||
@@ -93,4 +97,27 @@ export class ConfigService {
|
||||
const config = await this.getConfig(key, tenantId);
|
||||
return config ? config.isEnabled : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有配置
|
||||
*/
|
||||
static async getAllConfigs(tenantId: string = 'SYSTEM'): Promise<AppConfig[]> {
|
||||
const configs = await db(this.TABLE_NAME).where({ tenantId });
|
||||
return configs.map(config => ({
|
||||
...config,
|
||||
value: typeof config.value === 'string' ? JSON.parse(config.value) : config.value
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个配置
|
||||
*/
|
||||
static async getConfig(key: string, tenantId: string = 'SYSTEM'): Promise<AppConfig | null> {
|
||||
const config = await db(this.TABLE_NAME).where({ key, tenantId }).first();
|
||||
if (!config) return null;
|
||||
return {
|
||||
...config,
|
||||
value: typeof config.value === 'string' ? JSON.parse(config.value) : config.value
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user