1.add comment for filter query page

main
Gary 9 months ago
parent 0a495a922f
commit f9086e7deb

@ -1,12 +1,8 @@
package com.luoo.music.service;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
@ -14,36 +10,30 @@ import javax.persistence.criteria.Root;
import api.Result;
import constants.Constants;
import enums.CollectTypeEnum;
import enums.JournalPublishEnum;
import enums.JournalStatusEnum;
import net.oschina.j2cache.CacheChannel;
import net.oschina.j2cache.CacheObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import util.IdWorker;
import util.StringTools;
import com.luoo.music.dao.CommentDao;
import com.luoo.music.dao.JournalDao;
import com.luoo.music.dao.JournalSongDao;
import com.luoo.music.dao.JournalTagDao;
import com.luoo.music.dao.TagDao;
import com.luoo.music.dto.mapper.CommentMapper;
import com.luoo.music.dto.mapper.JournalMapper;
import com.luoo.music.dto.request.JournalQueryReq;
import com.luoo.music.dto.response.CommentDTO;
import com.luoo.music.dto.response.JournalFilterDTO;
import com.luoo.music.dto.response.JournalRespDTO;
import com.luoo.music.dto.response.SearchCategoryDTO;
import com.luoo.music.dto.response.TagDTO;
import com.luoo.music.pojo.Journal;
import com.luoo.music.pojo.Tag;
@ -359,9 +349,22 @@ public class JournalService {
if(StringTools.isEmpty(queryReq.getCategoryId())&&StringTools.isEmpty(queryReq.getJournalNoRange())) {
return (List<JournalRespDTO>) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString(), key -> getJournalRespDTOWithComment(queryReq) , true).getValue() ;
}
return (List<JournalRespDTO>) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString(), key -> getJournalRespDTO(queryReq) , true).getValue() ;
List<JournalRespDTO> list= (List<JournalRespDTO>) this.cacheChannel.get(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE, queryReq.toString(), key -> getJournalRespDTO(queryReq) , true).getValue() ;
list.parallelStream().forEach(j->{
updateComment(j);
});
return list;
}
private void updateComment(JournalRespDTO journalRespDTO) {
CommentDTO commentDTO = CommentMapper.getCommentDTO(journalRespDTO.getId(), mongoTemplate, commentDao,
redisTemplate);
journalRespDTO.setCommentList(commentDTO.getCommentList());
journalRespDTO.setTotalCommentReply(commentDTO.getTotalCommentReply());
journalRespDTO.setTotalCommentReplyInt(commentDTO.getTotalCommentReplyInt());
}
private List<JournalRespDTO> getJournalRespDTO(JournalQueryReq queryReq) {
List<Journal> pageList = queryPage(queryReq);
return pageList.stream().map(a ->

Loading…
Cancel
Save