Skip to content

Commit

Permalink
fix: bookmark controller @RequestBody / @Valid
Browse files Browse the repository at this point in the history
  • Loading branch information
JuneParkCode committed Aug 23, 2024
1 parent 6d75eda commit 223f81c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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());
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BookmarkDetailReqDto> details
) {
public BookmarkEntity toEntity(UserEntity user) {
Expand Down

0 comments on commit 223f81c

Please sign in to comment.