Commit 94585bef authored by liuyang's avatar liuyang

修改推荐课程加载慢的问题

parent 0ca5b5cc
......@@ -236,12 +236,16 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
baseMapper.updateStatusById(model.getId(), model.getStatus());
}
public List<CourseChaperModel> chaperList(Long courseId) {
return chaperList(courseId,true);
}
/**
* 获取课程章节列表
* @param courseId
* @param needCoverUrl
* @return
*/
public List<CourseChaperModel> chaperList(Long courseId) {
public List<CourseChaperModel> chaperList(Long courseId,boolean needCoverUrl) {
List<CourseChaperModel> list = Lists.newArrayList();
List<CourseChapterPO> poList = chapterMapper.selectList(Wrappers.<CourseChapterPO>lambdaQuery().eq(CourseChapterPO::getCourseId, courseId).orderByAsc(CourseChapterPO::getSortNo));
if (CollUtil.isNotEmpty(poList)) {
......@@ -252,7 +256,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
model.setCourseId(po.getCourseId());
model.setSortNo(po.getSortNo());
Long resourceId = po.getResourceId();
setVideoInfo(resourceId, model);
setVideoInfo(resourceId, model,needCoverUrl);
list.add(model);
}
}
......@@ -264,7 +268,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
* @param resourceId
* @param model
*/
private void setVideoInfo(Long resourceId, CourseChaperModel model) {
private void setVideoInfo(Long resourceId, CourseChaperModel model,boolean needCoverUrl) {
ResourcePO resourcePO = resourceService.getById(resourceId);
if (resourcePO != null) {
String videoId = resourcePO.getVideoId();
......@@ -272,6 +276,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
model.setDuration(resourcePO.getVideoDuration());
model.setSize(resourcePO.getSize());
if (needCoverUrl){
try {
GetVideoInfoResponse response = aliyunService.getVideoInfo(videoId);
GetVideoInfoResponse.Video videoInfo = response.getVideo();
......@@ -285,7 +290,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
} catch (ClientException e) {
log.error(e.getMessage(), e);
}
}
}
}
......@@ -624,7 +629,7 @@ public class CourseService extends ServiceImpl<CourseMapper, CoursePO> {
for (SearchCourseResultModel recommend : list){
List<CourseTagsModel> tagList = tagService.findListByCourseId(recommend.getCourseId());
recommend.setTags(tagList);
List<CourseChaperModel> chaperList = chaperList(recommend.getCourseId());
List<CourseChaperModel> chaperList = chaperList(recommend.getCourseId(),false);
if (CollUtil.isNotEmpty(chaperList)){
CourseChaperModel chaperModel = chaperList.get(0);
ResourcePO resourcePO = resourceService.getById(chaperModel.getResourceId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment