/*
 * 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.Dmausercbb;
import com.tofly.xrtygis.service.DmausercbbService;
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("/dmausercbb")
@Api(tags="营销用户抄表本接口")
public class DmausercbbController {

    private final  DmausercbbService dmausercbbService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param dmausercbb 营销用户抄表本
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getDmausercbbPage(Page page, @ModelAttribute Dmausercbb dmausercbb) {
      return ResultRespone.success(dmausercbbService.page(page, Wrappers.query(dmausercbb)));
    }


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

    /**
     * 新增营销用户抄表本
     * @param dmausercbb 营销用户抄表本
     * @return ResultRespone
     */
    //(title="新增营销用户抄表本" )
    @ApiOperation(value = "新增营销用户抄表本")
    @PostMapping
    public ResultRespone save(@RequestBody Dmausercbb dmausercbb) {
      return ResultRespone.success(dmausercbbService.save(dmausercbb));
    }

    /**
     * 修改营销用户抄表本
     * @param dmausercbb 营销用户抄表本
     * @return ResultRespone
     */
    //(title="修改营销用户抄表本" )
    @ApiOperation(value = "修改营销用户抄表本")
    @PutMapping
    public ResultRespone updateById(@RequestBody Dmausercbb dmausercbb) {
      return ResultRespone.success(dmausercbbService.updateById(dmausercbb));
    }

    /**
     * 通过id删除营销用户抄表本
     * @param cbbbm id
     * @return ResultRespone
     */
    //(title="通过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(dmausercbbService.removeById(cbbbm));
    }

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