package com.fs.course.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.course.domain.FsUserVideoComment;
import com.fs.course.service.IFsUserVideoCommentService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 课堂视频评论Controller
 * 
 * @author fs
 * @date 2024-05-15
 */
@RestController
@RequestMapping("/course/userVideoComment")
public class FsUserVideoCommentController extends BaseController
{
    @Autowired
    private IFsUserVideoCommentService fsUserVideoCommentService;

    /**
     * 查询课堂视频评论列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoComment:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserVideoComment fsUserVideoComment)
    {
        startPage();
        List<FsUserVideoComment> list = fsUserVideoCommentService.selectFsUserVideoCommentList(fsUserVideoComment);
        return getDataTable(list);
    }

    /**
     * 导出课堂视频评论列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoComment:export')")
    @Log(title = "课堂视频评论", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserVideoComment fsUserVideoComment)
    {
        List<FsUserVideoComment> list = fsUserVideoCommentService.selectFsUserVideoCommentList(fsUserVideoComment);
        ExcelUtil<FsUserVideoComment> util = new ExcelUtil<FsUserVideoComment>(FsUserVideoComment.class);
        return util.exportExcel(list, "课堂视频评论数据");
    }

    /**
     * 获取课堂视频评论详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoComment:query')")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId)
    {
        return AjaxResult.success(fsUserVideoCommentService.selectFsUserVideoCommentByCommentId(commentId));
    }

    /**
     * 新增课堂视频评论
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoComment:add')")
    @Log(title = "课堂视频评论", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserVideoComment fsUserVideoComment)
    {
        return toAjax(fsUserVideoCommentService.insertFsUserVideoComment(fsUserVideoComment));
    }

    /**
     * 修改课堂视频评论
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoComment:edit')")
    @Log(title = "课堂视频评论", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserVideoComment fsUserVideoComment)
    {
        return toAjax(fsUserVideoCommentService.updateFsUserVideoComment(fsUserVideoComment));
    }

    /**
     * 删除课堂视频评论
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoComment:remove')")
    @Log(title = "课堂视频评论", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds)
    {
        return toAjax(fsUserVideoCommentService.deleteFsUserVideoCommentByCommentIds(commentIds));
    }
}
