package com.fs.app.controller;

import com.fs.common.core.domain.ResponseResult;
import com.fs.course.param.newfs.FsUserCourseListParam;
import com.fs.course.param.newfs.UserCourseVideoPageParam;
import com.fs.course.service.IFsUserCourseService;
import com.fs.course.service.IFsUserCourseVideoService;
import com.fs.course.vo.newfs.FsUserCourseListVO;
import com.fs.course.vo.newfs.FsUserCourseVideoDetailsVO;
import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
import com.fs.course.vo.newfs.FsUserVideoListVO;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api("课程库相关接口")
@RestController
@RequestMapping("/app/fs/course")
@Slf4j
public class FsUserCourseVideoController extends AppBaseController {

    @Autowired
    private IFsUserCourseVideoService fsUserCourseVideoService;

    @Autowired
    private IFsUserCourseService fsUserCourseService;

    @GetMapping("/pageList")
    @ApiOperation("课程分页列表")
    public ResponseResult<PageInfo<FsUserCourseVideoPageListVO>> list(UserCourseVideoPageParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        param.setCompanyId(getCompanyId());
        List<FsUserCourseVideoPageListVO> list = fsUserCourseVideoService.pageListCourseVideo(param);
        PageInfo<FsUserCourseVideoPageListVO> pageInfo = new PageInfo<>(list);
        return ResponseResult.ok(pageInfo);
    }

    @ApiOperation("课程视频详情")
    @GetMapping(value = "/videoDetails")
    public ResponseResult<FsUserCourseVideoDetailsVO> getVideoDetails(Long videoId) {
        return fsUserCourseVideoService.getVideoDetails(videoId);
    }

    @GetMapping("/courseList")
    @ApiOperation("获取课程下拉列表")
    public ResponseResult<PageInfo<FsUserCourseListVO>> getAllCourseList(FsUserCourseListParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        param.setCompanyId(getCompanyId());
        List<FsUserCourseListVO> fsUserCourseList = fsUserCourseService.getFsUserCourseList(param);
        PageInfo<FsUserCourseListVO> pageInfo = new PageInfo<>(fsUserCourseList);
        return ResponseResult.ok(pageInfo);
    }

    @GetMapping("/videoList")
    @ApiOperation("获取视频下拉列表")
    public ResponseResult<PageInfo<FsUserVideoListVO>> getAllVideoList(UserCourseVideoPageParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        param.setCompanyId(getCompanyId());
        List<FsUserVideoListVO> listCourseVideo = fsUserCourseVideoService.getListCourseVideo(param);
        PageInfo<FsUserVideoListVO> result = new PageInfo<>(listCourseVideo);
        return ResponseResult.ok(result);
    }
}
