package com.fs.course.controller;

import java.util.List;

import com.fs.course.vo.FsUserVideoTagsPVO;
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.course.domain.FsUserVideoTags;
import com.fs.course.service.IFsUserVideoTagsService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 短视频标签Controller
 *
 * @author fs
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/course/videoTags")
public class FsUserVideoTagsController extends BaseController
{
    @Autowired
    private IFsUserVideoTagsService fsUserVideoTagsService;

    /**
     * 查询短视频标签列表
     */
    @PreAuthorize("@ss.hasPermi('course:videoTags:list')")
    @GetMapping("/list")
    public AjaxResult list(FsUserVideoTags fsUserVideoTags)
    {
        List<FsUserVideoTags> list = fsUserVideoTagsService.selectFsUserVideoTagsList(fsUserVideoTags);
        return AjaxResult.success(list);
    }

    @GetMapping("/subList")
    public AjaxResult subList()
    {
        List<FsUserVideoTagsPVO> list = fsUserVideoTagsService.selectFsUserVideoTagsSubList();
        return AjaxResult.success(list);
    }

    /**
     * 导出短视频标签列表
     */
    @PreAuthorize("@ss.hasPermi('course:videoTags:export')")
    @Log(title = "短视频标签", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserVideoTags fsUserVideoTags)
    {
        List<FsUserVideoTags> list = fsUserVideoTagsService.selectFsUserVideoTagsList(fsUserVideoTags);
        ExcelUtil<FsUserVideoTags> util = new ExcelUtil<FsUserVideoTags>(FsUserVideoTags.class);
        return util.exportExcel(list, "短视频标签数据");
    }

    /**
     * 获取短视频标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:videoTags:query')")
    @GetMapping(value = "/{tagId}")
    public AjaxResult getInfo(@PathVariable("tagId") Long tagId)
    {
        return AjaxResult.success(fsUserVideoTagsService.selectFsUserVideoTagsByTagId(tagId));
    }

    /**
     * 新增短视频标签
     */
    @PreAuthorize("@ss.hasPermi('course:videoTags:add')")
    @Log(title = "短视频标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserVideoTags fsUserVideoTags)
    {
        return toAjax(fsUserVideoTagsService.insertFsUserVideoTags(fsUserVideoTags));
    }

    /**
     * 修改短视频标签
     */
    @PreAuthorize("@ss.hasPermi('course:videoTags:edit')")
    @Log(title = "短视频标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserVideoTags fsUserVideoTags)
    {
        return toAjax(fsUserVideoTagsService.updateFsUserVideoTags(fsUserVideoTags));
    }

    /**
     * 删除短视频标签
     */
    @PreAuthorize("@ss.hasPermi('course:videoTags:remove')")
    @Log(title = "短视频标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagIds}")
    public AjaxResult remove(@PathVariable Long[] tagIds)
    {
        return toAjax(fsUserVideoTagsService.deleteFsUserVideoTagsByTagIds(tagIds));
    }
}
