144 lines
5.2 KiB
Java
144 lines
5.2 KiB
Java
package com.peanut.modules.sociology.controller;
|
||
|
||
import com.aliyun.tea.TeaException;
|
||
import com.aliyun.teautil.models.RuntimeOptions;
|
||
import com.aliyun.vod20170321.Client;
|
||
import com.aliyun.vod20170321.models.*;
|
||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
import com.peanut.common.utils.R;
|
||
import com.peanut.common.utils.ShiroUtils;
|
||
import com.peanut.common.utils.SpdbUtil;
|
||
import com.peanut.modules.common.dao.CourseCatalogueChapterVideoDao;
|
||
import com.peanut.modules.common.entity.CourseCatalogueChapterEntity;
|
||
import com.peanut.modules.common.entity.CourseCatalogueChapterVideoEntity;
|
||
import com.peanut.modules.common.entity.CourseEntity;
|
||
import com.peanut.modules.common.to.ParamTo;
|
||
import com.peanut.modules.master.service.CourseCatalogueChapterVideoService;
|
||
import com.peanut.modules.sociology.service.CourseCatalogueChapterService;
|
||
import com.peanut.modules.sociology.service.CourseService;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
//import org.bytedeco.javacv.FFmpegFrameGrabber;
|
||
//import org.bytedeco.javacv.FrameGrabber;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.web.bind.annotation.RequestBody;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RestController;
|
||
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
|
||
@Slf4j
|
||
@RestController("sociologyCourse")
|
||
@RequestMapping("sociology/course")
|
||
public class CourseController {
|
||
@Autowired
|
||
private CourseService courseService;
|
||
@Autowired
|
||
private CourseCatalogueChapterService courseCatalogueChapterService;
|
||
@Autowired
|
||
private CourseCatalogueChapterVideoService courseCatalogueChapterVideoService;
|
||
|
||
/**
|
||
* 获取用户最近学习课程列表
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getUserLateCourseList")
|
||
public R getUserLateCourseList(){
|
||
ParamTo param = new ParamTo();
|
||
Integer userId = ShiroUtils.getUId();
|
||
param.setId(userId);
|
||
List<CourseEntity> userLateCourseList = courseService.getUserLateCourseList(param);
|
||
return R.ok().put("page",userLateCourseList);
|
||
}
|
||
|
||
/**
|
||
* 获取营销标签下的课程列表
|
||
* @param param
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getMarketCourseList")
|
||
public R getMarketCourseList(@RequestBody ParamTo param){
|
||
Page<CourseEntity> marketCourseList = courseService.getMarketCourseList(param);
|
||
return R.ok().put("courseList",marketCourseList);
|
||
}
|
||
|
||
/**
|
||
* 获取国学标签下的课程列表
|
||
* @param param
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getSociologyCourseList")
|
||
public R getSociologyCourseList(@RequestBody ParamTo param){
|
||
Page sociologyCourseList = courseService.getSociologyCourseList(param);
|
||
return R.ok().put("courses",sociologyCourseList);
|
||
}
|
||
|
||
/**
|
||
* 获取课程目录章节详情
|
||
* @param param
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getCourseCatalogueChapterDetail")
|
||
public R getCourseCatalogueChapterDetail(@RequestBody ParamTo param){
|
||
Map<String, Object> chapterDetail = courseCatalogueChapterService.getChapterDetail(param.getId());
|
||
return R.ok().put("data",chapterDetail);
|
||
}
|
||
|
||
/**
|
||
* 获取课程详情
|
||
* @param param
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getCourseDetail")
|
||
public R getCourseDetail(@RequestBody ParamTo param){
|
||
Map<String, Object> courseDetail = courseService.getCourseDetail(param.getId());
|
||
return R.ok().put("data",courseDetail);
|
||
}
|
||
|
||
/**
|
||
* 获取课程目录章节条目列表
|
||
* @param param
|
||
* @return
|
||
*/
|
||
@RequestMapping("/getCourseCatalogueChapterList")
|
||
public R getCourseCatalogueChapterList(@RequestBody ParamTo param){
|
||
List<CourseCatalogueChapterEntity> courseCatalogueChapterList = courseCatalogueChapterService.getCourseCatalogueChapterList(param.getId());
|
||
return R.ok().put("chapterList",courseCatalogueChapterList);
|
||
}
|
||
|
||
@RequestMapping("/getPlayAuth")
|
||
public R getPlayAuth(@RequestBody Map<String,String> map) throws Exception {
|
||
GetVideoPlayAuthResponse vid = SpdbUtil.getPlayAuth(map.get("vid"));
|
||
String playAuth = vid.getBody().getPlayAuth();
|
||
return R.ok().put("playAuth",playAuth);
|
||
}
|
||
|
||
@RequestMapping("/saveCoursePosition")
|
||
public R saveCoursePosition(@RequestBody Map<String,Integer> map){
|
||
Integer uId = ShiroUtils.getUId();
|
||
Integer videoId = map.get("videoId");
|
||
Integer position = map.get("position");
|
||
courseCatalogueChapterVideoService.saveCoursePosition(uId,videoId,position);
|
||
return R.ok();
|
||
}
|
||
/**
|
||
* 验证video权限,并解决足迹,加密视频签名问题
|
||
* @param video
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
@RequestMapping("/checkVideo")
|
||
public R checkVideo(@RequestBody CourseCatalogueChapterVideoEntity video) throws Exception {
|
||
CourseCatalogueChapterVideoEntity courseCatalogueChapterVideoEntity = courseCatalogueChapterVideoService.checkVideo(video);
|
||
return R.ok().put("video",courseCatalogueChapterVideoEntity);
|
||
}
|
||
|
||
@RequestMapping("/getMyCourse")
|
||
public R getMyCourse(@RequestBody Map<String,Integer> map){
|
||
List<CourseEntity> courses = courseService.getMyCourse(map.get("type"));
|
||
return R.ok().put("courses",courses);
|
||
}
|
||
|
||
}
|