|
|
|
@ -91,21 +91,16 @@ public class JournalController {
|
|
|
|
|
|
|
|
|
|
if(StringTools.isEmpty(queryReq.getCategoryId())&&StringTools.isEmpty(queryReq.getJournalNoRange())) {
|
|
|
|
|
List<JournalRespDTO> cacheList = getPagableJournalRespDTO(queryReq,journalCollectSet);
|
|
|
|
|
List<String> ids=cacheList.stream().map(JournalRespDTO::getId).collect(Collectors.toList());
|
|
|
|
|
Map<String,List<String>> tagMap=tagService.getTagMap(ids);
|
|
|
|
|
List<JournalRespDTO> list = cacheList.stream().map(j->updateCollectAndTag(j,journalCollectSet,tagMap)).collect(Collectors.toList());
|
|
|
|
|
List<JournalRespDTO> list = cacheList.stream().map(j->updateCollectAndTag(j,journalCollectSet)).collect(Collectors.toList());
|
|
|
|
|
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Journal> pageList = journalService.queryPage(queryReq);
|
|
|
|
|
List<String> ids=pageList.stream().map(Journal::getId).collect(Collectors.toList());
|
|
|
|
|
Map<String,List<String>> tagMap=tagService.getTagMap(ids);
|
|
|
|
|
List<JournalRespDTO> list = pageList.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet,tagMap)).collect(Collectors.toList());
|
|
|
|
|
List<JournalRespDTO> list = pageList.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
|
|
|
|
|
}
|
|
|
|
|
private JournalRespDTO updateCollectAndTag(JournalRespDTO journalRespDTO,Set<String> journalCollectSet, Map<String, List<String>> tagMap) {
|
|
|
|
|
journalRespDTO.setTags(tagMap.getOrDefault(journalRespDTO.getId(), Collections.emptyList()));
|
|
|
|
|
private JournalRespDTO updateCollectAndTag(JournalRespDTO journalRespDTO,Set<String> journalCollectSet) {
|
|
|
|
|
journalRespDTO.setHaveCollect(journalCollectSet.contains(journalRespDTO.getId()));
|
|
|
|
|
return journalRespDTO;
|
|
|
|
|
}
|
|
|
|
@ -115,10 +110,7 @@ public class JournalController {
|
|
|
|
|
List<JournalRespDTO> journalRespDTOs = (List<JournalRespDTO>)redisTemplate.opsForValue().get(redisPageJournalResponseDtoKey);
|
|
|
|
|
if(null==journalRespDTOs) {
|
|
|
|
|
List<Journal> pageList = journalService.queryPage(queryReq);
|
|
|
|
|
List<String> ids=pageList.stream().map(Journal::getId).collect(Collectors.toList());
|
|
|
|
|
Map<String,List<String>> tagMap=tagService.getTagMap(ids);
|
|
|
|
|
|
|
|
|
|
journalRespDTOs = pageList.stream().map(journal -> JournalMapper.getJournalRespDTO(journal, journalCollectSet,mongoTemplate,redisTemplate,commentDao,tagMap)).collect(Collectors.toList());
|
|
|
|
|
journalRespDTOs = pageList.stream().map(journal -> JournalMapper.getJournalRespDTO(journal, journalCollectSet,mongoTemplate,redisTemplate,commentDao)).collect(Collectors.toList());
|
|
|
|
|
redisTemplate.opsForValue().set(redisPageJournalResponseDtoKey,journalRespDTOs);
|
|
|
|
|
}
|
|
|
|
|
return journalRespDTOs;
|
|
|
|
@ -150,8 +142,7 @@ public class JournalController {
|
|
|
|
|
}
|
|
|
|
|
List<Journal> pageList = journalService.orderByField(objectIds);
|
|
|
|
|
Set<String> journalCollectSet = new HashSet<>(objectIds);
|
|
|
|
|
Map<String,List<String>> tagMap=tagService.getTagMap(objectIds);
|
|
|
|
|
List<JournalRespDTO> list = pageList.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet,tagMap))
|
|
|
|
|
List<JournalRespDTO> list = pageList.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
return Result.success(new PageResult<JournalRespDTO>(Long.valueOf(list.size()), list));
|
|
|
|
|
}
|
|
|
|
@ -167,8 +158,7 @@ public class JournalController {
|
|
|
|
|
return Result.unauthorized(null);
|
|
|
|
|
}
|
|
|
|
|
Journal journal = journalService.findById(id);
|
|
|
|
|
Map<String,List<String>> tagMap=tagService.getTagMap(Arrays.asList(id));
|
|
|
|
|
JournalRespDTO journalRespDTO=JournalMapper.getJournalRespDTO(journal, Collections.emptySet(),mongoTemplate,redisTemplate,commentDao,tagMap);
|
|
|
|
|
JournalRespDTO journalRespDTO=JournalMapper.getJournalRespDTO(journal, Collections.emptySet(),mongoTemplate,redisTemplate,commentDao);
|
|
|
|
|
boolean isCollect=null == user ? false:userCollectInfoService.isCollect(user.getUserId(),id, CollectTypeEnum.JOURNAL);
|
|
|
|
|
journalRespDTO.setHaveCollect(isCollect);
|
|
|
|
|
return Result.success(journalRespDTO);
|
|
|
|
@ -215,8 +205,7 @@ public class JournalController {
|
|
|
|
|
List<String> ids=journals.stream().map(Journal::getId).collect(Collectors.toList());
|
|
|
|
|
Set<String> journalCollectSet = null == user ? Collections.emptySet()
|
|
|
|
|
: userCollectInfoService.getCollectSet(user.getUserId(),ids, CollectTypeEnum.JOURNAL);
|
|
|
|
|
Map<String,List<String>> tagMap=tagService.getTagMap(ids);
|
|
|
|
|
List<JournalRespDTO> list = journals.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet,tagMap))
|
|
|
|
|
List<JournalRespDTO> list = journals.stream().map(a -> JournalMapper.getJournalRespDTO(a, journalCollectSet))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return Result.success(list);
|
|
|
|
|