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.LiveMsg;
import com.fs.live.service.ILiveMsgService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 直播讨论Controller
 * 
 * @author fs
 * @date 2025-01-17
 */
@RestController
@RequestMapping("/live/liveMsg")
public class LiveMsgController extends BaseController
{
    @Autowired
    private ILiveMsgService liveMsgService;

    /**
     * 查询直播讨论列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveMsg:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveMsg liveMsg)
    {
        startPage();
        List<LiveMsg> list = liveMsgService.selectLiveMsgList(liveMsg);
        return getDataTable(list);
    }

    /**
     * 导出直播讨论列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveMsg:export')")
    @Log(title = "直播讨论", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveMsg liveMsg)
    {
        List<LiveMsg> list = liveMsgService.selectLiveMsgList(liveMsg);
        ExcelUtil<LiveMsg> util = new ExcelUtil<LiveMsg>(LiveMsg.class);
        return util.exportExcel(list, "直播讨论数据");
    }

    /**
     * 获取直播讨论详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:liveMsg:query')")
    @GetMapping(value = "/{msgId}")
    public AjaxResult getInfo(@PathVariable("msgId") Long msgId)
    {
        return AjaxResult.success(liveMsgService.selectLiveMsgByMsgId(msgId));
    }

    /**
     * 新增直播讨论
     */
    @PreAuthorize("@ss.hasPermi('live:liveMsg:add')")
    @Log(title = "直播讨论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveMsg liveMsg)
    {
        return toAjax(liveMsgService.insertLiveMsg(liveMsg));
    }

    /**
     * 修改直播讨论
     */
    @PreAuthorize("@ss.hasPermi('live:liveMsg:edit')")
    @Log(title = "直播讨论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveMsg liveMsg)
    {
        return toAjax(liveMsgService.updateLiveMsg(liveMsg));
    }

    /**
     * 删除直播讨论
     */
    @PreAuthorize("@ss.hasPermi('live:liveMsg:remove')")
    @Log(title = "直播讨论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{msgIds}")
    public AjaxResult remove(@PathVariable Long[] msgIds)
    {
        return toAjax(liveMsgService.deleteLiveMsgByMsgIds(msgIds));
    }
}
