-
Notifications
You must be signed in to change notification settings - Fork 1
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: 여행 상세 목록 조회 API 구현 #19 #60
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4191311
test: 여행 상세 목록 조회 통합 테스트 작성
linirini 11f6708
feat: 여행 상세 목록 조회 DTO 구현
linirini 3a1ef05
feat: 모든 여행 상세 목록 조회 서비스 구현
linirini f5c8905
refactor: 미사용 반환값 제거
linirini 226299a
feat: 년도 조건에 따른 여행 상세 조회 서비스 구현
linirini 3bfae99
test: import 수정
linirini a74b7d2
test: 년도와 사용자 식별자로 여행 목록 조회하는 JPQL 테스트 추가
linirini 3bd69ad
style: 코드 컨벤션 적용
linirini f440e32
test: 여행 상세 목록 조회 컨트롤러 구현
linirini 4965a40
test: disabled 제거 및 테스트 오류 수정
linirini 327f5f5
refactor: 불필요한 변수 분리 제거
linirini ebdebdc
refactor: Optional로 분기 처리
linirini e1272bd
test: DisplayName 수정
linirini 0a795ec
Merge branch 'develop-be' into feature/#19-read-travel-list
linirini 84c3cd4
refactor: DTO 이름 변경
linirini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/com/staccato/member/service/dto/response/MemberResponse.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 com.staccato.member.service.dto.response; | ||
|
||
import com.staccato.member.domain.Member; | ||
|
||
public record MemberResponse( | ||
Long memberId, | ||
String nickName, | ||
String memberImage | ||
) { | ||
public MemberResponse(Member member) { | ||
this(member.getId(), member.getNickname(), member.getImageUrl()); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/com/staccato/member/service/dto/response/MemberResponses.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 com.staccato.member.service.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import com.staccato.member.domain.Member; | ||
|
||
public record MemberResponses(List<MemberResponse> members) { | ||
public static MemberResponses from(List<Member> members) { | ||
return new MemberResponses(members.stream() | ||
.map(MemberResponse::new) | ||
.toList()); | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/com/staccato/travel/repository/TravelMemberRepository.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,16 @@ | ||
package com.staccato.travel.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
import com.staccato.travel.domain.TravelMember; | ||
|
||
public interface TravelMemberRepository extends JpaRepository<TravelMember, Long> { | ||
List<TravelMember> findAllByMemberId(long memberId); | ||
|
||
@Query("SELECT tm FROM TravelMember tm WHERE tm.member.id = :memberId AND YEAR(tm.travel.startAt) = :year") | ||
List<TravelMember> findAllByMemberIdAndTravelStartAtYear(@Param("memberId") long memberId, @Param("year") int year); | ||
} |
8 changes: 0 additions & 8 deletions
8
backend/src/main/java/com/staccato/travel/repository/TravelMemberRepostiory.java
This file was deleted.
Oops, something went wrong.
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
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/com/staccato/travel/service/dto/response/TravelDetailResponse.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,28 @@ | ||
package com.staccato.travel.service.dto.response; | ||
|
||
import java.time.LocalDate; | ||
|
||
import com.staccato.member.service.dto.response.MemberResponses; | ||
import com.staccato.travel.domain.Travel; | ||
|
||
public record TravelDetailResponse( | ||
Long travelId, | ||
String travelThumbnail, | ||
String travelTitle, | ||
String description, | ||
LocalDate startAt, | ||
LocalDate endAt, | ||
MemberResponses mates | ||
) { | ||
public TravelDetailResponse(Travel travel) { | ||
this( | ||
travel.getId(), | ||
travel.getThumbnailUrl(), | ||
travel.getTitle(), | ||
travel.getDescription(), | ||
travel.getStartAt(), | ||
travel.getEndAt(), | ||
MemberResponses.from(travel.getMates()) | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/main/java/com/staccato/travel/service/dto/response/TravelDetailResponses.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 com.staccato.travel.service.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import com.staccato.travel.domain.Travel; | ||
|
||
public record TravelDetailResponses( | ||
List<TravelDetailResponse> travels | ||
) { | ||
public static TravelDetailResponses from(List<Travel> travels) { | ||
return new TravelDetailResponses(travels.stream() | ||
.map(TravelDetailResponse::new) | ||
.toList()); | ||
} | ||
} |
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
53 changes: 53 additions & 0 deletions
53
backend/src/test/java/com/staccato/travel/repository/TravelMemberRepositoryTest.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,53 @@ | ||
package com.staccato.travel.repository; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
|
||
import com.staccato.member.domain.Member; | ||
import com.staccato.member.repository.MemberRepository; | ||
import com.staccato.travel.domain.Travel; | ||
import com.staccato.travel.domain.TravelMember; | ||
|
||
@DataJpaTest | ||
class TravelMemberRepositoryTest { | ||
@Autowired | ||
private TravelMemberRepository travelMemberRepository; | ||
@Autowired | ||
private MemberRepository memberRepository; | ||
@Autowired | ||
private TravelRepository travelRepository; | ||
|
||
@DisplayName("사용자 식별자와 년도로 여행 상세 목록을 조회한다.") | ||
@Test | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
void findAllByMemberIdAndTravelStartAtYear() { | ||
// given | ||
Member member = memberRepository.save(Member.builder().nickname("staccato").build()); | ||
Travel travel = travelRepository.save(createTravel(LocalDate.of(2023, 7, 1), LocalDate.of(2023, 7, 10))); | ||
Travel travel2 = travelRepository.save(createTravel(LocalDate.of(2023, 12, 31), LocalDate.of(2024, 1, 10))); | ||
Travel travel3 = travelRepository.save(createTravel(LocalDate.of(2024, 7, 1), LocalDate.of(2024, 7, 10))); | ||
travelMemberRepository.save(new TravelMember(member, travel)); | ||
travelMemberRepository.save(new TravelMember(member, travel2)); | ||
travelMemberRepository.save(new TravelMember(member, travel3)); | ||
|
||
// when | ||
List<TravelMember> result = travelMemberRepository.findAllByMemberIdAndTravelStartAtYear(member.getId(), 2023); | ||
|
||
// then | ||
assertThat(result).hasSize(2); | ||
} | ||
|
||
private static Travel createTravel(LocalDate startAt, LocalDate endAt) { | ||
return Travel.builder() | ||
.title("여행") | ||
.startAt(startAt) | ||
.endAt(endAt) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 메시지는 "사용자가 타임라인을 조회하면 1개의 여행 목록이 조회된다." 가 맞는 것 같네요! (2 -> 1로 변경)