瀏覽代碼

华为hag接口 bug fix

xushengqiang 5 年之前
父節點
當前提交
3dce496e70
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11 2
      src/main/java/cn/efunbox/audio/impl/hag/HagContentServiceImpl.java

+ 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;
     }