package com.brilliance.isc.common.context;

import com.brilliance.isc.bo.Cbb;
import com.brilliance.isc.common.jshmod.vo.JshmodRequest;
import com.brilliance.isc.common.liaallg.vo.LiaallgVo;
import com.brilliance.isc.common.rmbbop.vo.RmbbopRequest;
import com.brilliance.isc.common.setfeg.vo.SetfegVo;
import com.brilliance.isc.common.setglg.vo.SetglgVo;
import com.brilliance.isc.common.vo.BizAmdInfoVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.common.vo.PtsptaVo;

import java.util.List;
import java.util.Map;

public class BopContext {
    private static ThreadLocal<List<PtsptaVo>> ptsList = new ThreadLocal<>();
    private static ThreadLocal<BizInfoVo> bizInfo = new ThreadLocal<>();
    private static ThreadLocal<BizAmdInfoVo> bizAmdInfo = new ThreadLocal<>();
    private static ThreadLocal<Map<String, Cbb>> cbsMap = new ThreadLocal<>();
    private static ThreadLocal<SetfegVo> setfeg = new ThreadLocal<>();
    private static ThreadLocal<SetglgVo> setglg = new ThreadLocal<>();
    private static ThreadLocal<List<LiaallgVo>> liaallg = new ThreadLocal<>();

    public static List<PtsptaVo> getPtsList() {
        return BopContext.ptsList.get();
    }

    public static void setPtsList(List<PtsptaVo> ptsList) {
        BopContext.ptsList.set(ptsList);
    }

    public static BizInfoVo getBizInfo() {
        return BopContext.bizInfo.get();
    }

    public static void setBizInfo(BizInfoVo bizInfo) {
        BopContext.bizInfo.set(bizInfo);
    }

    public static BizAmdInfoVo getBizAmdInfo() {
        return BopContext.bizAmdInfo.get();
    }

    public static void setBizAmdInfo(BizAmdInfoVo bizAmdInfo) {
        BopContext.bizAmdInfo.set(bizAmdInfo);
    }

    public static Map<String, Cbb> getCbsMap() {
        return BopContext.cbsMap.get();
    }

    public static void setCbsMap(Map<String, Cbb> cbsMap) {
        BopContext.cbsMap.set(cbsMap);
    }

    public static SetfegVo getSetfeg() {
        return BopContext.setfeg.get();
    }

    public static void setSetfeg(SetfegVo setfeg) {
        BopContext.setfeg.set(setfeg);
    }

    public static SetglgVo getSetglg() {
        return BopContext.setglg.get();
    }

    public static void setSetglg(SetglgVo setglg) {
        BopContext.setglg.set(setglg);
    }

    public static List<LiaallgVo> getLiaallg() {
        return BopContext.liaallg.get();
    }

    public static void setLiaallg(List<LiaallgVo> liaallg) {
        BopContext.liaallg.set(liaallg);
    }

    public static <T1 extends BizInfoVo, T2 extends BizAmdInfoVo> void load(RmbbopRequest<T1, T2> rmbbopRequest) {
        BopContext.setBizInfo(rmbbopRequest.getRec());
        BopContext.setBizAmdInfo(rmbbopRequest.getAmdRec());
        BopContext.setPtsList(rmbbopRequest.getPtsList());
        BopContext.setCbsMap(rmbbopRequest.getCbsMap());
        BopContext.setSetglg(rmbbopRequest.getSetglg());
        BopContext.setLiaallg(rmbbopRequest.getLiaallg());
    }

    public static <T extends BizInfoVo> void load(JshmodRequest<T> jshmodRequest) {
        BopContext.setBizInfo(jshmodRequest.getRec());
        BopContext.setPtsList(jshmodRequest.getPtsList());
        BopContext.setCbsMap(jshmodRequest.getCbsMap());
        BopContext.setSetfeg(jshmodRequest.getSetfeg());
        BopContext.setSetglg(jshmodRequest.getSetglg());
    }

    public static void remove() {
        BopContext.ptsList.remove();
        BopContext.bizInfo.remove();
        BopContext.bizAmdInfo.remove();
        BopContext.cbsMap.remove();
        BopContext.setfeg.remove();
        BopContext.setglg.remove();
        BopContext.liaallg.remove();
    }
}
