package com.ruoyi.web.controller.brewery;

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

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.brewery.domain.WyBeerQrcode;
import com.ruoyi.brewery.service.IWyBeerQrcodeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 酒品二维码Controller
 * 
 * @author ruoyi
 * @date 2024-12-21
 */
@Api(tags = "酒品二维码")
@RestController
@RequestMapping("/system/brewery/qrcode")
public class WyBeerQrcodeController extends BaseController
{
    @Autowired
    private IWyBeerQrcodeService wyBeerQrcodeService;

    /**
     * 查询酒品二维码列表
     */
    @ApiOperation("查询酒品二维码列表")
    @PreAuthorize("@ss.hasPermi('brewery:qrcode:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyBeerQrcode wyBeerQrcode)
    {
        startPage();
        List<WyBeerQrcode> list = wyBeerQrcodeService.selectWyBeerQrcodeList(wyBeerQrcode);
        return getDataTable(list);
    }

    /**
     * 导出酒品二维码列表
     */
    @ApiOperation("导出酒品二维码列表")
    @PreAuthorize("@ss.hasPermi('brewery:qrcode:export')")
    @Log(title = "酒品二维码", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyBeerQrcode wyBeerQrcode)
    {
        List<WyBeerQrcode> list = wyBeerQrcodeService.selectWyBeerQrcodeList(wyBeerQrcode);
        ExcelUtil<WyBeerQrcode> util = new ExcelUtil<WyBeerQrcode>(WyBeerQrcode.class);
        util.exportExcel(response, list, "酒品二维码数据");
    }

    /**
     * 获取酒品二维码详细信息
     */
    @ApiOperation("获取酒品二维码详细信息")
    @PreAuthorize("@ss.hasPermi('brewery:qrcode:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wyBeerQrcodeService.selectWyBeerQrcodeById(id));
    }

    /**
     * 新增酒品二维码
     */
    @ApiOperation("新增酒品二维码")
    @PreAuthorize("@ss.hasPermi('brewery:qrcode:add')")
    @Log(title = "酒品二维码", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyBeerQrcode wyBeerQrcode)
    {
        return toAjax(wyBeerQrcodeService.insertWyBeerQrcode(wyBeerQrcode));
    }

    /**
     * 修改酒品二维码
     */
    @ApiOperation("修改酒品二维码")
    @PreAuthorize("@ss.hasPermi('brewery:qrcode:edit')")
    @Log(title = "酒品二维码", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyBeerQrcode wyBeerQrcode)
    {
        return toAjax(wyBeerQrcodeService.updateWyBeerQrcode(wyBeerQrcode));
    }

    /**
     * 删除酒品二维码
     */
    @ApiOperation("删除酒品二维码")
    @PreAuthorize("@ss.hasPermi('brewery:qrcode:remove')")
    @Log(title = "酒品二维码", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wyBeerQrcodeService.deleteWyBeerQrcodeByIds(ids));
    }
}
