diff --git a/backend/src/place/entities/place.entity.ts b/backend/src/place/entities/place.entity.ts index 595e1f252b75d14c9a756221cb4c39065fb8d127..b4ed14c743b8e11fed25013537693d58aa39adee 100644 --- a/backend/src/place/entities/place.entity.ts +++ b/backend/src/place/entities/place.entity.ts @@ -30,7 +30,7 @@ export class Place { @OneToMany(() => AvailableDate, (available) => available.place) availableDates: AvailableDate[]; - @ManyToMany(() => Category) + @ManyToMany(() => Category, { eager: true }) @JoinTable() categories: Category[]; diff --git a/backend/src/route/entities/route.entity.ts b/backend/src/route/entities/route.entity.ts index 566b3da51cf37fbd8f85f7cfc920a939f736c7b6..fd14cf7e4e5cbad27b96d6915137c95a59d01cb6 100644 --- a/backend/src/route/entities/route.entity.ts +++ b/backend/src/route/entities/route.entity.ts @@ -18,7 +18,7 @@ export class Route { user: User; @JoinColumn({ name: 'town' }) - @ManyToOne(() => Town, (town) => town.townId, { nullable: false }) + @ManyToOne(() => Town, (town) => town.townId, { nullable: false, eager: true }) town: Town; @OneToMany(() => TravelPlace, (travelPlace) => travelPlace.route, { eager: true }) diff --git a/backend/src/route/route.controller.ts b/backend/src/route/route.controller.ts index 54de3b40833c9c8a868fffb55e5424e8a2d22429..4e51670c8b46caeb5dea8c2645aa124040bcf1ec 100644 --- a/backend/src/route/route.controller.ts +++ b/backend/src/route/route.controller.ts @@ -39,8 +39,13 @@ export class RouteController { @ApiBearerAuth('jwt') @UseGuards(AuthUserGuard) async getRecommendRoute(@Req() req: CustomUserRequest, @Query('routeStatus') routeStatus: RouteStatus) { - const { email } = req.user; - return await this.routeService.getRouteAndPlacesByUser(email, routeStatus); + try { + const { email } = req.user; + return await this.routeService.getRouteAndPlacesByUser(email, routeStatus); + } catch (error) { + console.log(error); + return error; + } } @Get('/:idRoute') diff --git a/backend/src/route/route.service.ts b/backend/src/route/route.service.ts index baf2dd22af72338c885369355a17e2c4ae0dc668..1b4c9df16ecf65cd5b9320dea78ab078babaa7fc 100644 --- a/backend/src/route/route.service.ts +++ b/backend/src/route/route.service.ts @@ -105,6 +105,7 @@ export class RouteService { async getRouteById(idRoute: number, email: string) { const user: User = await this.userService.findOne(email); - return await this.routeRepository.findOneBy({ idRoute, user }); + const res = await this.routeRepository.findOneBy({ idRoute, user }); + return res; } }