/*
 * Author: wangjian
 * 生成controller
 */
package com.tofly.xrtygis.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.xrtygis.entity.Dmanightflow;
import com.tofly.xrtygis.service.DmanightflowService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;
/**
 * 夜间最小流量分析表
 *
 * @author wangjieliu
 * @date Tue May 25 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dmanightflow")
@Api(tags="夜间最小流量分析表接口")
public class DmanightflowController {

    private final  DmanightflowService dmanightflowService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param dmanightflow 夜间最小流量分析表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getDmanightflowPage(Page page, @ModelAttribute Dmanightflow dmanightflow) {
      return ResultRespone.success(dmanightflowService.page(page, Wrappers.query(dmanightflow)));
    }


    /**
     * 通过id查询夜间最小流量分析表
     * @param lid id
     * @return ResultRespone
     */
    @GetMapping("/{lid}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lid", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("lid" ) String lid) {
      return ResultRespone.success(dmanightflowService.getById(lid));
    }

    /**
     * 新增夜间最小流量分析表
     * @param dmanightflow 夜间最小流量分析表
     * @return ResultRespone
     */
    //(title="新增夜间最小流量分析表" )
    @ApiOperation(value = "新增夜间最小流量分析表")
    @PostMapping
    public ResultRespone save(@RequestBody Dmanightflow dmanightflow) {
      return ResultRespone.success(dmanightflowService.save(dmanightflow));
    }

    /**
     * 修改夜间最小流量分析表
     * @param dmanightflow 夜间最小流量分析表
     * @return ResultRespone
     */
    //(title="修改夜间最小流量分析表" )
    @ApiOperation(value = "修改夜间最小流量分析表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Dmanightflow dmanightflow) {
      return ResultRespone.success(dmanightflowService.updateById(dmanightflow));
    }

    /**
     * 通过id删除夜间最小流量分析表
     * @param lid id
     * @return ResultRespone
     */
    //(title="通过id删除夜间最小流量分析表" )
    @ApiOperation(value = "通过ID删除夜间最小流量分析表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "lid", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{lid}" )
    public ResultRespone removeById(@PathVariable String lid) {
      return ResultRespone.success(dmanightflowService.removeById(lid));
    }

    /**
     * 通过id批量删除夜间最小流量分析表
     * @param ids id
     * @return ResultRespone
     */
    //(title="通过id批量删除夜间最小流量分析表" )
    @ApiOperation(value = "通过ID批量删除夜间最小流量分析表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(dmanightflowService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
