package com.its.op.controller.its.management;

import com.its.op.dto.its.code.FcltTypeDto;
import com.its.op.dto.its.ifsc.TbIfscVrtxArrDto;
import com.its.op.dto.its.link.TbLinkVrtxArrDto;
import com.its.op.dto.its.road.TbRoadVrtxArrDto;
import com.its.op.service.its.code.TbCmmnCdService;
import com.its.op.service.its.ifsc.TbIfscVrtxArrService;
import com.its.op.service.its.link.TbLinkVrtxArrService;
import com.its.op.service.its.road.TbRoadVrtxArrService;
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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "00.교통상황관리-0.메인-0.지도")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/manage/main/map")
public class GisMapController {

    private final TbCmmnCdService cmmnCdService;
    private final TbLinkVrtxArrService linkService;
    private final TbIfscVrtxArrService ifscService;
    private final TbRoadVrtxArrService roadService;

    @ApiOperation(value = "시설물 유형(TB_CMMN_CD)", response = FcltTypeDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/fclt-type", produces = {"application/json; charset=utf8"})
    public List<FcltTypeDto> findFcltTypeAll() {
        return this.cmmnCdService.selectAllFcltType();
    }

    @ApiOperation(value = "링크버텍스검색(TB_LINK_VRTX_ARR)", response = TbLinkVrtxArrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vrtx/link/{levl}", produces = {"application/json; charset=utf8"})
    public List<TbLinkVrtxArrDto> findLinkByLevl(
            @ApiParam(name = "levl", value = "레벨(1,2)", example = "1", required = true)
            @PathVariable final Integer levl) {
        return this.linkService.findAllByLevl(levl);
    }

    @ApiOperation(value = "정보제공구간검색(TB_IFSC_VRTX_ARR)", response = TbIfscVrtxArrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vrtx/ifsc/{levl}", produces = {"application/json; charset=utf8"})
    public List<TbIfscVrtxArrDto> findIfscByLevl(
            @ApiParam(name = "levl", value = "레벨(3,4,5)", example = "3", required = true)
            @PathVariable final Integer levl) {
        return this.ifscService.findAllByLevl(levl);
    }

    @ApiOperation(value = "도로검색(TB_ROAD_VRTX_ARR)", response = TbRoadVrtxArrDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/vrtx/road/{levl}", produces = {"application/json; charset=utf8"})
    public List<TbRoadVrtxArrDto> findRoadByLevl(
            @ApiParam(name = "levl", value = "레벨(6,7)", example = "6", required = true)
            @PathVariable final Integer levl) {
        return this.roadService.findAllByLevl(levl);
    }

}
