package com.its.op.controller.its.common;

import com.its.op.dto.its.common.FcltSttsListDto;
import com.its.op.dto.its.common.SttsCommErrDto;
import com.its.op.dto.its.dbms.TbDbmsSttsDto;
import com.its.op.dto.its.unit.TbUnitSystSttsDto;
import com.its.op.service.its.common.CommonSttsService;
import com.its.op.service.its.dbms.TbDbmsSttsService;
import com.its.op.service.its.unit.TbUnitSystService;
import com.its.op.service.its.vds.TbVdsCtlrService;
import com.its.op.service.its.vms.TbVmsCtlrService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "00.공통-01.상태조회")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/common/stts")
public class CommonSttsController {

    private final CommonSttsService service;
    private final TbDbmsSttsService dbmsSttsService;
    //private final TbCctvCtlrService cctvService;
    private final TbVmsCtlrService vmsService;
    private final TbVdsCtlrService vdsService;
    private final TbUnitSystService unitSystService;

    @ApiOperation(value = "ITS 프로세스 상태", response = TbUnitSystSttsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/process/its", produces = {"application/json; charset=utf8"})
    public List<TbUnitSystSttsDto> findAllItsProcessStts() {
        return this.unitSystService.findAllStts();
    }

    @ApiOperation(value = "시설물 상태현황(종합)", response = FcltSttsListDto.class)
    @GetMapping(value = "/summary", produces = {"application/json; charset=utf8"})
    public FcltSttsListDto findAllFcltSttsSummary() {
        return this.service.findAllFcltSttsSummary();
    }

    @ApiOperation(value = "시설물 상태현황(종합)", response = FcltSttsListDto.class)
    @GetMapping(value = "/total", produces = {"application/json; charset=utf8"})
    public FcltSttsListDto findAllFcltSttsTotal() {
        return this.service.findAllFcltSttsTotal();
    }

//    @ApiOperation(value = "CCTV 통신상태(장애)", response = SttsCommErrDto.class, responseContainer = "ArrayList")
//    @GetMapping(value = "/cctv/error", produces = {"application/json; charset=utf8"})
//    public List<SttsCommErrDto> findAllCctvCommError() {
//        return this.cctvService.findAllListCommError();
//    }

    @ApiOperation(value = "VMS 통신상태(장애)", response = SttsCommErrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms/error", produces = {"application/json; charset=utf8"})
    public List<SttsCommErrDto> findAllVmsCommError() {
        return this.vmsService.findAllListCommError();
    }

    @ApiOperation(value = "VDS 통신상태(장애)", response = SttsCommErrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vds/error", produces = {"application/json; charset=utf8"})
    public List<SttsCommErrDto> findAllVdsCommError() {
        return this.vdsService.findAllListCommError();
    }

    // TODO
    @ApiOperation(value = "DBMS STTS", response = TbDbmsSttsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/dbms", produces = {"application/json; charset=utf8"})
    public List<TbDbmsSttsDto> findAllDbmsStts() {
        return this.dbmsSttsService.findAll();
    }

}
