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.FsUserVideoView;
import com.fs.course.service.IFsUserVideoViewService;
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/userVideoView")
public class FsUserVideoViewController extends BaseController
{
    @Autowired
    private IFsUserVideoViewService fsUserVideoViewService;

    /**
     * 查询课堂视频观看记录列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoView:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserVideoView fsUserVideoView)
    {
        startPage();
        List<FsUserVideoView> list = fsUserVideoViewService.selectFsUserVideoViewList(fsUserVideoView);
        return getDataTable(list);
    }

    /**
     * 导出课堂视频观看记录列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoView:export')")
    @Log(title = "课堂视频观看记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserVideoView fsUserVideoView)
    {
        List<FsUserVideoView> list = fsUserVideoViewService.selectFsUserVideoViewList(fsUserVideoView);
        ExcelUtil<FsUserVideoView> util = new ExcelUtil<FsUserVideoView>(FsUserVideoView.class);
        return util.exportExcel(list, "课堂视频观看记录数据");
    }

    /**
     * 获取课堂视频观看记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoView:query')")
    @GetMapping(value = "/{viewId}")
    public AjaxResult getInfo(@PathVariable("viewId") Long viewId)
    {
        return AjaxResult.success(fsUserVideoViewService.selectFsUserVideoViewByViewId(viewId));
    }

    /**
     * 新增课堂视频观看记录
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoView:add')")
    @Log(title = "课堂视频观看记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserVideoView fsUserVideoView)
    {
        return toAjax(fsUserVideoViewService.insertFsUserVideoView(fsUserVideoView));
    }

    /**
     * 修改课堂视频观看记录
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoView:edit')")
    @Log(title = "课堂视频观看记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserVideoView fsUserVideoView)
    {
        return toAjax(fsUserVideoViewService.updateFsUserVideoView(fsUserVideoView));
    }

    /**
     * 删除课堂视频观看记录
     */
    @PreAuthorize("@ss.hasPermi('course:userVideoView:remove')")
    @Log(title = "课堂视频观看记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{viewIds}")
    public AjaxResult remove(@PathVariable Long[] viewIds)
    {
        return toAjax(fsUserVideoViewService.deleteFsUserVideoViewByViewIds(viewIds));
    }
}
