fixed controllers
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user