package com.brilliance.isc.common.bopset.controller;

import com.brilliance.isc.bo.model.Boppay;
import com.brilliance.isc.common.bopset.service.BoppayService;
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.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

@Api("收支申报境内外承兑服务")
public class AbstractBoppayController<T1 extends BizInfoVo, T2 extends BizAmdInfoVo> {
    @Autowired
    private BoppayService boppayService;
    @Autowired
    private SettleContext settleContext;

    Logger logger = LoggerFactory.getLogger(AbstractBoppayController.class);

    @ApiOperation("收支申报boppay前端数据交互（试算）")
    public ResponseSet<Boppay> mappingBoppayData(Boppay<T1, T2>  boppay) {
        try {
            settleContext.loadSettleSession(boppay.getTransName(), boppay.getUserId(), boppay.getRec(), boppay.getPtsList());
            return ResponseSet.simpleSuccess(boppayService.mappingBoppayDataAAAAAA(boppay));
        } catch (Exception ex) {
            logger.error("收支申报boppay前端试算异常",ex);
            throw ex;
        } finally {
            SettleContext.removeUserSession();
        }
    }
}
