/*
 * 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.Qfcbcbbbm;
import com.tofly.watermeter.service.QfcbcbbbmService;
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("/qfcbcbbbm")
@Api(tags="中间抄表本编码表接口")
public class QfcbcbbbmController {

    private final  QfcbcbbbmService qfcbcbbbmService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param qfcbcbbbm 中间抄表本编码表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getQfcbcbbbmPage(Page page, @ModelAttribute Qfcbcbbbm qfcbcbbbm) {
      return ResultRespone.success(qfcbcbbbmService.page(page, Wrappers.query(qfcbcbbbm)));
    }


    /**
     * 通过id查询中间抄表本编码表
     * @param cbbbm id
     * @return ResultRespone
     */
    @GetMapping("/{cbbbm}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cbbbm", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("cbbbm" ) String cbbbm) {
      return ResultRespone.success(qfcbcbbbmService.getById(cbbbm));
    }

    /**
     * 新增中间抄表本编码表
     * @param qfcbcbbbm 中间抄表本编码表
     * @return ResultRespone
     */
    //="新增中间抄表本编码表" )
    @ApiOperation(value = "新增中间抄表本编码表")
    @PostMapping
    public ResultRespone save(@RequestBody Qfcbcbbbm qfcbcbbbm) {
      return ResultRespone.success(qfcbcbbbmService.save(qfcbcbbbm));
    }

    /**
     * 修改中间抄表本编码表
     * @param qfcbcbbbm 中间抄表本编码表
     * @return ResultRespone
     */
    //="修改中间抄表本编码表" )
    @ApiOperation(value = "修改中间抄表本编码表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Qfcbcbbbm qfcbcbbbm) {
      return ResultRespone.success(qfcbcbbbmService.updateById(qfcbcbbbm));
    }

    /**
     * 通过id删除中间抄表本编码表
     * @param cbbbm id
     * @return ResultRespone
     */
    //="通过id删除中间抄表本编码表" )
    @ApiOperation(value = "通过ID删除中间抄表本编码表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cbbbm", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{cbbbm}" )
    public ResultRespone removeById(@PathVariable String cbbbm) {
      return ResultRespone.success(qfcbcbbbmService.removeById(cbbbm));
    }

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