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



/**
 * 档案信息服务对象基类
 *
 * @export
 * @class HRArchivesServiceBase
 * @extends {EntityServie}
 */
export default class HRArchivesServiceBase extends EntityService {

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

    /**
     * 初始化基础数据
     *
     * @memberof HRArchivesServiceBase
     */
    public initBasicData(){
        this.APPLYDEKEY ='hrarchives';
        this.APPDEKEY = 'hrarchivesid';
        this.APPDENAME = 'hrarchives';
        this.APPDETEXT = 'hrarchivesname';
        this.APPNAME = 'pim';
        this.SYSTEMNAME = 'ibizhumanresources';
    }

// 实体接口

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

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

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

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

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

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

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

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

    /**
     * FetchActive接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRArchivesServiceBase
     */
    public async FetchActive(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrarchives/fetchactive`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrarchives/fetchactive`,tempData,isloading);
        return res;
    }

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

    /**
     * FetchNonArchives接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRArchivesServiceBase
     */
    public async FetchNonArchives(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrarchives/fetchnonarchives`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrarchives/fetchnonarchives`,tempData,isloading);
        return res;
    }

    /**
     * FetchNonEmployee接口方法
     *
     * @param {*} [context={}]
     * @param {*} [data={}]
     * @param {boolean} [isloading]
     * @returns {Promise<any>}
     * @memberof HRArchivesServiceBase
     */
    public async FetchNonEmployee(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
        if(context.hremployee && true){
            let tempData:any = JSON.parse(JSON.stringify(data));
            let res:any = Http.getInstance().get(`/hremployees/${context.hremployee}/hrarchives/fetchnonemployee`,tempData,isloading);
            return res;
        }
        let tempData:any = JSON.parse(JSON.stringify(data));
        let res:any = Http.getInstance().get(`/hrarchives/fetchnonemployee`,tempData,isloading);
        return res;
    }
}