fix: tags không có trong csdl gây nên lỗi crash backend
This commit is contained in:
Vendored
+3
-1
@@ -211,12 +211,13 @@ let TourController = class TourController {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async createTour(body, req) {
|
||||
const { title, startDate, endDate, adultCount, childCount, childDiscount } = body;
|
||||
const { title, startDate, endDate, adultCount, childCount, childDiscount, tags } = body;
|
||||
return this.prisma.tour.create({
|
||||
data: {
|
||||
title,
|
||||
startDate: startDate ? new Date(startDate) : null,
|
||||
endDate: endDate ? new Date(endDate) : null,
|
||||
tags: tags || [],
|
||||
adultCount: adultCount || 1,
|
||||
childCount: childCount || 0,
|
||||
childDiscount: childDiscount || 0,
|
||||
@@ -384,6 +385,7 @@ let TourController = class TourController {
|
||||
title: body.title,
|
||||
description: body.description,
|
||||
startDate: body.startDate ? new Date(body.startDate) : undefined,
|
||||
tags: body.tags,
|
||||
endDate: body.endDate ? new Date(body.endDate) : undefined,
|
||||
adultCount: body.adultCount !== undefined ? Number(body.adultCount) : undefined,
|
||||
childCount: body.childCount !== undefined ? Number(body.childCount) : undefined,
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Tour" ADD COLUMN "tags" TEXT[];
|
||||
@@ -90,6 +90,7 @@ model Tour {
|
||||
childCount Int @default(0)
|
||||
childDiscount Int @default(30)
|
||||
|
||||
tags String[]
|
||||
createdById String
|
||||
creator User @relation("TourCreator", fields: [createdById], references: [id])
|
||||
|
||||
|
||||
+3
-1
@@ -150,12 +150,13 @@ class TourController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post()
|
||||
async createTour(@Body() body: any, @Req() req: any) {
|
||||
const { title, startDate, endDate, adultCount, childCount, childDiscount } = body;
|
||||
const { title, startDate, endDate, adultCount, childCount, childDiscount, tags } = body;
|
||||
return this.prisma.tour.create({
|
||||
data: {
|
||||
title,
|
||||
startDate: startDate ? new Date(startDate) : null,
|
||||
endDate: endDate ? new Date(endDate) : null,
|
||||
tags: tags || [],
|
||||
adultCount: adultCount || 1,
|
||||
childCount: childCount || 0,
|
||||
childDiscount: childDiscount || 0,
|
||||
@@ -368,6 +369,7 @@ class TourController {
|
||||
title: body.title,
|
||||
description: body.description,
|
||||
startDate: body.startDate ? new Date(body.startDate) : undefined,
|
||||
tags: body.tags,
|
||||
endDate: body.endDate ? new Date(body.endDate) : undefined,
|
||||
adultCount: body.adultCount !== undefined ? Number(body.adultCount) : undefined,
|
||||
childCount: body.childCount !== undefined ? Number(body.childCount) : undefined,
|
||||
|
||||
Reference in New Issue
Block a user