package com.its.op.controller.its.cctv;

import com.its.op.dto.its.cctv.TbCctvCtlrSttsHsDto;
import com.its.op.service.its.cctv.TbCctvCtlrSttsHsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "11.CCTV-3.CCTV 상태이력")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/cctv/history")
public class TbCctvCtlrSttsHsController {

    private final TbCctvCtlrSttsHsService service;

    @ApiOperation(value = "CCTV 상태 이력 조회(TB_CCTV_STTS_HS)", response = TbCctvCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/stts-hs", produces = {"application/json; charset=utf8"})
    public List<TbCctvCtlrSttsHsDto> findAllByDateRange(
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH24MI00)", example = "20210112152000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH24MI59)", example = "20221112152000", required = true)
            @RequestParam String TO_DT,
            @ApiParam(name = "id", value = "CCTV 관리번호 목록", example = "[1,2]", required = true)
            @RequestParam List<Long> id
    ) {
        return this.service.findAllByDateRange(FROM_DT, TO_DT, id);
    }

    @ApiOperation(value = "CCTV 장애 이력 조회(TB_CCTV_STTS_HS)", response = TbCctvCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/stts-hs/fail", produces = {"application/json; charset=utf8"})
    public List<TbCctvCtlrSttsHsDto> findAllFailByDateRange(
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH24MI00)", example = "20210112152000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH24MI59)", example = "20221112152000", required = true)
            @RequestParam String TO_DT,
            @ApiParam(name = "id", value = "CCTV 관리번호 목록", example = "[1,2]", required = true)
            @RequestParam List<Long> id
    ) {
        return this.service.findAllFailByDateRange(FROM_DT, TO_DT, id);
    }
}
