-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] 매칭 상태에 따른 matchingDoneCount 계산 및 게시글 상태 업데이트 기능 구현 (#182)
* feat: @formula를 이용해 Native Query로 matchingDoneCount 계산 * feat: 매칭이 다 찼을 때 예외 코드 작성 * feat: 매칭 완료된 수를 가져오는 네이티브 쿼리 함수 작성 * feat: 매칭 상태 업데이트 및 매칭 상태의 수에 따른 게시글 상태 업데이트 로직 구현 * rename: 모집완료 열거형 식별자 EXCEEDED_MATCHING_LIMIT에서 MATCHING_COMPLETED로 변경 * refactor: MatchingRepository에 집계 가능 함수 추가 하므로 @formula로 집계하던 matchingDoneCount 필드 제거 * feat: MatchingRepository 집계 함수로 matchingDoneCount 집계 * feat: MatchingRepository 집계 함수 사용 * refactor: 집계 함수 Native Query -> JPQL로 변경 * refactor: 게시글 목록을 조회하는 경우 PostRepository 사용하도록 변경, PostLikeRepository는 찜만 관리 * feat: BooleanExpression, OrderSpecifier에 Qpost 지정을 통해 함수 중복 제거
- Loading branch information
Showing
14 changed files
with
119 additions
and
109 deletions.
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
src/main/java/econo/buddybridge/matching/exception/MatchingCompletedException.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,12 @@ | ||
package econo.buddybridge.matching.exception; | ||
|
||
import econo.buddybridge.common.exception.BusinessException; | ||
|
||
public class MatchingCompletedException extends BusinessException { | ||
|
||
public static BusinessException EXCEPTION = new MatchingCompletedException(); | ||
|
||
private MatchingCompletedException() { | ||
super(MatchingErrorCode.MATCHING_COMPLETED); | ||
} | ||
} |
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
6 changes: 5 additions & 1 deletion
6
src/main/java/econo/buddybridge/matching/repository/MatchingRepository.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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package econo.buddybridge.matching.repository; | ||
|
||
import econo.buddybridge.matching.entity.Matching; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
import java.util.Optional; | ||
|
||
public interface MatchingRepository extends JpaRepository<Matching, Long> { | ||
|
||
@Query("SELECT m FROM Matching m JOIN FETCH m.post JOIN FETCH m.giver JOIN FETCH m.taker WHERE m.id = :matchingId") | ||
Optional<Matching> findByIdWithMembersAndPost(Long matchingId); | ||
|
||
@Query("SELECT COUNT(m) FROM Matching m WHERE m.post.id = :post_id AND m.matchingStatus = 'DONE'") | ||
Integer countMatchingDoneByPostId(Long post_id); | ||
} |
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
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
5 changes: 1 addition & 4 deletions
5
src/main/java/econo/buddybridge/post/repository/PostLikeRepositoryCustom.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 |
---|---|---|
@@ -1,13 +1,10 @@ | ||
package econo.buddybridge.post.repository; | ||
|
||
import econo.buddybridge.post.dto.PostCustomPage; | ||
import econo.buddybridge.post.entity.PostLike; | ||
import econo.buddybridge.post.entity.PostType; | ||
|
||
import java.util.Optional; | ||
|
||
public interface PostLikeRepositoryCustom { | ||
|
||
Optional<PostLike> findByPostIdAndMemberId(Long postId, Long memberId); | ||
|
||
PostCustomPage findPostsByLikes(Long memberId, Integer page, Integer size, String sort, PostType postType); | ||
} |
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.