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



/**
 * 维护保养服务对象基类
 *
 * @export
 * @class EMEQKeepServiceBase
 * @extends {EntityServie}
 */
export default class EMEQKeepServiceBase extends EntityService {

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

    /**
     * 初始化基础数据
     *
     * @memberof EMEQKeepServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='emeqkeep';
        this.APPDEKEY = 'emeqkeepid';
        this.APPDENAME = 'emeqkeeps';
        this.APPDETEXT = 'emeqkeepname';
        this.APPNAME = 'eamweb';
        this.SYSTEMNAME = 'eam_practice03';
    }

// 实体接口

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

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

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

    /**
     * GetDraft接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQKeepServiceBase
     */
    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}/emeqkeeps/getdraft`,isloading);
        }
        if(context.emeqtype && context.emequip && true){
            return Http.getInstance().get(`/emeqtypes/${context.emeqtype}/emequips/${context.emequip}/emeqkeeps/getdraft`,isloading);
        }
        if(context.emequip && true){
            return Http.getInstance().get(`/emequips/${context.emequip}/emeqkeeps/getdraft`,isloading);
        }
        let res:any = await  Http.getInstance().get(`/emeqkeeps/getdraft`,isloading);
        res.data.emeqkeep = data.emeqkeep;
        return res;
    }

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

    }

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

    /**
     * Create接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQKeepServiceBase
     */
    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}/emeqkeeps`,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}/emeqkeeps`,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}/emeqkeeps`,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(`/emeqkeeps`,data,isloading);
        return res;
    }

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

    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof EMEQKeepServiceBase
     */
    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}/emeqkeeps/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}/emeqkeeps/fetchdefault`,tempData,isloading);
        }
        if(context.emequip && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            return Http.getInstance().get(`/emequips/${context.emequip}/emeqkeeps/fetchdefault`,tempData,isloading);
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        return Http.getInstance().get(`/emeqkeeps/fetchdefault`,tempData,isloading);
    }
}