Review Controller UUID

This commit is contained in:
Tim
2025-06-05 14:35:15 +02:00
parent d312495ae5
commit 07d8446cd0
4 changed files with 7 additions and 7 deletions

View File

@@ -3,7 +3,6 @@ package de.htwsaar.webshop.controller;
import de.htwsaar.webshop.repository.entities.Review;
import de.htwsaar.webshop.service.ArticleService;
import de.htwsaar.webshop.service.ReviewService;
import de.htwsaar.webshop.service.ValidatorService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,9 +31,9 @@ public class ReviewController {
@RequestMapping(path = REVIEW_GET_ALL, method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<List<Review>> getAll(HttpServletRequest request,
@RequestParam(value = PARAM_ARTICLE_ID) Long articleId) {
@RequestParam(value = PARAM_UUID) UUID uuid) {
logRequest(request);
List<Review> review = reviewService.getAllByArticleId(articleId);
List<Review> review = reviewService.getAllByUUID(uuid);
if(review.isEmpty()) {
return ResponseEntity.noContent().build();
}

View File

@@ -1,6 +1,7 @@
package de.htwsaar.webshop.repository;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;
import org.springframework.data.jpa.repository.JpaRepository;
@@ -14,5 +15,5 @@ import jakarta.validation.constraints.Positive;
public interface ReviewRepository extends JpaRepository<Review, Long> {
Stream<Review> streamReviewsByArticleId(@NotNull @Positive Long id);
List<Review> getReviewsByArticleId(Long articleId);
List<Review> getReviewsByArticle_Uuid(UUID articleUuid);
}

View File

@@ -10,5 +10,5 @@ public interface ReviewService {
Review save(UUID articleUuid, int rating, String content);
void delete(Long reviewId);
Review getReviewById(Long id);
List<Review> getAllByArticleId(Long articleId);
List<Review> getAllByUUID(UUID uuid);
}

View File

@@ -48,7 +48,7 @@ public class ReviewServiceImpl implements ReviewService {
}
@Override
public List<Review> getAllByArticleId(Long articleId) {
return reviewRepository.getReviewsByArticleId(articleId);
public List<Review> getAllByUUID(UUID uuid) {
return reviewRepository.getReviewsByArticle_Uuid(uuid);
}
}