package com.its.op.controller.its.analysis;

import com.its.op.dto.its.analysis.PtrnDataDto;
import com.its.op.dto.its.analysis.PtrnDataParam;
import com.its.op.service.its.analysis.PtrnDataService;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/analysis/ptrn-data")
@Api(tags = "04.분석-5.패턴데이터분석")
public class PtrnDataController {

    private final PtrnDataService service;

    @ApiOperation(value = "패턴 요일구분 목록 조회(TB_CMMN_CD)", response = PtrnDataDto.PtrnDataDayType.class, responseContainer = "ArrayList")
    @GetMapping(value = "/day-type", produces = {"application/json; charset=utf8"})
    public List<PtrnDataDto.PtrnDataDayType> findAllDayType() {
        return this.service.findAllDayType();
    }

    @ApiOperation(value = "패턴데이터분석(TB_XXXX_PTRN_5M, TB_XXXX_PTRN_15M)", response = PtrnDataDto.class, responseContainer = "ArrayList")
    @GetMapping(value = "", produces = {"application/json; charset=utf8"})
    public List<PtrnDataDto> findAllByDateRange(
            @ApiParam(name = "PTRN_TYPE", value = "LINK(링크), IFSC(서비스링크), ROAD(도로) 선택", example = "LINK", required = true)
            @RequestParam String PTRN_TYPE,
            @ApiParam(name = "PTRN_DATA", value = "5M(5분패턴), 15M(15분패턴)", example = "5M", required = true)
            @RequestParam String PTRN_DATA,
            @ApiParam(name = "ID", value = "LINK_ID, IFSC_ID, ROAD_ID", example = "2280004600", required = true)
            @RequestParam String ID,
            @ApiParam(name = "PTRN_WEEK", value = "DTW1(월), DTW2(화), DTW3(수), DTW4(목), DTW5(금), DTW6(토), DTW7(일)", example = "DTW1", required = true)
            @RequestParam String PTRN_WEEK,
            @ApiParam(name = "BASE_MN", value = "기준월(YYYYMM)", example = "202112", required = true)
            @RequestParam String BASE_MN,
            @ApiParam(name = "COMP_MN", value = "비교월(YYYYMM)", example = "202111", required = true)
            @RequestParam String COMP_MN,
            @ApiParam(name = "FROM_HM", value = "시작시간대(HH24MI)", example = "0000", required = true)
            @RequestParam String FROM_HM,
            @ApiParam(name = "TO_HM", value = "종료시간대(HH24MI)", example = "2359", required = true)
            @RequestParam String TO_HM
            ) {

        PtrnDataParam cond = new PtrnDataParam(PTRN_TYPE, PTRN_DATA, ID, PTRN_WEEK, BASE_MN, COMP_MN, FROM_HM, TO_HM, "");
        return this.service.findAllByDateRange(cond);
    }

}
