Loading backend/src/pointOfInterest/PointOfInterest.service.ts +10 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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'); Loading Loading @@ -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[]> { Loading Loading @@ -84,6 +93,7 @@ export class PointOfInterestService { directions: point.directions, }; }); return points; } Loading Loading
backend/src/pointOfInterest/PointOfInterest.service.ts +10 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading @@ -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'); Loading Loading @@ -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[]> { Loading Loading @@ -84,6 +93,7 @@ export class PointOfInterestService { directions: point.directions, }; }); return points; } Loading