Loading backend/src/app.module.ts +8 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ import { PointOfInterestTraduction } from './pointOfInterest/entities/PointOfInt import { PlaceTraduction } from './place/entities/place-traduction.entity'; import { CategoryModule } from './category/category.module'; import { Category } from './category/entities/category.entity'; import { RouteModule } from './route/route.module'; import { Route } from './route/entities/route.entity'; import { TravelPlaceModule } from './travel-place/travel-place.module'; import { TravelPlace } from './travel-place/entities/travel-place.entity'; @Module({ imports: [ Loading @@ -48,6 +52,8 @@ import { Category } from './category/entities/category.entity'; PointOfInterestTraduction, PlaceTraduction, Category, Route, TravelPlace, ], synchronize: DbConstants.DB_SYNC, logging: false, Loading @@ -65,6 +71,8 @@ import { Category } from './category/entities/category.entity'; }), PointOfInterestModule, CategoryModule, RouteModule, TravelPlaceModule, ], controllers: [AppController], providers: [AppService, DatabaseSeederModule], Loading backend/src/route/dto/create-route.dto.ts 0 → 100644 +9 −0 Original line number Diff line number Diff line import { Town } from 'src/town/entities/town.entity'; import { User } from 'src/user/entities/user.entity'; export class CreateRouteDto { user: User; town: Town; startDate: Date; endDate: Date; } backend/src/route/dto/update-route.dto.ts 0 → 100644 +4 −0 Original line number Diff line number Diff line import { PartialType } from '@nestjs/swagger'; import { CreateRouteDto } from './create-route.dto'; export class UpdateRouteDto extends PartialType(CreateRouteDto) {} backend/src/route/entities/route.entity.ts 0 → 100644 +26 −0 Original line number Diff line number Diff line import { Town } from 'src/town/entities/town.entity'; import { TravelPlace } from 'src/travel-place/entities/travel-place.entity'; import { User } from 'src/user/entities/user.entity'; import { PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, Entity, OneToMany } from 'typeorm'; @Entity() export class Route { @PrimaryGeneratedColumn() idRoute: number; @JoinColumn({ name: 'user' }) @ManyToOne(() => User, (user) => user.email, { nullable: false }) user: User; @JoinColumn({ name: 'town' }) @ManyToOne(() => Town, (town) => town.townId, { nullable: false }) town: Town; @OneToMany(() => TravelPlace, (travelPlace) => travelPlace.route) travelPlace: TravelPlace[]; @Column({ nullable: false }) startDate: Date; @Column({ nullable: false }) endDate: Date; } backend/src/route/route.controller.ts 0 → 100644 +38 −0 Original line number Diff line number Diff line import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common'; import { RouteService } from './route.service'; import { CreateRouteDto } from './dto/create-route.dto'; import { UpdateRouteDto } from './dto/update-route.dto'; import { ApiConsumes, ApiTags } from '@nestjs/swagger'; @Controller('Route') @ApiTags('testing') export class RouteController { constructor(private readonly routeService: RouteService) {} @Post() @ApiConsumes('multipart/form-data') // @UseGuards(AuthUserGuard) async create(@Body() createRouteDto: CreateRouteDto) { return await this.routeService.create(); } @Get() findAll() { return this.routeService.findAll(); } @Get(':idRoute') async findOne(@Param('idRoute') idRoute: number) { return await this.routeService.findOne(idRoute); } @Patch(':id') update(@Param('id') id: string, @Body() updateRouteDto: UpdateRouteDto) { return this.routeService.update(+id, updateRouteDto); } @Delete(':id') remove(@Param('id') id: string) { return this.routeService.remove(+id); } } Loading
backend/src/app.module.ts +8 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ import { PointOfInterestTraduction } from './pointOfInterest/entities/PointOfInt import { PlaceTraduction } from './place/entities/place-traduction.entity'; import { CategoryModule } from './category/category.module'; import { Category } from './category/entities/category.entity'; import { RouteModule } from './route/route.module'; import { Route } from './route/entities/route.entity'; import { TravelPlaceModule } from './travel-place/travel-place.module'; import { TravelPlace } from './travel-place/entities/travel-place.entity'; @Module({ imports: [ Loading @@ -48,6 +52,8 @@ import { Category } from './category/entities/category.entity'; PointOfInterestTraduction, PlaceTraduction, Category, Route, TravelPlace, ], synchronize: DbConstants.DB_SYNC, logging: false, Loading @@ -65,6 +71,8 @@ import { Category } from './category/entities/category.entity'; }), PointOfInterestModule, CategoryModule, RouteModule, TravelPlaceModule, ], controllers: [AppController], providers: [AppService, DatabaseSeederModule], Loading
backend/src/route/dto/create-route.dto.ts 0 → 100644 +9 −0 Original line number Diff line number Diff line import { Town } from 'src/town/entities/town.entity'; import { User } from 'src/user/entities/user.entity'; export class CreateRouteDto { user: User; town: Town; startDate: Date; endDate: Date; }
backend/src/route/dto/update-route.dto.ts 0 → 100644 +4 −0 Original line number Diff line number Diff line import { PartialType } from '@nestjs/swagger'; import { CreateRouteDto } from './create-route.dto'; export class UpdateRouteDto extends PartialType(CreateRouteDto) {}
backend/src/route/entities/route.entity.ts 0 → 100644 +26 −0 Original line number Diff line number Diff line import { Town } from 'src/town/entities/town.entity'; import { TravelPlace } from 'src/travel-place/entities/travel-place.entity'; import { User } from 'src/user/entities/user.entity'; import { PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, Entity, OneToMany } from 'typeorm'; @Entity() export class Route { @PrimaryGeneratedColumn() idRoute: number; @JoinColumn({ name: 'user' }) @ManyToOne(() => User, (user) => user.email, { nullable: false }) user: User; @JoinColumn({ name: 'town' }) @ManyToOne(() => Town, (town) => town.townId, { nullable: false }) town: Town; @OneToMany(() => TravelPlace, (travelPlace) => travelPlace.route) travelPlace: TravelPlace[]; @Column({ nullable: false }) startDate: Date; @Column({ nullable: false }) endDate: Date; }
backend/src/route/route.controller.ts 0 → 100644 +38 −0 Original line number Diff line number Diff line import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards } from '@nestjs/common'; import { RouteService } from './route.service'; import { CreateRouteDto } from './dto/create-route.dto'; import { UpdateRouteDto } from './dto/update-route.dto'; import { ApiConsumes, ApiTags } from '@nestjs/swagger'; @Controller('Route') @ApiTags('testing') export class RouteController { constructor(private readonly routeService: RouteService) {} @Post() @ApiConsumes('multipart/form-data') // @UseGuards(AuthUserGuard) async create(@Body() createRouteDto: CreateRouteDto) { return await this.routeService.create(); } @Get() findAll() { return this.routeService.findAll(); } @Get(':idRoute') async findOne(@Param('idRoute') idRoute: number) { return await this.routeService.findOne(idRoute); } @Patch(':id') update(@Param('id') id: string, @Body() updateRouteDto: UpdateRouteDto) { return this.routeService.update(+id, updateRouteDto); } @Delete(':id') remove(@Param('id') id: string) { return this.routeService.remove(+id); } }