Skip to content

Commit

Permalink
#264 feat: 일대다 상담 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
aeyongdodam committed Oct 5, 2024
1 parent a5b3af0 commit 9e862cd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public interface AdminService {

List<PostGetUnpaidPrivateResponse> getUnpaidPrivatePosts();

List<PostGetUnpaidPrivateResponse> getPaidPrivatePosts();

void updatePostIsPaid(Long postId);

List<CustomerGetByNicknameOrEmailResponse> getCustomersByNicknameOrEmail(String keyword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ public List<PostGetUnpaidPrivateResponse> getUnpaidPrivatePosts() {
.toList();
}

@Override
public List<PostGetUnpaidPrivateResponse> getPaidPrivatePosts() {
return postService.getPaidPrivatePosts().stream()
.map(PostGetUnpaidPrivateResponse::of)
.toList();
}

@Transactional
@Override
public void updatePostIsPaid(Long postId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,15 @@ public ResponseEntity<List<PostGetUnpaidPrivateResponse>> getUnpaidPrivatePosts(
return ResponseEntity.ok(adminService.getUnpaidPrivatePosts());
}

@Operation(summary = "결제 일대다 상담 리스트 조회", description = "결제 여부(isPaid)가 true인 일대다 상담 리스트 조회")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "조회 성공")
})
@GetMapping("/paid-posts")
public ResponseEntity<List<PostGetUnpaidPrivateResponse>> getPaidPrivatePosts() {
return ResponseEntity.ok(adminService.getPaidPrivatePosts());
}

@Operation(summary = "일대다 비공개 상담 결제 여부 수정", description = "결제 여부(isPaid)가 false인 일대다 상담을 true로 수정")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "수정 성공"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public interface PostService {

List<Post> getUnpaidPrivatePosts();

List<Post> getPaidPrivatePosts();

Post getPostByPostId(Long postId);

Post getPostByPayAppId(String payAppId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public List<Post> getUnpaidPrivatePosts() {
return postRepository.findAllByIsPaidIsFalseAndIsActivatedIsTrue();
}

@Override
public List<Post> getPaidPrivatePosts() {
return postRepository.findAllByIsPaidIsTrueAndIsActivatedIsTrue();
}

@Override
public Post getPostByPostId(Long postId) {
return postRepository.findByPostIdAndIsActivatedIsTrue(postId).orElseThrow(
Expand Down Expand Up @@ -250,7 +255,7 @@ public Boolean getIsPostOwner(Long postId, Long customerId) {
@Transactional
public void checkPostStatus() {
postRepository.findAllWaitingPublicPostsAfter24Hours()
.forEach(BaseEntity::updateIsActivatedFalse);
.forEach(BaseEntity::updateIsActivatedFalse);

postRepository.findAllCommentedProceedingPublicPostsAfter72Hours()
.forEach(post -> post.updatePostStatus(PostStatus.TIME_OUT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public interface PostRepository extends JpaRepository<Post, Long>, PostCustomRep

List<Post> findAllByIsPaidIsFalseAndIsActivatedIsTrue();

List<Post> findAllByIsPaidIsTrueAndIsActivatedIsTrue();

@Query(value = "SELECT * FROM post " +
"WHERE is_public = true AND post_status = 'WAITING' AND is_activated = true "
+ "AND created_at <= CURRENT_TIMESTAMP - INTERVAL 1 DAY ", nativeQuery = true)
Expand Down

0 comments on commit 9e862cd

Please sign in to comment.