package com.ruoyi.frequency.orderoperatorhistory.controller;

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.frequency.orderoperatorhistory.entity.OrderOperatorHistory;
import com.ruoyi.frequency.orderoperatorhistory.service.OrderOperatorHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单操作记录Controller
 *
 * @author liwenlong
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/frequency/orderoperatorhistory")
public class OrderOperatorHistoryController extends BaseController {
    @Autowired
    private OrderOperatorHistoryService orderOperatorHistoryService;

    /**
     * 查询订单操作记录列表
     */
//    @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:list')")
    @PostMapping("/list")
    public TableDataInfo<OrderOperatorHistory> list(@RequestBody OrderOperatorHistory orderOperatorHistory) {
        startPage();
        List<OrderOperatorHistory> list = orderOperatorHistoryService.selectOrderOperatorHistoryList(orderOperatorHistory);
        return getDataTable(list);
    }

    /**
     * 导出订单操作记录列表
     */
//    @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:export')")
    @Log(title = "订单操作记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderOperatorHistory orderOperatorHistory) {
        List<OrderOperatorHistory> list = orderOperatorHistoryService.selectOrderOperatorHistoryList(orderOperatorHistory);
        ExcelUtil<OrderOperatorHistory> util = new ExcelUtil<OrderOperatorHistory>(OrderOperatorHistory.class);
        return util.exportExcel(list, "订单操作记录数据");
    }

    /**
     * 获取订单操作记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<OrderOperatorHistory> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(orderOperatorHistoryService.selectOrderOperatorHistoryById(id));
    }

    /**
     * 新增订单操作记录
     */
//    @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:add')")
    @Log(title = "订单操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderOperatorHistory orderOperatorHistory) {
        return toAjax(orderOperatorHistoryService.insertOrderOperatorHistory(orderOperatorHistory));
    }

    /**
     * 修改订单操作记录
     */
//    @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:edit')")
    @Log(title = "订单操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderOperatorHistory orderOperatorHistory) {
        return toAjax(orderOperatorHistoryService.updateOrderOperatorHistory(orderOperatorHistory));
    }

    /**
     * 删除订单操作记录
     */
//    @PreAuthorize("@ss.hasPermi('frequency:orderoperatorhistory:remove')")
    @Log(title = "订单操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids, @PathVariable("delFlag") Integer delFlag) {
        return toAjax(orderOperatorHistoryService.deleteOrderOperatorHistoryByIds(ids, delFlag));
    }
}
