diff --git a/backend/src/route/route.controller.ts b/backend/src/route/route.controller.ts index 7586762fdaa7f6d15f83b3e6114f920efed932c3..54de3b40833c9c8a868fffb55e5424e8a2d22429 100644 --- a/backend/src/route/route.controller.ts +++ b/backend/src/route/route.controller.ts @@ -38,7 +38,7 @@ export class RouteController { @ApiQuery({ name: 'routeStatus', type: String, schema: { enum: Object.values(RouteStatus) } }) @ApiBearerAuth('jwt') @UseGuards(AuthUserGuard) - async recommendRouteGet(@Req() req: CustomUserRequest, @Query('routeStatus') routeStatus: RouteStatus) { + async getRecommendRoute(@Req() req: CustomUserRequest, @Query('routeStatus') routeStatus: RouteStatus) { const { email } = req.user; return await this.routeService.getRouteAndPlacesByUser(email, routeStatus); } @@ -54,7 +54,7 @@ export class RouteController { @Patch('/:idRoute') @ApiParam({ name: 'idRoute', type: Number }) - @ApiBody({ type: UpdateRouteStatusDto, description: 'accepted, rejected, pending' }) + @ApiBody({ type: UpdateRouteStatusDto, description: 'accepted, pending' }) @ApiBearerAuth('jwt') @UseGuards(AuthUserGuard) async updateRoute(@Body() updateRouteStatusDto: UpdateRouteStatusDto, @Param('idRoute') idRoute: number) { diff --git a/backend/src/route/route.service.ts b/backend/src/route/route.service.ts index b4acebdcc4975bd645aa6b23940083dce5fc6a0e..baf2dd22af72338c885369355a17e2c4ae0dc668 100644 --- a/backend/src/route/route.service.ts +++ b/backend/src/route/route.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { InjectDataSource, InjectRepository } from '@nestjs/typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; import { Route, RouteStatus } from './entities/route.entity'; -import { DataSource, Repository } from 'typeorm'; +import { MoreThan, Repository } from 'typeorm'; import { User } from 'src/user/entities/user.entity'; import { Town } from 'src/town/entities/town.entity'; import { TravelPlaceService } from 'src/travel-place/travel-place.service'; @@ -23,7 +23,6 @@ export class RouteService { @InjectRepository(User) private userRepository: Repository, @InjectRepository(Town) private townRepository: Repository, private readonly travelPlaceService: TravelPlaceService, - @InjectDataSource() private dataSource: DataSource, private readonly placeService: PlaceService, private readonly visitedService: VisitedService, private readonly userService: UserService, @@ -87,12 +86,14 @@ export class RouteService { await this.travelPlaceService.create(createTravelPlace); } + + return await this.getRouteById(idRoute, email); } async getRouteAndPlacesByUser(email: string, routeStatus: RouteStatus) { const res = await this.routeRepository.find({ relations: ['travelPlace'], - where: { user: { email }, status: routeStatus }, + where: { user: { email }, status: routeStatus, endDate: MoreThan(new Date()) }, }); return res;