added functional favorites posts
This commit is contained in:
@@ -325,7 +325,7 @@ public class PostService {
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Long, Long> countLikes(List<Long> postIds) {
|
||||
public Map<Long, Long> countLikes(List<Long> postIds) {
|
||||
if (postIds.isEmpty()) {
|
||||
return Map.of();
|
||||
}
|
||||
@@ -340,7 +340,7 @@ public class PostService {
|
||||
* Возвращает id постов, лайкнутых текущим пользователем, либо пустой набор,
|
||||
* если пользователь не авторизован.
|
||||
*/
|
||||
private Set<Long> currentUserFavoriteIds(List<Long> postIds) {
|
||||
public Set<Long> currentUserFavoriteIds(List<Long> postIds) {
|
||||
if (postIds.isEmpty()) {
|
||||
return Set.of();
|
||||
}
|
||||
@@ -360,7 +360,7 @@ public class PostService {
|
||||
}
|
||||
}
|
||||
|
||||
private PostResponse toResponse(Post post, Map<Long, Long> likeCounts, Set<Long> userFavoriteIds, boolean includeUserRole) {
|
||||
public PostResponse toResponse(Post post, Map<Long, Long> likeCounts, Set<Long> userFavoriteIds, boolean includeUserRole) {
|
||||
PostResponse response = mapper.toResponse(post);
|
||||
response.setLikeCount(likeCounts.getOrDefault(post.getId(), 0L));
|
||||
response.setFavorite(userFavoriteIds.contains(post.getId()));
|
||||
|
||||
Reference in New Issue
Block a user