modulo institución día final
This commit is contained in:
@@ -3,6 +3,9 @@ import { DiaOutputDto } from './dia.dto';
|
||||
import { InstitucionMinOutputDto } from '../../../institucion/dto/output/institucion-min.dto';
|
||||
|
||||
export class InstitucionCarreaOutputDto {
|
||||
@Expose()
|
||||
id_institucion_dia;
|
||||
|
||||
@Expose()
|
||||
activo;
|
||||
|
||||
@@ -12,9 +15,6 @@ export class InstitucionCarreaOutputDto {
|
||||
@Expose()
|
||||
hora_inicio;
|
||||
|
||||
@Expose()
|
||||
id_institucion_dia;
|
||||
|
||||
@Expose()
|
||||
@Type(() => DiaOutputDto)
|
||||
dia;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
|
||||
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { InstitucionDia } from './institucion-dia.entity';
|
||||
|
||||
@Entity()
|
||||
|
||||
@@ -21,7 +21,7 @@ export class InstitucionDia {
|
||||
@Column({ type: String, nullable: false, default: '17:45', length: 5 })
|
||||
hora_fin: string;
|
||||
|
||||
@Column({ type: String, nullable: false, default: '09:00', length: 5 })
|
||||
@Column({ type: String, nullable: false, default: '08:50', length: 5 })
|
||||
hora_inicio: string;
|
||||
|
||||
@ManyToOne(() => Dia, (dia) => dia.institucionesDias, { eager: true })
|
||||
|
||||
@@ -12,7 +12,7 @@ export class InstitucionDiaController {
|
||||
constructor(private institucionDiaService: InstitucionDiaService) {}
|
||||
|
||||
@Serealize(InstitucionCarreaOutputDto)
|
||||
@Get('dias')
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que retorna todos los días de una institución.',
|
||||
})
|
||||
@@ -29,7 +29,8 @@ export class InstitucionDiaController {
|
||||
|
||||
@Put()
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que actualiza la información de un día.',
|
||||
description:
|
||||
'Endpoint que actualiza la información de un día de una institución.',
|
||||
})
|
||||
@ApiBody({
|
||||
description:
|
||||
@@ -38,9 +39,9 @@ export class InstitucionDiaController {
|
||||
ejemplo: {
|
||||
value: {
|
||||
id_institucion_dia: 217,
|
||||
activo: true,
|
||||
hora_inicio: '09:00',
|
||||
hora_fin: '17:45',
|
||||
_activo: true,
|
||||
_hora_fin: '17:45',
|
||||
_hora_inicio: '09:00',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { InstitucionDiaController } from './institucion-dia.controller';
|
||||
import { InstitucionDiaService } from './institucion-dia.service';
|
||||
import { InstitucionDia } from './entity/institucion-dia.entity';
|
||||
import { Dia } from './entity/dia.entity';
|
||||
import { InstitucionDia } from './entity/institucion-dia.entity';
|
||||
import { InstitucionModule } from '../institucion/institucion.module';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Dia, InstitucionDia]), InstitucionModule],
|
||||
imports: [InstitucionModule, TypeOrmModule.forFeature([Dia, InstitucionDia])],
|
||||
controllers: [InstitucionDiaController],
|
||||
providers: [InstitucionDiaService],
|
||||
exports: [InstitucionDiaService]
|
||||
exports: [InstitucionDiaService],
|
||||
})
|
||||
export class InstitucionDiaModule {}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { InstitucionDia } from './entity/institucion-dia.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { InstitucionDia } from './entity/institucion-dia.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
@Injectable()
|
||||
export class InstitucionDiaService {
|
||||
@@ -22,7 +22,8 @@ export class InstitucionDiaService {
|
||||
return this.repository
|
||||
.findOne({ id_institucion_dia })
|
||||
.then((institucionDia) => {
|
||||
if (!institucionDia) throw new Error('No existe esta institucion dia.');
|
||||
if (!institucionDia)
|
||||
throw new Error('No existe este id día institución.');
|
||||
return institucionDia;
|
||||
});
|
||||
}
|
||||
@@ -38,7 +39,7 @@ export class InstitucionDiaService {
|
||||
return this.repository.save(institucionDia);
|
||||
})
|
||||
.then((_) => ({
|
||||
message: 'Se actualizó correctamente la institución infracción.',
|
||||
message: 'Se guardaron los cambios correctamente.',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {
|
||||
IsBoolean,
|
||||
IsInt,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsInt,
|
||||
IsBoolean,
|
||||
IsString,
|
||||
} from 'class-validator';
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Expose } from 'class-transformer';
|
||||
|
||||
export class InstitucionOutputDto {
|
||||
@Expose()
|
||||
id_institucion;
|
||||
|
||||
@Expose()
|
||||
activo;
|
||||
|
||||
@@ -16,9 +19,6 @@ export class InstitucionOutputDto {
|
||||
@Expose()
|
||||
email_institucional;
|
||||
|
||||
@Expose()
|
||||
id_institucion;
|
||||
|
||||
@Expose()
|
||||
institucion;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ export class InstitucionService {
|
||||
return this.repository.save(institucion);
|
||||
})
|
||||
.then((_) => ({
|
||||
message: 'Se guardaron los cambios correctamente .',
|
||||
message: 'Se guardaron los cambios correctamente.',
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user