package com.its.web.controller.statistics;


import com.its.web.dto.statistics.TrafficStatisticsCongestDto;
import com.its.web.dto.statistics.TrafficStatisticsDto;
import com.its.web.service.statistics.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

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

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/statistics")
@Api(tags = "02.교통통계")
public class StatisticsController {

    private final StatisticsService service;

    @ApiOperation(value = "01.교통량 통계 조회", response = TrafficStatisticsDto.TrafficStatisticsDtoReq.class, responseContainer = "ArrayList")
    @PostMapping(value = "/amount/{searchType}", produces = {"application/json; charset=utf8"})
    @ResponseBody
    public List<TrafficStatisticsDto> findStatisticsTrafficAmount(@Valid final TrafficStatisticsDto.TrafficStatisticsDtoReq paramInfo,
                                                                     @PathVariable String searchType) {
        return service.findStatisticsTrafficAmount(paramInfo, searchType);
    }

    @ApiOperation(value = "02.소통 통계 조회-01.속도통계", response = TrafficStatisticsDto.TrafficStatisticsDtoReq.class, responseContainer = "ArrayList")
    @PostMapping(value = "/speed/{searchType}", produces = {"application/json; charset=utf8"})
    @ResponseBody
    public List<TrafficStatisticsDto> findStatisticsCommSpeed(@Valid final TrafficStatisticsDto.TrafficStatisticsDtoReq paramInfo,
                                                              @PathVariable String searchType) {
        return service.findStatisticsCommSpeed(paramInfo, searchType);
    }

    @ApiOperation(value = "02.소통 통계 조회-02.지/정체통계", response = TrafficStatisticsDto.TrafficStatisticsDtoReq.class, responseContainer = "ArrayList")
    @PostMapping(value = "/grade/{searchType}", produces = {"application/json; charset=utf8"})
    @ResponseBody
    public List<TrafficStatisticsDto> findStatisticsCommGrad(@Valid final TrafficStatisticsDto.TrafficStatisticsDtoReq paramInfo,
                                                             @PathVariable String searchType) {
        return service.findStatisticsCommGrade(paramInfo, searchType);
    }

    @ApiOperation(value = "03.정체 통계 조회", response = TrafficStatisticsCongestDto.TrafficStatisticsCongestDtoReq.class, responseContainer = "ArrayList")
    @PostMapping(value = "/congest", produces = {"application/json; charset=utf8"})
    @ResponseBody
    public List<TrafficStatisticsCongestDto> findStatisticsCommGrad(@Valid final TrafficStatisticsCongestDto.TrafficStatisticsCongestDtoReq paramInfo) {
        return service.findStatisticsCongest(paramInfo);
    }

}
