Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.PARAMETER})
@Target(ElementType.METHOD)
public @interface AssignUserId {
boolean required() default true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ public ResponseEntity<ResponseBody<Page<GuestbookResponseDto>>> getMyGuestbooks(
}
)
@AssignUserId
@PatchMapping("/{kakaoPlaceId}")
@PatchMapping
@PreAuthorize("isAuthenticated()")
public ResponseEntity<ResponseBody<Void>> updatePartial(
@Parameter(hidden = true) Long userId,
@PathVariable String kakaoPlaceId,
@RequestBody GuestbookRequestDto requestDto
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ public ResponseEntity<ResponseBody<Page<GuestbookResponseDto>>> getMyGuestbooks(
}

@AssignUserId
@PatchMapping("/{kakaoPlaceId}")
@PatchMapping
@PreAuthorize("isAuthenticated()")
public ResponseEntity<ResponseBody<Void>> updatePartial(
Long userId,
@PathVariable String kakaoPlaceId,
@RequestBody GuestbookRequestDto requestDto
) {
guestbookService.updatePartial(userId, kakaoPlaceId, requestDto);
guestbookService.updatePartial(userId, requestDto);
return ResponseEntity.ok(ResponseUtil.createSuccessResponse());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public Page<GuestbookResponseDto> getByUserId(Long userId, Pageable pageable) {
}

@Transactional
public void updatePartial(Long userId, String kakaoPlaceId, GuestbookRequestDto dto) {
Guestbook guestbook = guestbookRepository.findByKakaoPlaceIdAndUserId(kakaoPlaceId, userId)
public void updatePartial(Long userId, GuestbookRequestDto dto) {
Guestbook guestbook = guestbookRepository.findByKakaoPlaceIdAndUserId(dto.kakaoPlaceId(), userId)
.orElseThrow(() -> new BusinessException(ExceptionType.GUEST_BOOK_NOT_FOUND));
guestbook.updatePartial(dto.restaurantName(), dto.kakaoPlaceId(), dto.content(), dto.rating());
}
Expand Down