package com.fs.live.controller;

import java.util.List;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.live.domain.LiveVideo;
import com.fs.live.service.ILiveVideoService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 直播视频Controller
 * 
 * @author fs
 * @date 2025-01-17
 */
@RestController
@RequestMapping("/live/liveVideo")
public class LiveVideoController extends BaseController
{
    @Autowired
    private ILiveVideoService liveVideoService;

    /**
     * 查询直播视频列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveVideo:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveVideo liveVideo)
    {
        startPage();
        List<LiveVideo> list = liveVideoService.selectLiveVideoList(liveVideo);
        return getDataTable(list);
    }

    /**
     * 导出直播视频列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveVideo:export')")
    @Log(title = "直播视频", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveVideo liveVideo)
    {
        List<LiveVideo> list = liveVideoService.selectLiveVideoList(liveVideo);
        ExcelUtil<LiveVideo> util = new ExcelUtil<LiveVideo>(LiveVideo.class);
        return util.exportExcel(list, "直播视频数据");
    }

    /**
     * 获取直播视频详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:liveVideo:query')")
    @GetMapping(value = "/{videoId}")
    public AjaxResult getInfo(@PathVariable("videoId") Long videoId)
    {
        return AjaxResult.success(liveVideoService.selectLiveVideoByVideoId(videoId));
    }

    /**
     * 新增直播视频
     */
    @PreAuthorize("@ss.hasPermi('live:liveVideo:add')")
    @Log(title = "直播视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveVideo liveVideo)
    {
        return toAjax(liveVideoService.insertLiveVideo(liveVideo));
    }

    /**
     * 修改直播视频
     */
    @PreAuthorize("@ss.hasPermi('live:liveVideo:edit')")
    @Log(title = "直播视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveVideo liveVideo)
    {
        return toAjax(liveVideoService.updateLiveVideo(liveVideo));
    }

    /**
     * 删除直播视频
     */
    @PreAuthorize("@ss.hasPermi('live:liveVideo:remove')")
    @Log(title = "直播视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Long[] videoIds)
    {
        return toAjax(liveVideoService.deleteLiveVideoByVideoIds(videoIds));
    }
}
