package com.brilliance.isc.common.api.usrmd.controller;

import com.brilliance.isc.common.api.usrmd.service.UsrmdApiService;
import com.brilliance.isc.common.api.usrmd.vo.UsrmdRequest;
import com.brilliance.isc.common.api.usrmd.vo.UsrmdResponse;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.vo.BizAmdInfoVo;
import com.brilliance.isc.common.vo.BizInfoVo;
import com.brilliance.isc.vo.ResponseSet;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;


public class AbstractUrsMdController<T1 extends BizInfoVo,T2 extends BizAmdInfoVo> {

    @Autowired
    private SettleContext settleContext;

    @Autowired
    private UsrmdApiService usrmdApiService;


    @ApiOperation("统一名单筛查查询按钮")
    public ResponseSet<UsrmdResponse> QueryTymd(UsrmdRequest<T1, T2> usrmdRequest) {
        try {
            settleContext.loadSettleSession(usrmdRequest.getTransName(), usrmdRequest.getUserId(), usrmdRequest.getRec(), usrmdRequest.getPtsList());
            return ResponseSet.simpleSuccess(usrmdApiService.clacUsrMingdan(usrmdRequest));
        } catch (Exception e) {
            throw e;
        }finally {
            SettleContext.removeUserSession();
        }
    }

    @ApiOperation("统一名单初始化")
    public ResponseSet<UsrmdResponse> initUmd(UsrmdRequest<T1, T2> usrmdRequest) {
        try {
            settleContext.loadSettleSession(usrmdRequest.getTransName(), usrmdRequest.getUserId(), usrmdRequest.getRec(), usrmdRequest.getPtsList());
            return ResponseSet.simpleSuccess(usrmdApiService.initUmdList(usrmdRequest));
        } catch (Exception e) {
            throw e;
        }finally {
            SettleContext.removeUserSession();
        }
    }

}
