package com.its.api.its.service.common;

import com.its.api.its.model.dto.common.FcltSttsListDto;
import com.its.api.its.service.cctv.TbCctvCtlrService;
import com.its.api.its.service.vds.TbVdsCtlrService;
import com.its.api.its.service.vms.TbVmsCtlrService;
import com.its.api.utis.service.RsemstService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@RequiredArgsConstructor
@Service
public class CommonSttsService {

    private final TbCctvCtlrService cctvService;
    private final TbVmsCtlrService vmsService;
    private final TbVdsCtlrService vdsService;
    private final RsemstService rseService;

    /**
     * 시설물 상태정보 조회(통합)
     * @return
     */
    @Transactional(readOnly = true)
    public FcltSttsListDto findAllFcltSttsTotal() {

        FcltSttsListDto result = new FcltSttsListDto();

        // CCTV
        FcltSttsListDto cctv = this.cctvService.findAllSttsListTotal();
        result.getFcltList().add(cctv.getFcltList().get(0));

        // VMS
        FcltSttsListDto vms = this.vmsService.findAllSttsListTotal();
        result.getFcltList().add(vms.getFcltList().get(0));

        // VMS
        FcltSttsListDto vds = this.vdsService.findAllSttsListTotal();
        result.getFcltList().add(vds.getFcltList().get(0));

        // RSE
        FcltSttsListDto rse = this.rseService.findAllListSttsTotal();
        result.getFcltList().add(rse.getFcltList().get(0));

        return result;
    }
}
