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