package com.tofly.feesapi.bmgl.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.feesapi.bmgl.entity.BmDbhysyh;
import com.tofly.feesapi.bmgl.service.BmDbhysyhService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

@RestController
@RequestMapping("/bmdbhysyh")
@Api(tags="编码表-低保户用水优惠接口")
public class BmDbhysyhController {

    @Autowired
    private BmDbhysyhService bmDbhysyhService;

    /**
    * 分页查询
    */
    @GetMapping("/page" )
    @ApiOperation(value = "分页查询")
    public ResultRespone getBmDbhysyhPage(Page page, @ModelAttribute BmDbhysyh bmDbhysyh) {
      return ResultRespone.success(bmDbhysyhService.page(page, Wrappers.query(bmDbhysyh)));
    }


    /**
     * 通过id查询编码表-低保户用水优惠
     * @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(bmDbhysyhService.getById(id));
    }

    /**
     * 新增编码表-低保户用水优惠
     * @param bmDbhysyh 编码表-低保户用水优惠
     * @return ResultRespone
     */
    @ApiOperation(value = "新增编码表-低保户用水优惠")
    @PostMapping
    public ResultRespone save(@RequestBody BmDbhysyh bmDbhysyh) {
      return ResultRespone.success(bmDbhysyhService.save(bmDbhysyh));
    }

    /**
     * 修改编码表-低保户用水优惠
     * @param bmDbhysyh 编码表-低保户用水优惠
     * @return ResultRespone
     */
    @ApiOperation(value = "修改编码表-低保户用水优惠")
    @PutMapping
    public ResultRespone updateById(@RequestBody BmDbhysyh bmDbhysyh) {
      return ResultRespone.success(bmDbhysyhService.updateById(bmDbhysyh));
    }

    /**
     * 通过id删除编码表-低保户用水优惠
     * @param id id
     * @return ResultRespone
     */
    @ApiOperation(value = "通过ID删除编码表-低保户用水优惠")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{id}" )
    public ResultRespone removeById(@PathVariable String id) {
      return ResultRespone.success(bmDbhysyhService.removeById(id));
    }

    /**
     * 通过id批量删除编码表-低保户用水优惠
     * @param ids id
     * @return ResultRespone
     */
    @ApiOperation(value = "通过ID批量删除编码表-低保户用水优惠")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds" )
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(bmDbhysyhService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
