package com.jiayue.ipp.idp.controller.an;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiayue.ipp.idp.service.an.ParsingLogService;
import com.jiayue.ipp.idp.util.R;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;


@RestController
@RequiredArgsConstructor
@RequestMapping("/parsingLog")
public class ParsingLogController {
    @Autowired
    ParsingLogService parsingLogService;

    /**
     * 根据场站编号 解析时间 文件状态 分页查询
     *
     * @param currentPage
     * @param pageSize
     * @param stationCode
     * @param time
     * @param fileStatus
     * @return
     */
    @ApiOperation(value = "根据场站编号分页查询", notes = "分页查询")
    @PostMapping("/getByStationCodeAndCreateTimeAndFileStatusAndFileType")
    public R getByStationCodeAndCreateTimeAndFileStatusAndFileType(Long currentPage, Long pageSize, String stationCode, Long time, String fileStatus, String fileType) {
        Page page = new Page(currentPage, pageSize);
        page.setMaxLimit((long) -1);
        return R.ok(parsingLogService.page(page, parsingLogService.getByStationCodeAndCreateTimeAndFileStatusAndFileType(stationCode, new Date(time), new Date(time + 60 * 60 * 24 * 1000 - 1000), fileStatus, fileType)));
    }
}
