diff --git a/backend/src/pointOfInterest/PointOfInterest.controller.ts b/backend/src/pointOfInterest/PointOfInterest.controller.ts index 746b9c5aa00c18c2020de3e273522d23533a9ed3..57c26d37a4661ca0ce301e5c5a484ce19c31ab9d 100644 --- a/backend/src/pointOfInterest/PointOfInterest.controller.ts +++ b/backend/src/pointOfInterest/PointOfInterest.controller.ts @@ -21,7 +21,7 @@ import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Controller('') @ApiTags('Point of interest') export class PointOfInterestController { - constructor(private readonly activityService: PointOfInterestService) {} + constructor(private readonly pointService: PointOfInterestService) {} @ApiConsumes('multipart/form-data') @Roles(ADMIN_ROLES) @@ -31,7 +31,7 @@ export class PointOfInterestController { async create(@UploadedFile(new FileValidationPipe()) file, @Body() createActivityDto: CreatePointAndTradDto) { try { createActivityDto.image = file.filename; - return await this.activityService.create(createActivityDto); + return await this.pointService.create(createActivityDto); } catch (error) { throw error; } @@ -41,13 +41,18 @@ export class PointOfInterestController { @ApiParam({ name: 'idPlace', type: Number }) @Get('/place/:idPlace/point') async findAllByPlace(@Param('idPlace') idPlace: number, @Query('lang') lang: string) { - return this.activityService.findAllByPlace(idPlace, lang as LANGUAGES); + return this.pointService.findAllByPlace(idPlace, lang as LANGUAGES); } @ApiQuery({ name: 'lang', type: String }) @Get('point/:idPoint/audio') async getAudio(@Param('idPoint') idPoint: number, @Query('lang') lang: string): Promise { - const file = await this.activityService.getAudio(idPoint, lang as LANGUAGES); + const file = await this.pointService.getAudio(idPoint, lang as LANGUAGES); return file; } + + @Get('point/:idPoint?lang') + async findOne(@Param('idPoint') idPoint: number, @Query('lang') lang: string) { + return await this.pointService.findOne(idPoint, lang as LANGUAGES); + } } diff --git a/backend/src/pointOfInterest/PointOfInterest.service.ts b/backend/src/pointOfInterest/PointOfInterest.service.ts index 7b9f1db5fc7d5eea70c534f920b94e7b69484ef7..95cd7232964027ee4fd1303b861b51f661481113 100644 --- a/backend/src/pointOfInterest/PointOfInterest.service.ts +++ b/backend/src/pointOfInterest/PointOfInterest.service.ts @@ -82,7 +82,6 @@ export class PointOfInterestService { imageName: `${ServerConstants.HOST}/points/${point.imageName}`, content: point.content, directions: point.directions, - audioName: `${ServerConstants.HOST}/audios/${point.audioName}`, }; }); return points; @@ -102,4 +101,36 @@ export class PointOfInterestService { } async createAudio() {} + + async findOne(idPoint: number, lang: LANGUAGES): Promise { + const pointTrad = await this.dataSource + .getRepository(PointOfInterestTraduction) + .createQueryBuilder('pointTrad') + .leftJoin('pointTrad.idPoint', 'point') + .select([ + 'point.idPoint as idPoint', + 'point.name as name', + 'point.imageName as imageName', + 'pointTrad.content as content', + 'pointTrad.directions as directions', + 'pointTrad.audioName as audioName', + 'point.idPlace as idPlace', + ]) + .where('point.idPoint = :idPoint', { idPoint }) + .andWhere('pointTrad.language = :lang', { lang }) + .getRawOne(); + if (!pointTrad) { + throw new NotFoundException('Point not found'); + } + + const point: getPointDto = { + idPoint: pointTrad.idPoint, + idPlace: pointTrad.idPlace, + name: pointTrad.name, + imageName: `${ServerConstants.HOST}/points/${pointTrad.imageName}`, + content: pointTrad.content, + directions: pointTrad.directions, + }; + return point; + } } diff --git a/backend/src/pointOfInterest/dto/getPoint.dto.ts b/backend/src/pointOfInterest/dto/getPoint.dto.ts index b4c41fb61e668688559b5e96651a20407580cc13..2a826ef0cb98c7a1127062c050860c0368857b4c 100644 --- a/backend/src/pointOfInterest/dto/getPoint.dto.ts +++ b/backend/src/pointOfInterest/dto/getPoint.dto.ts @@ -5,5 +5,4 @@ export class getPointDto { imageName: string; content: string; directions: string; - audioName: string; }