added find post by id on map
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user