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.LiveSensitiveWords;
import com.fs.live.service.ILiveSensitiveWordsService;
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-08
 */
@RestController
@RequestMapping("/live/words")
public class LiveSensitiveWordsController extends BaseController
{
    @Autowired
    private ILiveSensitiveWordsService liveSensitiveWordsService;

    /**
     * 查询直播间敏感词过滤列表
     */
    @PreAuthorize("@ss.hasPermi('live:words:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveSensitiveWords liveSensitiveWords)
    {
        startPage();
        List<LiveSensitiveWords> list = liveSensitiveWordsService.selectLiveSensitiveWordsList(liveSensitiveWords);
        return getDataTable(list);
    }

    /**
     * 导出直播间敏感词过滤列表
     */
    @PreAuthorize("@ss.hasPermi('live:words:export')")
    @Log(title = "直播间敏感词过滤", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveSensitiveWords liveSensitiveWords)
    {
        List<LiveSensitiveWords> list = liveSensitiveWordsService.selectLiveSensitiveWordsList(liveSensitiveWords);
        ExcelUtil<LiveSensitiveWords> util = new ExcelUtil<LiveSensitiveWords>(LiveSensitiveWords.class);
        return util.exportExcel(list, "直播间敏感词过滤数据");
    }

    /**
     * 获取直播间敏感词过滤详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:words:query')")
    @GetMapping(value = "/{wordId}")
    public AjaxResult getInfo(@PathVariable("wordId") Long wordId)
    {
        return AjaxResult.success(liveSensitiveWordsService.selectLiveSensitiveWordsByWordId(wordId));
    }

    /**
     * 新增直播间敏感词过滤
     */
    @PreAuthorize("@ss.hasPermi('live:words:add')")
    @Log(title = "直播间敏感词过滤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveSensitiveWords liveSensitiveWords)
    {

        return toAjax(liveSensitiveWordsService.insertLiveSensitiveWords(liveSensitiveWords));
    }

    /**
     * 修改直播间敏感词过滤
     */
    @PreAuthorize("@ss.hasPermi('live:words:edit')")
    @Log(title = "直播间敏感词过滤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveSensitiveWords liveSensitiveWords)
    {
        return toAjax(liveSensitiveWordsService.updateLiveSensitiveWords(liveSensitiveWords));
    }

    /**
     * 删除直播间敏感词过滤
     */
    @PreAuthorize("@ss.hasPermi('live:words:remove')")
    @Log(title = "直播间敏感词过滤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wordIds}")
    public AjaxResult remove(@PathVariable Long[] wordIds)
    {
        return toAjax(liveSensitiveWordsService.deleteLiveSensitiveWordsByWordIds(wordIds));
    }
}
