added table equipo
This commit is contained in:
@@ -24,6 +24,7 @@ import { MesaModule } from './mesa/mesa.module';
|
||||
import { Mesa } from './mesa/entities/mesa.entity';
|
||||
import { AlumnoInscritoModule } from './alumno_inscrito/alumno_inscrito.module';
|
||||
import { AlumnoInscrito, Plataforma } from './alumno_inscrito/entities/alumno_inscrito.entity';
|
||||
import { EquipoModule } from './equipo/equipo.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -69,6 +70,7 @@ import { AlumnoInscrito, Plataforma } from './alumno_inscrito/entities/alumno_in
|
||||
ReciboModule,
|
||||
MesaModule,
|
||||
AlumnoInscritoModule,
|
||||
EquipoModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export class CreateEquipoDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateEquipoDto } from './create-equipo.dto';
|
||||
|
||||
export class UpdateEquipoDto extends PartialType(CreateEquipoDto) {}
|
||||
@@ -0,0 +1,80 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
ManyToOne,
|
||||
JoinColumn,
|
||||
Unique,
|
||||
OneToMany,
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity({ name: 'plataforma' })
|
||||
export class Plataforma {
|
||||
@PrimaryGeneratedColumn({ name: 'id_plataforma', type: 'int' })
|
||||
id_plataforma: number;
|
||||
|
||||
@Column({ name: 'plataforma', type: 'varchar', length: 45 })
|
||||
plataforma: string;
|
||||
|
||||
// Relación con equipos
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.plataforma)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
|
||||
@Entity({ name: 'area_ubicacion' })
|
||||
export class AreaUbicacion {
|
||||
@PrimaryGeneratedColumn({ name: 'id_area_ubicacion', type: 'int' })
|
||||
id_area_ubicacion: number;
|
||||
|
||||
@Column({ name: 'area', type: 'varchar', length: 45 })
|
||||
area: string;
|
||||
|
||||
@Column({ name: 'extra', type: 'char', length: 1, default: '0' })
|
||||
extra: string;
|
||||
|
||||
// Relación con equipos
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.areaUbicacion)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
|
||||
@Entity({ name: 'equipo' })
|
||||
@Unique('indice_unico_ubicacion', ['ubicacion'])
|
||||
export class Equipo {
|
||||
@PrimaryGeneratedColumn({ name: 'id_equipo', type: 'int' })
|
||||
id_equipo: number;
|
||||
|
||||
@Column({ name: 'id_plataforma', type: 'int' })
|
||||
id_plataforma: number;
|
||||
|
||||
@Column({ name: 'id_area_ubicacion', type: 'int' })
|
||||
id_area_ubicacion: number;
|
||||
|
||||
@Column({ name: 'nombre_equipo', type: 'varchar', length: 45 })
|
||||
nombre_equipo: string;
|
||||
|
||||
@Column({ name: 'ubicacion', type: 'varchar', length: 25 })
|
||||
ubicacion: string;
|
||||
|
||||
@Column({ name: 'activo', type: 'bit', default: () => "b'1'" })
|
||||
activo: boolean;
|
||||
|
||||
@Column({
|
||||
name: 'ip',
|
||||
type: 'varchar',
|
||||
length: 15,
|
||||
default: () => "'no service'",
|
||||
})
|
||||
ip: string;
|
||||
|
||||
@ManyToOne(() => Plataforma, (plataforma) => plataforma.equipos, {
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'id_plataforma' })
|
||||
plataforma: Plataforma;
|
||||
|
||||
@ManyToOne(() => AreaUbicacion, (area) => area.equipos, {
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'id_area_ubicacion' })
|
||||
areaUbicacion: AreaUbicacion;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { EquipoService } from './equipo.service';
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
import { UpdateEquipoDto } from './dto/update-equipo.dto';
|
||||
|
||||
@Controller('equipo')
|
||||
export class EquipoController {
|
||||
constructor(private readonly equipoService: EquipoService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createEquipoDto: CreateEquipoDto) {
|
||||
return this.equipoService.create(createEquipoDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.equipoService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.equipoService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateEquipoDto: UpdateEquipoDto) {
|
||||
return this.equipoService.update(+id, updateEquipoDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.equipoService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { EquipoService } from './equipo.service';
|
||||
import { EquipoController } from './equipo.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [EquipoController],
|
||||
providers: [EquipoService],
|
||||
})
|
||||
export class EquipoModule {}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateEquipoDto } from './dto/create-equipo.dto';
|
||||
import { UpdateEquipoDto } from './dto/update-equipo.dto';
|
||||
|
||||
@Injectable()
|
||||
export class EquipoService {
|
||||
create(createEquipoDto: CreateEquipoDto) {
|
||||
return 'This action adds a new equipo';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all equipo`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} equipo`;
|
||||
}
|
||||
|
||||
update(id: number, updateEquipoDto: UpdateEquipoDto) {
|
||||
return `This action updates a #${id} equipo`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} equipo`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user