Skip to content

Commit

Permalink
[feat] setting reponse dto
Browse files Browse the repository at this point in the history
  • Loading branch information
PicturePark1101 committed Jul 9, 2024
1 parent 1b5d90e commit ed4ea5c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
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());
}
}
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());
}
}

0 comments on commit ed4ea5c

Please sign in to comment.