package com.cpp.web.controller.overhaulPlan;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cpp.common.core.domain.R;
import com.cpp.web.service.overhaulplan.OverhaulPlanRecordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


@RestController
@RequiredArgsConstructor
@RequestMapping("/overhaulPlanRecords")
@Api(value = "overhaulplanrecords", tags = "cpp_overhaul_plan_records管理")
public class OverhaulPlanRecordsController {

    private final OverhaulPlanRecordsService overhaulPlanRecordsService;
    @ApiOperation(value = "通过场站编号查询记录（分页查询）", notes = "通过场站编号查询记录（分页查询）")
    @GetMapping("/findByStationCode")
    public R findByStationCode(String stationCode,Long pageSize,Long currentPage){
        Page page = new Page(currentPage,pageSize);
        page.setMaxLimit((long)-1);
        return R.ok(overhaulPlanRecordsService.page(page,overhaulPlanRecordsService.getByStationCode(stationCode)));
    }

    @ApiOperation(value = "通过场站编号查询记录（分页查询）", notes = "通过场站编号查询记录（分页查询）")
    @GetMapping("/findByStationCodeAndTimeBetween")
    public R findByStationCodeAndTimeBetween(String stationCode, Long startTime,Long endTime){
        return R.ok(overhaulPlanRecordsService.findByStationCodeAndTimeBetween(stationCode,new Date(startTime),new Date(endTime)));
    }

}
