package com.tofly.feesapi.wxgl.wechatofficalacctmgt.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.feesapi.common.core.ResultRespone;

import com.tofly.feesapi.wxgl.wechatofficalacctmgt.entity.WxBzsq;
import com.tofly.feesapi.wxgl.wechatofficalacctmgt.service.WxBzsqService;
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("/api/wechatofficalacctmgt/wxbzsq")
@Api(tags = "微信公众号-报装申请接口")
public class WxBzsqController {

    @Autowired
    private WxBzsqService wxBzsqService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultRespone getWxBzsqPage(Page page, @ModelAttribute WxBzsq wxBzsq) {
        return ResultRespone.success(wxBzsqService.page(page, Wrappers.query(wxBzsq)));
    }

    @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(wxBzsqService.getById(id));
    }


    @ApiOperation(value = "新增微信-报装申请")
    @PostMapping
    public ResultRespone save(@RequestBody WxBzsq wxBzsq) {
        return ResultRespone.success(wxBzsqService.save(wxBzsq));
    }


    @ApiOperation(value = "修改微信-报装申请")
    @PutMapping
    public ResultRespone updateById(@RequestBody WxBzsq wxBzsq) {
        return ResultRespone.success(wxBzsqService.updateById(wxBzsq));
    }

    @ApiOperation(value = "通过ID删除微信-报装申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
    })
    @DeleteMapping("/{id}")
    public ResultRespone removeById(@PathVariable String id) {
        return ResultRespone.success(wxBzsqService.removeById(id));
    }

    @ApiOperation(value = "通过ID批量删除微信-报装申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds")
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(wxBzsqService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
