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

    private final  QfmidcbbbmEService qfmidcbbbmEService;

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


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

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

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

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