package com.brilliance.isc.common.api;

import com.brilliance.isc.common.api.trndoc.service.TrndocApiService;
import com.brilliance.isc.common.api.trndoc.vo.TrndocRequest;
import com.brilliance.isc.common.api.trndoc.vo.TrndocResponse;
import com.brilliance.isc.common.trndoc.service.TrndocService;
import com.brilliance.isc.common.trndoc.vo.TrndocVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TrndocApiServiceImpl implements TrndocApiService {

    @Autowired
    private TrndocService trndocService;

    @Override
    public TrndocResponse calcTrndoc(TrndocRequest trndocRequest) {
        trndocRequest.reset();
        TrndocVo trndocVo = trndocRequest.getTrndocVo();
        trndocService.assertDOCS(trndocVo);
        return TrndocResponse.builder()
                .doceot(trndocVo.getDoceot())
                .parstm(trndocVo.getParstm())
                .build();
    }

    @Override
    public TrndocResponse calcDoctre(TrndocRequest trndocRequest) {
        trndocRequest.reset();
        TrndocVo trndocVo = trndocRequest.getTrndocVo();
        trndocService.fillCONDOCSTM(trndocVo);
        return TrndocResponse.builder()
                .shwinc(trndocVo.getShwinc())
                .shwout(trndocVo.getShwout())
                .build();
    }
}
