added programa, area ubicacion and programa_equipo
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { AreaUbicacionService } from './area_ubicacion.service';
|
||||
|
||||
@Controller('area-ubicacion')
|
||||
export class AreaUbicacionController {
|
||||
constructor(private readonly areaUbicacionService: AreaUbicacionService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.areaUbicacionService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.areaUbicacionService.findOne(+id);
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AreaUbicacionService } from './area_ubicacion.service';
|
||||
import { AreaUbicacionController } from './area_ubicacion.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AreaUbicacion } from './entities/area_ubicacion.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([AreaUbicacion])],
|
||||
controllers: [AreaUbicacionController],
|
||||
providers: [AreaUbicacionService],
|
||||
})
|
||||
export class AreaUbicacionModule {}
|
||||
//IO
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { AreaUbicacion } from './entities/area_ubicacion.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class AreaUbicacionService {
|
||||
constructor(
|
||||
@InjectRepository(AreaUbicacion)
|
||||
private readonly areaUbicacionRepository: Repository<AreaUbicacion>,
|
||||
) {}
|
||||
findAll() {
|
||||
return this.areaUbicacionRepository.find();
|
||||
}
|
||||
|
||||
findOne(id_area_ubicacion: number) {
|
||||
const area = this.areaUbicacionRepository.findOne({
|
||||
where: { id_area_ubicacion },
|
||||
});
|
||||
|
||||
if(!area){
|
||||
return "this area dosnt exist"
|
||||
}
|
||||
|
||||
return area
|
||||
}
|
||||
}
|
||||
//IO
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Equipo } from 'src/equipo/entities/equipo.entity';
|
||||
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
|
||||
|
||||
@Entity({ name: 'area_ubicacion' })
|
||||
export class AreaUbicacion {
|
||||
@PrimaryGeneratedColumn({ name: 'id_area_ubicacion' })
|
||||
id_area_ubicacion: number;
|
||||
|
||||
@Column({ type: 'varchar', length: 45, nullable: false })
|
||||
area: string;
|
||||
|
||||
@Column({ type: 'char', length: 1, default: '0', nullable: false })
|
||||
extra: string;
|
||||
|
||||
@OneToMany(() => Equipo, (equipo) => equipo.areaUbicacion)
|
||||
equipos: Equipo[];
|
||||
}
|
||||
//IO
|
||||
Reference in New Issue
Block a user