package com.its.api.its.controller.vms;

import com.its.api.its.model.dto.common.TrafDto;
import com.its.api.its.model.dto.vms.*;
import com.its.api.its.service.vms.*;
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.*;

import java.util.List;

@Api(tags = "12.VMS-0.공통")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vms/common")
public class VmsCommonController {

    private final TbVmsUsagTypeService usagTypeService;
    private final TbVmsTypeService vmsTypeService;
    private final TbVmsCtlrService vmsCtlrService;
    private final TbVmsFormTypeService formTypeService;
    private final TbVmsMsgDsplMthdService msgDsplMthdService;
    private final TbVmsMsgDsplDrctService msgDsplDrctService;
    private final TbVmsFontShpeService fontShpeService;
    private final TbVmsFormObjectTypeService objectTypeService;
    private final TbVmsFontColrService fontColrService;
    private final TbVmsDsplPrstService dsplPrstService;
    private final TbVmsCmtrInfrService vmsTrafService;

    @ApiOperation(value = "VMS 목록 조회(TB_VMS_CTLR)", response = TbVmsIfscRltnDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-list", produces = {"application/json; charset=utf8"})
    public List<TbVmsCtlrDto> findVmsCtlrAll() {
        return this.vmsCtlrService.findAllList();
    }

    @ApiOperation(value = "VMS 목록 조회-크기유형별(TB_VMS_CTLR)", response = TbVmsIfscRltnDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-list/{type}", produces = {"application/json; charset=utf8"})
    public List<TbVmsCtlrDto> findVmsCtlrAllByType(
            @ApiParam(name = "type", value = "VMS 유형 코드", example = "VMP2", required = true)
            @PathVariable final String type
    ) {
        return this.vmsCtlrService.findAllListByType(type);
    }

    @ApiOperation(value = "VMS 제어기 용도 유형 조회(TB_VMS_USAG_TYPE)", response = TbVmsUsagTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-usage", produces = {"application/json; charset=utf8"})
    public List<TbVmsUsagTypeDto> findAllVmsUsageType() {
        return this.usagTypeService.findAll();
    }

    @ApiOperation(value = "VMS 제어기 유형(크기) 조회(TB_VMS_TYPE)", response = TbVmsTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-type", produces = {"application/json; charset=utf8"})
    public List<TbVmsTypeDto> findAllVmsType() {
        return this.vmsTypeService.findAll();
    }

    @ApiOperation(value = "VMS 폼 유형 조회(TB_VMS_FORM_TYPE)", response = TbVmsFormTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-type", produces = {"application/json; charset=utf8"})
    public List<TbVmsFormTypeDto> findVmsFormTypeAll() {
        return this.formTypeService.findAll();
    }

    @ApiOperation(value = "VMS 폼 표출방법 조회(TB_VMS_MSG_DSPL_MTHD)", response = TbVmsMsgDsplMthdDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-dspl-mthd", produces = {"application/json; charset=utf8"})
    public List<TbVmsMsgDsplMthdDto> findVmsFormDsplMthdAll() {
        return this.msgDsplMthdService.findAll();
    }

    @ApiOperation(value = "VMS 폼 표출방향 조회(TB_VMS_MSG_DSPL_DRCT)", response = TbVmsMsgDsplDrctDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-dspl-drct", produces = {"application/json; charset=utf8"})
    public List<TbVmsMsgDsplDrctDto> findVmsFormDsplDrctAll() {
        return this.msgDsplDrctService.findAll();
    }

    @ApiOperation(value = "VMS 폼 폰트유형 조회(TB_VMS_FONT_SHPE)", response = TbVmsFontShpeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-font", produces = {"application/json; charset=utf8"})
    public List<TbVmsFontShpeDto> findVmsFormFontAll() {
        return this.fontShpeService.findAll();
    }

    @ApiOperation(value = "VMS 폼 폰트색상 조회(TB_VMS_FONT_COLR)", response = TbVmsFontColrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-font-colr", produces = {"application/json; charset=utf8"})
    public List<TbVmsFontColrDto> findVmsFormFontColrAll() {
        return this.fontColrService.findAll();
    }

    @ApiOperation(value = "VMS 폼 객체유형 조회-전체(TB_VMS_FORM_OBJECT_TYPE)", response = TbVmsFormObjectTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-object", produces = {"application/json; charset=utf8"})
    public List<TbVmsFormObjectTypeDto> findVmsFormObjectTypeAll() {
        return this.objectTypeService.findAll();
    }

    @ApiOperation(value = "VMS 폼 객체유형 조회(TB_VMS_FORM_OBJECT_TYPE)", response = TbVmsFormObjectTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form-object/{type}", produces = {"application/json; charset=utf8"})
    public List<TbVmsFormObjectTypeDto> findVmsFormObjectTypeAllByFormType(
            @ApiParam(name = "type", value = "VMS 폼 유형 코드", example = "11", required = true)
            @PathVariable final Integer type
    ) {
        return this.objectTypeService.findAllByFormType(type);
    }

    @ApiOperation(value = "VMS 표출 현재 폼 조회-전체(TB_VMS_DSPL_PRST)", response = TbVmsDsplPrstDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form/dspl-prst/all", produces = {"application/json; charset=utf8"})
    public List<TbVmsDsplPrstDto> findAllVmsDsplPrst() {
        return this.dsplPrstService.findAll();
    }

    @ApiOperation(value = "VMS 표출 현재 폼 조회-목록(TB_VMS_DSPL_PRST)", response = TbVmsDsplPrstDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form/dspl-prst", produces = {"application/json; charset=utf8"})
    public List<TbVmsDsplPrstDto> findAllVmsDsplPrst(
            @ApiParam(name = "id", value = "VMS 제어기 관리번호 목록", example = "10005", required = true)
            @RequestParam final List<Long> id) {
        return this.dsplPrstService.findAllByIds(id);
    }

    @ApiOperation(value = "VMS 표출 현재 폼 조회(PHASE)(TB_VMS_DSPL_PRST)", response = TbVmsDsplPrstDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-form/dspl-prst/{id}/{phase}", produces = {"application/json; charset=utf8"})
    public TbVmsDsplPrstDto findAllVmsDsplPrstPhase(
            @ApiParam(name = "id", value = "VMS 제어기 관리번호", example = "10005", required = true)
            @PathVariable final Long id,
            @ApiParam(name = "phase", value = "표출 메시지 Phase", example = "1", required = true)
            @PathVariable final Integer phase) {
        return this.dsplPrstService.findAllByIdAndPhase(id, phase);
    }

    @ApiOperation(value = "VMS정보제공구간소통정보(TB_VMS_CMTRINFR)", response = TrafDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vms-ifsc-traf/{id}", produces = {"application/json; charset=utf8"})
    public List<TbVmsCmtrInfrDto> findAllTrafVms(
            @ApiParam(name = "id", value = "VMS 제어기 관리번호", example = "10005", required = true)
            @PathVariable final Long id) {
        return this.vmsTrafService.findAllTrafByVms(id);
    }

}
