Skip to content

Commit da4cae0

Browse files
committed
[FIX] HTTP delete 메서드에 바디를 담을수 없는점, POST,PATCH,DELETE 에 바디를 담아서 꼭 보내야한다는 점 때문에 컨트롤러 대량 수정
1 parent bb4fc5f commit da4cae0

14 files changed

Lines changed: 98 additions & 92 deletions

‎src/main/java/com/example/dplus/controller/account/AccountMyPageController.java‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
import com.example.dplus.dto.Success;
5-
import com.example.dplus.dto.request.AccountRequestDto.AccountMasterPiece;
5+
import com.example.dplus.dto.common.CommonDto.Id;
66
import com.example.dplus.dto.request.AccountRequestDto.UpdateAccountIntro;
77
import com.example.dplus.dto.request.AccountRequestDto.UpdateSpecialty;
88
import com.example.dplus.dto.request.HistoryRequestDto.HistoryUpdateList;
@@ -85,25 +85,25 @@ public ResponseEntity<Success> ArtWorkBookmarkList(@PathVariable Long last_artwo
8585
accountMyPageService.showAccountArtWorkBookMark(last_artwork_id,user)),HttpStatus.OK);
8686
}
8787

88-
@PostMapping("/masterpiece/{artwork_id}")
89-
public ResponseEntity<Success> masterpieceSelect(@PathVariable Long artwork_id,
88+
@PostMapping("/masterpiece")
89+
public ResponseEntity<Success> masterpieceSelect(@RequestBody Id artworkId,
9090
@AuthenticationPrincipal UserDetailsImpl user) {
91-
accountMyPageService.masterAccountCareerFeed(artwork_id,user.getUser());
91+
accountMyPageService.masterAccountCareerFeed(artworkId.getId(),user.getUser());
9292
return new ResponseEntity<>(new Success("포트폴리오 작품 선택/해지",""),HttpStatus.OK);
9393
}
9494

95-
@PatchMapping("/masterpiece/{artwork_id}")
96-
public ResponseEntity<Success> updateMasterpiece(@PathVariable Long artwork_id,
97-
@RequestBody AccountMasterPiece prev_artwork_id,
98-
@AuthenticationPrincipal UserDetailsImpl user) {
99-
accountMyPageService.updateMasterAccountCareerFeed(artwork_id,prev_artwork_id.getPrev_artwork_id(),user.getUser());
100-
return new ResponseEntity<>(new Success("포트폴리오 작품 수정",""),HttpStatus.OK);
101-
}
95+
// @PatchMapping("/masterpiece")
96+
// public ResponseEntity<Success> updateMasterpiece(@RequestBody Id artworkId,
97+
// @RequestBody AccountMasterPiece prev_artwork_id,
98+
// @AuthenticationPrincipal UserDetailsImpl user) {
99+
// accountMyPageService.updateMasterAccountCareerFeed(artworkId.getId(),prev_artwork_id.getPrev_artwork_id(),user.getUser());
100+
// return new ResponseEntity<>(new Success("포트폴리오 작품 수정",""),HttpStatus.OK);
101+
// }
102102

103-
@PostMapping("/hidepiece/{artwork_id}")
104-
public ResponseEntity<Success> hidePieceClear(@PathVariable Long artwork_id,
103+
@PostMapping("/hidepiece")
104+
public ResponseEntity<Success> hidePieceClear(@RequestBody Id artworkId,
105105
@AuthenticationPrincipal UserDetailsImpl user) {
106-
accountMyPageService.hideArtWorkScope(artwork_id,user.getUser());
106+
accountMyPageService.hideArtWorkScope(artworkId.getId(),user.getUser());
107107
return new ResponseEntity<>(new Success("작품 보이기/숨기기",""),HttpStatus.OK);
108108
}
109109

‎src/main/java/com/example/dplus/controller/artwork/ArtWorkBookMarkController.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.example.dplus.advice.ErrorCode;
55
import com.example.dplus.advice.ErrorCustomException;
66
import com.example.dplus.dto.Success;
7+
import com.example.dplus.dto.common.CommonDto.Id;
78
import com.example.dplus.jwt.UserDetailsImpl;
89
import com.example.dplus.service.artwork.bookmark.ArtWorkBookMarkService;
910
import lombok.RequiredArgsConstructor;
@@ -19,21 +20,21 @@ public class ArtWorkBookMarkController {
1920

2021
private final ArtWorkBookMarkService artWorkBookMarkService;
2122

22-
@PostMapping("/artwork/{artwork_id}")
23-
public ResponseEntity<Success> doBookmark(@PathVariable Long artwork_id,
23+
@PostMapping("/artwork")
24+
public ResponseEntity<Success> doBookmark(@RequestBody Id artWorkId,
2425
@AuthenticationPrincipal UserDetailsImpl user) {
2526
if (user != null) {
26-
artWorkBookMarkService.doBookMark(user.getUser(),artwork_id);
27+
artWorkBookMarkService.doBookMark(user.getUser(), artWorkId.getId());
2728
return new ResponseEntity<>(new Success("작품 북마크 성공",""), HttpStatus.OK);
2829
}
2930
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);
3031

3132
}
32-
@PatchMapping("/artwork/{artwork_id}")
33-
public ResponseEntity<Success> unBookmark(@PathVariable Long artwork_id,
33+
@PatchMapping("/artwork")
34+
public ResponseEntity<Success> unBookmark(@RequestBody Id artWorkId,
3435
@AuthenticationPrincipal UserDetailsImpl user) {
3536
if (user != null) {
36-
artWorkBookMarkService.unBookMark(user.getUser(),artwork_id);
37+
artWorkBookMarkService.unBookMark(user.getUser(),artWorkId.getId());
3738
return new ResponseEntity<>(new Success("작품 북마크 해지",""), HttpStatus.OK);
3839
}
3940
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);

‎src/main/java/com/example/dplus/controller/artwork/ArtWorkCommentController.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.example.dplus.advice.ErrorCode;
55
import com.example.dplus.advice.ErrorCustomException;
66
import com.example.dplus.dto.Success;
7+
import com.example.dplus.dto.common.CommonDto.Id;
78
import com.example.dplus.dto.request.ArtWorkRequestDto.ArtWorkComment;
89
import com.example.dplus.jwt.UserDetailsImpl;
910
import com.example.dplus.service.artwork.comment.ArtWorkCommentService;
@@ -38,10 +39,10 @@ public ResponseEntity<Success> updateComment(@PathVariable Long comment_id,
3839
artWorkCommentService.updateComment(comment_id,data,user.getUser().getId());
3940
return new ResponseEntity<>(new Success("코멘트 수정 완료","" ), HttpStatus.OK);
4041
}
41-
@PatchMapping("/del/{comment_id}")
42-
public ResponseEntity<Success> updateComment(@PathVariable Long comment_id,
42+
@PatchMapping("/del")
43+
public ResponseEntity<Success> updateComment(@RequestBody Id commentId,
4344
@AuthenticationPrincipal UserDetailsImpl user) {
44-
artWorkCommentService.deleteComment(comment_id,user.getUser().getId());
45+
artWorkCommentService.deleteComment(commentId.getId(),user.getUser().getId());
4546
return new ResponseEntity<>(new Success("코멘트 삭제 완료","" ), HttpStatus.OK);
4647
}
4748
}

‎src/main/java/com/example/dplus/controller/artwork/ArtWorkLikeController.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.example.dplus.advice.ErrorCode;
55
import com.example.dplus.advice.ErrorCustomException;
66
import com.example.dplus.dto.Success;
7+
import com.example.dplus.dto.common.CommonDto.Id;
78
import com.example.dplus.jwt.UserDetailsImpl;
89
import com.example.dplus.service.artwork.like.ArtworkLikeService;
910
import lombok.RequiredArgsConstructor;
@@ -19,20 +20,20 @@ public class ArtWorkLikeController {
1920

2021
private final ArtworkLikeService artworkLikeService;
2122

22-
@PostMapping("/{artwork_id}")
23-
public ResponseEntity<Success> doLike(@PathVariable Long artwork_id,
23+
@PostMapping("")
24+
public ResponseEntity<Success> doLike(@RequestBody Id artworkId,
2425
@AuthenticationPrincipal UserDetailsImpl user) {
2526
if (user != null) {
26-
artworkLikeService.doLike(user.getUser(),artwork_id);
27+
artworkLikeService.doLike(user.getUser(),artworkId.getId());
2728
return new ResponseEntity<>(new Success("작품 좋아요 완료",""), HttpStatus.OK);
2829
}
2930
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);
3031
}
31-
@PatchMapping("/{artwork_id}")
32-
public ResponseEntity<Success> unLike(@PathVariable Long artwork_id,
32+
@PatchMapping("")
33+
public ResponseEntity<Success> unLike(@RequestBody Id artworkId,
3334
@AuthenticationPrincipal UserDetailsImpl user) {
3435
if (user != null) {
35-
artworkLikeService.unLike(user.getUser(), artwork_id);
36+
artworkLikeService.unLike(user.getUser(), artworkId.getId());
3637
return new ResponseEntity<>(new Success("작품 좋아요 해지", ""), HttpStatus.OK);
3738
}
3839
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);

‎src/main/java/com/example/dplus/controller/artwork/ArtWorkMainController.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import com.example.dplus.advice.ErrorCode;
55
import com.example.dplus.advice.ErrorCustomException;
66
import com.example.dplus.dto.Success;
7+
import com.example.dplus.dto.common.CommonDto.Id;
78
import com.example.dplus.dto.request.ArtWorkRequestDto.ArtWorkCreate;
8-
import com.example.dplus.dto.request.ArtWorkRequestDto.ArtWorkId;
99
import com.example.dplus.dto.request.ArtWorkRequestDto.ArtWorkUpdate;
1010
import com.example.dplus.jwt.UserDetailsImpl;
1111
import com.example.dplus.service.artwork.ArtworkMainService;
@@ -99,10 +99,10 @@ public ResponseEntity<Success> updateArtWork(@AuthenticationPrincipal UserDetail
9999

100100
@PatchMapping("/api/artwork/del/{category}")
101101
public ResponseEntity<Success> deleteArtWork(@AuthenticationPrincipal UserDetailsImpl user,
102-
@RequestBody ArtWorkId artworkId,
102+
@RequestBody Id artworkId,
103103
@PathVariable String category) {
104104
if (user != null) {
105-
artworkMainService.deleteArtwork(user.getUser().getId(), artworkId.getArtwork_id(), category);
105+
artworkMainService.deleteArtwork(user.getUser().getId(), artworkId.getId(), category);
106106
return new ResponseEntity<>(new Success("작품 삭제",""),HttpStatus.OK);
107107
}
108108
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);

‎src/main/java/com/example/dplus/controller/post/PostAnswerController.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.example.dplus.advice.ErrorCode;
44
import com.example.dplus.advice.ErrorCustomException;
55
import com.example.dplus.dto.Success;
6+
import com.example.dplus.dto.common.CommonDto.Id;
67
import com.example.dplus.dto.request.PostRequestDto;
78
import com.example.dplus.jwt.UserDetailsImpl;
89
import com.example.dplus.service.post.answer.PostAnswerService;
@@ -42,21 +43,21 @@ public ResponseEntity<Success> updatePostAnswer(@AuthenticationPrincipal UserDet
4243
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);
4344
}
4445

45-
@PatchMapping("/del/answer/{answer_id}")
46+
@PatchMapping("/del/answer")
4647
public ResponseEntity<Success> deletePostAnswer(@AuthenticationPrincipal UserDetailsImpl user,
47-
@PathVariable Long answer_id) {
48+
@RequestBody Id answerId) {
4849
if (user != null) {
49-
postAnswerService.deleteAnswer(answer_id, user.getUser().getId());
50+
postAnswerService.deleteAnswer(answerId.getId(), user.getUser().getId());
5051
return new ResponseEntity<>(new Success("질문글 답변 삭제 완료", ""), HttpStatus.OK);
5152
}
5253
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);
5354
}
5455

55-
@PatchMapping("/answer/select/{answer_id}")
56+
@PatchMapping("/answer/select")
5657
public ResponseEntity<Success> doIsSelected(@AuthenticationPrincipal UserDetailsImpl user,
57-
@PathVariable Long answer_id) {
58+
@RequestBody Id answerId) {
5859
if (user != null) {
59-
postAnswerService.doIsSelected(answer_id, user.getUser().getId());
60+
postAnswerService.doIsSelected(answerId.getId(), user.getUser().getId());
6061
return new ResponseEntity<>(new Success("채택 완료", ""), HttpStatus.OK);
6162
}
6263
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);

‎src/main/java/com/example/dplus/controller/post/PostBookMarkController.java‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.example.dplus.advice.ErrorCode;
44
import com.example.dplus.advice.ErrorCustomException;
55
import com.example.dplus.dto.Success;
6+
import com.example.dplus.dto.common.CommonDto.Id;
67
import com.example.dplus.jwt.UserDetailsImpl;
78
import com.example.dplus.service.post.bookmark.PostBookMarkService;
89
import lombok.RequiredArgsConstructor;
@@ -18,21 +19,21 @@ public class PostBookMarkController {
1819

1920
private final PostBookMarkService postBookMarkService;
2021

21-
@PostMapping("/post/{post_id}")
22-
public ResponseEntity<Success> doBookmark(@PathVariable Long post_id,
22+
@PostMapping("/post")
23+
public ResponseEntity<Success> doBookmark(@RequestBody Id postId,
2324
@AuthenticationPrincipal UserDetailsImpl user) {
2425
if (user != null) {
25-
postBookMarkService.doBookMark(user.getUser(), post_id);
26+
postBookMarkService.doBookMark(user.getUser(), postId.getId());
2627
return new ResponseEntity<>(new Success("게시글 북마크 성공", ""), HttpStatus.OK);
2728
}
2829
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);
2930
}
3031

31-
@PatchMapping("/post/{post_id}")
32-
public ResponseEntity<Success> unBookmark(@PathVariable Long post_id,
32+
@PatchMapping("/post")
33+
public ResponseEntity<Success> unBookmark(@RequestBody Id postId,
3334
@AuthenticationPrincipal UserDetailsImpl user) {
3435
if (user != null) {
35-
postBookMarkService.unBookMark(user.getUser(), post_id);
36+
postBookMarkService.unBookMark(user.getUser(), postId.getId());
3637
return new ResponseEntity<>(new Success("게시글 북마크 해지", ""), HttpStatus.OK);
3738
}
3839
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);

‎src/main/java/com/example/dplus/controller/post/PostCommentController.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.example.dplus.advice.ErrorCode;
44
import com.example.dplus.advice.ErrorCustomException;
55
import com.example.dplus.dto.Success;
6+
import com.example.dplus.dto.common.CommonDto;
67
import com.example.dplus.dto.request.PostRequestDto;
78
import com.example.dplus.jwt.UserDetailsImpl;
89
import com.example.dplus.service.post.comment.PostCommentService;
@@ -43,11 +44,11 @@ public ResponseEntity<Success> updatePostComment(@AuthenticationPrincipal UserDe
4344
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);
4445
}
4546

46-
@PatchMapping("/comment/del/{post_comment_id}")
47+
@PatchMapping("/comment/del")
4748
public ResponseEntity<Success> deletePostComment(@AuthenticationPrincipal UserDetailsImpl user,
48-
@PathVariable Long post_comment_id) {
49+
@RequestBody CommonDto.Id postCommentId) {
4950
if (user != null) {
50-
postCommentService.deleteComment(user.getUser().getId(), post_comment_id);
51+
postCommentService.deleteComment(user.getUser().getId(), postCommentId.getId());
5152
return new ResponseEntity<>(new Success("게시글 코멘트 삭제 완료",""), HttpStatus.OK);
5253
}
5354
throw new ErrorCustomException(ErrorCode.NO_AUTHENTICATION_ERROR);

‎src/main/java/com/example/dplus/controller/post/PostLikeController.java‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.example.dplus.advice.ErrorCode;
44
import com.example.dplus.advice.ErrorCustomException;
55
import com.example.dplus.dto.Success;
6+
import com.example.dplus.dto.common.CommonDto.Id;
67
import com.example.dplus.jwt.UserDetailsImpl;
78
import com.example.dplus.service.post.comment.like.PostCommentLikeService;
89
import 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

Comments
 (0)