package com.its.api.its.controller.vds;

import com.its.api.its.model.dto.vds.TbVdsCtlrSttsHsDto;
import com.its.api.its.service.vds.TbVdsCtlrSttsHsService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "13.VDS-2.VDS 이력조회-1.제어기 상태이력")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vds/history/stts")
public class TbVdsCtlrSttsHsController {

    private final TbVdsCtlrSttsHsService service;

    @ApiOperation(value = "VDS 제어기 상태 이력조회(TB_VDS_CTLR_STTS_RAW)", response = TbVdsCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVdsCtlrSttsHsDto> 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 = "VDS 관리번호 목록", example = "[00000001,00000002]", required = true)
            @RequestParam List<String> id
    ) {
        return this.service.findAllByDateRange(FROM_DT, TO_DT, id);
    }

    @ApiOperation(value = "VDS 제어기 장애 이력조회(TB_VDS_CTLR_STTS_RAW)", response = TbVdsCtlrSttsHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/fail", produces = {"application/json; charset=utf8"})
    public List<TbVdsCtlrSttsHsDto> 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 = "VDS 관리번호 목록", example = "[00000001,00000002]", required = true)
            @RequestParam List<String> id
    ) {
        return this.service.findAllFailByDateRange(FROM_DT, TO_DT, id);
    }

}
