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



/**
 * 应聘者审批表服务对象基类
 *
 * @export
 * @class PcmProfileApprovalServiceBase
 * @extends {EntityServie}
 */
export default class PcmProfileApprovalServiceBase extends EntityService {

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

    /**
     * 初始化基础数据
     *
     * @memberof PcmProfileApprovalServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='pcmprofileapproval';
        this.APPDEKEY = 'pcmprofileapprovalid';
        this.APPDENAME = 'pcmprofileapprovals';
        this.APPDETEXT = 'pcmprofileapprovalname';
        this.APPNAME = 'ehrpcm';
        this.SYSTEMNAME = 'ehr_practice05';
    }

// 实体接口

    /**
     * Select接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && context.pcmprofileapproval){
            let res:any = Http.getInstance().get(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/${context.pcmprofileapproval}/select`,isloading);
            
            return res;
        }
            let res:any = Http.getInstance().get(`/pcmprofileapprovals/${context.pcmprofileapproval}/select`,isloading);
            
            return res;
    }

    /**
     * Create接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && true){
            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(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals`,data,isloading);
            
            return res;
        }
        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(`/pcmprofileapprovals`,data,isloading);
        
        return res;
    }

    /**
     * Update接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && context.pcmprofileapproval){
            let masterData:any = {};
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().put(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/${context.pcmprofileapproval}`,data,isloading);
            
            return res;
        }
        let masterData:any = {};
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().put(`/pcmprofileapprovals/${context.pcmprofileapproval}`,data,isloading);
            
            return res;
    }

    /**
     * Remove接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && context.pcmprofileapproval){
            let res:any = Http.getInstance().delete(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/${context.pcmprofileapproval}`,isloading);
            return res;
        }
            let res:any = Http.getInstance().delete(`/pcmprofileapprovals/${context.pcmprofileapproval}`,isloading);
            return res;
    }

    /**
     * Get接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && context.pcmprofileapproval){
            let res:any = await Http.getInstance().get(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/${context.pcmprofileapproval}`,isloading);
            
            return res;
        }
            let res:any = await Http.getInstance().get(`/pcmprofileapprovals/${context.pcmprofileapproval}`,isloading);
            
            return res;
    }

    /**
     * GetDraft接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && true){
            let res:any = await Http.getInstance().get(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/getdraft`,isloading);
            res.data.pcmprofileapproval = data.pcmprofileapproval;
            
            return res;
        }
        let res:any = await  Http.getInstance().get(`/pcmprofileapprovals/getdraft`,isloading);
        res.data.pcmprofileapproval = data.pcmprofileapproval;
        
        return res;
    }

    /**
     * CheckKey接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && context.pcmprofileapproval){
            let masterData:any = {};
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().post(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/${context.pcmprofileapproval}/checkkey`,data,isloading);
            
            return res;
        }
            let res:any = Http.getInstance().post(`/pcmprofileapprovals/${context.pcmprofileapproval}/checkkey`,data,isloading);
            return res;
    }

    /**
     * Save接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && context.pcmprofileapproval){
            let masterData:any = {};
            Object.assign(data,masterData);
            let res:any = await Http.getInstance().post(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/${context.pcmprofileapproval}/save`,data,isloading);
            
            return res;
        }
        let masterData:any = {};
        Object.assign(data,masterData);
            let res:any = await  Http.getInstance().post(`/pcmprofileapprovals/${context.pcmprofileapproval}/save`,data,isloading);
            
            return res;
    }

    /**
     * FetchDefault接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/fetchdefault`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/pcmprofileapprovals/fetchdefault`,tempData,isloading);
        return res;
    }

    /**
     * FetchDisagree接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof PcmProfileApprovalServiceBase
     */
    public async FetchDisagree(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.pcmprofile && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/pcmprofiles/${context.pcmprofile}/pcmprofileapprovals/fetchdisagree`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/pcmprofileapprovals/fetchdisagree`,tempData,isloading);
        return res;
    }
}