1313import java .util .UUID ;
1414import lombok .RequiredArgsConstructor ;
1515import org .springframework .security .access .annotation .Secured ;
16- import org .springframework .security .core .context . SecurityContextHolder ;
16+ import org .springframework .security .core .annotation . AuthenticationPrincipal ;
1717import org .springframework .web .bind .annotation .PostMapping ;
1818import org .springframework .web .bind .annotation .RequestMapping ;
1919import org .springframework .web .bind .annotation .RequestPart ;
@@ -33,19 +33,20 @@ public class ReviewCommandApiController {
3333 @ Operation (summary = "리뷰 등록" , description = "리뷰를 등록합니다." )
3434 @ PostMapping (value = "/review" , consumes = MULTIPART_FORM_DATA_VALUE )
3535 public ApiResponse <Long > createReview (
36+ @ AuthenticationPrincipal String userId ,
3637 @ Valid @ RequestPart ("data" ) ReviewCreateRequestDto requestDto ,
3738 @ RequestPart (value = "img_file" , required = false ) MultipartFile image ) {
3839
3940 String imgUrl = imageUploadUseCase .uploadImage (new ImageUploadRequestDto (image ));
4041 return ApiResponse .ok (
4142 201 ,
42- createReviewUseCase .createReview (requestDto , getId (), imgUrl ),
43+ createReviewUseCase .createReview (requestDto , getId (userId ), imgUrl ),
4344 "리뷰 등록 성공"
4445 );
4546 }
4647
47- private static UUID getId () {
48- return UUID .fromString (SecurityContextHolder . getContext (). getAuthentication (). getName () );
48+ private static UUID getId (String id ) {
49+ return UUID .fromString (id );
4950 }
5051
5152}
0 commit comments