institucion listo
This commit is contained in:
parent
73db06d773
commit
5fa2e4cf21
@ -1,12 +1,12 @@
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsMilitaryTime,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
} from 'class-validator';
|
||||
|
||||
export class InstitucionDiaUpdateDto {
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_institucion_dia: number;
|
||||
|
||||
@IsBoolean()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { IsNumber } from 'class-validator';
|
||||
import { IsInt, IsNumber } from 'class-validator';
|
||||
|
||||
export class InstitucionInfraccionUpdateDto {
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_institucion_infraccion: number;
|
||||
|
||||
@IsNumber()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { IsBoolean, IsNumber } from 'class-validator';
|
||||
import { IsBoolean, IsInt, IsNumber } from 'class-validator';
|
||||
|
||||
export class InstitucionTipoCarritoUpdateDto {
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_institucion_tipo_carrito: number;
|
||||
|
||||
@IsBoolean()
|
||||
|
18
src/institucion/dto/institucion-update.dto.ts
Normal file
18
src/institucion/dto/institucion-update.dto.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { IsNumber, IsOptional, IsInt } from 'class-validator';
|
||||
|
||||
export class InstitucionUpdateDto {
|
||||
@IsInt()
|
||||
id_institucion: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
tiempo_prestamo: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
tiempo_recoger: number;
|
||||
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
dias_multa_retraso: number;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import { Controller, Get, Put } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Put, Query } from '@nestjs/common';
|
||||
import { InstitucionService } from './institucion.service';
|
||||
import { IdInstitucionDto } from '../dto/id-institucion.dto';
|
||||
import { InstitucionUpdateDto } from './dto/institucion-update.dto';
|
||||
|
||||
@Controller('institucion')
|
||||
export class InstitucionController {
|
||||
@ -10,6 +12,13 @@ export class InstitucionController {
|
||||
return this.institucionService.findAll();
|
||||
}
|
||||
|
||||
@Get('institucion')
|
||||
institucion(@Query() query: IdInstitucionDto) {
|
||||
return this.institucionService.findById(Number(query.id_institucion));
|
||||
}
|
||||
|
||||
@Put()
|
||||
update() {}
|
||||
update(@Body() body: InstitucionUpdateDto) {
|
||||
return this.institucionService.update(body);
|
||||
}
|
||||
}
|
||||
|
@ -20,4 +20,15 @@ export class InstitucionService {
|
||||
return institucion;
|
||||
});
|
||||
}
|
||||
|
||||
update(attrs: Partial<Institucion>) {
|
||||
return this.findById(attrs.id_institucion)
|
||||
.then((institucion) => {
|
||||
Object.assign(institucion, attrs);
|
||||
return this.repository.save(institucion);
|
||||
})
|
||||
.then((_) => ({
|
||||
message: 'Se actualió correctamente la institucion.',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { IsNumber, IsString } from 'class-validator';
|
||||
import { IsInt, IsString } from 'class-validator';
|
||||
|
||||
export class ModuloCreateDto {
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_institucion: number;
|
||||
|
||||
@IsString()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { IsBoolean, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||
import { IsBoolean, IsInt, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
export class ModuloUpdateDto {
|
||||
@IsNumber()
|
||||
@IsInt()
|
||||
id_modulo: number;
|
||||
|
||||
@IsString()
|
||||
|
Loading…
Reference in New Issue
Block a user