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.RobotOpsBroadcastContent;
import com.ruoyi.base.service.IRobotOpsBroadcastContentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 播报内容Controller
 *
 * @author ruoyi
 * @date 2026-04-27
 */
@RestController
@RequestMapping("/base/broadcastContent")
public class RobotOpsBroadcastContentController extends BaseController
{
    @Autowired
    private IRobotOpsBroadcastContentService robotOpsBroadcastContentService;

    /**
     * 查询播报内容列表
     */
    @PreAuthorize("@ss.hasPermi('base:broadcastContent:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotOpsBroadcastContent robotOpsBroadcastContent)
    {
        startPage();
        List<RobotOpsBroadcastContent> list = robotOpsBroadcastContentService.selectRobotOpsBroadcastContentList(robotOpsBroadcastContent);
        return getDataTable(list);
    }

    /**
     * 导出播报内容列表
     */
    @PreAuthorize("@ss.hasPermi('base:broadcastContent:export')")
    @Log(title = "播报内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotOpsBroadcastContent robotOpsBroadcastContent)
    {
        List<RobotOpsBroadcastContent> list = robotOpsBroadcastContentService.selectRobotOpsBroadcastContentList(robotOpsBroadcastContent);
        ExcelUtil<RobotOpsBroadcastContent> util = new ExcelUtil<RobotOpsBroadcastContent>(RobotOpsBroadcastContent.class);
        util.exportExcel(response, list, "播报内容数据");
    }

    /**
     * 获取播报内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:broadcastContent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotOpsBroadcastContentService.selectRobotOpsBroadcastContentById(id));
    }

    /**
     * 新增播报内容
     */
    @PreAuthorize("@ss.hasPermi('base:broadcastContent:add')")
    @Log(title = "播报内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotOpsBroadcastContent robotOpsBroadcastContent)
    {
        return toAjax(robotOpsBroadcastContentService.insertRobotOpsBroadcastContent(robotOpsBroadcastContent));
    }

    /**
     * 修改播报内容
     */
    @PreAuthorize("@ss.hasPermi('base:broadcastContent:edit')")
    @Log(title = "播报内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotOpsBroadcastContent robotOpsBroadcastContent)
    {
        return toAjax(robotOpsBroadcastContentService.updateRobotOpsBroadcastContent(robotOpsBroadcastContent));
    }

    /**
     * 删除播报内容
     */
    @PreAuthorize("@ss.hasPermi('base:broadcastContent:remove')")
    @Log(title = "播报内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotOpsBroadcastContentService.deleteRobotOpsBroadcastContentByIds(ids));
    }
}
