Commit 415228ec authored by Diego Iván's avatar Diego Iván
Browse files

agregando creacion de codigo qr

parent e43fa26f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ import { getPointDto } from './dto/getPoint.dto';
import { ServerConstants } from 'src/constants/server.contants';
import { createReadStream } from 'fs';
import { join } from 'path';
import { generateQRCode } from './utils/qrcode';
import { Place } from 'src/place/entities/place.entity';

@Injectable()
export class PointOfInterestService {
@@ -19,9 +21,15 @@ export class PointOfInterestService {
    @InjectRepository(PointOfInterest) private pointRepository: Repository<PointOfInterest>,
    @InjectRepository(PointOfInterestTraduction) private pointTraductionRepository,
    private readonly placeService: PlaceService,
    @InjectRepository(Place) private placeRepository: Repository<Place>,
    @InjectDataSource() private dataSource: DataSource,
  ) {}
  async create(createPointAndTradDto: CreatePointAndTradDto) {
    const placeRelation = await this.placeRepository.findOne({
      where: { idPlace: createPointAndTradDto.idPlace },
      relations: ['town'],
    });

    const place = await this.placeService.findOne(createPointAndTradDto.idPlace);
    if (!place) {
      throw new BadRequestException('Place not found');
@@ -50,6 +58,7 @@ export class PointOfInterestService {
    };
    await this.pointTraductionRepository.insert(createTradEs);
    await this.pointTraductionRepository.insert(createTradEn);
    generateQRCode(placeRelation.town.state.stateId, placeRelation.town.townId, placeRelation.idPlace, insertedId);
  }

  async findAllByPlace(idPlace: number, lang: LANGUAGES): Promise<getPointDto[]> {
@@ -84,6 +93,7 @@ export class PointOfInterestService {
        directions: point.directions,
      };
    });

    return points;
  }