-
Notifications
You must be signed in to change notification settings - Fork 5
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
[Feature] - 여행 계획 공유 기능 구현 #203
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
072c64c
refactor: TravelPlan 공유를 위한 URL 생성에 사용되는 Key(UUID) 필드 추가
hangillee 80c94be
refactor: TravelPlan 생성 과정과 응답 DTO에 UUID 필드 추가
hangillee 82aafa8
refactor: TravelPlan UUID 필드 추가에 따른 테스트 코드 수정
hangillee c251ed4
feat: 공유된 여행 계획 조회 기능 구현
Libienz 7cf631f
feat: Swagger DTO 필드 example 작성
Libienz 11d4977
fix: 공유된 여행 계획 조회 엔드포인트 수정
Libienz 8887ad2
test: 여행 계획 공유 테스트 작성
Libienz 810cbd0
refactor: 여행 계획 공유 키 생성 로직 DTO에서 서비스로 이동 개선
Libienz 429adef
feat: 로그인 되지 않은 유저도 공유된 여행 계획을 조회할 수 있도록 기능 추가
Libienz 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
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
6 changes: 3 additions & 3 deletions
6
backend/src/main/java/kr/touroot/travelplan/dto/response/TravelPlanPlaceResponse.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
package kr.touroot.travelplan.service; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import kr.touroot.global.auth.dto.MemberAuth; | ||
import kr.touroot.global.exception.BadRequestException; | ||
import kr.touroot.global.exception.ForbiddenException; | ||
|
@@ -26,9 +29,6 @@ | |
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class TravelPlanService { | ||
|
@@ -42,7 +42,7 @@ public class TravelPlanService { | |
@Transactional | ||
public TravelPlanCreateResponse createTravelPlan(TravelPlanCreateRequest request, MemberAuth memberAuth) { | ||
Member author = getMemberByMemberAuth(memberAuth); | ||
TravelPlan travelPlan = request.toTravelPlan(author); | ||
TravelPlan travelPlan = request.toTravelPlan(author, UUID.randomUUID()); | ||
validStartDate(travelPlan); | ||
|
||
TravelPlan savedTravelPlan = travelPlanRepository.save(travelPlan); | ||
|
@@ -95,6 +95,13 @@ public TravelPlanResponse readTravelPlan(Long planId, MemberAuth memberAuth) { | |
return TravelPlanResponse.of(travelPlan, getTravelPlanDayResponses(travelPlan)); | ||
} | ||
|
||
@Transactional(readOnly = true) | ||
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. 다형성 활용 굿~ 👍 |
||
public TravelPlanResponse readTravelPlan(UUID shareKey) { | ||
TravelPlan travelPlan = getTravelPlanByShareKey(shareKey); | ||
|
||
return TravelPlanResponse.of(travelPlan, getTravelPlanDayResponses(travelPlan)); | ||
} | ||
|
||
private void validateAuthor(TravelPlan travelPlan, Member member) { | ||
if (!travelPlan.isAuthor(member)) { | ||
throw new ForbiddenException("여행 계획은 작성자만 조회할 수 있습니다."); | ||
|
@@ -106,6 +113,11 @@ private TravelPlan getTravelPlanById(Long planId) { | |
.orElseThrow(() -> new BadRequestException("존재하지 않는 여행 계획입니다.")); | ||
} | ||
|
||
private TravelPlan getTravelPlanByShareKey(UUID shareKey) { | ||
return travelPlanRepository.findByShareKey(shareKey) | ||
.orElseThrow(() -> new BadRequestException("존재하지 않는 여행 계획입니다.")); | ||
} | ||
|
||
private List<TravelPlanDayResponse> getTravelPlanDayResponses(TravelPlan travelPlan) { | ||
List<TravelPlanDay> planDays = travelPlanDayRepository.findByPlan(travelPlan); | ||
|
||
|
Oops, something went wrong.
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.
추가 감사합니다 👍 👍