-
Notifications
You must be signed in to change notification settings - Fork 1
[refactor] 마이페이지 내 게시글 조회(내가 기록하거나 저장한) API 리팩토링 및 응답 형식 변경 #195
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
Open
daeun-han
wants to merge
9
commits into
develop
Choose a base branch
from
refactor/#192
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
27eb2c3
[refactor] PostCardResponseDto 구조 변경
daeun-han ba199bd
[refactor] facade에 적용 및 service 코드 추가
daeun-han 02fa0a2
[feat] isLike 필드 관련 로직 추가
daeun-han a984249
[refactor] PostCardResponseDto 구조 변경에 따른 다른 도메인 관련 수정
daeun-han 1b8e667
[refactor] 요청 파라미터에 userId 삭제
daeun-han dc7df80
[refactor] Facade-Service 계층 간 역할 분리 및 비즈니스 로직 위임
daeun-han cc9fb9e
[refactor] NPE 방어 코드 추가
daeun-han 0b86005
[refactor] 중복 제거 및 시간 복잡도 완화
daeun-han 46367f7
[refactor] 좋아요 게시물 관련 facade 코드를 service로 이동
daeun-han 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
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
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
50 changes: 50 additions & 0 deletions
50
...g/sopt/pawkey/backendapi/domain/user/application/service/UserWrittenPostQueryService.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,50 @@ | ||
| package org.sopt.pawkey.backendapi.domain.user.application.service; | ||
|
|
||
| import java.util.Comparator; | ||
| import java.util.List; | ||
|
|
||
| import org.sopt.pawkey.backendapi.domain.post.application.dto.result.GetPostCardResult; | ||
| import org.sopt.pawkey.backendapi.domain.post.domain.repository.PostLikeRepository; | ||
| import org.sopt.pawkey.backendapi.domain.post.domain.repository.PostRepository; | ||
| import org.sopt.pawkey.backendapi.domain.post.infra.persistence.entity.PostEntity; | ||
| import org.sopt.pawkey.backendapi.domain.post.infra.persistence.entity.PostLikeEntity; | ||
| import org.sopt.pawkey.backendapi.domain.user.infra.persistence.entity.UserEntity; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| @Transactional(readOnly = true) | ||
| public class UserWrittenPostQueryService { | ||
|
|
||
| private final PostRepository postRepository; | ||
| private final PostLikeRepository postLikeRepository; | ||
|
|
||
| public List<GetPostCardResult> findMyPostResults(UserEntity user, List<Long> likedPostIds) { | ||
| return postRepository.findAllByUser(user).stream() | ||
| .sorted(Comparator.comparing(PostEntity::getPostId).reversed()) | ||
| .map(post -> { | ||
| String regionName = post.getRoute().getRegion().getParent().getRegionName() + " " + | ||
| post.getRoute().getRegion().getRegionName(); | ||
|
|
||
| int durationMinutes = (int)(post.getRoute().getDuration() / 60); | ||
daeun-han marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return GetPostCardResult.builder() | ||
| .postId(post.getPostId()) | ||
| .regionName(regionName) | ||
| .title(post.getTitle()) | ||
| .createdAt(post.getCreatedAt()) | ||
| .durationMinutes(durationMinutes) | ||
| .isLike(likedPostIds.contains(post.getPostId())) | ||
daeun-han marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .routeMapImageUrl(post.getRoute().getTrackingImage().getImageUrl()) | ||
daeun-han marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .build(); | ||
| }) | ||
| .toList(); | ||
| } | ||
|
|
||
| public List<Long> getLikedPostIds(Long userId) { | ||
| return postLikeRepository.findLikedPostIdsByUserId(userId); | ||
| } | ||
| } | ||
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.