package com.ruoyi.logistics.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.logistics.domain.BizMonthQrcodeRecord;
import com.ruoyi.logistics.service.IBizMonthQrcodeRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 月结二维码使用记录Controller
 * 
 * @author RuiJing
 * @date 2026-02-12
 */
@RestController
@RequestMapping("/record")
public class BizMonthQrcodeRecordController extends BaseController
{
    @Autowired
    private IBizMonthQrcodeRecordService bizMonthQrcodeRecordService;

    /**
     * 查询月结二维码使用记录列表
     */
    @RequiresPermissions("system:record:list")
    @GetMapping("/list")
    public TableDataInfo list(BizMonthQrcodeRecord bizMonthQrcodeRecord)
    {
        startPage();
        List<BizMonthQrcodeRecord> list = bizMonthQrcodeRecordService.selectBizMonthQrcodeRecordList(bizMonthQrcodeRecord);
        return getDataTable(list);
    }

    /**
     * 导出月结二维码使用记录列表
     */
    @RequiresPermissions("system:record:export")
    @Log(title = "月结二维码使用记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizMonthQrcodeRecord bizMonthQrcodeRecord)
    {
        List<BizMonthQrcodeRecord> list = bizMonthQrcodeRecordService.selectBizMonthQrcodeRecordList(bizMonthQrcodeRecord);
        ExcelUtil<BizMonthQrcodeRecord> util = new ExcelUtil<BizMonthQrcodeRecord>(BizMonthQrcodeRecord.class);
        util.exportExcel(response, list, "月结二维码使用记录数据");
    }

    /**
     * 获取月结二维码使用记录详细信息
     */
    @RequiresPermissions("system:record:query")
    @GetMapping(value = "/{qrcodeId}")
    public AjaxResult getInfo(@PathVariable("qrcodeId") Long qrcodeId)
    {
        return success(bizMonthQrcodeRecordService.selectBizMonthQrcodeRecordByQrcodeId(qrcodeId));
    }

    /**
     * 新增月结二维码使用记录
     */
    @RequiresPermissions("system:record:add")
    @Log(title = "月结二维码使用记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizMonthQrcodeRecord bizMonthQrcodeRecord)
    {
        return toAjax(bizMonthQrcodeRecordService.insertBizMonthQrcodeRecord(bizMonthQrcodeRecord));
    }

    /**
     * 修改月结二维码使用记录
     */
    @RequiresPermissions("system:record:edit")
    @Log(title = "月结二维码使用记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizMonthQrcodeRecord bizMonthQrcodeRecord)
    {
        return toAjax(bizMonthQrcodeRecordService.updateBizMonthQrcodeRecord(bizMonthQrcodeRecord));
    }

    /**
     * 删除月结二维码使用记录
     */
    @RequiresPermissions("system:record:remove")
    @Log(title = "月结二维码使用记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{qrcodeIds}")
    public AjaxResult remove(@PathVariable Long[] qrcodeIds)
    {
        return toAjax(bizMonthQrcodeRecordService.deleteBizMonthQrcodeRecordByQrcodeIds(qrcodeIds));
    }
}
