-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from HyeJiJUN11/feature/32-Comment
feat: ๋๊ธ/์๋ฆผ API ๊ตฌํ
- Loading branch information
Showing
20 changed files
with
624 additions
and
187 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/main/java/com/potatocake/everymoment/controller/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.potatocake.everymoment.controller; | ||
|
||
import com.potatocake.everymoment.dto.SuccessResponse; | ||
import com.potatocake.everymoment.dto.request.CommentRequest; | ||
import com.potatocake.everymoment.security.MemberDetails; | ||
import com.potatocake.everymoment.service.CommentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/comments") | ||
public class CommentController { | ||
|
||
private final CommentService commentService; | ||
|
||
//๋๊ธ ์์ | ||
@PatchMapping("/{commentId}") | ||
public ResponseEntity<SuccessResponse<Void>> updateComment( | ||
@AuthenticationPrincipal MemberDetails memberDetails, | ||
@PathVariable Long commentId, | ||
@RequestBody CommentRequest commentRequest) { | ||
Long memberId = memberDetails.getId(); | ||
|
||
commentService.updateComment(memberId, commentId, commentRequest); | ||
|
||
return ResponseEntity.ok() | ||
.body(SuccessResponse.ok()); | ||
} | ||
|
||
//๋๊ธ ์ญ์ | ||
@DeleteMapping("/{commentId}") | ||
public ResponseEntity<SuccessResponse<Void>> deleteComment( | ||
@AuthenticationPrincipal MemberDetails memberDetails, | ||
@PathVariable Long commentId) { | ||
Long memberId = memberDetails.getId(); | ||
|
||
commentService.deleteComment(memberId, commentId); | ||
|
||
return ResponseEntity.ok() | ||
.body(SuccessResponse.ok()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.