Skip to content

Commit 093831c

Browse files
authored
Merge pull request #100 from everymeals/feature/get-s3-muti-url
2 parents b0fa925 + 125594a commit 093831c

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/main/java/everymeal/server/review/entity/Review.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,20 @@ public void updateTodayReview(boolean isTodayReview) {
107107
public void addMark(User user) {
108108
ReviewMark reviewMark = ReviewMark.builder().review(this).user(user).build();
109109
this.reviewMarks.add(reviewMark);
110-
this.restaurant.getGradeStatistics().addRecommendedCount();
110+
if (this.restaurant == null) {
111+
this.store.getGradeStatistics().addRecommendedCount();
112+
} else {
113+
this.restaurant.getGradeStatistics().addRecommendedCount();
114+
}
111115
}
112116

113117
public void removeMark(User user) {
114118
this.reviewMarks.removeIf(mark -> mark.getUser().getIdx().equals(user.getIdx()));
115-
this.restaurant.getGradeStatistics().removeRecommendedCount();
119+
if (this.restaurant == null) {
120+
this.store.getGradeStatistics().addRecommendedCount();
121+
} else {
122+
this.restaurant.getGradeStatistics().addRecommendedCount();
123+
}
116124
}
117125

118126
public boolean isLike(Long userIdx) {

src/main/java/everymeal/server/store/controller/dto/response/StoreGetReviewRes.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public record StoreGetReviewRes(
1515
String nickName,
1616
String profileImageUrl,
1717
Integer recommendedCount,
18-
List<String> images) {
18+
List<String> images,
19+
Long likeCount) {
1920

2021
public static List<StoreGetReviewRes> of(List<Map<String, Object>> storeReview) {
2122
return storeReview.stream()
@@ -34,7 +35,8 @@ public static List<StoreGetReviewRes> of(List<Map<String, Object>> storeReview)
3435
(String) review.get("nickName"),
3536
S3Util.getImgUrl((String) review.get("profileImageUrl")),
3637
(Integer) review.get("recommendedCount"),
37-
images);
38+
images,
39+
(Long) review.get("likeCount"));
3840
})
3941
.toList();
4042
}

src/main/resources/mybatis/mappers/StoreMapper.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@
385385
u.nickname as 'nickname',
386386
u.profile_img_url as 'profileImageUrl',
387387
s.recommended_count as 'recommendedCount',
388-
GROUP_CONCAT(i.image_url SEPARATOR ',') AS 'images'
388+
GROUP_CONCAT(i.image_url SEPARATOR ',') AS 'images',
389+
count(distinct rm.review_idx) as 'likeCount'
389390
FROM
390391
reviews r
391392
JOIN
@@ -394,6 +395,8 @@
394395
images i ON r.idx = i.review_idx AND i.is_deleted = false
395396
LEFT JOIN
396397
store s ON r.store_idx = s.idx AND s.is_deleted = false
398+
LEFT JOIN
399+
review_marks rm ON r.idx = rm.review_idx
397400
WHERE
398401
r.store_idx = #{storeIdx}
399402
AND r.is_deleted = false

0 commit comments

Comments
 (0)