/*
 * 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.Dmaandcbb;
import com.tofly.xrtygis.service.DmaandcbbService;
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;
/**
 * DMA分区与抄表本关系表
 *
 * @author wangjieliu
 * @date Wed May 26 00:00:00 CST 2021
 */
@RestController
@AllArgsConstructor
@RequestMapping("/dmaandcbb")
@Api(tags="DMA分区与抄表本关系表接口")
public class DmaandcbbController {

    private final  DmaandcbbService dmaandcbbService;

    /**
    * 分页查询
    * @param page 分页对象
    * @param dmaandcbb DMA分区与抄表本关系表
    * @return
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getDmaandcbbPage(Page page, @ModelAttribute Dmaandcbb dmaandcbb) {
      return ResultRespone.success(dmaandcbbService.page(page, Wrappers.query(dmaandcbb)));
    }


    /**
     * 通过id查询DMA分区与抄表本关系表
     * @param id id
     * @return ResultRespone
     */
    @GetMapping("/{id}" )
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("id" ) String id) {
      return ResultRespone.success(dmaandcbbService.getById(id));
    }

    /**
     * 新增DMA分区与抄表本关系表
     * @param dmaandcbb DMA分区与抄表本关系表
     * @return ResultRespone
     */
    //(title="新增DMA分区与抄表本关系表" )
    @ApiOperation(value = "新增DMA分区与抄表本关系表")
    @PostMapping
    public ResultRespone save(@RequestBody Dmaandcbb dmaandcbb) {
      return ResultRespone.success(dmaandcbbService.save(dmaandcbb));
    }

    /**
     * 修改DMA分区与抄表本关系表
     * @param dmaandcbb DMA分区与抄表本关系表
     * @return ResultRespone
     */
    //(title="修改DMA分区与抄表本关系表" )
    @ApiOperation(value = "修改DMA分区与抄表本关系表")
    @PutMapping
    public ResultRespone updateById(@RequestBody Dmaandcbb dmaandcbb) {
      return ResultRespone.success(dmaandcbbService.updateById(dmaandcbb));
    }

    /**
     * 通过id删除DMA分区与抄表本关系表
     * @param id id
     * @return ResultRespone
     */
    //(title="通过id删除DMA分区与抄表本关系表" )
    @ApiOperation(value = "通过ID删除DMA分区与抄表本关系表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable String id) {
      return ResultRespone.success(dmaandcbbService.removeById(id));
    }

    /**
     * 通过id批量删除DMA分区与抄表本关系表
     * @param ids id
     * @return ResultRespone
     */
    //(title="通过id批量删除DMA分区与抄表本关系表" )
    @ApiOperation(value = "通过ID批量删除DMA分区与抄表本关系表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(dmaandcbbService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
