/*
 * 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.Qfcbcbpq;
import com.tofly.watermeter.service.QfcbcbpqService;
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 Wed Apr 14 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/qfcbcbpq")
@Api(tags="抄表片区接口")
public class QfcbcbpqController {

    private final  QfcbcbpqService qfcbcbpqService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param qfcbcbpq 抄表片区
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getQfcbcbpqPage(Page page, @ModelAttribute Qfcbcbpq qfcbcbpq) {
      return ResultRespone.success(qfcbcbpqService.page(page, Wrappers.query(qfcbcbpq)));
    }


    /**
     * 通过id查询抄表片区
     * @param pqbm id
     * @return ResultRespone
     */
    @GetMapping("/{pqbm}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pqbm", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("pqbm" ) String pqbm) {
      return ResultRespone.success(qfcbcbpqService.getById(pqbm));
    }

    /**
     * 新增抄表片区
     * @param qfcbcbpq 抄表片区
     * @return ResultRespone
     */
    //="新增抄表片区" )
    @ApiOperation(value = "新增抄表片区")
    @PostMapping
    public ResultRespone save(@RequestBody Qfcbcbpq qfcbcbpq) {
      return ResultRespone.success(qfcbcbpqService.save(qfcbcbpq));
    }

    /**
     * 修改抄表片区
     * @param qfcbcbpq 抄表片区
     * @return ResultRespone
     */
    //="修改抄表片区" )
    @ApiOperation(value = "修改抄表片区")
    @PutMapping
    public ResultRespone updateById(@RequestBody Qfcbcbpq qfcbcbpq) {
      return ResultRespone.success(qfcbcbpqService.updateById(qfcbcbpq));
    }

    /**
     * 通过id删除抄表片区
     * @param pqbm id
     * @return ResultRespone
     */
    //="通过id删除抄表片区" )
    @ApiOperation(value = "通过ID删除抄表片区")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pqbm", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{pqbm}" )
    public ResultRespone removeById(@PathVariable String pqbm) {
      return ResultRespone.success(qfcbcbpqService.removeById(pqbm));
    }

    /**
     * 通过id批量删除抄表片区
     * @param ids id
     * @return ResultRespone
     */
    //="通过id批量删除抄表片区" )
    @ApiOperation(value = "通过ID批量删除抄表片区")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(qfcbcbpqService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
