package com.its.api.its.controller.incident;

import com.its.api.its.global.CodeManager;
import com.its.api.its.model.dto.code.IncdCodeDto;
import com.its.api.its.service.incident.TbIncdOcrrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "00.교통상황관리-2.돌발관리-0.코드조회")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/manage/incident/code")
public class TbIncdOcrrCodeController {

    private final TbIncdOcrrService service;

    @ApiOperation(value = "돌발상황 원본 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/ist", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllIST() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_IST);
    }

    @ApiOperation(value = "돌발상황 소통 상황 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/ltcu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllLTCU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_LTCU);
    }

    @ApiOperation(value = "돌발상황 확인(종료) 방법 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/icm", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllICM() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_ICM);
    }

    @ApiOperation(value = "돌발상황 유형 분류 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/idtu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllIDTU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_IDTU);
    }

    @ApiOperation(value = "돌발상황 사고 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/actu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllACTU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_ACTU);
    }

    @ApiOperation(value = "돌발상황 공사 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/crtu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllCRTU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_CRTU);
    }

    @ApiOperation(value = "돌발상황 행사 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/evtu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllEVTU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_EVTU);
    }

    @ApiOperation(value = "돌발상황 기상 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/wetu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllWETU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_WETU);
    }

    @ApiOperation(value = "돌발상황 유형별 세부 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/idtu/{id}", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllIDTUSub(
            @ApiParam(name = "id", value = "돌발상황 유형 분류 코드(1,2,3,4)", example = "1", required = true)
            @PathVariable String id
    ) {
        if (("1").equals(id)) {
            return findAllACTU();
        }
        else if (("2").equals(id)) {
            return findAllCRTU();
        }
        else if (("3").equals(id)) {
            return findAllEVTU();
        }
        //else //if (("4").equals(id)) {
            return findAllWETU();
        //}
    }

    @ApiOperation(value = "돌발상황 심각도 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/srlu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllSRLU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_SRLU);
    }

    @ApiOperation(value = "돌발상황 통행 제한 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/prtu", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllPRTU() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_PRTU);
    }

    @ApiOperation(value = "돌발상황 대응 수준 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/rsl", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllRSL() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_RSL);
    }

    @ApiOperation(value = "돌발상황 진행 단계 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/iss", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllISS() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_ISS);
    }

    @ApiOperation(value = "돌발상황 기상 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/dfw", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllDFW() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_DFW);
    }

    @ApiOperation(value = "VMS 돌발 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vit", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllVIT() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_VIT);
    }

    @ApiOperation(value = "VMS 돌발 유형 세부 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/idt", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllIDT() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_IDT);
    }

    @ApiOperation(value = "VMS 돌발 유형 세부 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/edt", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllEDT() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_EDT);
    }

    @ApiOperation(value = "VMS 돌발 세부 유형 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vit/{id}", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllVITSub(
            @ApiParam(name = "id", value = "VMS 돌발 유형 코드(VIT1,VIT2)", example = "VIT1", required = true)
            @PathVariable String id
    ) {
        if (("VIT1").equals(id)) {
            return findAllIDT();
        }
        //else //if (("VIT2").equals(id)) {
        return findAllEDT();
        //}
    }

    @ApiOperation(value = "VMS 돌발 통제 코드", response = IncdCodeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vrt", produces = {"application/json; charset=utf8"})
    public List<IncdCodeDto> findAllVRT() {
        return service.findAllByCmmnClsfCd(CodeManager.INCD_CODE_VRT);
    }

}
