-
Notifications
You must be signed in to change notification settings - Fork 0
[DP-449] 내가 썼어요 댓글 API 개발 #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3d87386
Merge pull request #131 from dreamyPatisiel/develop
yu-so-young2 50dc79c
feat(CommentMapper): findByMemberIdAndPickCommentIdAndTechCommentIdOr…
ssosee f8d2da8
feat(CommentRepository): findMyWrittenCommentsByCursor(..)
ssosee 95ab0b1
feat(MemberService): findMyWrittenComments(..)
ssosee d499d8b
feat(MypageController): getMyWrittenComments(..)
ssosee 357c5f0
feat(MypageController): getMyWrittenComments(..)
ssosee aa0a029
Merge branch 'develop' into DP-449
ssosee 1cfc706
fix(MemberServiceTest): BookmarkRepository 패키징 변경
ssosee 7673017
fix(build.yml): build 시 로그 레벨 수정
ssosee 704f8b7
fix(MemberServiceTest): 시간 nano sec 설정
ssosee 5c4c97c
fix(MemberServiceTest): 시간 필드 검증 제외
ssosee 1325e4c
fix(MemberServiceTest): 시간 필드 검증 제외
ssosee c4f6273
fix(PR 반영):
ssosee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
| [[Comment-Get]] | ||
| == 내가 썼어요 댓글/답글 조회 API(GET: /devdevdev/api/v1/mypage/comments) | ||
|
|
||
| * 회원이 작성한 댓글/답글을 조회한다. | ||
| * 최초 요청시 pickCommentId, techCommentId 는 가장 큰 숫자 값을 요청해야 합니다. | ||
|
|
||
| === 정상 요청/응답 | ||
|
|
||
| ==== HTTP Request | ||
|
|
||
| include::{snippets}/mypage-comments/http-request.adoc[] | ||
|
|
||
| ==== HTTP Request Header Fields | ||
|
|
||
| include::{snippets}/mypage-comments/request-headers.adoc[] | ||
|
|
||
| ==== HTTP Request Query Parameters Fields | ||
|
|
||
| include::{snippets}/mypage-comments/query-parameters.adoc[] | ||
|
|
||
| ==== HTTP Response | ||
|
|
||
| include::{snippets}/mypage-comments/http-response.adoc[] | ||
|
|
||
| ==== HTTP Response Fields | ||
|
|
||
| include::{snippets}/mypage-comments/response-fields.adoc[] | ||
|
|
||
| === 예외 | ||
|
|
||
| ==== HTTP Response | ||
|
|
||
| * `익명 회원은 사용할 수 없는 기능 입니다.`: 익명 회원인 경우 | ||
| * `회원을 찾을 수 없습니다.`: 회원이 존재하지 않는 경우 | ||
| * `유효하지 않은 회원 입니다.`: 회원이 유효하지 않은 경우 | ||
|
|
||
| include::{snippets}/mypage-comments-member-exception/response-body.adoc[] |
This file contains hidden or 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 hidden or 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 hidden or 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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/dreamypatisiel/devdevdev/domain/repository/comment/CommentRepository.java
This file contains hidden or 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,61 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository.comment; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.repository.comment.mybatis.CommentMapper; | ||
| import com.dreamypatisiel.devdevdev.domain.repository.pick.PickCommentRepository; | ||
| import com.dreamypatisiel.devdevdev.domain.repository.techArticle.TechCommentRepository; | ||
| import com.dreamypatisiel.devdevdev.web.dto.SliceCustom; | ||
| import com.dreamypatisiel.devdevdev.web.dto.request.comment.MyWrittenCommentFilter; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
| @RequiredArgsConstructor | ||
| public class CommentRepository { | ||
|
|
||
| private final CommentMapper commentMapper; | ||
| private final PickCommentRepository pickCommentRepository; | ||
| private final TechCommentRepository techCommentRepository; | ||
|
|
||
| public SliceCustom<MyWrittenCommentDto> findMyWrittenCommentsByCursor(Long memberId, | ||
| Long pickCommentId, | ||
| Long techCommentId, | ||
| MyWrittenCommentFilter myWrittenCommentSort, | ||
| Pageable pageable) { | ||
|
|
||
| // 픽픽픽 | ||
| if (MyWrittenCommentFilter.PICK.equals(myWrittenCommentSort)) { | ||
| return pickCommentRepository.findMyWrittenPickCommentsByCursor(memberId, pickCommentId, pageable); | ||
| } | ||
|
|
||
| // 기술블로그 | ||
| if (MyWrittenCommentFilter.TECH_ARTICLE.equals(myWrittenCommentSort)) { | ||
| return techCommentRepository.findMyWrittenTechCommentsByCursor(memberId, techCommentId, pageable); | ||
| } | ||
|
|
||
| // 전체 | ||
| // 회원이 작성한 픽픽픽, 기술블로그 댓글 조회 | ||
| List<MyWrittenCommentDto> findMyWrittenComments = commentMapper.findByMemberIdAndPickCommentIdAndTechCommentIdOrderByCommentCreatedAtDesc( | ||
| memberId, pickCommentId, techCommentId, pageable.getPageSize()); | ||
|
|
||
| // 다음 페이지 존재 여부 | ||
| boolean hasNext = findMyWrittenComments.size() >= pageable.getPageSize(); | ||
|
|
||
| // 회원이 작성한 댓글 총 갯수(삭제 미포함) | ||
| Long commentTotalCount = countByCreatedByIdAndDeletedAtIsNull(memberId); | ||
|
|
||
| return new SliceCustom<>(findMyWrittenComments, pageable, hasNext, commentTotalCount); | ||
| } | ||
|
|
||
| private Long countByCreatedByIdAndDeletedAtIsNull(Long createdById) { | ||
yu-so-young2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // 회원이 작성한 픽픽픽 댓글 갯수(삭제 미포함) | ||
| Long pickCommentTotal = pickCommentRepository.countByCreatedByIdAndDeletedAtIsNull(createdById); | ||
|
|
||
| // 회원이 작성한 기술블로그 댓글 갯수(삭제 미포함) | ||
| Long techCommentTotal = techCommentRepository.countByCreatedByIdAndDeletedAtIsNull(createdById); | ||
|
|
||
| return pickCommentTotal + techCommentTotal; | ||
| } | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
...main/java/com/dreamypatisiel/devdevdev/domain/repository/comment/MyWrittenCommentDto.java
This file contains hidden or 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,33 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository.comment; | ||
|
|
||
| import com.querydsl.core.annotations.QueryProjection; | ||
| import java.time.LocalDateTime; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class MyWrittenCommentDto { | ||
| private Long postId; | ||
| private String postTitle; | ||
| private Long commentId; | ||
| private String commentType; | ||
| private String commentContents; | ||
| private Long commentRecommendTotalCount; | ||
| private LocalDateTime commentCreatedAt; | ||
| private String pickOptionTitle; | ||
| private String pickOptionType; | ||
|
|
||
| @QueryProjection | ||
| public MyWrittenCommentDto(Long postId, String postTitle, Long commentId, String commentType, | ||
| String commentContents, Long commentRecommendTotalCount, LocalDateTime commentCreatedAt, | ||
| String pickOptionTitle, String pickOptionType) { | ||
| this.postId = postId; | ||
| this.postTitle = postTitle; | ||
| this.commentId = commentId; | ||
| this.commentType = commentType; | ||
| this.commentContents = commentContents; | ||
yu-so-young2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.commentRecommendTotalCount = commentRecommendTotalCount; | ||
| this.commentCreatedAt = commentCreatedAt; | ||
| this.pickOptionTitle = pickOptionTitle; | ||
| this.pickOptionType = pickOptionType; | ||
| } | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
...in/java/com/dreamypatisiel/devdevdev/domain/repository/comment/mybatis/CommentMapper.java
This file contains hidden or 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,15 @@ | ||
| package com.dreamypatisiel.devdevdev.domain.repository.comment.mybatis; | ||
|
|
||
| import com.dreamypatisiel.devdevdev.domain.repository.comment.MyWrittenCommentDto; | ||
| import java.util.List; | ||
| import org.apache.ibatis.annotations.Mapper; | ||
| import org.apache.ibatis.annotations.Param; | ||
|
|
||
| @Mapper | ||
| public interface CommentMapper { | ||
| List<MyWrittenCommentDto> findByMemberIdAndPickCommentIdAndTechCommentIdOrderByCommentCreatedAtDesc( | ||
| @Param("memberId") Long memberId, | ||
| @Param("pickCommentId") Long pickCommentId, | ||
| @Param("techCommentId") Long techCommentId, | ||
| @Param("limit") int limit); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.