fixed controllers

This commit is contained in:
SlimusMinus
2026-07-31 01:08:53 +03:00
parent 74f7c88843
commit 2468c26b84
32 changed files with 536 additions and 432 deletions

View File

@@ -15,25 +15,24 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/api/v1/reviews")
@RequiredArgsConstructor
@Slf4j
public class ReviewsController {
private final ReviewService reviewService;
@GetMapping
public List<ReviewResponseDto> getAllReviews() {
List<ReviewResponseDto> allReviews = reviewService.getAllReviews();
log.info("Got all reviews: {}", allReviews);
return allReviews;
log.info("get all reviews");
return reviewService.getAllReviews();
}
@PostMapping
@PreAuthorize("isAuthenticated()")
public ReviewResponseDto createReview(@Valid @RequestBody ReviewRequestDto request, Authentication authentication) {
// Взять имя пользователя из authentication
log.info("user {} create review {}", authentication.getName(), request);
return reviewService.createReview(request, authentication.getName());
}
}