package com.its.op.controller.its.management;

import com.its.op.dto.its.ifsc.TbReptCngsSectDto;
import com.its.op.dto.its.ifsc.TbReptCngsSectKeyDto;
import com.its.op.service.its.ifsc.TbReptCngsSectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "00.교통상황관리-3.반복정체관리-1.반복정체구간관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/manage/rept-cngs/sect")
public class TbReptCngsSectController {

    private final TbReptCngsSectService service;

    @ApiOperation(value = "반복 정체 구간 전체조회-현재 확정(TB_REPT_CNGS_SECT)", response = TbReptCngsSectDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/cnfm", produces = {"application/json; charset=utf8"})
    public List<TbReptCngsSectDto> findAllCurrentCnfm() {
        return service.findAllCurrent("Y");
    }

    @ApiOperation(value = "반복 정체 구간 전체조회-현재 미확정(TB_REPT_CNGS_SECT)", response = TbReptCngsSectDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/un-cnfm", produces = {"application/json; charset=utf8"})
    public List<TbReptCngsSectDto> findAllCurrentUnCnfm() {
        return service.findAllCurrent("N");
    }

    @ApiOperation(value = "반복 정체 구간 운영자등록-목록(TB_REPT_CNGS_SECT)", response = TbReptCngsSectDto.class, responseContainer = "ArrayList")
    @PostMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbReptCngsSectDto> mergeInfoList(@RequestBody @Valid final List<TbReptCngsSectDto.TbReptCngsSectUpdReq> listReq) {
        return this.service.mergeInfoList(listReq);
    }

    @ApiOperation(value = "반복 정체 구간 확정하기-목록(TB_REPT_CNGS_SECT)", response = TbReptCngsSectKeyDto.class, responseContainer = "ArrayList")
    @PutMapping(value = "/cnfm", produces = {"application/json; charset=utf8"})
    public List<TbReptCngsSectKeyDto> cnfmInfoList(@RequestBody @Valid final List<TbReptCngsSectKeyDto> listReq) {
        return this.service.cnfmInfoList(listReq);
    }

    @ApiOperation(value = "반복 정체 구간 예상취소-목록(TB_REPT_CNGS_SECT)", response = TbReptCngsSectKeyDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "/cancel-pred", produces = {"application/json; charset=utf8"})
    public List<TbReptCngsSectKeyDto> cancelPred(@RequestBody @Valid final List<TbReptCngsSectKeyDto> ids) {
        return this.service.deleteByIds(ids);
    }

    @ApiOperation(value = "반복 정체 구간 확정취소-목록(TB_REPT_CNGS_SECT)", response = TbReptCngsSectKeyDto.class, responseContainer = "ArrayList")
    @DeleteMapping(value = "/cancel-cnfm", produces = {"application/json; charset=utf8"})
    public List<TbReptCngsSectKeyDto> cancelCnfm(@RequestBody @Valid final List<TbReptCngsSectKeyDto> ids) {
        return this.service.cancelCnfmByIds(ids);
    }

}
