-
Notifications
You must be signed in to change notification settings - Fork 6
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
[BE] Feat/#587 핀 댓글 기능 추가 구현 #601
Merged
Merged
Changes from 10 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
110e964
feat: 핀 댓글 뼈대 코드 작성
kpeel5839 f5685c0
refactor: 핀 Comment Exception 수정
kpeel5839 6fe015d
feat: 현재 유저가 해당 pin 에다가 댓글을 작성할 수 있는지 확인하는 메서드 추가
kpeel5839 cc717f0
feat: 댓글 생성 API 구현
kpeel5839 c39f04a
feat: 댓글 조회 API 구현
kpeel5839 4a7424d
refactor: PinResponseComment 에서 Parent, Child Comment 로 메서드 분리
kpeel5839 843e577
feat: 핀 댓글 수정, 삭제 API 구현
kpeel5839 efa640d
refactor: 어드민은 Comment 에 대한 모든 권한을 가지도록 수정
kpeel5839 04fb540
refactor: @OnDelete 를 추가함으로써 DDL 에 외래키 제약 조건 설정에 on Delete Cascade 집어넣기
kpeel5839 20dd07a
fix: canChange 여부 로직 수정
kpeel5839 dd701c0
test: 댓글 조회 통합 테스트 작성
kpeel5839 7741412
test: 댓글 생성 통합 테스트 작성
kpeel5839 d160dd2
test: 댓글 수정 통합 테스트 작성
kpeel5839 48b5c4b
test: 댓글 삭제 통합 테스트 작성
kpeel5839 8b98dfa
docs: 댓글 생성 문서 작성
kpeel5839 d6a5816
docs: 댓글 조회 문서 작성
kpeel5839 4d6cff1
docs: 댓글 수정 및 삭제 문서 작성
kpeel5839 efc2d0e
test: pinComment 생성, 수정 테스트
kpeel5839 f4e6416
refactor: 핀 댓글 읽기 권한 필터링 추가
kpeel5839 8a96d6e
test: 핀 댓글 조회 테스트 추가
kpeel5839 7b6cf26
test: 핀 댓글 생성 테스트 추가
kpeel5839 c66802a
test: 핀 수정 테스트 추가
kpeel5839 166b875
test: 핀 삭제 테스트 추가
kpeel5839 807d15d
style: 개행 조정
kpeel5839 26bead6
refactor: 정적 팩토리 메서드로 댓글 or 대댓글 나눔
kpeel5839 909ebf4
refactor: parent, child comment 분기로 인한 중복코드 제거
kpeel5839 d2d2fa5
refactor: PinIntegrationTest 개행 수정 및 변수명 수정
kpeel5839 4245228
refactor: EOF 추가
kpeel5839 38e35fd
refactor: Rest 하게 URI 변경
kpeel5839 c179ae0
refactor: PinCommandService Parameter 순서 변경
kpeel5839 97f5ea7
refactor: isGroup -> hasPermission 으로 변경
kpeel5839 b30b387
style: 공백 제거
kpeel5839 cd75da7
refactor: @DisplayName 에 개발 용어 대신 도메인 용어를 사용하도록 수정
kpeel5839 937a63d
refactor: 핀 대대댓글을 달 수 없도록 수정
kpeel5839 1232bf7
fix: 핀 댓글 조회 통합테스트 예외발생하는 문제 수정
kpeel5839 fb43e32
fix: git 충돌 해결
kpeel5839 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 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 |
---|---|---|
|
@@ -54,4 +54,4 @@ public boolean isGuest() { | |
return false; | ||
} | ||
|
||
} | ||
} |
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 |
---|---|---|
|
@@ -56,4 +56,4 @@ public boolean isGuest() { | |
return true; | ||
} | ||
|
||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import static com.mapbefine.mapbefine.pin.exception.PinCommentErrorCode.ILLEGAL_CONTENT_LENGTH; | ||
import static com.mapbefine.mapbefine.pin.exception.PinCommentErrorCode.ILLEGAL_CONTENT_NULL; | ||
import static com.mapbefine.mapbefine.pin.exception.PinCommentErrorCode.ILLEGAL_PIN_COMMENT_DEPTH; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
import com.mapbefine.mapbefine.common.entity.BaseTimeEntity; | ||
|
@@ -16,6 +17,7 @@ | |
import jakarta.persistence.Lob; | ||
import jakarta.persistence.ManyToOne; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.OnDelete; | ||
|
@@ -49,7 +51,7 @@ public class PinComment extends BaseTimeEntity { | |
@Column(nullable = false, length = 1000) | ||
private String content; | ||
|
||
public PinComment( | ||
private PinComment( | ||
Pin pin, | ||
PinComment parentPinComment, | ||
Member creator, | ||
|
@@ -61,17 +63,37 @@ public PinComment( | |
this.content = content; | ||
} | ||
|
||
public static PinComment of( | ||
public static PinComment ofParentPinComment( | ||
Pin pin, | ||
Member creator, | ||
String content | ||
) { | ||
validateContent(content); | ||
|
||
return new PinComment(pin, null, creator, content); | ||
} | ||
|
||
public static PinComment ofChildPinComment( | ||
Pin pin, | ||
PinComment parentPinComment, | ||
Member creator, | ||
String content | ||
) { | ||
validatePinCommentDepth(parentPinComment); | ||
validateContent(content); | ||
|
||
|
||
return new PinComment(pin, parentPinComment, creator, content); | ||
} | ||
|
||
private static void validatePinCommentDepth(PinComment parentPinComment) { | ||
if (parentPinComment.isParentComment()) { | ||
return; | ||
} | ||
|
||
throw new PinCommentBadRequestException(ILLEGAL_PIN_COMMENT_DEPTH); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍👍 |
||
private static void validateContent(String content) { | ||
if (Objects.isNull(content)) { | ||
throw new PinCommentBadRequestException(ILLEGAL_CONTENT_NULL); | ||
|
@@ -90,4 +112,9 @@ public boolean isParentComment() { | |
return Objects.isNull(parentPinComment); | ||
} | ||
|
||
public Optional<Long> getParentPinCommentId() { | ||
return Optional.ofNullable(parentPinComment) | ||
.map(PinComment::getId); | ||
} | ||
|
||
} |
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
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3. 필드 순서, 생성자 파라미터 순서에서 Service와 Repository를 분류하면 어떨까요?
Repository가 다음에 추가될 확률이 더 높으니 ImageService를 첫번째 파라미터, 필드로 올려도 좋을 것 같아요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
반영하겠습니다~!