-
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.
- Loading branch information
1 parent
1b5d90e
commit ed4ea5c
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...main/java/org/hankki/hankkiserver/api/favorite/service/response/FavoriteFindResponse.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,27 @@ | ||
package org.hankki.hankkiserver.api.favorite.service.response; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.hankki.hankkiserver.domain.favorite.model.Favorite; | ||
import org.hankki.hankkiserver.domain.store.model.Store; | ||
|
||
public record FavoriteFindResponse( | ||
String title, | ||
List<String> details, | ||
List<FavoriteStoreFindResponse> stores | ||
) { | ||
|
||
public static FavoriteFindResponse of(Favorite favorite, List<Store> stores) { | ||
|
||
List<String> details = new ArrayList<>(); | ||
if (favorite.getDetail() != null) { | ||
details = Arrays.asList(favorite.getDetail().split(" ")); | ||
} | ||
|
||
return new FavoriteFindResponse( | ||
favorite.getName(), | ||
details, | ||
stores.stream().map(FavoriteStoreFindResponse::of).toList()); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...java/org/hankki/hankkiserver/api/favorite/service/response/FavoriteStoreFindResponse.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,23 @@ | ||
package org.hankki.hankkiserver.api.favorite.service.response; | ||
|
||
import org.hankki.hankkiserver.domain.store.model.Store; | ||
import org.hankki.hankkiserver.domain.store.model.StoreCategory; | ||
|
||
public record FavoriteStoreFindResponse( | ||
long id, | ||
String name, | ||
String imageUrl, | ||
String storeCategory, | ||
int lowestPrice | ||
) { | ||
|
||
public static FavoriteStoreFindResponse of(Store store) { | ||
|
||
return new FavoriteStoreFindResponse( | ||
store.getId(), | ||
store.getName(), | ||
store.getImage(), | ||
store.getCategory().getName(), | ||
store.getLowestPrice()); | ||
} | ||
} |