From 92a16b42f4769c42bbdb0036fc395c95130b9cc5 Mon Sep 17 00:00:00 2001 From: GeunH Date: Wed, 6 Dec 2023 11:59:46 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat=20:=20=EC=9D=8C=EC=8B=9D=EC=A0=90=20?= =?UTF-8?q?=EC=83=81=EC=84=B8,=20=ED=95=84=ED=84=B0=20=EC=9D=8C=EC=8B=9D?= =?UTF-8?q?=EC=A0=90=20=EB=A6=AC=EC=8A=A4=ED=8A=B8,=20=EC=9D=8C=EC=8B=9D?= =?UTF-8?q?=EC=A0=90=20=EA=B2=80=EC=83=89=20=EC=9E=90=EB=8F=99=EC=99=84?= =?UTF-8?q?=EC=84=B1=20api=20=EC=9D=91=EB=8B=B5=EC=97=90=20=EC=82=AC?= =?UTF-8?q?=EC=A7=84=20=EC=B6=94=EA=B0=80=20#66=20#68=20#104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/src/restaurant/restaurant.service.ts | 34 +++++++++++++++++++++++++ be/src/review/entities/review.entity.ts | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/be/src/restaurant/restaurant.service.ts b/be/src/restaurant/restaurant.service.ts index 2187aeb..df0f81b 100644 --- a/be/src/restaurant/restaurant.service.ts +++ b/be/src/restaurant/restaurant.service.ts @@ -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; } @@ -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" @@ -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; @@ -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; } diff --git a/be/src/review/entities/review.entity.ts b/be/src/review/entities/review.entity.ts index 55e4be4..cd930a1 100644 --- a/be/src/review/entities/review.entity.ts +++ b/be/src/review/entities/review.entity.ts @@ -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" }) From b8839bdf76503090311000f6da4ec00d428067b0 Mon Sep 17 00:00:00 2001 From: GeunH Date: Wed, 6 Dec 2023 12:55:20 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat=20:=20=EB=82=B4=20=EB=A7=9B=EC=A7=91?= =?UTF-8?q?=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=9D=91=EB=8B=B5,=20?= =?UTF-8?q?=ED=98=84=EC=9C=84=EC=B9=98=20=EA=B8=B0=EB=B0=98=20=EC=9D=8C?= =?UTF-8?q?=EC=8B=9D=EC=A0=90=20=EC=9D=91=EB=8B=B5=EC=97=90=20=EC=82=AC?= =?UTF-8?q?=EC=A7=84=20=EC=B6=94=EA=B0=80=20#62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/src/restaurant/restaurant.service.ts | 15 ++++++++++++++- be/src/user/user.service.ts | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/be/src/restaurant/restaurant.service.ts b/be/src/restaurant/restaurant.service.ts index df0f81b..14808b0 100644 --- a/be/src/restaurant/restaurant.service.ts +++ b/be/src/restaurant/restaurant.service.ts @@ -165,7 +165,20 @@ export class RestaurantService implements OnModuleInit { restaurantId: restaurant.restaurant_id, }) .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; } diff --git a/be/src/user/user.service.ts b/be/src/user/user.service.ts index 4666ace..4e03591 100644 --- a/be/src/user/user.service.ts +++ b/be/src/user/user.service.ts @@ -128,6 +128,21 @@ export class UserService { }) .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.isMy = true; restaurant.restaurant_reviewCnt = reviewCount; } From c2402f65f8a349c03887dc95c0d588822b093e1e Mon Sep 17 00:00:00 2001 From: GeunH Date: Wed, 6 Dec 2023 13:00:54 +0900 Subject: [PATCH 3/5] =?UTF-8?q?feat=20:=20=ED=98=84=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EA=B8=B0=EB=B0=98=20=EC=9D=8C=EC=8B=9D=EC=A0=90=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=EC=97=90=20=EA=B8=B0=EB=B3=B8=20limit=20=EA=B0=9C?= =?UTF-8?q?=EC=88=98=20=EC=A7=80=EC=A0=95=20#62?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/src/restaurant/restaurant.controller.ts | 13 ++++++++++--- be/src/restaurant/restaurant.repository.ts | 5 ++++- be/src/restaurant/restaurant.service.ts | 5 +++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/be/src/restaurant/restaurant.controller.ts b/be/src/restaurant/restaurant.controller.ts index c3a918e..0f7c676 100644 --- a/be/src/restaurant/restaurant.controller.ts +++ b/be/src/restaurant/restaurant.controller.ts @@ -25,7 +25,7 @@ import { LocationDto } from "./dto/location.dto"; @ApiTags("Home") @Controller("restaurant") export class RestaurantController { - constructor(private restaurantService: RestaurantService) {} + constructor(private restaurantService: RestaurantService) { } @Get("autocomplete/:partialRestaurantName") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -162,6 +162,12 @@ export class RestaurantController { type: String, description: "검색 반경", }) + @ApiQuery({ + name: "limit", + required: false, + type: String, + description: "응답 개수", + }) @ApiResponse({ status: 200, description: "전체 음식점 리스트 요청 성공", @@ -174,8 +180,9 @@ export class RestaurantController { @UsePipes(new ValidationPipe()) entireRestaurantList( @GetUser() tokenInfo: TokenInfo, - @Query() locationDto: LocationDto + @Query() locationDto: LocationDto, + @Query("limit") limit: string ) { - return this.restaurantService.entireRestaurantList(locationDto, tokenInfo); + return this.restaurantService.entireRestaurantList(locationDto, tokenInfo, limit); } } diff --git a/be/src/restaurant/restaurant.repository.ts b/be/src/restaurant/restaurant.repository.ts index 370a144..cf15d1a 100644 --- a/be/src/restaurant/restaurant.repository.ts +++ b/be/src/restaurant/restaurant.repository.ts @@ -178,7 +178,9 @@ export class RestaurantRepository extends Repository { } } - async entireRestaurantList(locationDto: LocationDto, tokenInfo: TokenInfo) { + async entireRestaurantList(locationDto: LocationDto, tokenInfo: TokenInfo, limit: string = "40") { + const limitNum = parseInt(limit); + return this.createQueryBuilder("restaurant") .leftJoin( UserRestaurantListEntity, @@ -208,6 +210,7 @@ export class RestaurantRepository extends Repository { location, ST_GeomFromText('POINT(${locationDto.longitude} ${locationDto.latitude})', 4326)) < ${locationDto.radius}` ) + .limit(limitNum) .getRawMany(); } diff --git a/be/src/restaurant/restaurant.service.ts b/be/src/restaurant/restaurant.service.ts index 14808b0..3f36fd6 100644 --- a/be/src/restaurant/restaurant.service.ts +++ b/be/src/restaurant/restaurant.service.ts @@ -152,10 +152,11 @@ export class RestaurantService implements OnModuleInit { return restaurants; } - async entireRestaurantList(locationDto: LocationDto, tokenInfo: TokenInfo) { + async entireRestaurantList(locationDto: LocationDto, tokenInfo: TokenInfo, limit: string) { const restaurants = await this.restaurantRepository.entireRestaurantList( locationDto, - tokenInfo + tokenInfo, + limit ); for (const restaurant of restaurants) { From b8413e146994274977535c15923c014441bbf46b Mon Sep 17 00:00:00 2001 From: GeunH Date: Wed, 6 Dec 2023 15:55:03 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat=20:=20=EB=A6=AC=EB=B7=B0=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EC=9A=94=EC=B2=AD=20=EC=9D=91=EB=8B=B5=EC=97=90=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=EC=96=B4=20=EC=82=AC=EC=A7=84=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/src/review/dto/reviewInfo.dto.ts | 8 ++++++-- be/src/review/review.repository.ts | 3 +++ be/src/review/review.service.ts | 6 ++++-- be/src/user/entities/user.entity.ts | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/be/src/review/dto/reviewInfo.dto.ts b/be/src/review/dto/reviewInfo.dto.ts index 86be463..768f376 100644 --- a/be/src/review/dto/reviewInfo.dto.ts +++ b/be/src/review/dto/reviewInfo.dto.ts @@ -26,7 +26,9 @@ export class ReviewInfoDto { example: "0", description: "transportation Accessibility for visiting", }) - @Transform(({ value }) => parseInt(value)) + @Transform(({ value }) => { + return !value ? null : parseInt(value, 10); + }) @IsInt() @IsOptional() @Min(0) @@ -37,7 +39,9 @@ export class ReviewInfoDto { example: "0", description: "condition of the restaurant's parking area", }) - @Transform(({ value }) => parseInt(value)) + @Transform(({ value }) => { + return !value ? null : parseInt(value, 10); + }) @IsInt() @IsOptional() @Min(0) diff --git a/be/src/review/review.repository.ts b/be/src/review/review.repository.ts index e206d85..f46b362 100644 --- a/be/src/review/review.repository.ts +++ b/be/src/review/review.repository.ts @@ -50,6 +50,7 @@ export class ReviewRepository extends Repository { "review.restroomCleanliness", "review.overallExperience", "user.nickName as reviewer", + "user.profileImage", "review.createdAt", "review.reviewImage", "reviewLike.isLike as isLike", @@ -81,6 +82,7 @@ export class ReviewRepository extends Repository { "review.restroomCleanliness", "review.overallExperience", "user.nickName as reviewer", + "user.profileImage", "review.createdAt", "review.reviewImage", "reviewLike.isLike as isLike", @@ -113,6 +115,7 @@ export class ReviewRepository extends Repository { "review.restroomCleanliness", "review.overallExperience", "user.nickName as reviewer", + "user.profileImage", "review.createdAt", "review.reviewImage", "reviewLike.isLike as isLike", diff --git a/be/src/review/review.service.ts b/be/src/review/review.service.ts index 0d9b9be..5b3d502 100644 --- a/be/src/review/review.service.ts +++ b/be/src/review/review.service.ts @@ -3,12 +3,14 @@ import { ReviewRepository } from './review.repository'; import { TokenInfo } from 'src/user/user.decorator'; import { ReviewLikeRepository } from './review.like.repository'; import { SortInfoDto } from 'src/utils/sortInfo.dto'; +import { AwsService } from 'src/aws/aws.service'; @Injectable() export class ReviewService { constructor( private reviewRepository: ReviewRepository, - private reviewLikeRepository: ReviewLikeRepository + private reviewLikeRepository: ReviewLikeRepository, + private awsService: AwsService ) { } async getSortedReviews(tokenInfo: TokenInfo, restaurantId: number, getSortedReviewsDto: SortInfoDto) { @@ -30,7 +32,7 @@ export class ReviewService { .where("reviewLike.reviewId = :reviewId", { reviewId: review.review_id }) .groupBy("reviewLike.isLike") .getRawMany(); - + if (review.user_profileImage) review.user_profileImage = this.awsService.getImageURL(review.user_profileImage); review.likeCount = Number(likeCounts.find(lc => lc.status === true)?.count) || 0; review.dislikeCount = Number(likeCounts.find(lc => lc.status === false)?.count) || 0; } diff --git a/be/src/user/entities/user.entity.ts b/be/src/user/entities/user.entity.ts index 90c4b27..7eaa7ee 100644 --- a/be/src/user/entities/user.entity.ts +++ b/be/src/user/entities/user.entity.ts @@ -37,7 +37,7 @@ export class User { @Column({ type: "varchar", length: 20, nullable: true }) provider: string | null; - @Column({ type: "text", default : "profile/images/defaultprofile.png"}) + @Column({ type: "text", default: "profile/images/defaultprofile.png" }) profileImage: string; @CreateDateColumn({ type: "timestamp" }) @@ -55,7 +55,7 @@ export class User { @OneToMany(() => FollowEntity, (follow) => follow.followedUserId) follower: FollowEntity[]; - @OneToMany(() => UserRestaurantListEntity, (list) => list.userId) + @OneToMany(() => UserRestaurantListEntity, (list) => list.user) restaurant: UserRestaurantListEntity[]; @OneToMany(() => ReviewInfoEntity, (review) => review.user) From 2e839f500f3b2b13b0613ac9651206b03da82407 Mon Sep 17 00:00:00 2001 From: GeunH Date: Wed, 6 Dec 2023 16:14:49 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix=20:=20=EB=A6=AC=EB=B7=B0=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=8B=9C=20img=20=EC=97=86=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20default=20path=20=EC=A0=81=EC=9A=A9=20#69?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/src/user/user.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/be/src/user/user.service.ts b/be/src/user/user.service.ts index 4e03591..571e92d 100644 --- a/be/src/user/user.service.ts +++ b/be/src/user/user.service.ts @@ -287,6 +287,9 @@ export class UserService { reviewImage = `review/images/${uuid}.png`; reviewEntity.reviewImage = reviewImage; } + else { + reviewEntity.reviewImage = `review/images/defaultImage.png`; + } const userEntity = new User(); userEntity.id = tokenInfo["id"]; reviewEntity.user = userEntity;