Skip to content

Commit

Permalink
add update review
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinaMoon123 committed Dec 2, 2024
1 parent 94bd80e commit 94de93b
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@RestController
Expand Down Expand Up @@ -76,7 +78,10 @@ public ResponseEntity<?> addReview(

try {
Review savedReview = reviewService.addReview(lakeId, user.getId(), review.getMessage(), review.getStars());
return ResponseEntity.ok(savedReview);
Map<String, Object> response = new HashMap<>();
response.put("review", savedReview); // Добавляем отзыв в ответ
response.put("lake", lake.get());
return ResponseEntity.ok(response);
} catch (RuntimeException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); // Ответ 400 в случае ошибки
}
Expand Down

0 comments on commit 94de93b

Please sign in to comment.