carrera
This commit is contained in:
@@ -6,14 +6,13 @@ import { CarritoGetDto } from './dto/carrera-get-dto';
|
||||
export class CarreraController {
|
||||
constructor(private carreraService: CarreraService) {}
|
||||
|
||||
@Get()
|
||||
get() {
|
||||
// recibir id_institucion y traer todoas las carreras de esa institiucion
|
||||
return this.carreraService.findAll();
|
||||
}
|
||||
|
||||
@Get('carreras')
|
||||
carreras(@Query() query: CarritoGetDto) {
|
||||
return this.carreraService.findAllByIdInstitucion(Number(query.id_institucion));
|
||||
}
|
||||
|
||||
@Get('carrera')
|
||||
carrera(@Query() query: CarritoGetDto) {
|
||||
return this.carreraService.findById(Number(query.id_carrera));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,15 +2,20 @@ import { Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Carrera } from './entity/carrera.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { Institucion } from 'src/institucion/entity/institucion.entity';
|
||||
|
||||
@Injectable()
|
||||
export class CarreraService {
|
||||
constructor(
|
||||
@InjectRepository(Carrera) private repository: Repository<Carrera>,
|
||||
) {}
|
||||
private institucionService: InstitucionService,
|
||||
) { }
|
||||
|
||||
findAll() {
|
||||
return this.repository.find();
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findById(id_institucion)
|
||||
.then((institucion) => this.repository.find({institucion}))
|
||||
}
|
||||
|
||||
findById(id_carrera: number) {
|
||||
|
||||
@@ -4,4 +4,7 @@ export class CarritoGetDto {
|
||||
// Cambiar IsString por IsNumberString
|
||||
@IsString()
|
||||
id_carrera: string;
|
||||
|
||||
@IsString()
|
||||
id_institucion: String;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user