package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.RobotOpsMediaAsset;
import com.ruoyi.base.service.IRobotOpsMediaAssetService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 素材资源Controller
 *
 * @author ruoyi
 * @date 2026-05-08
 */
@RestController
@RequestMapping("/base/mediAasset")
public class RobotOpsMediaAssetController extends BaseController
{
    @Autowired
    private IRobotOpsMediaAssetService robotOpsMediaAssetService;

    /**
     * 查询素材资源列表
     */
    @PreAuthorize("@ss.hasPermi('base:mediAasset:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotOpsMediaAsset robotOpsMediaAsset)
    {
        startPage();
        List<RobotOpsMediaAsset> list = robotOpsMediaAssetService.selectRobotOpsMediaAssetList(robotOpsMediaAsset);
        return getDataTable(list);
    }

    /**
     * 导出素材资源列表
     */
    @PreAuthorize("@ss.hasPermi('base:mediAasset:export')")
    @Log(title = "素材资源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotOpsMediaAsset robotOpsMediaAsset)
    {
        List<RobotOpsMediaAsset> list = robotOpsMediaAssetService.selectRobotOpsMediaAssetList(robotOpsMediaAsset);
        ExcelUtil<RobotOpsMediaAsset> util = new ExcelUtil<RobotOpsMediaAsset>(RobotOpsMediaAsset.class);
        util.exportExcel(response, list, "素材资源数据");
    }

    /**
     * 获取素材资源详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:mediAasset:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotOpsMediaAssetService.selectRobotOpsMediaAssetById(id));
    }

    /**
     * 新增素材资源
     */
    @PreAuthorize("@ss.hasPermi('base:mediAasset:add')")
    @Log(title = "素材资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotOpsMediaAsset robotOpsMediaAsset)
    {
        return toAjax(robotOpsMediaAssetService.insertRobotOpsMediaAsset(robotOpsMediaAsset));
    }

    /**
     * 修改素材资源
     */
    @PreAuthorize("@ss.hasPermi('base:mediAasset:edit')")
    @Log(title = "素材资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotOpsMediaAsset robotOpsMediaAsset)
    {
        return toAjax(robotOpsMediaAssetService.updateRobotOpsMediaAsset(robotOpsMediaAsset));
    }

    /**
     * 删除素材资源
     */
    @PreAuthorize("@ss.hasPermi('base:mediAasset:remove')")
    @Log(title = "素材资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotOpsMediaAssetService.deleteRobotOpsMediaAssetByIds(ids));
    }
}
