added functional favorites posts

This commit is contained in:
SlimusMinus
2026-08-24 00:48:22 +03:00
parent e68d9910de
commit fe6e98170b
5 changed files with 64 additions and 20 deletions

View File

@@ -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()));