-
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.
Browse files
Browse the repository at this point in the history
[Feat/#38] 홈 화면 조회 API
- Loading branch information
Showing
7 changed files
with
133 additions
and
6 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
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,4 +1,49 @@ | ||
package makar.dev.converter; | ||
|
||
import makar.dev.domain.Noti; | ||
import makar.dev.domain.Route; | ||
import makar.dev.dto.response.NotiResponse; | ||
import makar.dev.dto.response.RouteResponse; | ||
import makar.dev.dto.response.UserResponse; | ||
|
||
import java.util.List; | ||
|
||
public class UserConverter { | ||
|
||
public static UserResponse.HomeDto toHomeDto(boolean isRouteSet, List<Noti> notiList, | ||
List<Route> favoriteRouteList, List<Route> recentRouteList){ | ||
List<RouteResponse.BriefRouteDto> favoriteRouteDtoList = favoriteRouteList.stream() | ||
.map(RouteConverter::toBriefRouteDto) | ||
.toList(); | ||
List<RouteResponse.BriefRouteDto> recentRouteDtoList = recentRouteList.stream() | ||
.map(RouteConverter::toBriefRouteDto) | ||
.toList(); | ||
|
||
if (notiList.isEmpty()) | ||
return UserResponse.HomeDto.builder() | ||
.isRouteSet(isRouteSet) | ||
.sourceStationName(null) | ||
.destinationStationName(null) | ||
.makarTime(null) | ||
.getoffTime(null) | ||
.notiList(null) | ||
.favoriteRouteList(favoriteRouteDtoList) | ||
.recentRouteList(recentRouteDtoList) | ||
.build(); | ||
|
||
Route route = notiList.get(0).getRoute(); | ||
List<NotiResponse.NotiDto> notiDtoList = notiList.stream() | ||
.map(NotiConverter::toNotiDto) | ||
.toList(); | ||
return UserResponse.HomeDto.builder() | ||
.isRouteSet(isRouteSet) | ||
.sourceStationName(route.getSourceStation().getStationName()) | ||
.destinationStationName(route.getDestinationStation().getStationName()) | ||
.makarTime(route.getSchedule().getSourceTime()) | ||
.getoffTime(route.getSchedule().getDestinationTime()) | ||
.notiList(notiDtoList) | ||
.favoriteRouteList(favoriteRouteDtoList) | ||
.recentRouteList(recentRouteDtoList) | ||
.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
package makar.dev.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import makar.dev.domain.Noti; | ||
|
||
import java.util.List; | ||
|
||
public class UserResponse { | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class HomeDto { | ||
private boolean isRouteSet; | ||
private String sourceStationName; | ||
private String destinationStationName; | ||
private String makarTime; | ||
private String getoffTime; | ||
private List<NotiResponse.NotiDto> notiList; | ||
private List<RouteResponse.BriefRouteDto> favoriteRouteList; | ||
private List<RouteResponse.BriefRouteDto> recentRouteList; | ||
} | ||
} |
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