Skip to content

Commit

Permalink
feat : 사용자 추천 음식점 응답에 사진 추가 #64
Browse files Browse the repository at this point in the history
  • Loading branch information
GeunH committed Dec 6, 2023
1 parent 0ff3ee5 commit ecaaf43
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion be/src/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,25 @@ export class UserService {
}
async getRecommendFood(tokenInfo: TokenInfo) {
const region = await this.usersRepository.findOne({ select: ["region"], where: { id: tokenInfo.id } });
return await this.userRestaurantListRepository.getMyFavoriteFoodCategory(tokenInfo.id, region);
const restaurants = await this.userRestaurantListRepository.getMyFavoriteFoodCategory(tokenInfo.id, region);

for (const restaurant of restaurants) {
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");
}
}
return restaurants;
}
async searchTargetUser(tokenInfo: TokenInfo, nickName: string, region: string[]) {
const whereCondition: any = {
Expand Down

0 comments on commit ecaaf43

Please sign in to comment.