package com.its.api.its.controller.common;

import com.its.api.its.model.dto.common.FcltSttsDto;
import com.its.api.its.model.dto.common.FcltSttsListDto;
import com.its.api.its.model.dto.common.FcltSttsSummaryDto;
import com.its.api.its.model.dto.common.SttsCommErrDto;
import com.its.api.its.model.dto.database.TbDbSvrSttsDto;
import com.its.api.its.model.dto.unit.TbUnitSystSttsDto;
import com.its.api.its.service.cctv.TbCctvCtlrService;
import com.its.api.its.service.common.CommonSttsService;
import com.its.api.its.service.database.TbDbSvrSttsService;
import com.its.api.its.service.unit.TbUnitSystService;
import com.its.api.its.service.vds.TbVdsCtlrService;
import com.its.api.its.service.vms.TbVmsCtlrService;
import com.its.api.utis.service.RsemstService;
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.공통-1.상태조회")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/common/stts")
public class CommonSttsController {

    private final CommonSttsService service;
    private final TbDbSvrSttsService dbSvrSttsService;
    private final TbCctvCtlrService cctvService;
    private final TbVmsCtlrService vmsService;
    private final TbVdsCtlrService vdsService;
    private final RsemstService rseService;
    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 = "/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();
    }

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


    @ApiOperation(value = "RSE 시설물상태(RSEMST, RSEOPSTATE)", response = FcltSttsSummaryDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/rse/summary", produces = {"application/json; charset=utf8"})
    public FcltSttsSummaryDto findAllStateTotal() {
        return this.rseService.findAllSttsSummary();
    }

    @ApiOperation(value = "RSE 통신상태(전체)", response = FcltSttsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/rse", produces = {"application/json; charset=utf8"})
    public List<FcltSttsDto> findAllCommStts() {
        return this.rseService.findAllListCommStts();
    }

}
