-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : post domain search query dev, application & presentation layer…
… deving (#53)
- Loading branch information
1 parent
5c84440
commit a8e58f5
Showing
45 changed files
with
1,071 additions
and
110 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
needeachother/src/main/java/com/neo/needeachother/post/application/DeletePostService.java
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
2 changes: 1 addition & 1 deletion
2
...c/main/java/com/neo/needeachother/post/application/ExposurePostToStarPageMainService.java
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
2 changes: 1 addition & 1 deletion
2
needeachother/src/main/java/com/neo/needeachother/post/application/HostHeartService.java
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
2 changes: 1 addition & 1 deletion
2
needeachother/src/main/java/com/neo/needeachother/post/application/LikePostService.java
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
2 changes: 1 addition & 1 deletion
2
...er/src/main/java/com/neo/needeachother/post/application/ModifyPostInformationService.java
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
37 changes: 37 additions & 0 deletions
37
...other/src/main/java/com/neo/needeachother/post/application/PostByCategoryViewService.java
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.neo.needeachother.post.application; | ||
|
||
import com.neo.needeachother.category.domain.CategoryId; | ||
import com.neo.needeachother.post.domain.dto.PostSearchCondition; | ||
import com.neo.needeachother.post.domain.dto.StarPagePostHeadlineDto; | ||
import com.neo.needeachother.post.domain.repository.PostRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Slice; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PostByCategoryViewService { | ||
|
||
private final PostRepository postRepository; | ||
|
||
public Slice<StarPagePostHeadlineDto> getPostPageByCategoryWithInfiniteScroll(String categoryId, Long lastPostId, Pageable pageable, | ||
boolean orderByCreatedAt, boolean orderByLikeCount, boolean onlySearchHostWritten, boolean onlySearchHostHearted) { | ||
|
||
return postRepository.searchPostHeadlineByCategoryIdWithNoOffset( | ||
CategoryId.of(categoryId), | ||
PostSearchCondition.of(orderByCreatedAt, orderByLikeCount, onlySearchHostWritten, onlySearchHostHearted), | ||
lastPostId, | ||
pageable); | ||
} | ||
|
||
public Page<StarPagePostHeadlineDto> getPostPageByCategoryWithPaging(String categoryId, Pageable pageable, | ||
boolean orderByCreatedAt, boolean orderByLikeCount, boolean onlySearchHostWritten, boolean onlySearchHostHearted) { | ||
return postRepository.searchPostHeadlineByCategoryIdWithPaging( | ||
CategoryId.of(categoryId), | ||
PostSearchCondition.of(orderByCreatedAt, orderByLikeCount, onlySearchHostWritten, onlySearchHostHearted), | ||
pageable | ||
); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...eachother/src/main/java/com/neo/needeachother/post/application/PostDetailViewService.java
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.neo.needeachother.post.application; | ||
|
||
import com.neo.needeachother.common.exception.NEOUnexpectedException; | ||
import com.neo.needeachother.post.application.dto.PostDetailDto; | ||
import com.neo.needeachother.post.domain.*; | ||
import com.neo.needeachother.post.domain.repository.PostRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PostDetailViewService { | ||
|
||
private final PostRepository postRepository; | ||
|
||
public PostDetailDto getPostDetailView(String contentType, Long postId) { | ||
PostType postType = PostType.valueOf(contentType); | ||
switch (postType) { | ||
case COMMON -> { | ||
return getCommonPostDetailView(postId); | ||
} | ||
case ALBUM -> { | ||
return getAlbumPostDetailView(postId); | ||
} | ||
case GOLD_BALANCE -> { | ||
return getGoldBalancePostDetailView(postId); | ||
} | ||
case VOTE -> { | ||
return getVotePostDetailView(postId); | ||
} | ||
default -> throw new NEOUnexpectedException("적절하지 않은 컨텐츠 타입의 입력"); | ||
} | ||
} | ||
|
||
private PostDetailDto getCommonPostDetailView(Long postId) { | ||
return postRepository.findCommonPostById(postId) | ||
.map(CommonPost::toPostDetailDto) | ||
// TODO : orElseThrow로 변경 | ||
.orElse(null); | ||
} | ||
|
||
private PostDetailDto getAlbumPostDetailView(Long postId) { | ||
return postRepository.findAlbumPostById(postId) | ||
.map(AlbumPost::toPostDetailDto) | ||
// TODO : orElseThrow로 변경 | ||
.orElse(null); | ||
} | ||
|
||
private PostDetailDto getGoldBalancePostDetailView(Long postId) { | ||
return postRepository.findGoldBalancePostById(postId) | ||
.map(GoldBalancePost::toPostDetailDto) | ||
// TODO : orElseThrow로 변경 | ||
.orElse(null); | ||
} | ||
|
||
private PostDetailDto getVotePostDetailView(Long postId) { | ||
return postRepository.findVotePostById(postId) | ||
.map(VotePost::toPostDetailDto) | ||
// TODO : orElseThrow로 변경 | ||
.orElse(null); | ||
} | ||
} |
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
11 changes: 0 additions & 11 deletions
11
needeachother/src/main/java/com/neo/needeachother/post/application/PostUseCase.java
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
needeachother/src/main/java/com/neo/needeachother/post/application/PostUseCaseImpl.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
needeachother/src/main/java/com/neo/needeachother/post/application/RestorePostService.java
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
13 changes: 13 additions & 0 deletions
13
...ther/src/main/java/com/neo/needeachother/post/application/dto/CommonPostParagraphDto.java
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.neo.needeachother.post.application.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
public class CommonPostParagraphDto { | ||
private String paragraphType; | ||
private String body; | ||
} |
37 changes: 37 additions & 0 deletions
37
needeachother/src/main/java/com/neo/needeachother/post/application/dto/PostDetailDto.java
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.neo.needeachother.post.application.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class PostDetailDto { | ||
|
||
private Long postId; | ||
private String categoryId; | ||
private String title; | ||
private String authorName; | ||
private String status; | ||
private int likeCount; | ||
private boolean hostHeart; | ||
private LocalDateTime exposureAt; | ||
private String postType; | ||
|
||
/* common & image post data */ | ||
private String representativeImage; | ||
|
||
/* only common post data */ | ||
private List<CommonPostParagraphDto> paragraph; | ||
|
||
/* GoldBalance, Vote post data */ | ||
private String question; | ||
private Map<String, VoteAblePostOptionDetailDto> options; | ||
} |
10 changes: 10 additions & 0 deletions
10
...src/main/java/com/neo/needeachother/post/application/dto/VoteAblePostOptionDetailDto.java
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.neo.needeachother.post.application.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
public class VoteAblePostOptionDetailDto { | ||
private String optionName; | ||
private Integer optionCount; | ||
private Integer optionRate; | ||
} |
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.