package com.fs.his.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsIntegralOrderLogs;
import com.fs.his.service.IFsIntegralOrderLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单操作记录Controller
 *
 * @author fs
 * @date 2025-11-25
 */
@RestController
@RequestMapping("/his/logs")
public class FsIntegralOrderLogsController extends BaseController
{
    @Autowired
    private IFsIntegralOrderLogsService fsIntegralOrderLogsService;

    /**
     * 查询订单操作记录列表
     */
//    @PreAuthorize("@ss.hasPermi('his:logs:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsIntegralOrderLogs fsIntegralOrderLogs)
    {
        startPage();
        List<FsIntegralOrderLogs> list = fsIntegralOrderLogsService.selectFsIntegralOrderLogsList(fsIntegralOrderLogs);
        return getDataTable(list);
    }

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

    /**
     * 获取订单操作记录详细信息
     */
//    @PreAuthorize("@ss.hasPermi('his:logs:query')")
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") String logsId)
    {
        return AjaxResult.success(fsIntegralOrderLogsService.selectFsIntegralOrderLogsByLogsId(logsId));
    }

    /**
     * 新增订单操作记录
     */
//    @PreAuthorize("@ss.hasPermi('his:logs:add')")
    @Log(title = "订单操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsIntegralOrderLogs fsIntegralOrderLogs)
    {
        return toAjax(fsIntegralOrderLogsService.insertFsIntegralOrderLogs(fsIntegralOrderLogs));
    }

    /**
     * 修改订单操作记录
     */
//    @PreAuthorize("@ss.hasPermi('his:logs:edit')")
    @Log(title = "订单操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsIntegralOrderLogs fsIntegralOrderLogs)
    {
        return toAjax(fsIntegralOrderLogsService.updateFsIntegralOrderLogs(fsIntegralOrderLogs));
    }

    /**
     * 根据订单ID查询操作记录
     */
//    @PreAuthorize("@ss.hasPermi('his:logs:query')")
    @GetMapping("/order/{orderId}")
    public AjaxResult getLogsByOrderId(@PathVariable("orderId") Long orderId)
    {
        FsIntegralOrderLogs queryParam = new FsIntegralOrderLogs();
        queryParam.setOrderId(orderId);
        List<FsIntegralOrderLogs> list = fsIntegralOrderLogsService.selectFsIntegralOrderLogsList(queryParam);
        return AjaxResult.success(list);
    }

    /**
     * 删除订单操作记录
     */
//    @PreAuthorize("@ss.hasPermi('his:logs:remove')")
    @Log(title = "订单操作记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable String[] logsIds)
    {
        return toAjax(fsIntegralOrderLogsService.deleteFsIntegralOrderLogsByLogsIds(logsIds));
    }
}
