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

import com.its.op.dto.its.link.TbLinkDto;
import com.its.op.dto.its.link.TbLinkTrafHsDto;
import com.its.op.service.its.link.TbLinkService;
import com.its.op.service.its.link.TbLinkTrafHsService;
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.가공데이터이력-1.링크")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/history/traf-hs/link")
public class TbLinkTrafHsController {

    private final TbLinkService linkService;
    private final TbLinkTrafHsService service;

    @ApiOperation(value = "링크정보 전체조회-지역센터(TB_LINK)", response = TbLinkDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/local", produces = {"application/json; charset=utf8"})
    public List<TbLinkDto> findLinkLocalAll() {
        return linkService.findLocalAll();
    }

    @ApiOperation(value = "링크이력조회(TB_LINK_TRAF_HS)", response = TbLinkTrafHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbLinkTrafHsDto> findLinkTrafHsAllByDateRange(
            @ApiParam(name = "LINK_ID", value = "링크 ID(link_id)", example = "2280212200", required = true)
            @RequestParam Long LINK_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(LINK_ID, FROM_DT, TO_DT);
    }

}
