-
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.
#256 Feat: comment 디렉토리 완성 및 컨트롤러 구현
- Loading branch information
1 parent
8ef0c4e
commit b0fe3ad
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/main/java/com/codiary/backend/domain/comment/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,52 @@ | ||
package com.codiary.backend.domain.comment.controller; | ||
|
||
import com.codiary.backend.domain.comment.service.CommentService; | ||
import com.codiary.backend.global.apiPayload.ApiResponse; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PageableDefault; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RequiredArgsConstructor | ||
@RestController | ||
@RequestMapping("/api/v2/posts/{post_id}/comments") | ||
@Tag(name = "댓글 API", description = "댓글 관련 API 입니다.") | ||
public class CommentController { | ||
|
||
private final CommentService commentService; | ||
|
||
@Operation(summary = "댓글 달기") | ||
@PostMapping("/{comment_id}") | ||
public ApiResponse<?> commentPost( | ||
@PathVariable("post_id") Long postId, | ||
@PathVariable("comment_id") Long commentId | ||
) { | ||
return null; | ||
} | ||
|
||
@Operation(summary = "댓글 삭제") | ||
@DeleteMapping("/{comment_id}") | ||
public ApiResponse<?> deleteComment( | ||
@PathVariable("post_id") Long postId, | ||
@PathVariable("comment_id") Long commentId | ||
) { | ||
return null; | ||
} | ||
|
||
@Operation(summary = "댓글 조회", description = "기본적으로 10개씩 페이지네이션 하여 제공됩니다.") | ||
@GetMapping("/{comment_id}") | ||
public ApiResponse<?> getComments( | ||
@PathVariable("post_id") Long postId, | ||
@PathVariable("comment_id") Long commentId, | ||
@PageableDefault(size = 10) Pageable pageable | ||
) { | ||
return null; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/codiary/backend/domain/comment/repository/CommentRepository.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,7 @@ | ||
package com.codiary.backend.domain.comment.repository; | ||
|
||
import com.codiary.backend.domain.comment.entity.Comment; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CommentRepository extends JpaRepository<Comment, Long> { | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/codiary/backend/domain/comment/service/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.codiary.backend.domain.comment.service; | ||
|
||
import com.codiary.backend.domain.comment.repository.CommentRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class CommentService { | ||
|
||
private final CommentRepository commentRepository; | ||
} |