added find post by id on map

This commit is contained in:
SlimusMinus
2026-08-27 01:31:50 +03:00
parent c85a321f24
commit ddebb5cf93
2 changed files with 17 additions and 0 deletions

View File

@@ -381,4 +381,15 @@ public class PostService {
throw new ApiException(ErrorCode.VALIDATION_ERROR, "Некорректный формат existingImages", HttpStatus.BAD_REQUEST);
}
}
public PostResponse getPostOnMapById(Long postId) {
Post post = postRepository.findById(postId)
.orElseThrow(() -> new ApiException(ErrorCode.NOT_FOUND, "Post not found", HttpStatus.NOT_FOUND));
List<Long> postIds = List.of(postId);
Map<Long, Long> likeCounts = countLikes(postIds);
Set<Long> userFavoriteIds = currentUserFavoriteIds(postIds);
return toResponse(post, likeCounts, userFavoriteIds, true);
}
}