mejora de código
This commit is contained in:
@@ -31,7 +31,7 @@ export class InstitucionUsuarioService {
|
||||
});
|
||||
}
|
||||
|
||||
findByUsuarioIdInstitucionCarrera(
|
||||
findByUsuarioInstitucionCarrera(
|
||||
usuario: Usuario,
|
||||
institucionCarrera: InstitucionCarrera,
|
||||
campo: string,
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { Expose, Type } from 'class-transformer';
|
||||
import { EquiposOutputDto } from '../../../equipo/dto/output/equipos.dto';
|
||||
import { UsuariosOutputDto } from '../../../usuario/dto/output/usuarios.dto';
|
||||
|
||||
export class PrestamosActivosOutputDto {
|
||||
export class ActivosOutputDto {
|
||||
@Expose()
|
||||
id_prestamo;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { EquipoMinOutputDto } from '../../../equipo/dto/output/equipo-min.dto';
|
||||
|
||||
export class EntregaOutputDto {
|
||||
@Expose()
|
||||
message;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoMinOutputDto)
|
||||
equipo;
|
||||
}
|
||||
@@ -2,7 +2,6 @@ import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiBody, ApiOperation, ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { Serealize } from '../interceptors/serialize.interceptor';
|
||||
import { PrestamoService } from './prestamo.service';
|
||||
|
||||
import { IdEquipoPaginaDto } from '../dto/id-equipo-pagina.dto';
|
||||
import { IdUsuarioDto } from '../dto/id-usuario.dto';
|
||||
import { IdUsuarioPaginaDto } from '../dto/id-usuario-pagina.dto';
|
||||
@@ -16,10 +15,11 @@ import { PedirDto } from './dto/input/pedir.dto';
|
||||
import { EntregarDto } from './dto/input/entregar.dto';
|
||||
import { RegresarIdPrestamoDto } from './dto/input/regresar-id-prestamo.dto';
|
||||
import { RegresarNumeroInventarioDto } from './dto/input/regresar-numero-inventario.dto';
|
||||
import { ActivosOutputDto } from './dto/output/activos.dto';
|
||||
import { EntregaOutputDto } from './dto/output/entrega.dto';
|
||||
import { PrestamoOutputDto } from './dto/output/prestamo.dto';
|
||||
import { PrestamoEquipoOutputDto } from './dto/output/prestamo-equipo.dto';
|
||||
import { PrestamosOutputDto } from './dto/output/prestamos.dto';
|
||||
import { PrestamosActivosOutputDto } from './dto/output/prestamos-activos.dto';
|
||||
import { PrestamosEquipoOutputDto } from './dto/output/prestamos-equipo.dto';
|
||||
import { PrestamosUsuarioOutputDto } from './dto/output/prestamos-usuario.dto';
|
||||
|
||||
@@ -28,7 +28,7 @@ import { PrestamosUsuarioOutputDto } from './dto/output/prestamos-usuario.dto';
|
||||
export class PrestamoController {
|
||||
constructor(private prestamoService: PrestamoService) {}
|
||||
|
||||
@Serealize(PrestamosActivosOutputDto)
|
||||
@Serealize(ActivosOutputDto)
|
||||
@Get('activos')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -121,6 +121,7 @@ export class PrestamoController {
|
||||
return this.prestamoService.cancelarUsuario(body.id_prestamo);
|
||||
}
|
||||
|
||||
@Serealize(EntregaOutputDto)
|
||||
@Put('entregar')
|
||||
@ApiOperation({
|
||||
description: 'Endpoint que actualiza el status del equipo a "En uso".',
|
||||
@@ -254,7 +255,7 @@ export class PrestamoController {
|
||||
);
|
||||
}
|
||||
|
||||
@Serealize(PrestamosUsuarioOutputDto)
|
||||
@Serealize(PrestamoOutputDto)
|
||||
@Post()
|
||||
@ApiOperation({ description: 'Endpoint que crea un prestamo nuevo.' })
|
||||
@ApiBody({
|
||||
|
||||
@@ -102,7 +102,7 @@ export class PrestamoService {
|
||||
id_programa?: number,
|
||||
id_tipo_entrada?: number,
|
||||
) {
|
||||
const ahora = moment().add(1, 'd');
|
||||
const ahora = moment();
|
||||
const sistema = await this.operadorService.findById(1);
|
||||
const modulo = await this.moduloService.findById(id_modulo);
|
||||
const usuario = await this.usuarioService.findById(id_usuario, true, true);
|
||||
|
||||
@@ -83,7 +83,7 @@ export class UsuarioService {
|
||||
throw new ConflictException(
|
||||
'No se puede registar con este número de cuenta por que se encuentra desactivado.',
|
||||
);
|
||||
return this.institucionUsuarioService.findByUsuarioIdInstitucionCarrera(
|
||||
return this.institucionUsuarioService.findByUsuarioInstitucionCarrera(
|
||||
existeUsuario,
|
||||
institucionCarrera,
|
||||
'cuenta',
|
||||
@@ -108,7 +108,7 @@ export class UsuarioService {
|
||||
throw new ConflictException(
|
||||
'No se puede registar con este número de trabajador por que se encuentra desactivado.',
|
||||
);
|
||||
return this.institucionUsuarioService.findByUsuarioIdInstitucionCarrera(
|
||||
return this.institucionUsuarioService.findByUsuarioInstitucionCarrera(
|
||||
existeUsuario,
|
||||
institucionCarrera,
|
||||
'trabajador',
|
||||
|
||||
Reference in New Issue
Block a user