Refactor: board 도메인 구조 및 엔티티 개선 (#212) #233
Merged
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.
📌 개요
🔨 작업 내용
1. 패키지 구조 리팩토링
domain/board→domain/board/post,domain/board/comment로 세분화controller/docs,repository/custom구조로 정리src/test/java) 디렉토리도 동일한 구조로 리네임2. 엔티티 개선 (관계 및 비즈니스 로직 보강)
🔹
PostUser와의 연관관계에nullable=false적용updateCategories()개선 및 중복 매핑 방지likeCount,bookmarkCount,commentCount관련 메서드 문서화🔹
Commentnullable=false제약 및columnDefinition="TEXT"추가createRoot(),createChild()정적 팩토리 메서드 추가addLike(),removeLike()등 연관관계 편의 메서드 추가increaseLikeCount(),decreaseLikeCount()보강🔹
PostLike,PostBookmark,CommentLike,PostCategoryMapping@UniqueConstraint추가로 중복 방지post.addLike(this)등)🔹
Userif (this.posts == null) this.posts = new ArrayList<>();)3. Service 계층 보완
deletePost,deleteComment,cancelLikeComment, 등)에연관관계 해제 로직(
user.removePost(),comment.removeLike()) 추가CommentService.createComment()→Comment.createRoot()사용하도록 수정DevInitData의 샘플 데이터 생성 시에도 팩토리 메서드 사용4. 테스트 코드 전체 수정
new Post(user, title, content, null)형태로 수정Comment.createRoot(),Comment.createChild()방식으로 변경PostCategory생성 시CategoryType명시 (new PostCategory("공지사항", CategoryType.SUBJECT))🔗 관련 이슈
Closes #{이슈 번호}
📝 참고 사항
✅ 체크리스트