Explorar el Código

华为hag接口 bug fix

xushengqiang hace 5 años
padre
commit
3dce496e70

+ 11 - 2
src/main/java/cn/efunbox/audio/impl/hag/HagContentServiceImpl.java

@@ -67,15 +67,24 @@ public class HagContentServiceImpl implements HagContentService {
             hagContents.forEach(content -> contentVOList.add(ContentConverter.contentToContentVO(content)));
         }
 
-        List<ContentVO> contentVOResp = contentVOList.subList(start, start + limit);
 
+        int size = contentVOList.size();
+        if (size < start) {
+            return hagContentResp;
+        }
+        int toIndex = start + limit;
+        if (size < toIndex) {
+            toIndex = size;
+        }
+        List<ContentVO> contentVOResp = contentVOList.subList(start, toIndex);
         Pagination pagination = new Pagination();
-        pagination.setNext(start + limit + "");
+        pagination.setNext(toIndex + "");
         pagination.setTotal(Long.valueOf(contentVOList.size()));
 
 
         hagContentResp.setSource(DateUtil.getDateStr() +"-同步数据");
         hagContentResp.setPagination(pagination);
+
         hagContentResp.setContentItems(contentVOResp);
         return hagContentResp;
     }