package com.fs.course.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.course.domain.FsUserVideoLike;
import com.fs.course.service.IFsUserVideoLikeService;
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 2024-05-15
 */
@RestController
@RequestMapping("/course/userVideoLike")
public class FsUserVideoLikeController extends BaseController
{
    @Autowired
    private IFsUserVideoLikeService fsUserVideoLikeService;

    /**
     * 查询课堂视频点赞列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoLike:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserVideoLike fsUserVideoLike)
    {
        startPage();
        List<FsUserVideoLike> list = fsUserVideoLikeService.selectFsUserVideoLikeList(fsUserVideoLike);
        return getDataTable(list);
    }

    /**
     * 导出课堂视频点赞列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoLike:export')")
    @Log(title = "课堂视频点赞", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserVideoLike fsUserVideoLike)
    {
        List<FsUserVideoLike> list = fsUserVideoLikeService.selectFsUserVideoLikeList(fsUserVideoLike);
        ExcelUtil<FsUserVideoLike> util = new ExcelUtil<FsUserVideoLike>(FsUserVideoLike.class);
        return util.exportExcel(list, "课堂视频点赞数据");
    }

    /**
     * 获取课堂视频点赞详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoLike:query')")
    @GetMapping(value = "/{likeId}")
    public AjaxResult getInfo(@PathVariable("likeId") Long likeId)
    {
        return AjaxResult.success(fsUserVideoLikeService.selectFsUserVideoLikeByLikeId(likeId));
    }

    /**
     * 新增课堂视频点赞
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoLike:add')")
    @Log(title = "课堂视频点赞", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserVideoLike fsUserVideoLike)
    {
        return toAjax(fsUserVideoLikeService.insertFsUserVideoLike(fsUserVideoLike));
    }

    /**
     * 修改课堂视频点赞
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoLike:edit')")
    @Log(title = "课堂视频点赞", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserVideoLike fsUserVideoLike)
    {
        return toAjax(fsUserVideoLikeService.updateFsUserVideoLike(fsUserVideoLike));
    }

    /**
     * 删除课堂视频点赞
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoLike:remove')")
    @Log(title = "课堂视频点赞", businessType = BusinessType.DELETE)
	@DeleteMapping("/{likeIds}")
    public AjaxResult remove(@PathVariable Long[] likeIds)
    {
        return toAjax(fsUserVideoLikeService.deleteFsUserVideoLikeByLikeIds(likeIds));
    }
}
