-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [FEAT] 내 매칭 기록 조회하기 기능 구현 * [FIX] 프로젝트 요청 정렬 누락 오류 해결 * [FIX] Repository 어노테이션 누락 해결 * [FIX] swagger 설명 추가
- Loading branch information
Showing
9 changed files
with
172 additions
and
3 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
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
14 changes: 14 additions & 0 deletions
14
src/main/java/io/oeid/mogakgo/domain/matching/infrastructure/MatchingRepositoryCustom.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,14 @@ | ||
package io.oeid.mogakgo.domain.matching.infrastructure; | ||
|
||
import io.oeid.mogakgo.common.base.CursorPaginationInfoReq; | ||
import io.oeid.mogakgo.common.base.CursorPaginationResult; | ||
import io.oeid.mogakgo.domain.matching.presentation.dto.MatchingHistoryRes; | ||
import java.util.List; | ||
|
||
public interface MatchingRepositoryCustom { | ||
|
||
CursorPaginationResult<MatchingHistoryRes> getMyMatches( | ||
Long userId, CursorPaginationInfoReq cursorPaginationInfoReq | ||
); | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...ain/java/io/oeid/mogakgo/domain/matching/infrastructure/MatchingRepositoryCustomImpl.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,64 @@ | ||
package io.oeid.mogakgo.domain.matching.infrastructure; | ||
|
||
import static io.oeid.mogakgo.domain.matching.domain.entity.QMatching.matching; | ||
import static io.oeid.mogakgo.domain.project.domain.entity.QProject.project; | ||
|
||
import com.querydsl.core.types.Projections; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import io.oeid.mogakgo.common.base.CursorPaginationInfoReq; | ||
import io.oeid.mogakgo.common.base.CursorPaginationResult; | ||
import io.oeid.mogakgo.domain.matching.presentation.dto.MatchingHistoryRes; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class MatchingRepositoryCustomImpl implements MatchingRepositoryCustom { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
|
||
|
||
@Override | ||
public CursorPaginationResult<MatchingHistoryRes> getMyMatches( | ||
Long userId, CursorPaginationInfoReq cursorPaginationInfoReq | ||
) { | ||
List<MatchingHistoryRes> matchingHistoryResList = jpaQueryFactory | ||
.select( | ||
Projections.constructor( | ||
MatchingHistoryRes.class, | ||
matching.id, | ||
matching.matchingStatus, | ||
matching.project.creator.avatarUrl, | ||
matching.project.meetingInfo.meetDetail, | ||
matching.project.meetingInfo.meetStartTime, | ||
matching.project.meetingInfo.meetEndTime | ||
) | ||
) | ||
.from(matching) | ||
.join(matching.project) | ||
.where( | ||
participantInMatching(userId), | ||
cursorIdCondition(cursorPaginationInfoReq.getCursorId()) | ||
) | ||
// 최근순 | ||
.orderBy(matching.id.desc()) | ||
.limit(cursorPaginationInfoReq.getPageSize() + 1) | ||
.fetch(); | ||
|
||
return CursorPaginationResult.fromDataWithExtraItemForNextCheck(matchingHistoryResList, | ||
cursorPaginationInfoReq.getPageSize()); | ||
} | ||
|
||
private BooleanExpression cursorIdCondition(Long cursorId) { | ||
return cursorId != null ? matching.id.lt(cursorId) : null; | ||
} | ||
|
||
private BooleanExpression participantInMatching(Long userId) { | ||
return userId != null ? (matching.sender.id.eq(userId).or(matching.project.creator.id.eq( | ||
userId))) : 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
27 changes: 27 additions & 0 deletions
27
src/main/java/io/oeid/mogakgo/domain/matching/presentation/dto/MatchingHistoryRes.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,27 @@ | ||
package io.oeid.mogakgo.domain.matching.presentation.dto; | ||
|
||
import io.oeid.mogakgo.domain.matching.domain.entity.enums.MatchingStatus; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.time.LocalDateTime; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Schema(description = "매칭 이력") | ||
@Getter | ||
@AllArgsConstructor | ||
public class MatchingHistoryRes { | ||
|
||
@Schema(description = "매칭 ID") | ||
private final Long matchingId; | ||
@Schema(description = "매칭 상태") | ||
private final MatchingStatus status; | ||
@Schema(description = "상대방 프로필 이미지 URL") | ||
private final String anotherUserAvatarUrl; | ||
@Schema(description = "프로젝트 위치 상세") | ||
private final String projectLocationDetail; | ||
@Schema(description = "프로젝트 시작 시간") | ||
private final LocalDateTime projectStartTime; | ||
@Schema(description = "프로젝트 종료 시간") | ||
private final LocalDateTime projectEndTime; | ||
|
||
} |
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