Commit ed9c1320 authored by Omar Luna Hernández's avatar Omar Luna Hernández
Browse files

Se crea el endpoint para generar el pdf con las targeta de los qr de los puntos de interes

parent beb5ed30
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -9,10 +9,11 @@ import {
  Query,
  StreamableFile,
  UseGuards,
  Res
} from '@nestjs/common';
import { PointOfInterestService } from './PointOfInterest.service';
import { CreatePointAndTradDto } from './dto/create-pointAndTraduction.dto';
import { ApiBearerAuth, ApiConsumes, ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger';
import { ApiBearerAuth, ApiBody, ApiConsumes, ApiParam, ApiQuery, ApiTags } from '@nestjs/swagger';
import { Roles } from 'src/auth/role.decorator';
import { ADMIN_ROLES } from 'src/shared/enum/admin-role.enum';
import { fileInterceptor } from 'src/shared/interceptors/file-save.interceptor';
@@ -59,4 +60,20 @@ export class PointOfInterestController {
  async findOne(@Param('idPoint') idPoint: number, @Query('lang') lang: string) {
    return await this.pointService.findOne(idPoint, lang as LANGUAGES);
  }

  @ApiParam({ name: 'idPlace', type: Number })
  @ApiQuery({ name: 'pointsId', type: String })
  @Get('/place/:idPlace/point/generate')
  async generatePdf(@Param('idPlace') idPlace: number, @Query('pointsId') pointsIdString: string, @Res() res) {
    const pointsId = pointsIdString.split(',').map(Number);
    const pdfBuffer = await this.pointService.generatePdf(idPlace, pointsId);

    res.set({
      'Content-Type': 'application/pdf',
      'Content-Disposition': 'attachment; filename=tarjetas.pdf',
      'Content-Length': pdfBuffer.length,
    });

    res.send(pdfBuffer);
  }
}