package com.ruoyi.web.controller.system;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
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 com.ruoyi.system.domain.PosOrderLog;
import com.ruoyi.system.service.IPosOrderLogService;

@RestController
@RequestMapping("/system/orderLog")
public class PosOrderLogController extends BaseController
{
    @Autowired
    private IPosOrderLogService orderLogService;

    @PreAuthorize("@ss.hasPermi('system:orderLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(PosOrderLog orderLog)
    {
        startPage();
        List<PosOrderLog> list = orderLogService.selectOrderLogList(orderLog);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:orderLog:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return success(orderLogService.selectOrderLogById(id));
    }

    @Log(title = "订单操作日志", businessType = BusinessType.EXPORT)
    @PreAuthorize("@ss.hasPermi('system:orderLog:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, PosOrderLog orderLog)
    {
        List<PosOrderLog> list = orderLogService.selectOrderLogList(orderLog);
        ExcelUtil<PosOrderLog> util = new ExcelUtil<PosOrderLog>(PosOrderLog.class);
        util.exportExcel(response, list, "订单操作日志");
    }
}