-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
182 additions
and
106 deletions.
There are no files selected for viewing
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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/drinkeg/drinkeg/controller/RecommentController.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,45 @@ | ||
package com.drinkeg.drinkeg.controller; | ||
|
||
import com.drinkeg.drinkeg.apipayLoad.ApiResponse; | ||
import com.drinkeg.drinkeg.domain.Member; | ||
import com.drinkeg.drinkeg.dto.RecommentDTO.RecommentRequestDTO; | ||
import com.drinkeg.drinkeg.dto.loginDTO.commonDTO.PrincipalDetail; | ||
import com.drinkeg.drinkeg.service.recommentService.RecommentService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.*; | ||
import com.drinkeg.drinkeg.service.memberService.MemberService; | ||
|
||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/recomments") | ||
public class RecommentController { | ||
|
||
private final RecommentService recommentService; | ||
|
||
// 대댓글 생성 | ||
@PostMapping("/{commentId}") | ||
public ApiResponse<String> createRecomment( | ||
@AuthenticationPrincipal PrincipalDetail principalDetail, | ||
@PathVariable("commentId") Long commentId, | ||
@RequestBody RecommentRequestDTO recommentRequest) { | ||
|
||
recommentService.createRecomment(commentId, recommentRequest, principalDetail); | ||
|
||
return ApiResponse.onSuccess("대댓글 생성 완료"); | ||
} | ||
|
||
|
||
// 대댓글 삭제 | ||
@DeleteMapping("/{recommentId}/{commentId}") | ||
public ApiResponse<String> deleteRecomment( | ||
@AuthenticationPrincipal PrincipalDetail principalDetail, | ||
@PathVariable("commentId") Long commentId, | ||
@PathVariable("recommentId") Long recommentId) { | ||
|
||
recommentService.deleteRecomment(commentId, recommentId, principalDetail); | ||
|
||
return ApiResponse.onSuccess("댓글 삭제 완료"); | ||
} | ||
} |
11 changes: 6 additions & 5 deletions
11
src/main/java/com/drinkeg/drinkeg/service/commentService/CommentService.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
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/drinkeg/drinkeg/service/recommentService/RecommentService.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,17 @@ | ||
package com.drinkeg.drinkeg.service.recommentService; | ||
|
||
import com.drinkeg.drinkeg.domain.Member; | ||
import com.drinkeg.drinkeg.domain.Recomment; | ||
import com.drinkeg.drinkeg.dto.RecommentDTO.RecommentRequestDTO; | ||
import com.drinkeg.drinkeg.dto.loginDTO.commonDTO.PrincipalDetail; | ||
|
||
import java.util.List; | ||
|
||
public interface RecommentService { | ||
|
||
List<Recomment> findByCommentId(Long commentId); | ||
boolean existsByCommentId(Long commentId); | ||
void createRecomment(Long commentId, RecommentRequestDTO recommentRequest, PrincipalDetail principalDetail); | ||
void deleteRecomment(Long commentId, Long recommentId, PrincipalDetail principalDetail); | ||
|
||
} |
Oops, something went wrong.