package com.ruoyi.rocketmq.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.rocketmq.domain.RmFileInfo;
import com.ruoyi.rocketmq.service.IRmFileInfoService;
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 gyt
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/info")
public class RmFileInfoController extends BaseController
{
    @Autowired
    private IRmFileInfoService rmFileInfoService;

    /**
     * 查询文件信息列表
     */
    @RequiresPermissions("rocketmq:info:list")
    @GetMapping("/list")
    public TableDataInfo list(RmFileInfo rmFileInfo)
    {
        startPage();
        List<RmFileInfo> list = rmFileInfoService.selectRmFileInfoList(rmFileInfo);
        return getDataTable(list);
    }

    /**
     * 导出文件信息列表
     */
    @RequiresPermissions("rocketmq:info:export")
    @Log(title = "文件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RmFileInfo rmFileInfo)
    {
        List<RmFileInfo> list = rmFileInfoService.selectRmFileInfoList(rmFileInfo);
        ExcelUtil<RmFileInfo> util = new ExcelUtil<RmFileInfo>(RmFileInfo.class);
        util.exportExcel(response, list, "文件信息数据");
    }

    /**
     * 获取文件信息详细信息
     */
    @RequiresPermissions("rocketmq:info:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rmFileInfoService.selectRmFileInfoById(id));
    }

    /**
     * 新增文件信息
     */
    @RequiresPermissions("rocketmq:info:add")
    @Log(title = "文件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RmFileInfo rmFileInfo)
    {
        return toAjax(rmFileInfoService.insertRmFileInfo(rmFileInfo));
    }

    /**
     * 修改文件信息
     */
    @RequiresPermissions("rocketmq:info:edit")
    @Log(title = "文件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RmFileInfo rmFileInfo)
    {
        return toAjax(rmFileInfoService.updateRmFileInfo(rmFileInfo));
    }

    /**
     * 删除文件信息
     */
    @RequiresPermissions("rocketmq:info:remove")
    @Log(title = "文件信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rmFileInfoService.deleteRmFileInfoByIds(ids));
    }
}
