Commit 91eb7c4d authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

Merge branch 'main' into 'main'

Agrengando endpoint para obtener un solo Point por su ID

See merge request ltrpro/pueblosmagicosconia!37
parents 199ed94e 1ce8a275
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -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<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);
  }
}
+32 −1
Original line number Diff line number Diff line
@@ -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<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;
  }
}
+0 −1
Original line number Diff line number Diff line
@@ -5,5 +5,4 @@ export class getPointDto {
  imageName: string;
  content: string;
  directions: string;
  audioName: string;
}