added new Ep
This commit is contained in:
@@ -1,24 +1,25 @@
|
||||
import { Equipo } from "src/equipo/entities/equipo.entity";
|
||||
import { Programa } from "src/programa/entities/programa.entity";
|
||||
import { Entity, PrimaryColumn, ManyToOne, JoinColumn } from "typeorm";
|
||||
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")
|
||||
@Entity('programa_equipo')
|
||||
export class ProgramaEquipo {
|
||||
@PrimaryColumn({ name: "id_programa", type: "int" })
|
||||
@PrimaryColumn({ name: 'id_programa', type: 'int' })
|
||||
id_programa: number;
|
||||
|
||||
@PrimaryColumn({ name: "id_equipo", type: "int" })
|
||||
@PrimaryColumn({ name: 'id_equipo', type: 'int' })
|
||||
id_equipo: number;
|
||||
|
||||
@ManyToOne(() => Programa, (programa) => programa.programaEquipos, {
|
||||
onUpdate: "CASCADE",
|
||||
eager: true,
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: "id_programa" })
|
||||
@JoinColumn({ name: 'id_programa' })
|
||||
programa: Programa;
|
||||
|
||||
@ManyToOne(() => Equipo, (equipo) => equipo.programaEquipos, {
|
||||
onUpdate: "CASCADE",
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: "id_equipo" })
|
||||
@JoinColumn({ name: 'id_equipo' })
|
||||
equipo: Equipo;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { Controller, Get, Body, Patch, Param } 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('programas/:id')
|
||||
findAllProgramByNumber(@Param('id') id: number) {
|
||||
return this.programaEquipoService.findAllProgramByNumber(+id);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@@ -18,7 +17,10 @@ export class ProgramaEquipoController {
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateProgramaEquipoDto: UpdateProgramaEquipoDto) {
|
||||
update(
|
||||
@Param('id') id: string,
|
||||
@Body() updateProgramaEquipoDto: UpdateProgramaEquipoDto,
|
||||
) {
|
||||
return this.programaEquipoService.update(+id, updateProgramaEquipoDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ export class ProgramaEquipoService {
|
||||
private readonly ProgramaEquipoRepository: Repository<ProgramaEquipo>,
|
||||
) {}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all programaEquipo`;
|
||||
findAllProgramByNumber(id_equipo: number) {
|
||||
return this.ProgramaEquipoRepository.find({ where: { id_equipo } });
|
||||
}
|
||||
|
||||
async findOne(id_equipo: number) {
|
||||
@@ -24,7 +24,7 @@ export class ProgramaEquipoService {
|
||||
if (equipo.length === 0) {
|
||||
throw new NotFoundException(`machine without programs`);
|
||||
}
|
||||
|
||||
|
||||
return equipo;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user