-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat/CK-114] 로드맵 리뷰를 조회하는 기능을 구현한다 (#74)
* feat: 로드맵 리뷰 조회 API 구현 * feat: 로드맵 리뷰 조회 Repository 구현 * feat: 로드맵 리뷰 조회 Service 구현 * feat: 로드맵 리뷰 조회 무한 스크롤 방식으로 변경 및 통합 테스트 추가 * refactor: 리뷰 반영 * refactor: LocalDateTime 요청/응답 formatting문제 해결 * test: 사용자 프로필 이미지 경로도 확인하도록 수정
- Loading branch information
Showing
19 changed files
with
821 additions
and
228 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
25 changes: 25 additions & 0 deletions
25
backend/kirikiri/src/main/java/co/kirikiri/persistence/dto/RoadmapReviewLastValueDto.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,25 @@ | ||
package co.kirikiri.persistence.dto; | ||
|
||
import co.kirikiri.service.dto.CustomReviewScrollRequest; | ||
import java.time.LocalDateTime; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@Getter | ||
public class RoadmapReviewLastValueDto { | ||
|
||
private final LocalDateTime lastCreatedAt; | ||
private final Double lastReviewRate; | ||
|
||
public static RoadmapReviewLastValueDto create(final CustomReviewScrollRequest request) { | ||
if (request.lastCreatedAt() == null && request.lastReviewRate() == null) { | ||
return null; | ||
} | ||
if (request.lastReviewRate() == null) { | ||
return new RoadmapReviewLastValueDto(request.lastCreatedAt(), null); | ||
} | ||
return new RoadmapReviewLastValueDto(null, request.lastReviewRate()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
.../kirikiri/src/main/java/co/kirikiri/persistence/roadmap/RoadmapReviewQueryRepository.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 co.kirikiri.persistence.roadmap; | ||
|
||
import co.kirikiri.domain.roadmap.Roadmap; | ||
import co.kirikiri.domain.roadmap.RoadmapReview; | ||
import co.kirikiri.persistence.dto.RoadmapReviewLastValueDto; | ||
import java.util.List; | ||
|
||
public interface RoadmapReviewQueryRepository { | ||
|
||
List<RoadmapReview> findRoadmapReviewWithMemberByRoadmapOrderByLatest(final Roadmap roadmap, | ||
final RoadmapReviewLastValueDto lastValue, | ||
final int pageSize); | ||
} |
49 changes: 49 additions & 0 deletions
49
...ikiri/src/main/java/co/kirikiri/persistence/roadmap/RoadmapReviewQueryRepositoryImpl.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,49 @@ | ||
package co.kirikiri.persistence.roadmap; | ||
|
||
import static co.kirikiri.domain.member.QMember.member; | ||
import static co.kirikiri.domain.roadmap.QRoadmapReview.roadmapReview; | ||
|
||
import co.kirikiri.domain.roadmap.Roadmap; | ||
import co.kirikiri.domain.roadmap.RoadmapReview; | ||
import co.kirikiri.persistence.QuerydslRepositorySupporter; | ||
import co.kirikiri.persistence.dto.RoadmapReviewLastValueDto; | ||
import com.querydsl.core.types.OrderSpecifier; | ||
import com.querydsl.core.types.dsl.BooleanExpression; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public class RoadmapReviewQueryRepositoryImpl extends QuerydslRepositorySupporter implements | ||
RoadmapReviewQueryRepository { | ||
|
||
public RoadmapReviewQueryRepositoryImpl() { | ||
super(RoadmapReview.class); | ||
} | ||
|
||
@Override | ||
public List<RoadmapReview> findRoadmapReviewWithMemberByRoadmapOrderByLatest(final Roadmap roadmap, | ||
final RoadmapReviewLastValueDto lastValue, | ||
final int pageSize) { | ||
return selectFrom(roadmapReview) | ||
.innerJoin(roadmapReview.member, member) | ||
.fetchJoin() | ||
.where(roadmapCond(roadmap), lessThanLastValue(lastValue)) | ||
.limit(pageSize) | ||
.orderBy(orderByCreatedAtDesc()) | ||
.fetch(); | ||
} | ||
|
||
private BooleanExpression roadmapCond(final Roadmap roadmap) { | ||
return roadmapReview.roadmap.eq(roadmap); | ||
} | ||
|
||
private BooleanExpression lessThanLastValue(final RoadmapReviewLastValueDto lastValue) { | ||
if (lastValue == null) { | ||
return null; | ||
} | ||
return roadmapReview.createdAt.lt(lastValue.getLastCreatedAt()); | ||
} | ||
|
||
private OrderSpecifier<LocalDateTime> orderByCreatedAtDesc() { | ||
return roadmapReview.createdAt.desc(); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
backend/kirikiri/src/main/java/co/kirikiri/service/dto/CustomReviewScrollRequest.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,15 @@ | ||
package co.kirikiri.service.dto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.time.LocalDateTime; | ||
import org.springframework.format.annotation.DateTimeFormat; | ||
|
||
public record CustomReviewScrollRequest( | ||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSSSSS") | ||
LocalDateTime lastCreatedAt, | ||
Double lastReviewRate, | ||
@NotNull(message = "사이즈를 입력해 주세요.") | ||
Integer size | ||
) { | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
...irikiri/src/main/java/co/kirikiri/service/dto/roadmap/response/RoadmapReviewResponse.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 co.kirikiri.service.dto.roadmap.response; | ||
|
||
import co.kirikiri.service.dto.member.response.MemberResponse; | ||
import java.time.LocalDateTime; | ||
|
||
public record RoadmapReviewResponse( | ||
Long id, | ||
MemberResponse member, | ||
LocalDateTime createdAt, | ||
String content, | ||
Double rate | ||
) { | ||
|
||
} |
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
Submodule properties
updated
from f8d288 to 3421e8
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.