/*
 * 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.Dmausercbpq;
import com.tofly.xrtygis.service.DmausercbpqService;
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 May 26 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dmausercbpq")
@Api(tags="营销用户抄表片区接口")
public class DmausercbpqController {

    private final  DmausercbpqService dmausercbpqService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param dmausercbpq 营销用户抄表片区
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getDmausercbpqPage(Page page, @ModelAttribute Dmausercbpq dmausercbpq) {
      return ResultRespone.success(dmausercbpqService.page(page, Wrappers.query(dmausercbpq)));
    }


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

    /**
     * 新增营销用户抄表片区
     * @param dmausercbpq 营销用户抄表片区
     * @return ResultRespone
     */
    //(title="新增营销用户抄表片区" )
    @ApiOperation(value = "新增营销用户抄表片区")
    @PostMapping
    public ResultRespone save(@RequestBody Dmausercbpq dmausercbpq) {
      return ResultRespone.success(dmausercbpqService.save(dmausercbpq));
    }

    /**
     * 修改营销用户抄表片区
     * @param dmausercbpq 营销用户抄表片区
     * @return ResultRespone
     */
    //(title="修改营销用户抄表片区" )
    @ApiOperation(value = "修改营销用户抄表片区")
    @PutMapping
    public ResultRespone updateById(@RequestBody Dmausercbpq dmausercbpq) {
      return ResultRespone.success(dmausercbpqService.updateById(dmausercbpq));
    }

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

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