修改ConfigManager,定义配置数据继承体系

This commit is contained in:
chen wei bo
2025-09-01 19:07:24 +08:00
parent c9817ea13e
commit 8eb3f01688
12 changed files with 457 additions and 10 deletions
@@ -0,0 +1,50 @@
/**
* 商城配置
*/
import { BaseConfig } from "./BaseConfig";
import { ConfigManager } from "../manager/ConfigManager";
export class PurchaseConfig extends BaseConfig {
public reset(): void {
}
public clear(): void {
}
public destroy(): void {
super.destroy();
}
/**
* 获取所有配置
*/
protected getAllConfig(): any | null {
return ConfigManager.tables.TbPurchaseConfig;
}
/**
* 获取配置,根据 id
*/
protected getConfigById(id: number): any | null {
let allData = this.getAllConfig();
if (!allData) return null;
return allData.get(id);
}
/** 根据商品 id 获取商品名字 */
public getNameById(id: number): string | null {
let oneData = this.getConfigById(id);
if (!oneData) return null;
return oneData.name;
}
/** 根据商品 id 获取商品数量 */
public getCountById(id: number): number | null {
let oneData = this.getConfigById(id);
if (!oneData) return null;
return oneData.count;
}
}