|
|
|
@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import com.luoo.music.pojo.Journal;
|
|
|
|
|
import com.luoo.music.pojo.Tag;
|
|
|
|
@ -135,12 +136,23 @@ public class JournalController {
|
|
|
|
|
return Result.success(new PageResult<JournalRespDTO>(0L, Collections.emptyList()));
|
|
|
|
|
}
|
|
|
|
|
List<Journal> pageList = journalService.orderByField(objectIds);
|
|
|
|
|
Set<String> journalCollectSet = new HashSet<>(objectIds);
|
|
|
|
|
UserLoginDto user = jwtUtil.getUserLoginDto(authorization);
|
|
|
|
|
Set<String> journalCollectSet = getMyCollectSet(user.getUserId(),queryReq.getUserId(),objectIds);
|
|
|
|
|
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 Set<String> getMyCollectSet(String loginUser, String checkUser, List<String> objectIds) {
|
|
|
|
|
if(loginUser.equals(checkUser)) {
|
|
|
|
|
return new HashSet<>(objectIds);
|
|
|
|
|
}
|
|
|
|
|
List<String> myObjectIds=userCollectInfoService.findByUserIdAndCollectTypeAndObjectIdIn(loginUser,CollectTypeEnum.JOURNAL,objectIds);
|
|
|
|
|
if(CollectionUtils.isEmpty(myObjectIds)) {
|
|
|
|
|
return Collections.emptySet();
|
|
|
|
|
}
|
|
|
|
|
return new HashSet<>(myObjectIds);
|
|
|
|
|
}
|
|
|
|
|
private List<String> getObjectIds(CollectQueryReq queryReq) {
|
|
|
|
|
if(null==queryReq.getPageNum()||queryReq.getPageNum()<1||null==queryReq.getPageSize()||queryReq.getPageSize()<1) {
|
|
|
|
|
return userCollectInfoService.findByUserIdAndCollectType(queryReq.getUserId(), CollectTypeEnum.JOURNAL);
|
|
|
|
|