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.ForecastPowerShortTermHis;
import com.jiayue.ipp.idp.service.ForecastPowerShortTermHisService;
import com.jiayue.ipp.idp.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;


/**
 * idp_forecast_power_short_term_his
 *
 * @author whc
 * @date 2022-03-18 15:48:57
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/forecastpowershorttermhis")
@Api(value = "forecastpowershorttermhis", tags = "idp_forecast_power_short_term_his管理")
public class ForecastPowerShortTermHisController {

    private final ForecastPowerShortTermHisService forecastPowerShortTermHisService;

    /**
     * 分页查询
     *
     * @param page                      分页对象
     * @param forecastPowerShortTermHis idp_forecast_power_short_term_his
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page")
    //@PreAuthorize("@pms.hasPermission('idp_forecastpowerdata_get')")
    public R getForecastPowerShortTermHisPage(Page page, ForecastPowerShortTermHis forecastPowerShortTermHis) {
        return R.ok(forecastPowerShortTermHisService.page(page, Wrappers.query(forecastPowerShortTermHis)));
    }

    /**
     * 通过id查询idp_forecast_power_short_term_his
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}")
    //@PreAuthorize("@pms.hasPermission('idp_forecastpowerdata_get')")
    public R getById(@PathVariable("id") String id) {
        return R.ok(forecastPowerShortTermHisService.getById(id));
    }

    /**
     * 新增idp_forecast_power_short_term_his
     *
     * @param forecastPowerShortTermHis idp_forecast_power_short_term_his
     * @return R
     */
    @ApiOperation(value = "新增idp_forecast_power_short_term_his", notes = "新增idp_forecast_power_short_term_his")
    //    //    @SysLog("新增idp_forecast_power_short_term_his")
    @PostMapping
    //@PreAuthorize("@pms.hasPermission('idp_forecastpowerdata_get')")
    public R save(@RequestBody ForecastPowerShortTermHis forecastPowerShortTermHis) {
        return R.ok(forecastPowerShortTermHisService.save(forecastPowerShortTermHis));
    }

    /**
     * 修改idp_forecast_power_short_term_his
     *
     * @param forecastPowerShortTermHis idp_forecast_power_short_term_his
     * @return R
     */
    @ApiOperation(value = "修改idp_forecast_power_short_term_his", notes = "修改idp_forecast_power_short_term_his")
    //    //    @SysLog("修改idp_forecast_power_short_term_his")
    @PutMapping
    //@PreAuthorize("@pms.hasPermission('idp_forecastpowershorttermhis_edit')")
    public R updateById(@RequestBody ForecastPowerShortTermHis forecastPowerShortTermHis) {
        return R.ok(forecastPowerShortTermHisService.updateById(forecastPowerShortTermHis));
    }

    /**
     * 通过id删除idp_forecast_power_short_term_his
     *
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除idp_forecast_power_short_term_his", notes = "通过id删除idp_forecast_power_short_term_his")
    //    //    @SysLog("通过id删除idp_forecast_power_short_term_his")
    @DeleteMapping("/{id}")
    //@PreAuthorize("@pms.hasPermission('idp_forecastpowershorttermhis_del')")
    public R removeById(@PathVariable String id) {
        return R.ok(forecastPowerShortTermHisService.removeById(id));
    }

}
