-
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.
Merge pull request #76 from Team-Going/feature/54
[feat] 여행 Our TODO 상세 조회 API 구현
- Loading branch information
Showing
5 changed files
with
124 additions
and
2 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
40 changes: 40 additions & 0 deletions
40
doorip-api/src/main/java/org/doorip/trip/dto/response/OurTodoResponse.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,40 @@ | ||
package org.doorip.trip.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.doorip.trip.domain.Participant; | ||
import org.doorip.trip.domain.Trip; | ||
|
||
import java.time.LocalDate; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.List; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record OurTodoResponse( | ||
String title, | ||
int day, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
LocalDate startDate, | ||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd", timezone = "Asia/Seoul") | ||
LocalDate endDate, | ||
int progress, | ||
String code, | ||
boolean isComplete, | ||
List<TripParticipantResponse> participants | ||
) { | ||
public static OurTodoResponse of(Trip trip, int progress, boolean isComplete, List<Participant> participants) { | ||
return OurTodoResponse.builder() | ||
.title(trip.getTitle()) | ||
.day((int) ChronoUnit.DAYS.between(LocalDate.now(), trip.getStartDate())) | ||
.startDate(trip.getStartDate()) | ||
.endDate(trip.getEndDate()) | ||
.progress(progress) | ||
.code(trip.getCode()) | ||
.isComplete(isComplete) | ||
.participants(participants.stream() | ||
.map(TripParticipantResponse::of) | ||
.toList()) | ||
.build(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
doorip-api/src/main/java/org/doorip/trip/dto/response/TripParticipantResponse.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,22 @@ | ||
package org.doorip.trip.dto.response; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import org.doorip.trip.domain.Participant; | ||
import org.doorip.user.domain.User; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public record TripParticipantResponse( | ||
Long participantId, | ||
String name, | ||
int result | ||
) { | ||
public static TripParticipantResponse of(Participant participant) { | ||
User user = participant.getUser(); | ||
return TripParticipantResponse.builder() | ||
.participantId(participant.getId()) | ||
.name(user.getName()) | ||
.result(user.getResult().getNumResult()) | ||
.build(); | ||
} | ||
} |
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