package cokr.xit.ens.biz.traffic.chuncheon.mydoc.v2.presentation;

import cokr.xit.ens.biz.traffic.chuncheon.mydoc.v2.model.TrafficCcMydocReqDTO;
import cokr.xit.ens.biz.traffic.chuncheon.mydoc.v2.service.TrafficCcMydocService;
import cokr.xit.ens.core.aop.EnsResponseVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Tag(name = "TrafficCcSigntalkController")
@Slf4j
@Controller
@RequiredArgsConstructor
public class TrafficCcMydocController {

    private final TrafficCcMydocService trafficCcMydocService;

    @Operation(summary = "접수")
    @PostMapping(value = "/traffic/cc/mydoc/accept", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<EnsResponseVO> accept(@RequestBody TrafficCcMydocReqDTO reqDTO){
        EnsResponseVO responseVO = trafficCcMydocService.accept(reqDTO.getElctrnNticSndngId());
        return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
    }

    @Operation(summary = "제작")
    @PutMapping(value = "/traffic/cc/mydoc/re/make", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<EnsResponseVO> reMake(@RequestBody TrafficCcMydocReqDTO reqDTO){
        EnsResponseVO responseVO = trafficCcMydocService.reMake(reqDTO.getElctrnNticSndngId());
        return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
    }

    @Operation(summary = "전송")
    @PutMapping(value = "/traffic/cc/mydoc/re/send", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<EnsResponseVO> reSend(@RequestBody TrafficCcMydocReqDTO reqDTO){
        EnsResponseVO responseVO = trafficCcMydocService.reSend(reqDTO.getElctrnNticSndngId());
        return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
    }

    @Operation(summary = "전송결과가져오기")
    @PostMapping(value = "/traffic/cc/mydoc/fetch", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<EnsResponseVO> fetch(@RequestBody TrafficCcMydocReqDTO reqDTO){
        EnsResponseVO responseVO = trafficCcMydocService.fetch(reqDTO.getElctrnNticSndngId());
        return new ResponseEntity<EnsResponseVO>(responseVO, HttpStatus.OK);
    }
}
