Skip to content

Commit

Permalink
feat : 음식점 상세, 필터 음식점 리스트, 음식점 검색 자동완성 api 응답에 사진 추가 #66 #68 #104
Browse files Browse the repository at this point in the history
  • Loading branch information
GeunH committed Dec 6, 2023
1 parent 82e9999 commit 92a16b4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions be/src/restaurant/restaurant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ export class RestaurantService implements OnModuleInit {
})
.getCount();

const reviewInfo = await this.reviewRepository
.createQueryBuilder("review")
.leftJoin("review.reviewLikes", "reviewLike")
.select(["review.id", "review.reviewImage"],)
.groupBy("review.id")
.where("review.restaurant_id = :restaurantId and review.reviewImage is NOT NULL", { restaurantId: restaurant.restaurant_id })
.orderBy("COUNT(CASE WHEN reviewLike.isLike = true THEN 1 ELSE NULL END)", "DESC")
.getRawOne();
if (reviewInfo) {
restaurant.restaurant_reviewImage = this.awsService.getImageURL(reviewInfo.review_reviewImage);
}
else {
restaurant.restaurant_reviewImage = this.awsService.getImageURL("review/images/defaultImage.png");
}


restaurant.restaurant_reviewCnt = reviewCount;
}

Expand All @@ -71,6 +87,7 @@ export class RestaurantService implements OnModuleInit {
"review.restroomCleanliness",
"review.overallExperience",
"user.nickName as reviewer",
"user.profileImage",
"review.createdAt",
"review.reviewImage",
"reviewLike.isLike as isLike"
Expand All @@ -84,6 +101,7 @@ export class RestaurantService implements OnModuleInit {
const reviewList = reviews.slice(0, 3);
reviewList.forEach((element) => {
if (element.review_reviewImage) element.review_reviewImage = this.awsService.getImageURL(element.review_reviewImage);
if (element.user_profileImage) element.user_profileImage = this.awsService.getImageURL(element.user_profileImage);
})
restaurant.reviews = reviewList;
return restaurant;
Expand Down Expand Up @@ -112,6 +130,22 @@ export class RestaurantService implements OnModuleInit {
})
.getCount();

const reviewInfo = await this.reviewRepository
.createQueryBuilder("review")
.leftJoin("review.reviewLikes", "reviewLike")
.select(["review.id", "review.reviewImage"],)
.groupBy("review.id")
.where("review.restaurant_id = :restaurantId and review.reviewImage is NOT NULL", { restaurantId: restaurant.restaurant_id })
.orderBy("COUNT(CASE WHEN reviewLike.isLike = true THEN 1 ELSE NULL END)", "DESC")
.getRawOne();
if (reviewInfo) {
restaurant.restaurant_reviewImage = this.awsService.getImageURL(reviewInfo.review_reviewImage);
}
else {
restaurant.restaurant_reviewImage = this.awsService.getImageURL("review/images/defaultImage.png");
}


restaurant.restaurant_reviewCnt = reviewCount;
}

Expand Down
2 changes: 1 addition & 1 deletion be/src/review/entities/review.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ReviewInfoEntity {
@Column({ type: "text" })
overallExperience: string;

@Column({ type: "text", nullable: true })
@Column({ type: "text", nullable: true, default: null })
reviewImage: string;

@CreateDateColumn({ name: "created_at" })
Expand Down

0 comments on commit 92a16b4

Please sign in to comment.