|
@@ -5,6 +5,7 @@ import cn.efunbox.audio.entity.hag.HagContent;
|
|
|
import cn.efunbox.audio.repository.hag.HagAlbumRepository;
|
|
|
import cn.efunbox.audio.repository.hag.HagContentRepository;
|
|
|
import cn.efunbox.audio.service.hag.HagContentService;
|
|
|
+import cn.efunbox.audio.utils.DateUtil;
|
|
|
import cn.efunbox.audio.vo.hag.*;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -31,26 +32,51 @@ public class HagContentServiceImpl implements HagContentService {
|
|
|
@Override
|
|
|
public HagBaseResp list(HagContentReq hagContentReq) {
|
|
|
|
|
|
- List<HagAlbum> hagAlbums = hagAlbumRepository.findAll();
|
|
|
+ Pagination paginationReq = hagContentReq.getPagination();
|
|
|
+ Integer limit = paginationReq.getLimit();
|
|
|
+ if (Objects.isNull(limit)) {
|
|
|
+ limit = 10;
|
|
|
+ }
|
|
|
+ if (limit > 1000) {
|
|
|
+ limit = 1000;
|
|
|
+ }
|
|
|
+ Integer start = paginationReq.getStart();
|
|
|
+ if (Objects.isNull(start)) {
|
|
|
+ start = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ HagContentResp hagContentResp = new HagContentResp();
|
|
|
+
|
|
|
+ String updateTime = hagContentReq.getTimestamp();
|
|
|
+ Date date = DateUtil.strToDate(updateTime);
|
|
|
+ if (Objects.isNull(date)) {
|
|
|
+ hagContentResp.setErrorCode("400");
|
|
|
+ hagContentResp.setErrorMessage("timestamp数据异常");
|
|
|
+ return hagContentResp;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<HagAlbum> hagAlbums = hagAlbumRepository.findByGmtModifiedAfter(date);
|
|
|
|
|
|
List<ContentVO> contentVOList = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(hagAlbums)) {
|
|
|
hagAlbums.forEach(album -> contentVOList.add(AlbumConverter.albumToContentVO(album)));
|
|
|
}
|
|
|
|
|
|
- List<HagContent> hagContents = hagContentRepository.findAll();
|
|
|
+ List<HagContent> hagContents = hagContentRepository.findByGmtModifiedAfter(date);
|
|
|
if (!CollectionUtils.isEmpty(hagContents)) {
|
|
|
hagContents.forEach(content -> contentVOList.add(ContentConverter.contentToContentVO(content)));
|
|
|
}
|
|
|
|
|
|
+ List<ContentVO> contentVOResp = contentVOList.subList(start, start + limit);
|
|
|
+
|
|
|
Pagination pagination = new Pagination();
|
|
|
- pagination.setNext("1");
|
|
|
+ pagination.setNext(start + limit + "");
|
|
|
pagination.setTotal(Long.valueOf(contentVOList.size()));
|
|
|
|
|
|
- HagContentResp hagContentResp = new HagContentResp();
|
|
|
- hagContentResp.setSource("test");
|
|
|
+
|
|
|
+ hagContentResp.setSource(DateUtil.getDateStr() +"-同步数据");
|
|
|
hagContentResp.setPagination(pagination);
|
|
|
- hagContentResp.setContentItems(contentVOList);
|
|
|
+ hagContentResp.setContentItems(contentVOResp);
|
|
|
return hagContentResp;
|
|
|
}
|
|
|
|