Commit 711859d6 authored by Lorenzo Trujillo Rojas's avatar Lorenzo Trujillo Rojas
Browse files

Merge branch 'main' into 'main'

Agregando entidades route y travel-place

See merge request ltrpro/pueblosmagicosconia!53
parents 7d25fe85 01fc0b89
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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: [
@@ -48,6 +52,8 @@ import { Category } from './category/entities/category.entity';
        PointOfInterestTraduction,
        PlaceTraduction,
        Category,
        Route,
        TravelPlace,
      ],
      synchronize: DbConstants.DB_SYNC,
      logging: false,
@@ -65,6 +71,8 @@ import { Category } from './category/entities/category.entity';
    }),
    PointOfInterestModule,
    CategoryModule,
    RouteModule,
    TravelPlaceModule,
  ],
  controllers: [AppController],
  providers: [AppService, DatabaseSeederModule],
+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;
}
+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) {}
+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;
}
+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