Bổ sung tính năng sửa chữa, cập nhật địa điểm trong chặng
This commit is contained in:
@@ -333,6 +333,35 @@ class TourController {
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('v1/locations')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
class LocationController {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
@Patch(':id')
|
||||
async updateLocation(@Param('id', ParseUUIDPipe) id: string, @Body() body: any) {
|
||||
return this.prisma.location.update({
|
||||
where: { id },
|
||||
data: {
|
||||
name: body.name,
|
||||
address: body.address,
|
||||
latitude: body.latitude,
|
||||
longitude: body.longitude,
|
||||
type: body.type,
|
||||
plannedStart: body.plannedStart ? new Date(body.plannedStart) : undefined,
|
||||
plannedEnd: body.plannedEnd ? new Date(body.plannedEnd) : undefined,
|
||||
status: body.status,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async deleteLocation(@Param('id', ParseUUIDPipe) id: string) {
|
||||
await this.prisma.location.delete({ where: { id } });
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('v1/legs')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
class LegController {
|
||||
@@ -546,7 +575,7 @@ class UserController {
|
||||
signOptions: { expiresIn: '1d' },
|
||||
}),
|
||||
],
|
||||
controllers: [AppController, AuthController, TourController, UserController, RoutingController, LegController],
|
||||
controllers: [AppController, AuthController, TourController, UserController, RoutingController, LegController, LocationController],
|
||||
providers: [PrismaService, JwtStrategy],
|
||||
exports: [PrismaService]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user