package com.bonus.material.basic.controller;

import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.material.basic.domain.BmQrBoxInfo;
import com.bonus.material.basic.service.BmQrBoxService;
import com.bonus.material.common.annotation.PreventRepeatSubmit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author ma_sh
 * @create 2024/12/11 17:25
 */
@Api(tags = "二维码标准箱管理接口")
@RestController
@RequestMapping("/bm_qrcode_box")
public class BmQrBoxController extends BaseController {

    @Resource
    private BmQrBoxService qrBoxService;

    /**
     * 查询二维码管理列表
     * @param bmQrBoxInfo
     * @return
     */
    @ApiOperation(value = "查询二维码标准箱管理列表")
    //@RequiresPermissions("basic:qrBox:list")
    @GetMapping("/list")
    public TableDataInfo list(BmQrBoxInfo bmQrBoxInfo)
    {
        startPage();
        List<BmQrBoxInfo> list = qrBoxService.selectBmQrBoxInfoList(bmQrBoxInfo);
        return getDataTable(list);
    }

    /**
     * 查询二维码标准箱绑定详情列表
     * @param bmQrBoxInfo
     * @return
     */
    @ApiOperation(value = "查询二维码标准箱绑定详情列表")
    //@RequiresPermissions("basic:qrBox:list")
    @GetMapping("/getList")
    public TableDataInfo getList(BmQrBoxInfo bmQrBoxInfo)
    {
        startPage();
        List<BmQrBoxInfo> list = qrBoxService.getList(bmQrBoxInfo);
        return getDataTable(list);
    }

    /**
     * 新增二维码标准箱管理
     * @param bmQrBoxInfo
     * @return
     */
    @ApiOperation(value = "新增二维码标准箱管理")
    //@PreventRepeatSubmit
    //@RequiresPermissions("basic:qrBox:add")
    @SysLog(title = "二维码标准箱管理", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增二维码标准箱管理")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BmQrBoxInfo bmQrBoxInfo)
    {
        return qrBoxService.insertBmQrcodeInfo(bmQrBoxInfo);
    }

    /**
     * 修改二维码标准箱管理
     * @param bmQrBoxInfo
     * @return
     */
    @ApiOperation(value = "二维码标准箱管理")
    @PreventRepeatSubmit
    //@RequiresPermissions("basic:qrBox:edit")
    @SysLog(title = "二维码标准箱管理", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->修改二维码标准箱")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BmQrBoxInfo bmQrBoxInfo)
    {
        return qrBoxService.updateBmQrcodeInfo(bmQrBoxInfo);
    }

    /**
     * 删除二维码标准箱
     * @param bmQrBoxInfo
     * @return
     */
    @ApiOperation(value = "删除二维码标准箱")
    @PreventRepeatSubmit
    //@RequiresPermissions("basic:info:remove")
    @SysLog(title = "二维码标准箱管理", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除二维码标准箱")
    @PostMapping("/deleteById")
    public AjaxResult deleteById(@RequestBody BmQrBoxInfo bmQrBoxInfo)
    {
        return qrBoxService.deleteById(bmQrBoxInfo);
    }

    /**
     * 下载二维码标准箱
     * @param bmQrBoxInfo
     * @param response
     * @return
     */
    @ApiOperation(value = "下载二维码标准箱")
    @PreventRepeatSubmit
    //@RequiresPermissions("basic:qrBox:download")
    @PostMapping("/download")
    public void download(@RequestBody BmQrBoxInfo bmQrBoxInfo, HttpServletResponse response)
    {
        qrBoxService.download(bmQrBoxInfo, response);
    }
}
