added programa, area ubicacion and programa_equipo
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export class CreateProgramaEquipoDto {}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateProgramaEquipoDto } from './create-programa_equipo.dto';
|
||||
|
||||
export class UpdateProgramaEquipoDto extends PartialType(CreateProgramaEquipoDto) {}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Equipo } from "src/equipo/entities/equipo.entity";
|
||||
import { Programa } from "src/programa/entities/programa.entity";
|
||||
import { Entity, PrimaryColumn, ManyToOne, JoinColumn } from "typeorm";
|
||||
|
||||
@Entity("programa_equipo")
|
||||
export class ProgramaEquipo {
|
||||
@PrimaryColumn({ name: "id_programa", type: "int" })
|
||||
id_programa: number;
|
||||
|
||||
@PrimaryColumn({ name: "id_equipo", type: "int" })
|
||||
id_equipo: number;
|
||||
|
||||
@ManyToOne(() => Programa, (programa) => programa.programaEquipos, {
|
||||
onUpdate: "CASCADE",
|
||||
})
|
||||
@JoinColumn({ name: "id_programa" })
|
||||
programa: Programa;
|
||||
|
||||
@ManyToOne(() => Equipo, (equipo) => equipo.programaEquipos, {
|
||||
onUpdate: "CASCADE",
|
||||
})
|
||||
@JoinColumn({ name: "id_equipo" })
|
||||
equipo: Equipo;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { ProgramaEquipoService } from './programa_equipo.service';
|
||||
import { CreateProgramaEquipoDto } from './dto/create-programa_equipo.dto';
|
||||
import { UpdateProgramaEquipoDto } from './dto/update-programa_equipo.dto';
|
||||
|
||||
@Controller('programa-equipo')
|
||||
export class ProgramaEquipoController {
|
||||
constructor(private readonly programaEquipoService: ProgramaEquipoService) {}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.programaEquipoService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.programaEquipoService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateProgramaEquipoDto: UpdateProgramaEquipoDto) {
|
||||
return this.programaEquipoService.update(+id, updateProgramaEquipoDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ProgramaEquipoService } from './programa_equipo.service';
|
||||
import { ProgramaEquipoController } from './programa_equipo.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ProgramaEquipo } from './entities/programa_equipo.entity';
|
||||
|
||||
@Module({
|
||||
imports:[TypeOrmModule.forFeature([ProgramaEquipo])],
|
||||
controllers: [ProgramaEquipoController],
|
||||
providers: [ProgramaEquipoService],
|
||||
})
|
||||
export class ProgramaEquipoModule {}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { CreateProgramaEquipoDto } from './dto/create-programa_equipo.dto';
|
||||
import { UpdateProgramaEquipoDto } from './dto/update-programa_equipo.dto';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { ProgramaEquipo } from './entities/programa_equipo.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
|
||||
@Injectable()
|
||||
export class ProgramaEquipoService {
|
||||
constructor(
|
||||
@InjectRepository(ProgramaEquipo)
|
||||
private readonly ProgramaEquipoRepository: Repository<ProgramaEquipo>,
|
||||
) {}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all programaEquipo`;
|
||||
}
|
||||
|
||||
async findOne(id_equipo: number) {
|
||||
const equipo = await this.ProgramaEquipoRepository.find({
|
||||
where: { id_equipo },
|
||||
});
|
||||
|
||||
if (equipo.length === 0) {
|
||||
throw new NotFoundException(`machine without programs`);
|
||||
}
|
||||
|
||||
return equipo;
|
||||
}
|
||||
|
||||
update(id: number, updateProgramaEquipoDto: UpdateProgramaEquipoDto) {
|
||||
return `This action updates a #${id} programaEquipo`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user