Commit c3bd4fca authored by fredericonizoli's avatar fredericonizoli
Browse files

feat: add reviews GET restaurant (comments + in progress)

parent a80538c2
Showing with 14 additions and 6 deletions
+14 -6
......@@ -16,7 +16,7 @@ export class RestaurantController {
averagePrice,
phone,
tagIds,
reviews, // esperando arquivos de Review
reviews,
} = req.body;
const restaurant = await RestaurantService.createRestaurant({
......@@ -30,7 +30,7 @@ export class RestaurantController {
averagePrice,
phone,
tagIds,
reviews, // esperando arquivos de Review
reviews,
});
res.status(201).json(restaurant);
......
......@@ -11,7 +11,7 @@ export interface CreateRestaurantDto {
averagePrice?: Prisma.Decimal;
phone: string;
tagIds?: string[];
reviews?: Review[]; // esperando arquivos de Review
reviews?: Review[];
}
export class RestaurantOutputDto {
......
......@@ -31,7 +31,7 @@ export class RestaurantRepository {
averagePrice,
phone,
tagIds,
reviews, // esperando arquivos de Review
reviews,
} = data;
return prisma.restaurant.create({
......@@ -52,7 +52,7 @@ export class RestaurantRepository {
},
}
: {}),
...(reviews && reviews.length > 0 // esperando arquivos de Review
...(reviews && reviews.length > 0
? {
reviews: {
create: reviews.map((review) => ({ review })),
......@@ -67,7 +67,7 @@ export class RestaurantRepository {
return prisma.restaurant.findMany({
include: {
tags: true,
reviews: true, // esperando arquivos de Review
reviews: true,
},
});
}
......
......@@ -26,6 +26,14 @@ export class RestaurantService {
}
// Necessita criação de 'if' para reviews[], esperando os arquivos de Review
/*
if (reviews && reviews.length > 0){
const foundReviews = await ReviewRepository.findReviewsById(reviews);
if (foundReviews.length !== reviews.length) {
throw new Error ('Reviews para esse restaurante não foram encontradas');
}
}
*/
const hashedPassword = await hashPassword(password);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment