Refactor: PostService 구조 개선 및 매핑 로직 분리 (#298) #316
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.
📌 개요
PostService내부 로직을 리팩토링하여 카테고리 매핑과 첨부파일 매핑을 각각 전담 서비스로 분리PostCategoryMappingService신규 추가DevInitService,PostControllerTest,PostServiceTest,PostRepositoryImplTest등 관련 테스트 수정🔨 작업 내용
PostService 리팩토링
PostCategoryMappingService를 통해 카테고리 검증 및 매핑 관리AttachmentMappingService로 첨부파일 생성/갱신/삭제 로직 통합updateCategories,validateAndFindCategories,validateAndFindAttachments제거PostCategoryMappingService 추가
createMappings(),updateMappings(),deleteMappings()구현CATEGORY_NOT_FOUND예외 처리AttachmentMappingService 개선
createAttachments(),updateAttachments(),deleteAttachmentsByIds()추가FILE_ACCESS_DENIED) 강화@EntityGraph를 활용해 N+1 쿼리 최소화DevInitService 개선
EntityManager의존성 제거attachCategories()내부에서PostCategoryMappingService사용테스트 코드 수정 및 보강
PostRepositoryImplTest,PostControllerTest,PostServiceTest등에서기존
post.updateCategories()호출 제거 후postCategoryMappingService.createMappings()로 대체AttachmentMappingServiceTest에 신규 단위 테스트 추가createAttachments_successupdateAttachments_successdeleteAttachmentsByIds_successcreatedAt DESC) 안정화를 위해Thread.sleep()기반 시간 간격 부여contains) 방식으로 변경하여 안정성 확보🔗 관련 이슈
Closes #298
📝 참고 사항
✅ 체크리스트