时长信息转到video主体 增加多线程获取时间方法
This commit is contained in:
@@ -17,6 +17,8 @@ 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;
|
||||
@@ -112,12 +114,13 @@ public class CourseController {
|
||||
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 null;
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 验证video权限,并解决足迹,加密视频签名问题
|
||||
|
||||
@@ -38,4 +38,6 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl<CourseCatalog
|
||||
flag.put("videos",courseCatalogueChapterVideoEntities);
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service("sociologyCourseService")
|
||||
@@ -30,6 +31,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
private CourseCatalogueDao courseCatalogueDao;
|
||||
@Autowired
|
||||
private UserCourseBuyDao userCourseBuyDao;
|
||||
@Autowired
|
||||
private CourseCatalogueChapterDao courseCatalogueChapterDao;
|
||||
@Autowired
|
||||
private CourseCatalogueChapterVideoDao courseCatalogueChapterVideoDao;
|
||||
@Autowired
|
||||
private UserCourseVideoPositionDao userCourseVideoPositionDao;
|
||||
|
||||
|
||||
//根据标签获取课程列表
|
||||
@@ -77,15 +84,37 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
||||
@Override
|
||||
public Map<String, Object> getCourseDetail(Integer id) {
|
||||
Map<String, Object> flag = new HashMap<>();
|
||||
//基础信息
|
||||
CourseEntity course = this.getById(id);
|
||||
flag.put("course",course);
|
||||
//目录信息
|
||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(new LambdaQueryWrapper<CourseCatalogueEntity>().eq(CourseCatalogueEntity::getCourseId, id));
|
||||
Integer uId = ShiroUtils.getUId();
|
||||
for (CourseCatalogueEntity c :courseCatalogueEntities){
|
||||
Integer integer = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>().eq(UserCourseBuyEntity::getUserId, uId).eq(UserCourseBuyEntity::getCatalogueId, c.getId()));
|
||||
c.setIsBuy(integer>0?1:0);
|
||||
c.setCompletion(catalogueCompletion(c));
|
||||
}
|
||||
flag.put("catalogues",courseCatalogueEntities);
|
||||
return flag;
|
||||
}
|
||||
|
||||
private Integer catalogueCompletion(CourseCatalogueEntity c){
|
||||
List<CourseCatalogueChapterEntity> courseCatalogueChapterEntities = courseCatalogueChapterDao.selectList(new LambdaQueryWrapper<CourseCatalogueChapterEntity>().eq(CourseCatalogueChapterEntity::getCatalogueId, c.getId()));
|
||||
Integer act = 0;
|
||||
for (CourseCatalogueChapterEntity cc : courseCatalogueChapterEntities){
|
||||
List<CourseCatalogueChapterVideoEntity> courseCatalogueChapterVideoEntities = courseCatalogueChapterVideoDao.selectList(new LambdaQueryWrapper<CourseCatalogueChapterVideoEntity>().eq(CourseCatalogueChapterVideoEntity::getChapterId, cc.getId()));
|
||||
List<Integer> collect = courseCatalogueChapterVideoEntities.stream().map(CourseCatalogueChapterVideoEntity::getId).collect(Collectors.toList());
|
||||
if(collect.size()==0){
|
||||
continue;
|
||||
}
|
||||
Integer integer = userCourseVideoPositionDao.selectCount(new LambdaQueryWrapper<UserCourseVideoPositionEntity>().eq(UserCourseVideoPositionEntity::getUserId, ShiroUtils.getUId()).in(UserCourseVideoPositionEntity::getVideoId, collect));
|
||||
if (integer>0){
|
||||
act++;
|
||||
}
|
||||
}
|
||||
return courseCatalogueChapterEntities.size()==0?0:act * 100 / courseCatalogueChapterEntities.size();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user