Browse Source

fix lesson empty exception

huodongdong 6 years ago
parent
commit
f37e9b6eb4

+ 5 - 0
rankin-product-service/src/main/java/cn/rankin/productservice/service/app/AppLessonService.java

@@ -11,6 +11,7 @@ import cn.rankin.productservice.code.ProductServiceAPICode;
 import cn.rankin.productservice.repository.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -46,6 +47,10 @@ public class AppLessonService {
 
         // get courseware id list
         List<LessonWareRelation> lessonWareRelationList = lessonWareRelationRepository.findByLessonId(lessonId, BaseStatusEnum.NORMAL);
+        if (CollectionUtils.isEmpty(lessonWareRelationList)) {
+            lesson.setWareList(new ArrayList<>());
+            return APIResult.ok(lesson);
+        }
         List<String> wareIdList = new ArrayList<>();
         lessonWareRelationList.forEach(relation -> wareIdList.add(relation.getWareId()));