revisar update y falta delete
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import { IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class ProgramaDto {
|
||||
@IsString()
|
||||
id_programa: string;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Body, Controller, Get, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { ProgramaCreateDto } from './dto/programa-create.dto';
|
||||
import { ProgramaDto } from './dto/programa.dto'
|
||||
|
||||
@Controller('programa')
|
||||
export class ProgramaController {
|
||||
@@ -15,4 +16,9 @@ export class ProgramaController {
|
||||
get() {
|
||||
return this.programaService.findAll();
|
||||
}
|
||||
|
||||
@Get('programa')
|
||||
programa(@Query() query: ProgramaDto) {
|
||||
return this.programaService.findById(Number(query.id_programa))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ConflictException, Injectable } from '@nestjs/common';
|
||||
import { ConflictException, Injectable, NotFoundException } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Programa } from './entity/programa.entity';
|
||||
@@ -23,4 +23,11 @@ export class ProgramaService {
|
||||
findAll() {
|
||||
return this.repository.find();
|
||||
}
|
||||
|
||||
findById(id_programa: number) {
|
||||
return this.repository.findOne({ id_programa }).then((programa) => {
|
||||
if(!programa) throw new NotFoundException('No existe este programa')
|
||||
return programa
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user