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.FsUserVideoFavorite;
import com.fs.course.service.IFsUserVideoFavoriteService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 课堂视频收藏Controller
 * 
 * @author fs
 * @date 2024-05-15
 */
@RestController
@RequestMapping("/course/userVideoFavorite")
public class FsUserVideoFavoriteController extends BaseController
{
    @Autowired
    private IFsUserVideoFavoriteService fsUserVideoFavoriteService;

    /**
     * 查询课堂视频收藏列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoFavorite:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserVideoFavorite fsUserVideoFavorite)
    {
        startPage();
        List<FsUserVideoFavorite> list = fsUserVideoFavoriteService.selectFsUserVideoFavoriteList(fsUserVideoFavorite);
        return getDataTable(list);
    }

    /**
     * 导出课堂视频收藏列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoFavorite:export')")
    @Log(title = "课堂视频收藏", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserVideoFavorite fsUserVideoFavorite)
    {
        List<FsUserVideoFavorite> list = fsUserVideoFavoriteService.selectFsUserVideoFavoriteList(fsUserVideoFavorite);
        ExcelUtil<FsUserVideoFavorite> util = new ExcelUtil<FsUserVideoFavorite>(FsUserVideoFavorite.class);
        return util.exportExcel(list, "课堂视频收藏数据");
    }

    /**
     * 获取课堂视频收藏详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoFavorite:query')")
    @GetMapping(value = "/{favoriteId}")
    public AjaxResult getInfo(@PathVariable("favoriteId") Long favoriteId)
    {
        return AjaxResult.success(fsUserVideoFavoriteService.selectFsUserVideoFavoriteByFavoriteId(favoriteId));
    }

    /**
     * 新增课堂视频收藏
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoFavorite:add')")
    @Log(title = "课堂视频收藏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserVideoFavorite fsUserVideoFavorite)
    {
        return toAjax(fsUserVideoFavoriteService.insertFsUserVideoFavorite(fsUserVideoFavorite));
    }

    /**
     * 修改课堂视频收藏
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoFavorite:edit')")
    @Log(title = "课堂视频收藏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserVideoFavorite fsUserVideoFavorite)
    {
        return toAjax(fsUserVideoFavoriteService.updateFsUserVideoFavorite(fsUserVideoFavorite));
    }

    /**
     * 删除课堂视频收藏
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoFavorite:remove')")
    @Log(title = "课堂视频收藏", businessType = BusinessType.DELETE)
	@DeleteMapping("/{favoriteIds}")
    public AjaxResult remove(@PathVariable Long[] favoriteIds)
    {
        return toAjax(fsUserVideoFavoriteService.deleteFsUserVideoFavoriteByFavoriteIds(favoriteIds));
    }
}
