package com.its.api.its.controller.history;

import com.its.api.its.model.dto.ifsc.TbIfscDto;
import com.its.api.its.model.dto.ifsc.TbIfscTrafHsDto;
import com.its.api.its.service.ifsc.TbIfscService;
import com.its.api.its.service.ifsc.TbIfscTrafHsService;
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.가공데이터이력-2.정보제공구간")
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/history/traf-hs/ifsc")
public class TbIfscTrafHsController {

    private final TbIfscService ifscService;
    private final TbIfscTrafHsService service;

    @ApiOperation(value = "정보제공구간 전체조회-지역센터(TB_IFSC)", response = TbIfscDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "/local", produces = {"application/json; charset=utf8"})
    public List<TbIfscDto> findIfscLocalAll() {
        return ifscService.findLocalAll();
    }

    @ApiOperation(value = "정보제공구간이력조회(TB_IFSC_TRAF_HS)", response = TbIfscTrafHsDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<TbIfscTrafHsDto> findIfscTrafHsAllByDateRange(
            @ApiParam(name = "IFSC_ID", value = "정보제공구간 ID(ifsc_id)", example = "2200000029", required = true)
            @RequestParam Long IFSC_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(IFSC_ID, FROM_DT, TO_DT);
    }

}
