/*
 * 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.QfmidcbpqE;
import com.tofly.watermeter.service.QfmidcbpqEService;
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("/qfmidcbpqe")
@Api(tags="抄表片区接口")
public class QfmidcbpqEController {

    private final  QfmidcbpqEService qfmidcbpqEService;

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


    /**
     * 通过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(qfmidcbpqEService.getById(pqbm));
    }

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

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

    /**
     * 通过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(qfmidcbpqEService.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(qfmidcbpqEService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
