diff --git a/backend/src/activity/activity.controller.ts b/backend/src/activity/activity.controller.ts deleted file mode 100644 index 26fb6becbb1d6812cbd5b5ebc330b690cedcb247..0000000000000000000000000000000000000000 --- a/backend/src/activity/activity.controller.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'; -import { ActivityService } from './activity.service'; -import { CreateActivityDto } from './dto/create-activity.dto'; -import { UpdateActivityDto } from './dto/update-activity.dto'; - -@Controller('activity') -export class ActivityController { - constructor(private readonly activityService: ActivityService) {} - - @Post() - create(@Body() createActivityDto: CreateActivityDto) { - return this.activityService.create(createActivityDto); - } - - @Get() - findAll() { - return this.activityService.findAll(); - } - - @Get(':id') - findOne(@Param('id') id: string) { - return this.activityService.findOne(+id); - } - - @Patch(':id') - update(@Param('id') id: string, @Body() updateActivityDto: UpdateActivityDto) { - return this.activityService.update(+id, updateActivityDto); - } - - @Delete(':id') - remove(@Param('id') id: string) { - return this.activityService.remove(+id); - } -} diff --git a/backend/src/activity/activity.module.ts b/backend/src/activity/activity.module.ts deleted file mode 100644 index d60b58cec8d42a4ef585ed3331272fbac80b0371..0000000000000000000000000000000000000000 --- a/backend/src/activity/activity.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common'; -import { ActivityService } from './activity.service'; -import { ActivityController } from './activity.controller'; - -@Module({ - controllers: [ActivityController], - providers: [ActivityService], -}) -export class ActivityModule {} diff --git a/backend/src/activity/activity.service.ts b/backend/src/activity/activity.service.ts deleted file mode 100644 index 4a6486cfe971ac6abb1247c6ed6a7b23c5f6d24d..0000000000000000000000000000000000000000 --- a/backend/src/activity/activity.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { CreateActivityDto } from './dto/create-activity.dto'; -import { UpdateActivityDto } from './dto/update-activity.dto'; - -@Injectable() -export class ActivityService { - create(createActivityDto: CreateActivityDto) { - return 'This action adds a new activity'; - } - - findAll() { - return `This action returns all activity`; - } - - findOne(id: number) { - return `This action returns a #${id} activity`; - } - - update(id: number, updateActivityDto: UpdateActivityDto) { - return `This action updates a #${id} activity`; - } - - remove(id: number) { - return `This action removes a #${id} activity`; - } -} diff --git a/backend/src/activity/dto/create-activity.dto.ts b/backend/src/activity/dto/create-activity.dto.ts deleted file mode 100644 index b54337e6f900365bca240201169b75480e731456..0000000000000000000000000000000000000000 --- a/backend/src/activity/dto/create-activity.dto.ts +++ /dev/null @@ -1,8 +0,0 @@ -export class CreateActivityDto { - idPlace: number; - name: string; - numberActivity: number; - imageName: string; - descriptionEN: string; - descriptionES: string; -} diff --git a/backend/src/activity/dto/update-activity.dto.ts b/backend/src/activity/dto/update-activity.dto.ts deleted file mode 100644 index a4b993857397f92a6758ac12bdab27933549e9a4..0000000000000000000000000000000000000000 --- a/backend/src/activity/dto/update-activity.dto.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { PartialType } from '@nestjs/swagger'; -import { CreateActivityDto } from './create-activity.dto'; - -export class UpdateActivityDto extends PartialType(CreateActivityDto) {} diff --git a/backend/src/activity/entities/activityTraduction.entity.ts b/backend/src/activity/entities/activityTraduction.entity.ts deleted file mode 100644 index e9156a603709365929e2c87681d7f16fb8ac195f..0000000000000000000000000000000000000000 --- a/backend/src/activity/entities/activityTraduction.entity.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Column, Entity, ManyToOne, PrimaryColumn } from 'typeorm'; -import { Activity } from './activity.entity'; -import { LANGUAGES } from 'src/shared/enum/languages.enum'; - -@Entity() -export class ActivityTraduction { - @PrimaryColumn({ name: 'idActivity' }) - @ManyToOne(() => Activity, (activity) => activity.idActivity) - idActivity: number; - @PrimaryColumn() - language: LANGUAGES; - - @Column({ nullable: false }) - content: string; - - @Column() - audioName: string; -} diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index eaf75daca623a4fb98f05f2de90df0d2f4158616..a03fa800ce56b16ce04d9273729d6fb83d537d70 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -22,10 +22,10 @@ import { APP_GUARD } from '@nestjs/core'; import { AuthGuard } from './auth/admin/auth.guard'; import { PlaceModule } from './place/place.module'; import { Place } from './place/entities/place.entity'; -import { ActivityModule } from './activity/activity.module'; -import { Activity } from './activity/entities/activity.entity'; +import { PointOfInterestModule } from './pointOfInterest/PointOfInterest.module'; +import { PointOfInterest } from './pointOfInterest/entities/PointOfInterest.entity'; import { AvailableDate } from './place/entities/available-date.entity'; -import { ActivityTraduction } from './activity/entities/activityTraduction.entity'; +import { PointOfInterestTraduction } from './pointOfInterest/entities/PointOfInterestTraduction.entity'; import { PlaceTraduction } from './place/entities/place-traduction.entity'; @Module({ @@ -44,9 +44,9 @@ import { PlaceTraduction } from './place/entities/place-traduction.entity'; Town, TownTraduction, Place, - Activity, + PointOfInterest, AvailableDate, - ActivityTraduction, + PointOfInterestTraduction, PlaceTraduction, ], synchronize: DbConstants.DB_SYNC, @@ -64,7 +64,7 @@ import { PlaceTraduction } from './place/entities/place-traduction.entity'; ServeStaticModule.forRoot({ rootPath: join(__dirname, '..', 'static'), }), - ActivityModule, + PointOfInterestModule, ], controllers: [AppController], providers: [AppService, DatabaseSeederModule, { provide: APP_GUARD, useClass: AuthGuard }], diff --git a/backend/src/database-seeder/database-seeder.module.ts b/backend/src/database-seeder/database-seeder.module.ts index 9096a25bd2921515356e45aa31850ede4bce06af..28c53db57c8323d47ba4b36ab8715aea2f220b02 100644 --- a/backend/src/database-seeder/database-seeder.module.ts +++ b/backend/src/database-seeder/database-seeder.module.ts @@ -12,12 +12,13 @@ import { JwtService } from '@nestjs/jwt'; import { EncryptionService } from 'src/auth/encryption/encryption.service'; import { TownService } from 'src/town/town.service'; import { TownTraduction } from 'src/town/entities/town-traduction.entity'; -import { ActivityService } from 'src/activity/activity.service'; +import { PointOfInterestService } from 'src/pointOfInterest/PointOfInterest.service'; import { PlaceService } from 'src/place/place.service'; import { Place } from 'src/place/entities/place.entity'; -import { Activity } from 'src/activity/entities/activity.entity'; +import { PointOfInterest } from 'src/pointOfInterest/entities/PointOfInterest.entity'; import { AvailableDate } from 'src/place/entities/available-date.entity'; import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; +import { PointOfInterestTraduction } from 'src/pointOfInterest/entities/PointOfInterestTraduction.entity'; @Module({ providers: [ @@ -28,7 +29,7 @@ import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; JwtService, EncryptionService, TownService, - ActivityService, + PointOfInterestService, PlaceService, ], imports: [ @@ -39,9 +40,10 @@ import { PlaceTraduction } from 'src/place/entities/place-traduction.entity'; Town, TownTraduction, Place, - Activity, + PointOfInterest, AvailableDate, PlaceTraduction, + PointOfInterestTraduction, ]), ], }) diff --git a/backend/src/database-seeder/database-seeder.service.ts b/backend/src/database-seeder/database-seeder.service.ts index abdbe6c726fea74337b3e9127f271ae6d0b41bb8..f5cec734d9c349a729b64811e73fec129650c5f7 100644 --- a/backend/src/database-seeder/database-seeder.service.ts +++ b/backend/src/database-seeder/database-seeder.service.ts @@ -10,7 +10,7 @@ import { UserStatus } from 'src/shared/enum/user-status.enum'; import { AuthAdminService } from 'src/auth/admin/authAdminservice'; import { TownService } from 'src/town/town.service'; import { CreateTownDto } from 'src/town/dto/create-town.dto'; -import { ActivityService } from 'src/activity/activity.service'; +import { PointOfInterestService } from 'src/pointOfInterest/PointOfInterest.service'; import { PlaceService } from 'src/place/place.service'; @Injectable() @@ -20,7 +20,7 @@ export class DatabaseSeederService implements OnModuleInit { private readonly stateService: StateService, private readonly authAdminService: AuthAdminService, private readonly townService: TownService, - private readonly activityService: ActivityService, + private readonly activityService: PointOfInterestService, private readonly placeService: PlaceService, ) {} diff --git a/backend/src/place/dto/create-place-date.dto.ts b/backend/src/place/dto/create-place-date.dto.ts index 9ecc2d8191e4e9e3de451582f2ecd8cf90cbf94b..5eb4923356e7a062f56c58193ba5c567ec3820eb 100644 --- a/backend/src/place/dto/create-place-date.dto.ts +++ b/backend/src/place/dto/create-place-date.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Available } from 'src/activity/enum/available.enum'; +import { Available } from 'src/pointOfInterest/enum/available.enum'; export class CreatePlaceDateTradDto { @ApiProperty({ enum: Available, enumName: 'Available' }) @@ -28,9 +28,9 @@ export class CreatePlaceDateTradDto { @ApiProperty({ maximum: 24, minimum: 0 }) closeAt: number; - @ApiProperty({ default: new Date() }) + @ApiProperty({ nullable: true, required: false, description: 'Only required if available is CUSTOM' }) startDate: Date; - @ApiProperty({ default: new Date() }) + @ApiProperty({ nullable: true, required: false, description: 'Only required if available is CUSTOM' }) endDate: Date; } diff --git a/backend/src/place/dto/create-place.dto.ts b/backend/src/place/dto/create-place.dto.ts index 320b52c663ef5a30599f7ba41cded86c713f1a35..cfb2aa2bee236a112d1d08afcdccd4aab45c27be 100644 --- a/backend/src/place/dto/create-place.dto.ts +++ b/backend/src/place/dto/create-place.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { Available } from 'src/activity/enum/available.enum'; +import { Available } from 'src/pointOfInterest/enum/available.enum'; import { Town } from 'src/town/entities/town.entity'; export class CreatePlaceDto { diff --git a/backend/src/place/dto/get-place.dto.ts b/backend/src/place/dto/get-place.dto.ts index ee107604de080a59d1798f6adc266e90b542efb9..ceca88a6ec9861a6c71ae5ae2bfcb1cee436e03f 100644 --- a/backend/src/place/dto/get-place.dto.ts +++ b/backend/src/place/dto/get-place.dto.ts @@ -1,4 +1,4 @@ -import { Available } from 'src/activity/enum/available.enum'; +import { Available } from 'src/pointOfInterest/enum/available.enum'; import { Town } from 'src/town/entities/town.entity'; export class GetPlaceDto { @@ -10,4 +10,6 @@ export class GetPlaceDto { coords: string; openAt: number; closeAt: number; + startDate: Date; + endDate: Date; } diff --git a/backend/src/place/entities/available-date.entity.ts b/backend/src/place/entities/available-date.entity.ts index f3c8db84d3b21fd6bf834b3c072405f2469395fc..f6c3737c43137e701c687b0336a290b5b1424e20 100644 --- a/backend/src/place/entities/available-date.entity.ts +++ b/backend/src/place/entities/available-date.entity.ts @@ -8,7 +8,7 @@ export class AvailableDate { @JoinColumn({ name: 'idPlace' }) @ManyToOne(() => Place, (place) => place.availableDates, { nullable: false }) - idPlace: number; + idPlace: Place; @Column() startDate: Date; diff --git a/backend/src/place/entities/place-traduction.entity.ts b/backend/src/place/entities/place-traduction.entity.ts index f6bbd132e687f2a540333b094e15d76962479d52..3c29b7dec07bc99147088c1609b981236e27a863 100644 --- a/backend/src/place/entities/place-traduction.entity.ts +++ b/backend/src/place/entities/place-traduction.entity.ts @@ -7,9 +7,9 @@ export class PlaceTraduction { @PrimaryColumn() language: LANGUAGES = LANGUAGES.ES; - @PrimaryColumn({ name: 'idPlace' }) + @PrimaryColumn({ name: 'idPlace', type: Number }) @ManyToOne(() => Place, (place) => place.availableDates, { nullable: false }) - idPlace: number; + idPlace: Place; @Column() description: string; diff --git a/backend/src/place/entities/place.entity.ts b/backend/src/place/entities/place.entity.ts index 047cff095bf4cbca9c53041d714558dec1c643b7..2c2a9b1e2b773a211c262eefb41fe16183f0d776 100644 --- a/backend/src/place/entities/place.entity.ts +++ b/backend/src/place/entities/place.entity.ts @@ -1,5 +1,5 @@ -import { Activity } from 'src/activity/entities/activity.entity'; -import { Available } from 'src/activity/enum/available.enum'; +import { PointOfInterest } from 'src/pointOfInterest/entities/PointOfInterest.entity'; +import { Available } from 'src/pointOfInterest/enum/available.enum'; import { Town } from 'src/town/entities/town.entity'; import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm'; import { AvailableDate } from './available-date.entity'; @@ -13,10 +13,10 @@ export class Place { @ManyToOne(() => Town, (town) => town.townId, { nullable: false }) idTown: Town; - @OneToMany(() => Activity, (activity) => activity.idActivity) - activities: Activity[]; + @OneToMany(() => PointOfInterest, (point) => point.idPoint) + points: PointOfInterest[]; - @OneToMany(() => AvailableDate, (availableDate) => availableDate.idAvailableDate) + @OneToMany(() => AvailableDate, (available) => available.idPlace) availableDates: AvailableDate[]; @Column() diff --git a/backend/src/place/place.service.ts b/backend/src/place/place.service.ts index ac41e02a61148714fbb2beba7ec07d3b15a276b5..2f0faf1b66bbaab25155d719d00918408e80829e 100644 --- a/backend/src/place/place.service.ts +++ b/backend/src/place/place.service.ts @@ -12,6 +12,7 @@ import { LANGUAGES } from 'src/shared/enum/languages.enum'; import { Town } from 'src/town/entities/town.entity'; import { GetPlaceDto } from './dto/get-place.dto'; import { ServerConstants } from 'src/constants/server.contants'; +import { Available } from 'src/pointOfInterest/enum/available.enum'; @Injectable() export class PlaceService { @@ -55,10 +56,13 @@ export class PlaceService { idPlace: insertedId, description: createPlaceDto.descriptionES, }; + // TODO: add transaction to rollback if one of the inserts fails await this.placeTraductionRepository.insert(createTradEs); await this.placeTraductionRepository.insert(createTradEn); - await this.availableDateRepository.insert(createDate); + if (createPlaceDto.available === Available.CUSTOM) { + await this.availableDateRepository.insert({ ...createDate, idPlace: insertedId }); + } } async findAllByTown(idTown: number, lang: LANGUAGES) { @@ -66,6 +70,7 @@ export class PlaceService { .getRepository(PlaceTraduction) .createQueryBuilder('placeTrad') .leftJoin('placeTrad.idPlace', 'place') + .leftJoin('place.availableDates', 'availableDate') .select([ 'place.idPlace AS idPlace', 'place.name AS name', @@ -75,8 +80,10 @@ export class PlaceService { 'place.coords AS coords', 'place.openAt AS openAt', 'place.closeAt AS closeAt', + 'availableDate.startDate AS startDate', + 'availableDate.endDate AS endDate', ]) - .where('place.idTown = :idTown', { idTown }) + .where('place.idTown = :idTown', { idTown: idTown }) .andWhere('placeTrad.language = :language', { language: lang }) .getRawMany(); const places: GetPlaceDto[] = res.map((place) => { @@ -89,13 +96,16 @@ export class PlaceService { name: place.name, openAt: place.openAt, closeAt: place.closeAt, + startDate: place.startDate, + endDate: place.endDate, }; }); return places; } - findOne(id: number) { - return `This action returns a #${id} place`; + async findOne(id: number) { + const place = await this.placeRepository.findOneBy({ idPlace: id }); + return place; } update(id: number, updatePlaceDto: UpdatePlaceDto) { diff --git a/backend/src/pointOfInterest/PointOfInterest.controller.ts b/backend/src/pointOfInterest/PointOfInterest.controller.ts new file mode 100644 index 0000000000000000000000000000000000000000..979398af38efee4ffbea554636a7ab08b8204b7e --- /dev/null +++ b/backend/src/pointOfInterest/PointOfInterest.controller.ts @@ -0,0 +1,49 @@ +import { Controller, Get, Post, Body, Patch, Param, Delete, UseInterceptors, UploadedFile } from '@nestjs/common'; +import { PointOfInterestService } from './PointOfInterest.service'; +import { CreatePointAndTradDto } from './dto/create-pointAndTraduction.dto'; +import { UpdatePointDto } from './dto/update-point.dto'; +import { ApiBearerAuth, ApiConsumes, 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'; +import { FileValidationPipe } from 'src/shared/pipe/file-validation.pipe'; + +@Controller('point') +@ApiTags('Point of interest') +export class PointOfInterestController { + constructor(private readonly activityService: PointOfInterestService) {} + + @ApiConsumes('multipart/form-data') + @Roles(ADMIN_ROLES) + @ApiBearerAuth('jwt') + @Post() + @UseInterceptors(fileInterceptor('image', 'static/points/', ['.jpg', '.jpeg', '.png'])) + async create(@UploadedFile(new FileValidationPipe()) file, @Body() createActivityDto: CreatePointAndTradDto) { + try { + createActivityDto.image = file.filename; + return await this.activityService.create(createActivityDto); + } catch (error) { + throw error; + } + } + + @Get() + findAll() { + return this.activityService.findAll(); + } + + @Get(':id') + findOne(@Param('id') id: string) { + return this.activityService.findOne(+id); + } + + @Patch(':id') + update(@Param('id') id: string, @Body() updateActivityDto: UpdatePointDto) { + return this.activityService.update(+id, updateActivityDto); + } + + @Delete(':id') + remove(@Param('id') id: string) { + return this.activityService.remove(+id); + } +} diff --git a/backend/src/pointOfInterest/PointOfInterest.module.ts b/backend/src/pointOfInterest/PointOfInterest.module.ts new file mode 100644 index 0000000000000000000000000000000000000000..c92230258af1ca75f112f6a7febed2bbe223904b --- /dev/null +++ b/backend/src/pointOfInterest/PointOfInterest.module.ts @@ -0,0 +1,20 @@ +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 {} diff --git a/backend/src/pointOfInterest/PointOfInterest.service.ts b/backend/src/pointOfInterest/PointOfInterest.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7184a8ab240a66bcd4ef462acaa9b2fa32e7221 --- /dev/null +++ b/backend/src/pointOfInterest/PointOfInterest.service.ts @@ -0,0 +1,66 @@ +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, + @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`; + } +} diff --git a/backend/src/pointOfInterest/dto/create-point.dto.ts b/backend/src/pointOfInterest/dto/create-point.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..10569d81da647085a23da6aee52b560ffd3f04a7 --- /dev/null +++ b/backend/src/pointOfInterest/dto/create-point.dto.ts @@ -0,0 +1,7 @@ +import { Place } from 'src/place/entities/place.entity'; + +export class CreatePointDto { + idPlace: Place; + name: string; + imageName: string; +} diff --git a/backend/src/pointOfInterest/dto/create-pointAndTraduction.dto.ts b/backend/src/pointOfInterest/dto/create-pointAndTraduction.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c77b9e534762442d46f7e5520a7be277fa2b8e8 --- /dev/null +++ b/backend/src/pointOfInterest/dto/create-pointAndTraduction.dto.ts @@ -0,0 +1,18 @@ +import { ApiProperty } from '@nestjs/swagger'; + +export class CreatePointAndTradDto { + @ApiProperty() + idPlace: number; + @ApiProperty() + name: string; + @ApiProperty({ type: 'string', format: 'binary' }) + image; + @ApiProperty() + contentEN: string; + @ApiProperty() + contentES: string; + @ApiProperty() + directionsEN: string; + @ApiProperty() + directionsES: string; +} diff --git a/backend/src/pointOfInterest/dto/create-pointTrad.dto.ts b/backend/src/pointOfInterest/dto/create-pointTrad.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..6c4a0dcdef5d694b9caad9b510e0463c67481e75 --- /dev/null +++ b/backend/src/pointOfInterest/dto/create-pointTrad.dto.ts @@ -0,0 +1,9 @@ +import { LANGUAGES } from 'src/shared/enum/languages.enum'; + +export class CreatePointTradDto { + language: LANGUAGES; + idPoint: number; + content: string; + directions: string; + audioName: string; +} diff --git a/backend/src/pointOfInterest/dto/update-point.dto.ts b/backend/src/pointOfInterest/dto/update-point.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..c763b64a8fd16a02fa8c1ee6ad6d80302eec7c5a --- /dev/null +++ b/backend/src/pointOfInterest/dto/update-point.dto.ts @@ -0,0 +1,4 @@ +import { PartialType } from '@nestjs/swagger'; +import { CreatePointAndTradDto } from './create-pointAndTraduction.dto'; + +export class UpdatePointDto extends PartialType(CreatePointAndTradDto) {} diff --git a/backend/src/activity/entities/activity.entity.ts b/backend/src/pointOfInterest/entities/PointOfInterest.entity.ts similarity index 66% rename from backend/src/activity/entities/activity.entity.ts rename to backend/src/pointOfInterest/entities/PointOfInterest.entity.ts index aa9f39c2c508c0d305ad62c63fe44fc1dc53b449..791f25c43077b7d631dbe03d83c9e30018eaab67 100644 --- a/backend/src/activity/entities/activity.entity.ts +++ b/backend/src/pointOfInterest/entities/PointOfInterest.entity.ts @@ -2,20 +2,17 @@ import { Place } from 'src/place/entities/place.entity'; import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; @Entity() -export class Activity { +export class PointOfInterest { @PrimaryGeneratedColumn() - idActivity: number; + idPoint: number; @Column({ nullable: false }) name: string; @JoinColumn({ name: 'idPlace' }) - @ManyToOne(() => Place, (place) => place.activities) + @ManyToOne(() => Place, (place) => place.points, { nullable: false }) idPlace: Place; - @Column({ nullable: false, primary: true }) - numberActivity: number; - @Column({ nullable: false }) imageName: string; } diff --git a/backend/src/pointOfInterest/entities/PointOfInterestTraduction.entity.ts b/backend/src/pointOfInterest/entities/PointOfInterestTraduction.entity.ts new file mode 100644 index 0000000000000000000000000000000000000000..f6cc23f380cab4d383bf3197571e0fea7f7b8db2 --- /dev/null +++ b/backend/src/pointOfInterest/entities/PointOfInterestTraduction.entity.ts @@ -0,0 +1,20 @@ +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; +} diff --git a/backend/src/activity/enum/available.enum.ts b/backend/src/pointOfInterest/enum/available.enum.ts similarity index 100% rename from backend/src/activity/enum/available.enum.ts rename to backend/src/pointOfInterest/enum/available.enum.ts diff --git a/backend/static/places/default.jpeg b/backend/static/places/default.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..a20424e9462de9eecc11a18ead64ba6a2d36b13c Binary files /dev/null and b/backend/static/places/default.jpeg differ diff --git a/backend/static/points/default.jpeg b/backend/static/points/default.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..a20424e9462de9eecc11a18ead64ba6a2d36b13c Binary files /dev/null and b/backend/static/points/default.jpeg differ