package cokr.xit.ens.biz.traffic.cheonan.signtalk.presentation;

import cokr.xit.ens.biz.traffic.cheonan.signtalk.model.TrafficCaSigntalkReqDTO;
import cokr.xit.ens.biz.traffic.cheonan.signtalk.service.TrafficCaSigntalkService;
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 = "TrafficCaSigntalkController")
@Slf4j
@Controller
@RequiredArgsConstructor
public class TrafficCaSigntalkController {

    private final TrafficCaSigntalkService trafficCaSigntalkService;

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

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

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

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