-
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 #82 from everymeals/feature/store-get-review
[feature/store-get-review] 주변 식당 (store) 리뷰 조회 API
- Loading branch information
Showing
9 changed files
with
283 additions
and
0 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
52 changes: 52 additions & 0 deletions
52
src/main/java/everymeal/server/store/controller/dto/response/StoresGetReviews.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,52 @@ | ||
package everymeal.server.store.controller.dto.response; | ||
|
||
|
||
import everymeal.server.global.util.TimeFormatUtil; | ||
import everymeal.server.global.util.aws.S3Util; | ||
import java.time.LocalDateTime; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public record StoresGetReviews( | ||
Long reviewIdx, | ||
String content, | ||
Integer grade, | ||
LocalDateTime createdAt, | ||
String formattedCreatedAt, | ||
String nickName, | ||
String profileImageUrl, | ||
Long reviewMarksCnt, | ||
List<String> images, | ||
Long storeIdx, | ||
String storeName) { | ||
|
||
public static List<StoresGetReviews> of(List<Map<String, Object>> storesReviews) { | ||
return storesReviews.stream() | ||
.map( | ||
storeReview -> { | ||
List<String> images = null; | ||
if (storeReview.get("images") != null) { | ||
images = | ||
Arrays.asList( | ||
((String) storeReview.get("images")).split(",")); | ||
images.replaceAll(S3Util::getImgUrl); | ||
} | ||
LocalDateTime createdAt = (LocalDateTime) storeReview.get("createdAt"); | ||
return new StoresGetReviews( | ||
(Long) storeReview.get("reviewIdx"), | ||
(String) storeReview.get("content"), | ||
(Integer) storeReview.get("grade"), | ||
createdAt, | ||
TimeFormatUtil.getTimeFormat( | ||
createdAt == null ? LocalDateTime.now() : createdAt), | ||
(String) storeReview.get("nickname"), | ||
(String) storeReview.get("profileImgUrl"), | ||
(Long) storeReview.get("reviewMarksCnt"), | ||
images, | ||
(Long) storeReview.get("storeIdx"), | ||
(String) storeReview.get("storeName")); | ||
}) | ||
.toList(); | ||
} | ||
} |
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
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