package com.its.op.controller.its.vms;

import com.its.op.dto.its.common.NewIdIntegerDto;
import com.its.op.dto.its.common.UsageCountDto;
import com.its.op.dto.its.vms.TbVmsRltnIfscDto;
import com.its.op.dto.its.vms.TbVmsSymbLibDto;
import com.its.op.dto.its.vms.TbVmsSymbLibIfscSbt1Dto;
import com.its.op.service.its.vms.TbVmsRltnIfscService;
import com.its.op.service.its.vms.TbVmsSymbLibSbt1Service;
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.*;

import javax.validation.Valid;
import java.util.List;

@Api(tags = "12.VMS-1.정보 관리-4.VMS 소통정보 배경이미지 관리")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/vms/manager/symb-sbt1")
public class TbVmsSymbLibSbt1Controller {

    private final TbVmsSymbLibSbt1Service service;
    private final TbVmsRltnIfscService vmsIfscRltnService;

    @ApiOperation(value = "VMS 도형식 정보제공구간 전체조회(TB_VMS_CTLR, TB_VMS_IFSC, TB_VMS_IFSC_RLTN)", response = TbVmsRltnIfscDto.class)
    @GetMapping(value = "/figure-ifsc", produces = {"application/json; charset=utf8"})
    public List<TbVmsRltnIfscDto> findFigureIfscAll() {
        return this.vmsIfscRltnService.findFigureIfscAll();
    }

    @ApiOperation(value = "VMS 소통정보 배경이미지 전체조회(TB_VMS_SYMB_LIB)", response = TbVmsSymbLibDto.class)
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbVmsSymbLibDto> findAllSymbolImage() {
        return service.findAllSymbolImage();
    }

    @ApiOperation(value = "VMS 소통정보 배경이미지 개별조회(TB_VMS_SYMB_LIB)", response = TbVmsSymbLibIfscSbt1Dto.class)
    @GetMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsSymbLibIfscSbt1Dto findById(@PathVariable final Integer id) {
        return this.service.findAllById(id);
    }

    @ApiOperation(value = "VMS 소통정보 배경이미지 정보변경/생성-개별(TB_VMS_SYMB_LIB)", response = TbVmsSymbLibIfscSbt1Dto.class)
    @PostMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsSymbLibIfscSbt1Dto mergeInfo(@PathVariable("id") Integer id, @RequestBody @Valid final TbVmsSymbLibIfscSbt1Dto.TbVmsSymbLibIfscVMP1UpdReq req) {
        return this.service.mergeSymbIfscInfo(req);
    }

    @ApiOperation(value = "VMS 소통정보 배경이미지 정보삭제-개별(TB_VMS_SYMB_LIB)", response = TbVmsSymbLibDto.class)
    @DeleteMapping(value = "/{id}", produces = {"application/json; charset=utf8"})
    public TbVmsSymbLibDto deleteDataById(@PathVariable("id") Integer id) {
        return this.service.deleteDataById(id);
    }

    @ApiOperation(value = "VMS 소통정보 배경이미지 사용여부 조회(TB_VMS_SYMB_LIB)", response = UsageCountDto.class)
    @GetMapping(value = "/usage/{id}", produces = {"application/json; charset=utf8"})
    public UsageCountDto findUsageCountBySymbolId(@PathVariable final Integer id) {
        return this.service.findUsageCountBySymbolId(id);
    }

    @ApiOperation(value = "VMS 소통정보 배경이미지 신규 ID 조회(TB_VMS_SYMB_LIB)", response = NewIdIntegerDto.class)
    @GetMapping(value = "/new-id", produces = {"application/json; charset=utf8"})
    public NewIdIntegerDto getNewSymbolId() {
        return this.service.getNewSymbolId();
    }

}
