package com.fs.live.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.live.domain.LiveEventConf;
import com.fs.live.service.ILiveEventConfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 直播触发事件配置Controller
 *
 * @author fs
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/live/liveEventConf")
public class LiveEventConfController extends BaseController
{
    @Autowired
    private ILiveEventConfService liveEventConfService;

    /**
     * 查询直播触发事件配置列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveEventConf:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveEventConf liveEventConf)
    {
        startPage();
        List<LiveEventConf> list = liveEventConfService.selectLiveEventConfList(liveEventConf);
        return getDataTable(list);
    }

    /**
     * 导出直播触发事件配置列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveEventConf:export')")
    @Log(title = "直播触发事件配置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveEventConf liveEventConf)
    {
        List<LiveEventConf> list = liveEventConfService.selectLiveEventConfList(liveEventConf);
        ExcelUtil<LiveEventConf> util = new ExcelUtil<LiveEventConf>(LiveEventConf.class);
        return util.exportExcel(list, "直播触发事件配置数据");
    }

    /**
     * 获取直播触发事件配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:liveEventConf:query')")
    @GetMapping(value = "/{eventId}")
    public AjaxResult getInfo(@PathVariable("eventId") Long eventId)
    {
        return AjaxResult.success(liveEventConfService.selectLiveEventConfByEventId(eventId));
    }

    /**
     * 新增直播触发事件配置
     */
    @PreAuthorize("@ss.hasPermi('live:liveEventConf:add')")
    @Log(title = "直播触发事件配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveEventConf liveEventConf)
    {
        return toAjax(liveEventConfService.insertLiveEventConf(liveEventConf));
    }

    /**
     * 修改直播触发事件配置
     */
    @PreAuthorize("@ss.hasPermi('live:liveEventConf:edit')")
    @Log(title = "直播触发事件配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveEventConf liveEventConf)
    {
        return toAjax(liveEventConfService.updateLiveEventConf(liveEventConf));
    }

    /**
     * 删除直播触发事件配置
     */
    @PreAuthorize("@ss.hasPermi('live:liveEventConf:remove')")
    @Log(title = "直播触发事件配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{eventIds}")
    public AjaxResult remove(@PathVariable Long[] eventIds)
    {
        return toAjax(liveEventConfService.deleteLiveEventConfByEventIds(eventIds));
    }
}
