package com.ningdatech.kqapi.irs.controller;

import com.ningdatech.kqapi.common.model.PageVo;
import com.ningdatech.kqapi.common.util.NdDateUtils;
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 com.alibaba.fastjson.JSON;
import com.ningdatech.kqapi.irs.manage.IrsManage;
import com.ningdatech.kqapi.zzsfw.model.entity.DscSxAdsShareItemQltQlsxCommonIDVKq;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.time.LocalDate;
import java.util.Date;

/**
 * @author CMM
 * @date 2024/8/19 11:11
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/irs")
@Api(value = "irs", tags = "irs-信息查询")
@RequiredArgsConstructor
public class IrsController {

    private final IrsManage irsManage;

    @ApiOperation(value = "irs事项基本信息列表", notes = "irs事项基本信息列表")
    @GetMapping("/item-basic-info-list")
    public Object itemBasicInfoList(@RequestParam(required = false) String startDate,
                                          @RequestParam(required = false) String endDate,
                                          @RequestParam(required = false) Integer pageSize,
                                          @RequestParam(required = false) Integer pageNum) {
        return irsManage.itemBasicInfoList(startDate, endDate, pageSize, pageNum);
    }

    @ApiOperation(value = "irs事项基本信息列表", notes = "irs事项基本信息列表")
    @GetMapping("/item-basic-info-detail")
    public Object itemBasicInfoDetail(@RequestParam String rowGuid) {
        return irsManage.itemBasicInfoDetail(rowGuid);
    }

    @ApiOperation(value = "转发请求接口", notes = "转发请求接口")
    @GetMapping("/transfer-request")
    public PageVo<DscSxAdsShareItemQltQlsxCommonIDVKq> transferRequest(String startDate, String endDate, Integer pageSize, Integer pageNum) {
        // 从5月1日开始更新 直到8月31日 循环更新 每次更新1天
        LocalDate start = NdDateUtils.parse(startDate);
        LocalDate end = NdDateUtils.parse(endDate);
        return irsManage.transferRequest(start, end, pageSize, pageNum);
    }

    @ApiOperation(value = "测试任务接口", notes = "测试任务接口")
    @GetMapping("/test-task")
    public String testTask(String startDate, String endDate) {
        return irsManage.testTask(startDate, endDate);
    }
}
