package com.ruoyi.web.controller.brewery;

import com.ruoyi.bar.domain.WyBeerQrcodeScanLog;
import com.ruoyi.bar.service.IWyBeerQrcodeScanLogService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping({"/system/brewery/QrcodeScanLog"})
public class BreweryBeerQrcodeScanLogController extends BaseController {
    @Autowired
    private IWyBeerQrcodeScanLogService wyBeerQrcodeScanLogService;

    @PreAuthorize("@ss.hasPermi('system:QrcodeScanLog:list')")
    @GetMapping({"/list"})
    public TableDataInfo list(WyBeerQrcodeScanLog wyBeerQrcodeScanLog) {
        startPage();
        List<WyBeerQrcodeScanLog> list = this.wyBeerQrcodeScanLogService.selectWyBeerQrcodeScanLogList(wyBeerQrcodeScanLog);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:QrcodeScanLog:export')")
    @Log(title = "酒品二维码扫码记录", businessType = BusinessType.EXPORT)
    @PostMapping({"/export"})
    public void export(HttpServletResponse response, WyBeerQrcodeScanLog wyBeerQrcodeScanLog) {
        List<WyBeerQrcodeScanLog> list = this.wyBeerQrcodeScanLogService.selectWyBeerQrcodeScanLogList(wyBeerQrcodeScanLog);
        ExcelUtil<WyBeerQrcodeScanLog> util = new ExcelUtil(WyBeerQrcodeScanLog.class);
        util.exportExcel(response, list, "酒品二维码扫码记录数据");
    }

    @PreAuthorize("@ss.hasPermi('system:QrcodeScanLog:query')")
    @GetMapping({"/{id}"})
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(this.wyBeerQrcodeScanLogService.selectWyBeerQrcodeScanLogById(id));
    }

    @PreAuthorize("@ss.hasPermi('system:QrcodeScanLog:remove')")
    @Log(title = "酒品二维码扫码记录", businessType = BusinessType.DELETE)
    @DeleteMapping({"/{ids}"})
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(this.wyBeerQrcodeScanLogService.deleteWyBeerQrcodeScanLogByIds(ids));
    }
}
