This commit is contained in:
2025-12-08 15:39:26 +03:30
parent 6dc40009a8
commit 6bda9bb31f
4 changed files with 39 additions and 7 deletions
+11 -2
View File
@@ -1,7 +1,7 @@
import { Injectable, NotFoundException, BadRequestException } from '@nestjs/common';
import { CreateReviewDto } from '../dto/create-review.dto';
import { UpdateReviewDto } from '../dto/update-review.dto';
import { FindReviewsDto } from '../dto/find-reviews.dto';
import { FindRestuarantReviewsDto, FindReviewsDto } from '../dto/find-reviews.dto';
import { ReviewRepository } from '../repositories/review.repository';
import { FoodRepository } from '../../foods/repositories/food.repository';
import { UserRepository } from '../../users/repositories/user.repository';
@@ -11,6 +11,7 @@ import { Review } from '../entities/review.entity';
import { FoodMessage, UserMessage, ReviewMessage } from 'src/common/enums/message.enum';
import { Order } from '../../orders/entities/order.entity';
import { OrderItem } from '../../orders/entities/order-item.entity';
import { Restaurant } from 'src/modules/restaurants/entities/restaurant.entity';
@Injectable()
export class ReviewService {
@@ -88,6 +89,15 @@ export class ReviewService {
return this.reviewRepository.findAllPaginated(dto);
}
async findRestuarantAllReviews(dto: FindRestuarantReviewsDto) {
const { restuarantSlug, ...restDto } = dto;
const restaurant = await this.em.findOne(Restaurant, { slug: restuarantSlug });
if (!restaurant) {
throw new NotFoundException('RestaurantMessage.NOT_FOUND');
}
return this.reviewRepository.findAllPaginated({ ...restDto, restId: restaurant.id });
}
async findById(id: string): Promise<Review> {
const review = await this.reviewRepository.findOne({ id }, { populate: ['food', 'user', 'order'] });
if (!review) {
@@ -167,4 +177,3 @@ export class ReviewService {
}
}
}