import { Http,Util } from '@/utils';
import EntityService from '../entity-service';



/**
 * 抢修记录服务对象基类
 *
 * @export
 * @class EMEQMaintanceServiceBase
 * @extends {EntityServie}
 */
export default class EMEQMaintanceServiceBase extends EntityService {

    /**
     * Creates an instance of  EMEQMaintanceServiceBase.
     * 
     * @param {*} [opts={}]
     * @memberof  EMEQMaintanceServiceBase
     */
    constructor(opts: any = {}) {
        super(opts);
    }

    /**
     * 初始化基础数据
     *
     * @memberof EMEQMaintanceServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='emeqmaintance';
        this.APPDEKEY = 'emeqmaintanceid';
        this.APPDENAME = 'emeqmaintances';
        this.APPDETEXT = 'emeqmaintancename';
        this.APPNAME = 'eamweb';
        this.SYSTEMNAME = 'eam_practice05';
    }

// 实体接口

    /**
     * Select接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && context.emeqmaintance){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/select`,isloading);
        }
        if(context.emeqtype && context.emequip && context.emeqmaintance){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/select`,isloading);
        }
        if(context.emequip && context.emeqmaintance){
            return Http.getInstance().get(`/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/select`,isloading);
        }
            return Http.getInstance().get(`/emeqmaintances/${context.emeqmaintance}/select`,isloading);
    }

    /**
     * Update接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && context.emeqmaintance){
            return Http.getInstance().put(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,data,isloading);
        }
        if(context.emeqtype && context.emequip && context.emeqmaintance){
            return Http.getInstance().put(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,data,isloading);
        }
        if(context.emequip && context.emeqmaintance){
            return Http.getInstance().put(`/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,data,isloading);
        }
        let masterData:any = {};
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().put(`/emeqmaintances/${context.emeqmaintance}`,data,isloading);
            return res;
    }

    /**
     * CheckKey接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && context.emeqmaintance){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/checkkey`,data,isloading);
        }
        if(context.emeqtype && context.emequip && context.emeqmaintance){
            return Http.getInstance().post(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/checkkey`,data,isloading);
        }
        if(context.emequip && context.emeqmaintance){
            return Http.getInstance().post(`/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/checkkey`,data,isloading);
        }
            return Http.getInstance().post(`/emeqmaintances/${context.emeqmaintance}/checkkey`,data,isloading);
    }

    /**
     * Get接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && context.emeqmaintance){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,isloading);
        }
        if(context.emeqtype && context.emequip && context.emeqmaintance){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,isloading);
        }
        if(context.emequip && context.emeqmaintance){
            return Http.getInstance().get(`/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,isloading);
        }
            let res:any = await Http.getInstance().get(`/emeqmaintances/${context.emeqmaintance}`,isloading);
            return res;

    }

    /**
     * Remove接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && context.emeqmaintance){
            return Http.getInstance().delete(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,isloading);
        }
        if(context.emeqtype && context.emequip && context.emeqmaintance){
            return Http.getInstance().delete(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,isloading);
        }
        if(context.emequip && context.emeqmaintance){
            return Http.getInstance().delete(`/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}`,isloading);
        }
            return Http.getInstance().delete(`/emeqmaintances/${context.emeqmaintance}`,isloading);

    }

    /**
     * Save接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && context.emeqmaintance){
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/save`,data,isloading);
        }
        if(context.emeqtype && context.emequip && context.emeqmaintance){
            return Http.getInstance().post(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/save`,data,isloading);
        }
        if(context.emequip && context.emeqmaintance){
            return Http.getInstance().post(`/emequips/${context.emequip}/emeqmaintances/${context.emeqmaintance}/save`,data,isloading);
        }
        let masterData:any = {};
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().post(`/emeqmaintances/${context.emeqmaintance}/save`,data,isloading);
            return res;
    }

    /**
     * Create接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances`,data,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances`,data,isloading);
        }
        if(context.emequip && true){
            if(!data.srffrontuf || data.srffrontuf !== "1"){
                data[this.APPDEKEY] = null;
            }
            if(data.srffrontuf){
                delete data.srffrontuf;
            }
            return Http.getInstance().post(`/emequips/${context.emequip}/emeqmaintances`,data,isloading);
        }
        let masterData:any = {};
        Object.assign(data,masterData);
        if(!data.srffrontuf || data.srffrontuf !== "1"){
            data[this.APPDEKEY] = null;
        }
        if(data.srffrontuf){
            delete data.srffrontuf;
        }
        let tempContext:any = JSON.parse(JSON.stringify(context));
        let res:any = await Http.getInstance().post(`/emeqmaintances`,data,isloading);
        return res;
    }

    /**
     * GetDraft接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && true){
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/getdraft`,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/getdraft`,isloading);
        }
        if(context.emequip && true){
            return Http.getInstance().get(`/emequips/${context.emequip}/emeqmaintances/getdraft`,isloading);
        }
        let res:any = await  Http.getInstance().get(`/emeqmaintances/getdraft`,isloading);
        res.data.emeqmaintance = data.emeqmaintance;
        return res;
    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQMaintanceServiceBase
     */
    public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pfteam && context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/pfteams/${context.pfteam}/emequips/${context.emequip}/emeqmaintances/fetchdefault`,tempData,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqmaintances/fetchdefault`,tempData,isloading);
        }
        if(context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emequips/${context.emequip}/emeqmaintances/fetchdefault`,tempData,isloading);
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        return Http.getInstance().get(`/emeqmaintances/fetchdefault`,tempData,isloading);
    }
}