Skip to content

Commit

Permalink
KKUMI-118 [FEATURE] #73 postId 없이 좋아요 요청시 예외처리
Browse files Browse the repository at this point in the history
기존: 500 서버 에러로 내려감
변경후: postId가 null이면 안된다는 메시지 내려감
  • Loading branch information
eekrwl committed Nov 8, 2024
1 parent 2a5eb90 commit b3e6541
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.swmarastro.mykkumiserver.auth.annotation.RequiresLogin;
import com.swmarastro.mykkumiserver.like.dto.LikesRequest;
import com.swmarastro.mykkumiserver.user.User;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -20,14 +21,14 @@ public class LikesController {

@RequiresLogin
@PostMapping("/like")
public ResponseEntity<Void> like(@Login User user, @RequestBody LikesRequest request) {
public ResponseEntity<Void> like(@Login User user, @Valid @RequestBody LikesRequest request) {
likeService.like(user, request.getPostId());
return ResponseEntity.ok().build();
}

@RequiresLogin
@PostMapping("/unlike")
public ResponseEntity<Void> unlike(@Login User user, @RequestBody LikesRequest request) {
public ResponseEntity<Void> unlike(@Login User user, @Valid @RequestBody LikesRequest request) {
likeService.unlike(user, request.getPostId());
return ResponseEntity.ok().build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.swmarastro.mykkumiserver.like.dto;

import jakarta.validation.constraints.NotNull;
import lombok.Getter;

@Getter
public class LikesRequest {

@NotNull
private Long postId;
}

0 comments on commit b3e6541

Please sign in to comment.