import { GetDictionaryItem, SetDictionaryItem } from "../BasicFunctions/Extensions/DictionaryExtension";

// 假设 TradeModel 类型已经定义
interface TradeModel {
    // 这里可以根据实际情况定义 TradeModel 的属性
}

export default class LoginUserInfo {
    // 缓存数据，柜员登陆时加载
    private static _dict: { [key: string]: any } = {};

    // 操作员基础信息
    static get KinbrNo(): string {
        return this.GetUserInfo('KinbrNo');
    }

    static get KinbrName(): string {
        return this.GetUserInfo('KinbrName');
    }

    static get TellerNo(): string {
        return this.GetUserInfo('TellerNo');
    }

    static get TellerName(): string {
        return this.GetUserInfo('TellerName');
    }

    static get TtyName(): string {
        return this.GetUserInfo('TtyName');
    }

    static get TradeDate(): string {
        return this.GetUserInfo('TradeDate');
    }

    static get TradeRight(): TradeModel[] {
        return this.GetUserInfo<TradeModel[]>('TradeRight');
    }

    // // 获取参数指定的缓存配置项 //TODO此处有两种方法 不能重载
    // static GetUserInfo(key: string): string {
    //     let ret = '';
    //     if (key && this._dict.hasOwnProperty(key)) {
    //         ret = this._dict[key] || '';
    //     }
    //     return ret;
    // }

    // 获取参数指定的缓冲配置项，并转换成相应类型
    static GetUserInfo<T>(key: string): T {
        return GetDictionaryItem<T>(this._dict, key);
    }

    // 设置参数指定的缓冲配置项
    static SetUserInfo(key: string, value: any): boolean {
        SetDictionaryItem(this._dict, key, value);
        return true;
    }
}
