33import com .example .dplus .advice .ErrorCode ;
44import com .example .dplus .advice .ErrorCustomException ;
55import com .example .dplus .dto .Success ;
6+ import com .example .dplus .dto .common .CommonDto .Id ;
67import com .example .dplus .jwt .UserDetailsImpl ;
78import com .example .dplus .service .post .comment .like .PostCommentLikeService ;
89import com .example .dplus .service .post .like .PostAnswerLikeService ;
@@ -22,62 +23,62 @@ public class PostLikeController {
2223 private final PostCommentLikeService postCommentLikeService ;
2324 private final PostAnswerLikeService postAnswerLikeService ;
2425
25- @ PostMapping ("/{post_id} " )
26- public ResponseEntity <Success > doLike (@ PathVariable Long post_id ,
26+ @ PostMapping ("" )
27+ public ResponseEntity <Success > doLike (@ RequestBody Id postId ,
2728 @ AuthenticationPrincipal UserDetailsImpl user ) {
2829 if (user != null ) {
29- postLikeService .doLike (user .getUser (), post_id );
30+ postLikeService .doLike (user .getUser (), postId . getId () );
3031 return new ResponseEntity <>(new Success ("게시물 좋아요 완료" , "" ), HttpStatus .OK );
3132 }
3233 throw new ErrorCustomException (ErrorCode .NO_AUTHENTICATION_ERROR );
3334 }
3435
35- @ PatchMapping ("/{post_id} " )
36- public ResponseEntity <Success > unLike (@ PathVariable Long post_id ,
36+ @ PatchMapping ("" )
37+ public ResponseEntity <Success > unLike (@ RequestBody Id postId ,
3738 @ AuthenticationPrincipal UserDetailsImpl user ) {
3839 if (user != null ) {
39- postLikeService .unLike (user .getUser (), post_id );
40+ postLikeService .unLike (user .getUser (), postId . getId () );
4041 return new ResponseEntity <>(new Success ("게시물 좋아요 취소" , "" ), HttpStatus .OK );
4142 }
4243 throw new ErrorCustomException (ErrorCode .NO_AUTHENTICATION_ERROR );
4344 }
4445
4546 // 코멘트에 대한 like 처리.. postId를 따로 찾지 않아도 되지 않을까.. seq베이스면?
46- @ PostMapping ("/comment/{postComment_id} " )
47- public ResponseEntity <Success > commentDoLike (@ PathVariable Long postComment_id ,
47+ @ PostMapping ("/comment" )
48+ public ResponseEntity <Success > commentDoLike (@ RequestBody Id postCommentId ,
4849 @ AuthenticationPrincipal UserDetailsImpl user ) {
4950 if (user != null ) {
50- postCommentLikeService .doLike (user .getUser (), postComment_id );
51+ postCommentLikeService .doLike (user .getUser (), postCommentId . getId () );
5152 return new ResponseEntity <>(new Success ("게시물 코멘트 좋아요 완료" , "" ), HttpStatus .OK );
5253 }
5354 throw new ErrorCustomException (ErrorCode .NO_AUTHENTICATION_ERROR );
5455 }
5556
56- @ PatchMapping ("/comment/{postComment_id} " )
57- public ResponseEntity <Success > commentUnLike (@ PathVariable Long postComment_id ,
57+ @ PatchMapping ("/comment" )
58+ public ResponseEntity <Success > commentUnLike (@ RequestBody Id postCommentId ,
5859 @ AuthenticationPrincipal UserDetailsImpl user ) {
5960 if (user != null ) {
60- postCommentLikeService .unLike (user .getUser (), postComment_id );
61+ postCommentLikeService .unLike (user .getUser (), postCommentId . getId () );
6162 return new ResponseEntity <>(new Success ("게시물 코멘트 좋아요 취소" , "" ), HttpStatus .OK );
6263 }
6364 throw new ErrorCustomException (ErrorCode .NO_AUTHENTICATION_ERROR );
6465 }
6566
66- @ PostMapping ("/answer/{postAnswer_id} " )
67- public ResponseEntity <Success > answerDoLike (@ PathVariable Long postAnswer_id ,
67+ @ PostMapping ("/answer" )
68+ public ResponseEntity <Success > answerDoLike (@ RequestBody Id postAnswerId ,
6869 @ AuthenticationPrincipal UserDetailsImpl user ) {
6970 if (user != null ) {
70- postAnswerLikeService .answerDoLike (user .getUser (), postAnswer_id );
71+ postAnswerLikeService .answerDoLike (user .getUser (), postAnswerId . getId () );
7172 return new ResponseEntity <>(new Success ("게시물 QnA 답글 좋아요 완료" , "" ), HttpStatus .OK );
7273 }
7374 throw new ErrorCustomException (ErrorCode .NO_AUTHENTICATION_ERROR );
7475 }
7576
76- @ PatchMapping ("/answer/{postAnswer_id} " )
77- public ResponseEntity <Success > answerUnLike (@ PathVariable Long postAnswer_id ,
77+ @ PatchMapping ("/answer" )
78+ public ResponseEntity <Success > answerUnLike (@ RequestBody Id postAnswerId ,
7879 @ AuthenticationPrincipal UserDetailsImpl user ) {
7980 if (user != null ) {
80- postAnswerLikeService .answerUnLike (user .getUser (), postAnswer_id );
81+ postAnswerLikeService .answerUnLike (user .getUser (), postAnswerId . getId () );
8182 return new ResponseEntity <>(new Success ("게시물 QnA 답글 좋아요 취소 완료" , "" ), HttpStatus .OK );
8283 }
8384 throw new ErrorCustomException (ErrorCode .NO_AUTHENTICATION_ERROR );
0 commit comments