package com.ruoyi.abuwx.controller;

import com.ruoyi.abuwx.domain.InfoOperationRecord;
import com.ruoyi.abuwx.service.IInfoOperationRecordService;
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;

/**
 * 资讯信息操作记录Controller
 * 
 * @author lujie
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/info/operationRecord")
public class InfoOperationRecordController extends BaseController
{
    @Autowired
    private IInfoOperationRecordService infoOperationRecordService;

    /**
     * 查询资讯信息操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('info:operationRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoOperationRecord infoOperationRecord)
    {
        startPage();
        List<InfoOperationRecord> list = infoOperationRecordService.selectInfoOperationRecordList(infoOperationRecord);
        return getDataTable(list);
    }

    /**
     * 导出资讯信息操作记录列表
     */
    @PreAuthorize("@ss.hasPermi('info:operationRecord:export')")
    @Log(title = "资讯信息操作记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoOperationRecord infoOperationRecord)
    {
        List<InfoOperationRecord> list = infoOperationRecordService.selectInfoOperationRecordList(infoOperationRecord);
        ExcelUtil<InfoOperationRecord> util = new ExcelUtil<InfoOperationRecord>(InfoOperationRecord.class);
        util.exportExcel(response, list, "资讯信息操作记录数据");
    }

    /**
     * 获取资讯信息操作记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:operationRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoOperationRecordService.selectInfoOperationRecordById(id));
    }

    /**
     * 新增资讯信息操作记录
     */
    @PreAuthorize("@ss.hasPermi('info:operationRecord:add')")
    @Log(title = "资讯信息操作记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoOperationRecord infoOperationRecord)
    {
        return toAjax(infoOperationRecordService.insertInfoOperationRecord(infoOperationRecord));
    }

    /**
     * 修改资讯信息操作记录
     */
    @PreAuthorize("@ss.hasPermi('info:operationRecord:edit')")
    @Log(title = "资讯信息操作记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoOperationRecord infoOperationRecord)
    {
        return toAjax(infoOperationRecordService.updateInfoOperationRecord(infoOperationRecord));
    }

    /**
     * 删除资讯信息操作记录
     */
    @PreAuthorize("@ss.hasPermi('info:operationRecord:remove')")
    @Log(title = "资讯信息操作记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoOperationRecordService.deleteInfoOperationRecordByIds(ids));
    }
}
