diff --git a/src/main/java/com/peanut/modules/sociology/service/impl/CourseCatalogueChapterServiceImpl.java b/src/main/java/com/peanut/modules/sociology/service/impl/CourseCatalogueChapterServiceImpl.java index cb2b380e..00a884b1 100644 --- a/src/main/java/com/peanut/modules/sociology/service/impl/CourseCatalogueChapterServiceImpl.java +++ b/src/main/java/com/peanut/modules/sociology/service/impl/CourseCatalogueChapterServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @Slf4j @Service("sociologyCourseCatalogueChapterService") @@ -71,7 +72,10 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl userCourseBuyEntities = userCourseBuyDao.selectList(new LambdaQueryWrapper().eq(UserCourseBuyEntity::getUserId, ShiroUtils.getUId()).eq(UserCourseBuyEntity::getCatalogueId, byId.getCatalogueId())); if (userCourseBuyEntities.size()==1){ flag.put("buy",userCourseBuyEntities.get(0)); @@ -81,4 +85,22 @@ public class CourseCatalogueChapterServiceImpl extends ServiceImpl wrapper = new MPJLambdaWrapper<>(); + wrapper.leftJoin(UserCourseVideoPositionEntity.class,UserCourseVideoPositionEntity::getVideoId,CourseCatalogueChapterVideoEntity::getId); + wrapper.selectAll(CourseCatalogueChapterVideoEntity.class); + wrapper.eq(CourseCatalogueChapterVideoEntity::getChapterId,chapterId); + wrapper.orderByDesc(UserCourseVideoPositionEntity::getUpdateTime); + List courseCatalogueChapterVideoEntities = courseCatalogueChapterVideoDao.selectJoinList(CourseCatalogueChapterVideoEntity.class, wrapper); + if(courseCatalogueChapterVideoEntities.size()>0){ + return courseCatalogueChapterVideoEntities.get(0).getId(); + }else { + List courseCatalogueChapterVideoEntities1 = courseCatalogueChapterVideoDao.selectList(new LambdaQueryWrapper() + .eq(CourseCatalogueChapterVideoEntity::getChapterId, chapterId).orderByAsc(CourseCatalogueChapterVideoEntity::getSort)); + return courseCatalogueChapterVideoEntities1.size()>0?courseCatalogueChapterVideoEntities1.get(0).getId():0; + } + + } + + }