Loading backend/src/pointOfInterest/PointOfInterest.module.ts 0 → 100644 +20 −0 Original line number Diff line number Diff line import { Module } from '@nestjs/common'; import { PointOfInterestService } from './PointOfInterest.service'; import { PointOfInterestController } from './PointOfInterest.controller'; import { TypeOrmModule } from '@nestjs/typeorm'; import { PointOfInterest } from './entities/PointOfInterest.entity'; import { PointOfInterestTraduction } from './entities/PointOfInterestTraduction.entity'; import { PlaceService } from 'src/place/place.service'; import { Place } from 'src/place/entities/place.entity'; import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; import { Town } from 'src/town/entities/town.entity'; @Module({ controllers: [PointOfInterestController], providers: [PointOfInterestService, PlaceService], imports: [ TypeOrmModule.forFeature([PointOfInterest, PointOfInterestTraduction, Place, AvailableDate, PlaceTraduction, Town]), ], }) export class PointOfInterestModule {} backend/src/pointOfInterest/PointOfInterest.service.ts 0 → 100644 +66 −0 Original line number Diff line number Diff line import { BadRequestException, Injectable } from '@nestjs/common'; import { CreatePointAndTradDto } from './dto/create-pointAndTraduction.dto'; import { UpdatePointDto } from './dto/update-point.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { PointOfInterest } from './entities/PointOfInterest.entity'; import { Repository } from 'typeorm'; import { PointOfInterestTraduction } from './entities/PointOfInterestTraduction.entity'; import { CreatePointDto } from './dto/create-point.dto'; import { PlaceService } from 'src/place/place.service'; import { CreatePointTradDto } from './dto/create-pointTrad.dto'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Injectable() export class PointOfInterestService { constructor( @InjectRepository(PointOfInterest) private pointRepository: Repository<PointOfInterest>, @InjectRepository(PointOfInterestTraduction) private pointTraductionRepository, private readonly placeService: PlaceService, ) {} async create(createPointAndTradDto: CreatePointAndTradDto) { const place = await this.placeService.findOne(createPointAndTradDto.idPlace); if (!place) { throw new BadRequestException('Place not found'); } const createPointDto: CreatePointDto = { name: createPointAndTradDto.name, imageName: createPointAndTradDto.image, idPlace: place, }; const insertedId = (await this.pointRepository.insert(createPointDto)).raw.insertId; const createTradEn: CreatePointTradDto = { idPoint: insertedId, language: LANGUAGES.EN, content: createPointAndTradDto.contentEN, audioName: 'audioName', directions: createPointAndTradDto.directionsEN, }; const createTradEs: CreatePointTradDto = { idPoint: insertedId, language: LANGUAGES.ES, content: createPointAndTradDto.contentES, audioName: 'audioName', directions: createPointAndTradDto.directionsES, }; await this.pointTraductionRepository.insert(createTradEs); await this.pointTraductionRepository.insert(createTradEn); } findAll() { return `This action returns all activity`; } findOne(id: number) { return `This action returns a #${id} activity`; } update(id: number, updateActivityDto: UpdatePointDto) { return `This action updates a #${id} activity`; } remove(id: number) { return `This action removes a #${id} activity`; } } backend/src/pointOfInterest/entities/PointOfInterestTraduction.entity.ts 0 → 100644 +20 −0 Original line number Diff line number Diff line import { Column, Entity, ManyToOne, PrimaryColumn } from 'typeorm'; import { PointOfInterest } from './PointOfInterest.entity'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Entity() export class PointOfInterestTraduction { @PrimaryColumn({ name: 'idPoint', type: Number }) @ManyToOne(() => PointOfInterest, (point) => point.idPoint) idPoint: PointOfInterest; @PrimaryColumn() language: LANGUAGES; @Column({ nullable: false }) content: string; @Column({ nullable: false }) directions: string; @Column() audioName: string; } Loading
backend/src/pointOfInterest/PointOfInterest.module.ts 0 → 100644 +20 −0 Original line number Diff line number Diff line import { Module } from '@nestjs/common'; import { PointOfInterestService } from './PointOfInterest.service'; import { PointOfInterestController } from './PointOfInterest.controller'; import { TypeOrmModule } from '@nestjs/typeorm'; import { PointOfInterest } from './entities/PointOfInterest.entity'; import { PointOfInterestTraduction } from './entities/PointOfInterestTraduction.entity'; import { PlaceService } from 'src/place/place.service'; import { Place } from 'src/place/entities/place.entity'; import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; import { Town } from 'src/town/entities/town.entity'; @Module({ controllers: [PointOfInterestController], providers: [PointOfInterestService, PlaceService], imports: [ TypeOrmModule.forFeature([PointOfInterest, PointOfInterestTraduction, Place, AvailableDate, PlaceTraduction, Town]), ], }) export class PointOfInterestModule {}
backend/src/pointOfInterest/PointOfInterest.service.ts 0 → 100644 +66 −0 Original line number Diff line number Diff line import { BadRequestException, Injectable } from '@nestjs/common'; import { CreatePointAndTradDto } from './dto/create-pointAndTraduction.dto'; import { UpdatePointDto } from './dto/update-point.dto'; import { InjectRepository } from '@nestjs/typeorm'; import { PointOfInterest } from './entities/PointOfInterest.entity'; import { Repository } from 'typeorm'; import { PointOfInterestTraduction } from './entities/PointOfInterestTraduction.entity'; import { CreatePointDto } from './dto/create-point.dto'; import { PlaceService } from 'src/place/place.service'; import { CreatePointTradDto } from './dto/create-pointTrad.dto'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Injectable() export class PointOfInterestService { constructor( @InjectRepository(PointOfInterest) private pointRepository: Repository<PointOfInterest>, @InjectRepository(PointOfInterestTraduction) private pointTraductionRepository, private readonly placeService: PlaceService, ) {} async create(createPointAndTradDto: CreatePointAndTradDto) { const place = await this.placeService.findOne(createPointAndTradDto.idPlace); if (!place) { throw new BadRequestException('Place not found'); } const createPointDto: CreatePointDto = { name: createPointAndTradDto.name, imageName: createPointAndTradDto.image, idPlace: place, }; const insertedId = (await this.pointRepository.insert(createPointDto)).raw.insertId; const createTradEn: CreatePointTradDto = { idPoint: insertedId, language: LANGUAGES.EN, content: createPointAndTradDto.contentEN, audioName: 'audioName', directions: createPointAndTradDto.directionsEN, }; const createTradEs: CreatePointTradDto = { idPoint: insertedId, language: LANGUAGES.ES, content: createPointAndTradDto.contentES, audioName: 'audioName', directions: createPointAndTradDto.directionsES, }; await this.pointTraductionRepository.insert(createTradEs); await this.pointTraductionRepository.insert(createTradEn); } findAll() { return `This action returns all activity`; } findOne(id: number) { return `This action returns a #${id} activity`; } update(id: number, updateActivityDto: UpdatePointDto) { return `This action updates a #${id} activity`; } remove(id: number) { return `This action removes a #${id} activity`; } }
backend/src/pointOfInterest/entities/PointOfInterestTraduction.entity.ts 0 → 100644 +20 −0 Original line number Diff line number Diff line import { Column, Entity, ManyToOne, PrimaryColumn } from 'typeorm'; import { PointOfInterest } from './PointOfInterest.entity'; import { LANGUAGES } from 'src/shared/enum/languages.enum'; @Entity() export class PointOfInterestTraduction { @PrimaryColumn({ name: 'idPoint', type: Number }) @ManyToOne(() => PointOfInterest, (point) => point.idPoint) idPoint: PointOfInterest; @PrimaryColumn() language: LANGUAGES; @Column({ nullable: false }) content: string; @Column({ nullable: false }) directions: string; @Column() audioName: string; }