package com.its.op.controller.its.history;

import com.its.op.dto.its.road.TbRoadDto;
import com.its.op.dto.its.road.TbRoadTrafHsDto;
import com.its.op.service.its.road.TbRoadService;
import com.its.op.service.its.road.TbRoadTrafHsService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "02.이력조회-3.가공데이터이력-3.도로")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/history/traf-hs/road")
public class TbRoadTrafHsController {

    private final TbRoadService roadService;
    private final TbRoadTrafHsService service;

    @ApiOperation(value = "도로 전체조회-지역센터(TB_ROAD)", response = TbRoadDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/local", produces = {"application/json; charset=utf8"})
    public List<TbRoadDto> findRoadLocalAll() {
        return roadService.findLocalAll();
    }

    @ApiOperation(value = "도로이력조회(TB_ROAD_TRAF_HS)", response = TbRoadTrafHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbRoadTrafHsDto> findRoadTrafHsAllByDateRange(
            @ApiParam(name = "ROAD_ID", value = "도로 ID(road_id)", example = "3200000173", required = true)
            @RequestParam Long ROAD_ID,
            @ApiParam(name = "FROM_DT", value = "조회시작시각(YYYYMMDDHH24MI00)", example = "20220112000000", required = true)
            @RequestParam String FROM_DT,
            @ApiParam(name = "TO_DT", value = "조회종료시각(YYYYMMDDHH24MI59)", example = "20220112235959", required = true)
            @RequestParam String TO_DT) {

        return this.service.findAllByDateRange(ROAD_ID, FROM_DT, TO_DT);
    }
}
