Skip to content

Commit

Permalink
feat : 음식점 상세 페이지 응답 reviewList에 review사진 응답 추가 #172
Browse files Browse the repository at this point in the history
  • Loading branch information
GeunH committed Dec 4, 2023
1 parent 04b296a commit 76faf69
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions be/src/restaurant/restaurant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TokenInfo } from "src/user/user.decorator";
import { UserRepository } from "src/user/user.repository";
import { ReviewRepository } from "src/review/review.repository";
import { LocationDto } from "./dto/location.dto";
import { AwsService } from "src/aws/aws.service";

const key = process.env.API_KEY;

Expand All @@ -26,7 +27,8 @@ export class RestaurantService implements OnModuleInit {
constructor(
private restaurantRepository: RestaurantRepository,
private userRepository: UserRepository,
private reviewRepository: ReviewRepository
private reviewRepository: ReviewRepository,
private awsService: AwsService
) { }

async searchRestaurant(searchInfoDto: SearchInfoDto, tokenInfo: TokenInfo) {
Expand Down Expand Up @@ -68,17 +70,20 @@ export class RestaurantService implements OnModuleInit {
"review.restroomCleanliness",
"review.overallExperience",
"user.nickName as reviewer",
"review.createdAt"
"review.createdAt",
"review.reviewImage"
])
.where("review.restaurant_id = :restaurantId", {
restaurantId: restaurant.restaurant_id,
})
.getRawMany();

restaurant.restaurant_reviewCnt = reviews.length;
restaurant.reviews = reviews.slice(0, 3);


const reviewList = reviews.slice(0, 3);
reviewList.forEach((element) => {
if (element.review_reviewImage) element.review_reviewImage = this.awsService.getImageURL(element.review_reviewImage);
})
restaurant.reviews = reviewList;
return restaurant;
}

Expand Down

0 comments on commit 76faf69

Please sign in to comment.