Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 여행 전체 조회 기능 추가 (#361) #364

Merged
merged 70 commits into from
Sep 19, 2023

Conversation

Combi153
Copy link
Collaborator

@Combi153 Combi153 commented Sep 16, 2023

📌 관련 이슈

📁 작업 설명

  • Cursor-based Pagination 구현했습니다.
    자세한 내용은 아래에서 확인해주세요!
    Pagination #374

  • 모든 회원의 감상이 있는 여행을 조회하는 api를 구현했습니다.

  • 개발한 api 여행 조회에 대한 테스트를 작성했습니다.
    관련해서 다음과 같은 에러를 마주했습니다.
    @Nested build 실패 에러 #375

@github-actions
Copy link

github-actions bot commented Sep 16, 2023

Test Results

241 tests   241 ✔️  23s ⏱️
  67 suites      0 💤
  67 files        0

Results for commit 069e7d7.

♻️ This comment has been updated with latest results.

@Combi153 Combi153 changed the title [feat] 여행 전체 조회 기능 추가 (#361) (아직 작업 중) [feat] 여행 전체 조회 기능 추가 (#361) Sep 18, 2023
Copy link
Member

@greeng00se greeng00se left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안녕하세요 후추 고생하셨습니다! 일정이 빡빡한데 빨리 구현한다고 고생하셨습니다! 👍 👍
코멘트 몇개 남겼으니 확인해주시면 감사하겠습니다!
추가로 Condition을 적용한 Controller 테스트가 하나 정도 있으면 좋을 것 같습니다!

Comment on lines 15 to 16
public QueryDslConfig() {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈 생성자를 제거하는건 어떤가요?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우렁각시가 만들어줬어요 제가 안 만들었어요

Comment on lines 21 to 24
return tripCustomRepository.findAllByConditions(
tripQueryConditions,
tripPaging
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한 줄로 작성하는건 어떨까요?

import org.springframework.transaction.annotation.Transactional;

@RequiredArgsConstructor
@Transactional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryService의 경우 클래스단에 readOnly를 적용하는건 어떤가요?

}

private BooleanExpression yearIn(Set<Integer> years) {
if (CollectionUtils.isEmpty(years)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null check를 위해 CollectionUtils를 사용하셨군요 👍

Comment on lines 18 to 28
@ParameterizedTest
@ValueSource(ints = {2009, 2024})
void 연도가_2010_미만_2023_초과이면_예외를_던진다(int year) {
// given
Set<Integer> years = of(year);

// expect
assertThatThrownBy(() -> new TripQueryConditions(years, of(), of(), of(), of(), ""))
.isInstanceOf(TripException.class)
.hasMessage("유효하지 않은 여행 조회 조건입니다.");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

경계값 테스트 👍

Comment on lines 33 to 34
private static final int FIRST_INDEX = 0;
private final TripRepository tripRepository;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

한 칸 띄우면 좋을 것 같아요 👍

private final TripRepository tripRepository;
private final PointRepository pointRepository;
private final MemberRepository memberRepository;
private final TripQueryService tripQueryService;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TripService가 TripQueryService를 사용하고 있는데 혹시 어떤 이유로 QueryService를 사용하는지 코멘트 남겨주실 수 있나요?

Comment on lines 6 to 12
public record TripSearchResponse(
@Schema(description = "여행 Id", example = "1")
Long tripId,

@Schema(description = "여행명", example = "통후추의 여행")
String name,

@Schema(description = "이미지 주소", example = "https://tripdraw.site/post-images/cd678ca2-30d5-11ee-be56-0242ac120002.jpg")
String imageUrl,

@Schema(description = "경로 이미지 주소", example = "https://tripdraw.site/route-images/cd678ca2-30d5-11ee-be56-0242ac120002.png")
String routeImageUrl
String routeImageUrl,
LocalDateTime startTime,
LocalDateTime endTime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일관성을 위해서 Schema를 추가하는 것도 좋을 것 같습니다.

Comment on lines +8 to +15
public record TripSearchConditions(
Set<Integer> years,
Set<Integer> months,
Set<Integer> daysOfWeek,
Set<Integer> ageRanges,
Set<Integer> genders,
String address
) {
Copy link
Member

@greeng00se greeng00se Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Builder
public record TripSearchConditions(
        Set<@Range(min = 2010, max = 2023) Integer> years,
        Set<@Range(min = 1, max = 12) Integer> months,
        Set<@Range(min = 1, max = 7) Integer> daysOfWeek,
        Set<@Range(min = 1, max = 10) Integer> ageRanges,
        Set<@Range(min = 1, max = 2) Integer> genders,
        String address
) {

    public TripQueryConditions toTripQueryConditions() {
        return new TripQueryConditions(years(), months(), daysOfWeek(), ageRanges(), genders(), address());
    }
}

Validation을 이용하는건 어떨까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리오는 아직 적용을 안 했던데, 일단은 두고 추후 함께 적용하겠습니다


@RequiredArgsConstructor
@Repository
public class TripCustomRepositoryImpl implements TripCustomRepository {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TripQueryRepository로 변경하고 implements를 제거하는건 어떤가요?

Copy link
Member

@greeng00se greeng00se left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 👍

Copy link
Collaborator

@Jaeyoung22 Jaeyoung22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어프루브 요청하셨지만 RC합니다 확인해주세요

) {

public TripQueryConditions toTripQueryConditions() {
return new TripQueryConditions(years(), months(), daysOfWeek(), ageRanges(), genders(), address());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TripQueryConditions에도 빌더패턴 적용하면 좋을 것 같아요~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TripQueryConditions 지우고 TripSearchConditions 만 사용하도록 리팩터링 했습니다!

public class TripSearchConditionsFixture {

public static TripSearchConditions emptyTripSearchConditions() {
return new TripSearchConditions(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TripSearchConditions에도 빌더 패턴 적용하면 필요한 프로퍼티만 설정할 수 있어서 테스트 코드가 깔끔해질 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

적용 완료 했습니다~

Copy link
Collaborator

@Jaeyoung22 Jaeyoung22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

@Combi153 Combi153 merged commit b1dd885 into develop-backend Sep 19, 2023
3 checks passed
@Combi153 Combi153 deleted the feature/#361 branch September 26, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants