package com.its.op.controller.its.facility;

import com.its.op.dto.its.facility.FcltSttsErrorDto;
import com.its.op.dto.its.statistics.FcltSttsStatTypeDto;
import com.its.op.service.its.facility.TbFcltSttsErrorHsService;
import com.its.op.service.its.statistics.FcltSttsStatisticsService;
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 = "01.시설물관리-1.시설물-3.시설물 장애관리-2.장애내역조회")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/facility/stts-error")
public class TbFcltSttsErrorHsController {

    private final TbFcltSttsErrorHsService service;
    private final FcltSttsStatisticsService sttsStatisticsService;

    @ApiOperation(value = "시설물 장애내역조회 시설물구분 목록 조회", response = FcltSttsStatTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/fclt-type", produces = {"application/json; charset=utf8"})
    public List<FcltSttsStatTypeDto> findAllFcltTypeList() {
        return this.sttsStatisticsService.findAllFcltSttsType(true);
    }

    @ApiOperation(value = "시설물 장애내역조회", response = FcltSttsErrorDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/list/{type}/{fromDt}/{toDt}", produces = {"application/json; charset=utf8"})
    public List<FcltSttsErrorDto> findAllFcltSttsErrorList(
            @ApiParam(name = "type", value = "시설물구분", example = "VMS", required = true)
            @PathVariable("type") final String type,
            @ApiParam(name = "fromDt", value = "조회시작시각(YYYYMMDDHH24MI00)", example = "20220613000000", required = true)
            @PathVariable("fromDt") final String fromDt,
            @ApiParam(name = "toDt", value = "조회종료시각(YYYYMMDDHH24MI59)", example = "20220613235959", required = true)
            @PathVariable("toDt") final String toDt) {
        return this.service.findAllFcltSttsErrorList(type, fromDt, toDt);
    }

 }
