package com.jiayue.ipp.idp.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiayue.ipp.common.data.entity.ForecastPowerShortTerm;
import com.jiayue.ipp.idp.service.ForecastPowerShortTermService;
import com.jiayue.ipp.idp.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Date;


/**
 * idp_forecast_power_short_term
 *
 * @author whc
 * @date 2022-03-18 15:48:55
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/forecastpowershortterm")
@Api(value = "forecastpowershortterm", tags = "idp_forecast_power_short_term管理")
public class ForecastPowerShortTermController {

    private final ForecastPowerShortTermService forecastPowerShortTermService;

    /**
     * 分页查询
     *
     * @param page                   分页对象
     * @param forecastPowerShortTerm idp_forecast_power_short_term
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    public R getForecastPowerShortTermPage(Page page, ForecastPowerShortTerm forecastPowerShortTerm) {
        return R.ok(forecastPowerShortTermService.page(page, Wrappers.query(forecastPowerShortTerm)));
    }

    /**
     * 通过id查询idp_forecast_power_short_term
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    public R getById(@PathVariable("id") String id) {
        return R.ok(forecastPowerShortTermService.getById(id));
    }


    @ApiOperation(value = "通过条件查询", notes = "通过条件查询")
    @PostMapping("/getShortData")
    public R getShortData(String stationCode,
                          Long startTime,
                          Long endTime,
                          String forecastManufactor) {
        return R.ok(forecastPowerShortTermService.findByStationCodeAndStartTimeAndEndTime(stationCode, new Date(startTime), new Date(endTime)));
    }
}
