Loading backend/src/pointOfInterest/PointOfInterest.controller.ts +9 −4 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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; } Loading @@ -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<StreamableFile> { 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); } } backend/src/pointOfInterest/PointOfInterest.service.ts +32 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -102,4 +101,36 @@ export class PointOfInterestService { } async createAudio() {} async findOne(idPoint: number, lang: LANGUAGES): Promise<getPointDto> { 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; } } Loading
backend/src/pointOfInterest/PointOfInterest.controller.ts +9 −4 Original line number Diff line number Diff line Loading @@ -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) Loading @@ -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; } Loading @@ -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<StreamableFile> { 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); } }
backend/src/pointOfInterest/PointOfInterest.service.ts +32 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -102,4 +101,36 @@ export class PointOfInterestService { } async createAudio() {} async findOne(idPoint: number, lang: LANGUAGES): Promise<getPointDto> { 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; } }