import { IParam } from '@core';
import { {{pascalCase appEntity.codeName}}ServiceBase } from './{{spinalCase appEntity.codeName}}-service-base';

/**
 * {{appEntity.logicName}}服务
 *
 * @export
 * @class {{pascalCase appEntity.codeName}}Service
 * @extends {{pascalCase appEntity.codeName}}ServiceBase
 */
export class {{pascalCase appEntity.codeName}}Service extends {{pascalCase appEntity.codeName}}ServiceBase {

    /**
     * 基础数据服务实例
     * 
     * @private
     * @type { {{pascalCase appEntity.codeName}}Service }
     * @memberof {{pascalCase appEntity.codeName}}Service
     */
    private static basicDataServiceInstance: {{pascalCase appEntity.codeName}}Service;

    /**
     * 数据服务存储Map对象
     *
     * @private
     * @type {Map<string, any>}
     * @memberof {{pascalCase appEntity.codeName}}Service
     */
    private static dataServiceMap: Map<string, any> = new Map();

    /**
     * Creates an instance of {{pascalCase appEntity.codeName}}Service.
     * @memberof {{pascalCase appEntity.codeName}}Service
     */
    constructor(opts?: IParam) {
        super(opts);
    }

    /**
     * 获取实例
     *
     * @static
     * @param 应用上下文
     * @return {*}  { {{pascalCase appEntity.codeName}}Service }
     * @memberof {{pascalCase appEntity.codeName}}Service
     */
    static getInstance(opts?: IParam): {{pascalCase appEntity.codeName}}Service {
        if (!this.basicDataServiceInstance) {
            this.basicDataServiceInstance = new {{pascalCase appEntity.codeName}}Service(opts);
        }
        if (!opts || !opts.srfdynainstid) {
            return this.basicDataServiceInstance;
        } else {
            if (!{{pascalCase appEntity.codeName}}Service.dataServiceMap.get(opts.srfdynainstid)) {
                {{pascalCase appEntity.codeName}}Service.dataServiceMap.set(opts.srfdynainstid, new {{pascalCase appEntity.codeName}}Service(opts));
            }
            return {{pascalCase appEntity.codeName}}Service.dataServiceMap.get(opts.srfdynainstid);
        }
    }
}
export default {{pascalCase appEntity.codeName}}Service;