/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.watermeter.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.watermeter.entity.Hourwateryield;
import com.tofly.watermeter.service.HourwateryieldService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
/**
 * 指标流量小时记录表
 *
 * @author admin
 * @date Wed Jun 08 00:00:00 CST 2022
 */
@RestController
@AllArgsConstructor
@RequestMapping("/hourwateryield")
@Api(tags="指标流量小时记录表接口")
public class HourwateryieldController {

    private final  HourwateryieldService hourwateryieldService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param hourwateryield 指标流量小时记录表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getHourwateryieldPage(Page page, @ModelAttribute Hourwateryield hourwateryield) {
      return ResultRespone.success(hourwateryieldService.page(page, Wrappers.query(hourwateryield)));
    }


    /**
     * 通过id查询指标流量小时记录表
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    public ResultRespone getById(@PathVariable("id" ) Long id) {
      return ResultRespone.success(hourwateryieldService.getById(id));
    }

    /**
     * 新增指标流量小时记录表
     * @param hourwateryield 指标流量小时记录表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="新增指标流量小时记录表" )
    @ApiOperation(value = "新增指标流量小时记录表")
    @PostMapping
    public ResultRespone save(@RequestBody Hourwateryield hourwateryield) {
      return ResultRespone.success(hourwateryieldService.save(hourwateryield));
    }

    /**
     * 修改指标流量小时记录表
     * @param hourwateryield 指标流量小时记录表
     * @return ResultRespone
     */
    @ToFlyAppLog(title="修改指标流量小时记录表" )
    @ApiOperation(value = "修改指标流量小时记录表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Hourwateryield hourwateryield) {
      return ResultRespone.success(hourwateryieldService.updateById(hourwateryield));
    }

    /**
     * 通过id删除指标流量小时记录表
     * @param id id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id删除指标流量小时记录表" )
    @ApiOperation(value = "通过ID删除指标流量小时记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "Long")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable Long id) {
      return ResultRespone.success(hourwateryieldService.removeById(id));
    }

    /**
     * 通过id批量删除指标流量小时记录表
     * @param ids id
     * @return ResultRespone
     */
    @ToFlyAppLog(title="通过id批量删除指标流量小时记录表" )
    @ApiOperation(value = "通过ID批量删除指标流量小时记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeById(String ids) {
        return ResultRespone.success(hourwateryieldService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
