Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gastrô
Gastrô Backend
Commits
c3bd4fca
Commit
c3bd4fca
authored
1 week ago
by
fredericonizoli
Browse files
Options
Download
Email Patches
Plain Diff
feat: add reviews GET restaurant (comments + in progress)
parent
a80538c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/controllers/restaurant-controller.ts
+2
-2
src/controllers/restaurant-controller.ts
src/dtos/restaurant-dto.ts
+1
-1
src/dtos/restaurant-dto.ts
src/repositories/restaurant-repository.ts
+3
-3
src/repositories/restaurant-repository.ts
src/services/restaurant-service.ts
+8
-0
src/services/restaurant-service.ts
with
14 additions
and
6 deletions
+14
-6
src/controllers/restaurant-controller.ts
View file @
c3bd4fca
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
src/dtos/restaurant-dto.ts
View file @
c3bd4fca
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
src/repositories/restaurant-repository.ts
View file @
c3bd4fca
...
...
@@ -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
,
},
});
}
...
...
This diff is collapsed.
Click to expand it.
src/services/restaurant-service.ts
View file @
c3bd4fca
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help