-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#35 - Feed/FeedComment CQRS 적용 #37
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 10 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
d8345fa
refactor: Feed 폴더 구조 변경
jbh010204 d75eae2
feat: FeedService를 command와 query로 분리
jbh010204 291ae9a
refactor: feed 도메인 내 어그레이트 약한 참조 관계로 변경
jbh010204 b30480a
refactor: Feed관련 DTO에서 사용하지 않는 메서드 삭제
jbh010204 7553103
refactor: Feed수정에 맞춰 테스트 변경
jbh010204 eb862fa
feat: FeedComment 약결합 분리 및 CQRS 패턴으로 변경
jbh010204 deec9d0
feat: FeedCommand 포트 확장
jbh010204 f80d05c
feat: FeedCommand 도메인 + 서비스 CQRS 분리
jbh010204 4a37258
feat: 댓글 조회시 필요한 유저 정보를 위해 UserData 포트/어댑터 추가
jbh010204 4179e1e
refactor: Feed와 FeedComment 느슨한 형태로 분리
jbh010204 76b8763
refactor: FeedResult 폴더 구조 Command의 DTO 위치로 변경
jbh010204 4b37f15
refactor: FeedQueryService 불필요한 트랜잭션 어노테이션 제거
jbh010204 f5971ef
feat: UserSnapshot DTO renamed to UserSnapShot and updated references
jbh010204 fb40dd7
refactor: FeedComment의 comment필드를 content로 명칭변경
jbh010204 ff62a4e
feat: rename FeedComment Aggregate to Comment
jbh010204 af6d726
feat: Feed 수정&삭제 기능 구현
jbh010204 0a43147
feat: Feed 통합 테스트 구현 및 단위 테스트 command용으로 분리
jbh010204 6065adb
Merge remote-tracking branch 'origin/develop' into feat/#35
jbh010204 fb1caef
docs: Feed 및 Comment Swaggeer 작성
jbh010204 7926140
refactor: test내부 클래스 stub 외부로 구조 변경
jbh010204 e7eebd9
refactor: User와 Profile 간접 참조 형태로 분리 및 연관된 코드 변경
jbh010204 d3a9022
feat: Replace UserDataPort with ProfileDataPort for user profile hand…
jbh010204 4367844
refactor: Rename entity from 'feed_comments' to 'comments' for clarity
jbh010204 c6aa091
refactor: ProfileSnapShot domain 패키지 구조로 이동
jbh010204 79cdea3
Merge remote-tracking branch 'origin/develop' into feat/#35
jbh010204 a37f38d
refactor: 피드 검증을 위한 FeedValidationPort and adapter 도입
jbh010204 2a54f69
refactor: author validation in Feed 도메인 내부 로직으로 변경
jbh010204 f2d6792
refactor: DB 스키마 변경에 따른 SQL feed_comments to comments 으로 변경
jbh010204 43a92c5
refactor: validation adapters의 스테레오타입을 Component로 변경
jbh010204 44ba7dd
refactor: ProfileJpaRepository 추가 및 프로필 저장 로직 구현
jbh010204 94e485b
fix : comments 객체와 다르게 구성된 sql문 수정
polyglot-k 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
Empty file.
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
17 changes: 17 additions & 0 deletions
17
src/main/java/com/example/bak/community/infra/command/CommunityValidationAdapter.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,17 @@ | ||
| package com.example.bak.community.infra.command; | ||
|
|
||
| import com.example.bak.feed.application.command.port.CommunityValidationPort; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Repository; | ||
|
|
||
| @Repository | ||
jbh010204 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @RequiredArgsConstructor | ||
| public class CommunityValidationAdapter implements CommunityValidationPort { | ||
|
|
||
| private final CommunityJpaRepository communityJpaRepository; | ||
|
|
||
| @Override | ||
| public boolean isCommunityExists(Long communityId) { | ||
| return communityJpaRepository.existsById(communityId); | ||
| } | ||
| } | ||
68 changes: 0 additions & 68 deletions
68
src/main/java/com/example/bak/feed/application/FeedService.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/main/java/com/example/bak/feed/application/command/FeedCommandService.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,32 @@ | ||
| package com.example.bak.feed.application.command; | ||
|
|
||
| import com.example.bak.feed.application.command.port.CommunityValidationPort; | ||
| import com.example.bak.feed.application.command.port.FeedCommandPort; | ||
| import com.example.bak.feed.application.query.dto.FeedResult; | ||
| import com.example.bak.feed.domain.Feed; | ||
| import com.example.bak.global.exception.BusinessException; | ||
| import com.example.bak.global.exception.ErrorCode; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional | ||
| public class FeedCommandService { | ||
|
|
||
| private final FeedCommandPort feedCommandPort; | ||
| private final CommunityValidationPort communityValidationPort; | ||
|
|
||
| public FeedResult createFeed(String title, String content, Long communityId, Long userId) { | ||
|
|
||
jbh010204 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (!communityValidationPort.isCommunityExists(communityId)) { | ||
| throw new BusinessException(ErrorCode.COMMUNITY_NOT_FOUND); | ||
| } | ||
|
|
||
| Feed newFeed = Feed.create(title, content, communityId, userId); | ||
| Feed savedFeed = feedCommandPort.save(newFeed); | ||
|
|
||
| return FeedResult.of(savedFeed.getId()); | ||
| } | ||
| } | ||
6 changes: 6 additions & 0 deletions
6
src/main/java/com/example/bak/feed/application/command/port/CommunityValidationPort.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,6 @@ | ||
| package com.example.bak.feed.application.command.port; | ||
|
|
||
| public interface CommunityValidationPort { | ||
|
|
||
| boolean isCommunityExists(Long communityId); | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/example/bak/feed/application/command/port/FeedCommandPort.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,11 @@ | ||
| package com.example.bak.feed.application.command.port; | ||
|
|
||
| import com.example.bak.feed.domain.Feed; | ||
| import java.util.Optional; | ||
|
|
||
| public interface FeedCommandPort { | ||
|
|
||
| Feed save(Feed feed); | ||
|
|
||
| Optional<Feed> findById(Long id); | ||
| } |
30 changes: 0 additions & 30 deletions
30
src/main/java/com/example/bak/feed/application/dto/FeedDetail.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
src/main/java/com/example/bak/feed/application/dto/FeedSummary.java
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/java/com/example/bak/feed/application/port/CommunityCommandPort.java
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
src/main/java/com/example/bak/feed/application/query/FeedQueryService.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,40 @@ | ||
| package com.example.bak.feed.application.query; | ||
|
|
||
| import com.example.bak.feed.application.query.dto.FeedDetail; | ||
| import com.example.bak.feed.application.query.dto.FeedSummary; | ||
| import com.example.bak.feed.application.query.port.FeedQueryPort; | ||
| import com.example.bak.global.exception.BusinessException; | ||
| import com.example.bak.global.exception.ErrorCode; | ||
| import java.util.List; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.PageRequest; | ||
| import org.springframework.data.domain.Pageable; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class FeedQueryService { | ||
|
|
||
| private final FeedQueryPort feedQueryPort; | ||
|
|
||
| @Transactional(readOnly = true) | ||
jbh010204 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public FeedDetail getFeedDetail(Long feedId) { | ||
| return feedQueryPort.findDetailById(feedId) | ||
| .orElseThrow(() -> new BusinessException(ErrorCode.FEED_NOT_FOUND)); | ||
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public FeedSummary getFeedSummary(Long feedId) { | ||
| return feedQueryPort.findSummaryById(feedId) | ||
| .orElseThrow(() -> new BusinessException(ErrorCode.FEED_NOT_FOUND)); | ||
| } | ||
|
|
||
| @Transactional(readOnly = true) | ||
| public List<FeedSummary> getFeeds(int page, int size) { | ||
| Pageable pageable = PageRequest.of(page, size); | ||
| Page<FeedSummary> feedPage = feedQueryPort.findAll(pageable); | ||
| return feedPage.getContent(); | ||
| } | ||
| } | ||
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/bak/feed/application/query/dto/FeedDetail.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,16 @@ | ||
| package com.example.bak.feed.application.query.dto; | ||
|
|
||
| import com.example.bak.community.application.query.dto.CommunityResult; | ||
| import com.example.bak.user.application.dto.UserInfo; | ||
|
|
||
| /** | ||
| * Feed 도메인의 상세 정보를 담는 DTO 단건 조회 시 사용 | ||
| */ | ||
| public record FeedDetail( | ||
| Long id, | ||
| String title, | ||
| String content, | ||
| UserInfo author, | ||
| CommunityResult.Detail community | ||
| ) { | ||
| } |
2 changes: 1 addition & 1 deletion
2
.../bak/feed/application/dto/FeedResult.java → ...eed/application/query/dto/FeedResult.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
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/bak/feed/application/query/dto/FeedSummary.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,16 @@ | ||
| package com.example.bak.feed.application.query.dto; | ||
|
|
||
| import com.example.bak.community.application.query.dto.CommunityResult; | ||
| import com.example.bak.user.application.dto.UserInfo; | ||
|
|
||
| /** | ||
| * Feed 도메인의 간단한 정보를 담는 DTO 목록 조회 시 사용 | ||
| */ | ||
| public record FeedSummary( | ||
| Long id, | ||
| String title, | ||
| UserInfo author, | ||
| CommunityResult.Detail community, | ||
| int commentCount | ||
| ) { | ||
| } |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/example/bak/feed/application/query/port/FeedQueryPort.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,16 @@ | ||
| package com.example.bak.feed.application.query.port; | ||
|
|
||
| import com.example.bak.feed.application.query.dto.FeedDetail; | ||
| import com.example.bak.feed.application.query.dto.FeedSummary; | ||
| import java.util.Optional; | ||
| import org.springframework.data.domain.Page; | ||
| import org.springframework.data.domain.Pageable; | ||
|
|
||
| public interface FeedQueryPort { | ||
|
|
||
| Page<FeedSummary> findAll(Pageable pageable); | ||
|
|
||
| Optional<FeedSummary> findSummaryById(Long feedId); | ||
|
|
||
| Optional<FeedDetail> findDetailById(Long feedId); | ||
| } |
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.