From 9306aa7a6e5b238f72566bb13253ba106382785f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Iv=C3=A1n?= <80365304+Diego-lvan@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:31:18 -0600 Subject: [PATCH 1/2] fix --- backend/src/pointOfInterest/PointOfInterest.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/pointOfInterest/PointOfInterest.service.ts b/backend/src/pointOfInterest/PointOfInterest.service.ts index 8ec12a18..607e1100 100644 --- a/backend/src/pointOfInterest/PointOfInterest.service.ts +++ b/backend/src/pointOfInterest/PointOfInterest.service.ts @@ -48,11 +48,11 @@ export class PointOfInterestService { const insertedId = (await this.pointRepository.insert(createPointDto)).raw.insertId; const spanishAudio = await this.convertTextToSpeech( - `${createPointAndTradDto.contentES}\n${createPointAndTradDto.directionsES}`, + `${createPointAndTradDto.contentES}\n${createPointAndTradDto.directionsES || ''}`, LANGUAGES.ES, ); const englishAudio = await this.convertTextToSpeech( - `${createPointAndTradDto.contentEN}\n${createPointAndTradDto.directionsEN}`, + `${createPointAndTradDto.contentEN}\n${createPointAndTradDto.directionsEN || ''}`, LANGUAGES.EN, ); -- GitLab From 2547088a4ffba063c3e2081a1e0fb27614d55612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Iv=C3=A1n?= <80365304+Diego-lvan@users.noreply.github.com> Date: Tue, 12 Nov 2024 21:02:56 -0600 Subject: [PATCH 2/2] endpoint de lugares abiertos --- backend/src/place/place.controller.ts | 11 +++++++++++ backend/src/place/place.module.ts | 16 ++++++++++++++++ backend/src/place/place.service.ts | 21 +++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/backend/src/place/place.controller.ts b/backend/src/place/place.controller.ts index b98b3ae8..4af70479 100644 --- a/backend/src/place/place.controller.ts +++ b/backend/src/place/place.controller.ts @@ -24,6 +24,8 @@ import { CustomAdminRequest } from 'src/auth/admin/interface/customAdminReq'; import { UpdatePlaceReqDto } from './dto/update-place.req.dto'; import { AuthAdminGuard } from 'src/auth/admin/authAdmin.guard'; import { GetPlaceDto } from './dto/get-place.dto'; +import { AuthUserGuard } from 'src/auth/user/authUser.guard'; +import { CustomUserRequest } from 'src/auth/user/interface/customUserReq'; @Controller('place') @ApiTags('Place') @@ -96,4 +98,13 @@ export class PlaceController { throw e; } } + + @Get('open/:idTown/:lang') + @ApiBearerAuth('jwt') + @ApiConsumes('json') + @UseGuards(AuthUserGuard) + @ApiParam({ name: 'idTown', type: Number }) + async findOpenPlaces(@Param('idTown') idTown: number, @Param('lang') lang: string, @Req() req: CustomUserRequest) { + return await this.placeService.findPlacesNotVisitedByUserAndOpenResponse(req.user.email, lang as LANGUAGES, idTown); + } } diff --git a/backend/src/place/place.module.ts b/backend/src/place/place.module.ts index 31f72221..2b6720f6 100644 --- a/backend/src/place/place.module.ts +++ b/backend/src/place/place.module.ts @@ -16,6 +16,14 @@ import { JwtService } from '@nestjs/jwt'; import { EncryptionService } from 'src/auth/encryption/encryption.service'; import { Admin } from 'src/admin/entities/admin.entity'; import { AdminResetCode } from 'src/auth/admin/entitites/admin-reset-code.entity'; +import { AuthUserService } from 'src/auth/user/authUserservice'; +import { UserResetCode } from 'src/auth/user/entities/user-reset-code.entity'; +import { UserConfirmCode } from 'src/auth/user/entities/user-confirm-code.entity'; +import { UserService } from 'src/user/user.service'; +import { EmailService } from 'src/email/email.service'; +import { User } from 'src/user/entities/user.entity'; +import { CategoryService } from 'src/category/category.service'; +import { Category } from 'src/category/entities/category.entity'; @Module({ controllers: [PlaceController], @@ -28,6 +36,10 @@ import { AdminResetCode } from 'src/auth/admin/entitites/admin-reset-code.entity JwtService, EncryptionService, TownService, + AuthUserService, + UserService, + EmailService, + CategoryService, ], imports: [ TypeOrmModule.forFeature([ @@ -39,6 +51,10 @@ import { AdminResetCode } from 'src/auth/admin/entitites/admin-reset-code.entity State, Admin, AdminResetCode, + UserResetCode, + UserConfirmCode, + User, + Category, ]), TypeOrmModule, ], diff --git a/backend/src/place/place.service.ts b/backend/src/place/place.service.ts index 115604f7..a480ddd3 100644 --- a/backend/src/place/place.service.ts +++ b/backend/src/place/place.service.ts @@ -249,4 +249,25 @@ export class PlaceService { return placesWithAvailability.filter((place) => place !== null); } + + async findPlacesNotVisitedByUserAndOpenResponse(email: string, lang: LANGUAGES, idTown: number) { + const places: GetPlaceDto[] = await this.findPlacesNotVisitedByUserAndOpen(email, lang, idTown); + + const placesResponse = []; + for (const place of places) { + const visited: any = await this.dataSource + .getRepository(Visited) + .createQueryBuilder('visited') + .leftJoinAndSelect('visited.place', 'place') + .where('visited.user = :email', { email }) + .andWhere('place.idPlace = :idPlace', { idPlace: place.idPlace }) + .getOne(); + + placesResponse.push({ + ...place, + visited: visited ? true : false, + }); + } + return placesResponse; + } } -- GitLab