diff --git a/server/src/main/java/com/talkka/server/bookmark/controller/BookmarkController.java b/server/src/main/java/com/talkka/server/bookmark/controller/BookmarkController.java index fb52d278..eda4cfcb 100644 --- a/server/src/main/java/com/talkka/server/bookmark/controller/BookmarkController.java +++ b/server/src/main/java/com/talkka/server/bookmark/controller/BookmarkController.java @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -23,6 +24,7 @@ import com.talkka.server.oauth.domain.OAuth2UserInfo; import com.talkka.server.review.exception.ContentAccessException; +import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @RestController @@ -58,7 +60,7 @@ public ResponseEntity getBookmark(@AuthenticationPrincipal OAuth2UserInfo oAu @PostMapping("") @Secured({"USER", "ADMIN"}) public ResponseEntity createBookmark(@AuthenticationPrincipal OAuth2UserInfo oAuth2UserInfo, - BookmarkReqDto bookmarkReqDto) { + @RequestBody @Valid BookmarkReqDto bookmarkReqDto) { ResponseEntity response; try { BookmarkRespDto bookmark = bookmarkService.createBookmark(bookmarkReqDto, oAuth2UserInfo.getUserId()); @@ -72,7 +74,7 @@ public ResponseEntity createBookmark(@AuthenticationPrincipal OAuth2UserInfo @PutMapping("{bookmarkId}") @Secured({"USER", "ADMIN"}) public ResponseEntity updateBookmark(@AuthenticationPrincipal OAuth2UserInfo oAuth2UserInfo, - BookmarkReqDto bookmarkReqDto, @PathVariable Long bookmarkId) { + @RequestBody @Valid BookmarkReqDto bookmarkReqDto, @PathVariable Long bookmarkId) { ResponseEntity response; try { BookmarkRespDto bookmark = bookmarkService.updateBookmark(bookmarkReqDto, oAuth2UserInfo.getUserId(), diff --git a/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkReqDto.java b/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkReqDto.java index a15da0c7..f3e5fb93 100644 --- a/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkReqDto.java +++ b/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkReqDto.java @@ -6,8 +6,10 @@ import com.talkka.server.bookmark.dao.BookmarkEntity; import com.talkka.server.user.dao.UserEntity; +import jakarta.validation.constraints.Size; + public record BookmarkReqDto( - String name, + @Size(min = 2, max = 10, message = "북마크 이름의 길이는 2자 이상 10자 미만 입니다.") String name, List details ) { public BookmarkEntity toEntity(UserEntity user) {