prestamo output dto
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { CarritoMinOutputDto } from '../../../carrito/dto/output/carrito-min.dto';
|
||||
import { StatusOutputDto } from '../../../status/dto/output/status.dto';
|
||||
import { EquipoTipoEntradaOutputDto } from '../../../equipo-tipo-entrada/dto/output/equipo-tipo-entrada.dto';
|
||||
import { EquipoProgramaOutputDto } from '../../../equipo-programa/dto/output/equipo-programa.dto';
|
||||
|
||||
export class EquipoMinOutputDto {
|
||||
@Expose()
|
||||
equipo;
|
||||
|
||||
@Expose()
|
||||
id_equipo;
|
||||
|
||||
@Expose()
|
||||
numero_inventario;
|
||||
|
||||
@Expose()
|
||||
@Type(() => CarritoMinOutputDto)
|
||||
carrito;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoProgramaOutputDto)
|
||||
programas;
|
||||
|
||||
@Expose()
|
||||
@Type(() => StatusOutputDto)
|
||||
status;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoTipoEntradaOutputDto)
|
||||
tiposEntradas;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { InstitucionMinOutputDto } from '../../../institucion/dto/output/institucion-min.dto';
|
||||
import { TipoUsuarioOutputDto } from '../../../tipo-usuario/dto/output/tipo-usuario.dto';
|
||||
|
||||
export class OperadorMinsOutputDto {
|
||||
@Expose()
|
||||
id_operador;
|
||||
|
||||
@Expose()
|
||||
operador;
|
||||
|
||||
@Expose()
|
||||
@Type(() => InstitucionMinOutputDto)
|
||||
institucion;
|
||||
|
||||
@Expose()
|
||||
@Type(() => TipoUsuarioOutputDto)
|
||||
tipoUsuario;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { EquiposOutputDto } from '../../../equipo/dto/output/equipos.dto';
|
||||
import { UsuariosOutputDto } from '../../../usuario/dto/output/usuarios.dto';
|
||||
|
||||
export class PrestamoActivoOutputDto {
|
||||
@Expose()
|
||||
activo;
|
||||
|
||||
@Expose()
|
||||
cancelado_operador;
|
||||
|
||||
@Expose()
|
||||
cancelado_usuario;
|
||||
|
||||
@Expose()
|
||||
fecha_entrega;
|
||||
|
||||
@Expose()
|
||||
fecha_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_fin;
|
||||
|
||||
@Expose()
|
||||
hora_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_max_recoger;
|
||||
|
||||
@Expose()
|
||||
id_prestamo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquiposOutputDto)
|
||||
equipo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => UsuariosOutputDto)
|
||||
usuario;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { OperadorMinsOutputDto } from '../../../operador/dto/output/operador-min.dto';
|
||||
import { UsuariosOutputDto } from '../../../usuario/dto/output/usuarios.dto';
|
||||
|
||||
export class PrestamoEquipoOutputDto {
|
||||
@Expose()
|
||||
activo;
|
||||
|
||||
@Expose()
|
||||
cancelado_operador;
|
||||
|
||||
@Expose()
|
||||
cancelado_usuario;
|
||||
|
||||
@Expose()
|
||||
fecha_entrega;
|
||||
|
||||
@Expose()
|
||||
fecha_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_fin;
|
||||
|
||||
@Expose()
|
||||
hora_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_max_recoger;
|
||||
|
||||
@Expose()
|
||||
id_prestamo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => OperadorMinsOutputDto)
|
||||
operadorEntrega;
|
||||
|
||||
@Expose()
|
||||
@Type(() => OperadorMinsOutputDto)
|
||||
operadorRegreso;
|
||||
|
||||
@Expose()
|
||||
@Type(() => UsuariosOutputDto)
|
||||
usuario;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { EquipoMinOutputDto } from '../../../equipo/dto/output/equipo-min.dto';
|
||||
|
||||
export class PrestamoUsuarioOutputDto {
|
||||
@Expose()
|
||||
activo;
|
||||
|
||||
@Expose()
|
||||
cancelado_operador;
|
||||
|
||||
@Expose()
|
||||
cancelado_usuario;
|
||||
|
||||
@Expose()
|
||||
fecha_entrega;
|
||||
|
||||
@Expose()
|
||||
fecha_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_fin;
|
||||
|
||||
@Expose()
|
||||
hora_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_max_recoger;
|
||||
|
||||
@Expose()
|
||||
id_prestamo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoMinOutputDto)
|
||||
equipo;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { EquipoMinOutputDto } from '../../../equipo/dto/output/equipo-min.dto';
|
||||
import { OperadorMinsOutputDto } from '../../../operador/dto/output/operador-min.dto';
|
||||
import { UsuariosOutputDto } from '../../../usuario/dto/output/usuarios.dto';
|
||||
|
||||
export class PrestamoOutputDto {
|
||||
@Expose()
|
||||
activo;
|
||||
|
||||
@Expose()
|
||||
cancelado_operador;
|
||||
|
||||
@Expose()
|
||||
cancelado_usuario;
|
||||
|
||||
@Expose()
|
||||
fecha_entrega;
|
||||
|
||||
@Expose()
|
||||
fecha_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_fin;
|
||||
|
||||
@Expose()
|
||||
hora_inicio;
|
||||
|
||||
@Expose()
|
||||
hora_max_recoger;
|
||||
|
||||
@Expose()
|
||||
id_prestamo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => EquipoMinOutputDto)
|
||||
equipo;
|
||||
|
||||
@Expose()
|
||||
@Type(() => OperadorMinsOutputDto)
|
||||
operadorEntrega;
|
||||
|
||||
@Expose()
|
||||
@Type(() => OperadorMinsOutputDto)
|
||||
operadorRegreso;
|
||||
|
||||
@Expose()
|
||||
@Type(() => UsuariosOutputDto)
|
||||
usuario;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ export class Prestamo {
|
||||
@JoinColumn({ name: 'id_operador_regreso' })
|
||||
operadorRegreso: Operador;
|
||||
|
||||
@ManyToOne(() => Usuario, (usuario) => usuario.prestamos)
|
||||
@ManyToOne(() => Usuario, (usuario) => usuario.prestamos, { eager: true })
|
||||
@JoinColumn({ name: 'id_usuario' })
|
||||
usuario: Usuario;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,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 { PedirDto } from './dto/input/pedir.dto';
|
||||
import { ActivosDto } from './dto/input/activos.dto';
|
||||
@@ -11,12 +12,17 @@ import { HistorialEquipoDto } from './dto/input/historial-equipo.dto';
|
||||
import { HistorialUsuarioDto } from './dto/input/historial-usuario.dto';
|
||||
import { UpdateOperadorDto } from './dto/input/update-operador.dto';
|
||||
import { CancelarUsuarioDto } from './dto/input/cancelar-usuario.dto';
|
||||
import { PrestamoOutputDto } from './dto/output/prestamo.dto';
|
||||
import { PrestamoActivoOutputDto } from './dto/output/prestamo-activo.dto';
|
||||
import { PrestamoUsuarioOutputDto } from './dto/output/prestamo-usuario.dto';
|
||||
import { PrestamoEquipoOutputDto } from './dto/output/prestamo-equipo.dto';
|
||||
|
||||
@Controller('prestamo')
|
||||
@ApiTags('prestamo')
|
||||
export class PrestamoController {
|
||||
constructor(private prestamoService: PrestamoService) {}
|
||||
|
||||
@Serealize(PrestamoActivoOutputDto)
|
||||
@Get('activos')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -118,6 +124,7 @@ export class PrestamoController {
|
||||
return this.prestamoService.entregar(body.id_prestamo, body.id_operador);
|
||||
}
|
||||
|
||||
@Serealize(PrestamoOutputDto)
|
||||
@Get('historial')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -192,6 +199,7 @@ export class PrestamoController {
|
||||
return this.prestamoService.findAll(query);
|
||||
}
|
||||
|
||||
@Serealize(PrestamoEquipoOutputDto)
|
||||
@Get('historial-equipo')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -214,6 +222,7 @@ export class PrestamoController {
|
||||
);
|
||||
}
|
||||
|
||||
@Serealize(PrestamoUsuarioOutputDto)
|
||||
@Get('historial-usuario')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -236,6 +245,7 @@ export class PrestamoController {
|
||||
);
|
||||
}
|
||||
|
||||
@Serealize(PrestamoUsuarioOutputDto)
|
||||
@Post()
|
||||
@ApiOperation({ description: 'Endpoint que crea un prestamo nuevo.' })
|
||||
@ApiBody({
|
||||
@@ -263,6 +273,7 @@ export class PrestamoController {
|
||||
);
|
||||
}
|
||||
|
||||
@Serealize(PrestamoOutputDto)
|
||||
@Get('prestamo-id-prestamo')
|
||||
@ApiOperation({ description: 'Endpoint que retorna un préstamo por su id.' })
|
||||
@ApiQuery({ description: '', name: '', type: '' })
|
||||
@@ -270,6 +281,7 @@ export class PrestamoController {
|
||||
return this.prestamoService.findById(parseInt(query.id_prestamo));
|
||||
}
|
||||
|
||||
@Serealize(PrestamoUsuarioOutputDto)
|
||||
@Get('prestamo-id-usuario')
|
||||
@ApiOperation({
|
||||
description:
|
||||
@@ -284,6 +296,7 @@ export class PrestamoController {
|
||||
return this.prestamoService.findByIdUsuario(parseInt(query.id_usuario));
|
||||
}
|
||||
|
||||
@Serealize(PrestamoEquipoOutputDto)
|
||||
@Get('prestamo-numero-inventario')
|
||||
@ApiOperation({
|
||||
description:
|
||||
|
||||
@@ -312,7 +312,7 @@ export class PrestamoService {
|
||||
return this.usuarioService
|
||||
.findById(id_usuario, true, true)
|
||||
.then((usuario) =>
|
||||
this.repository.find({
|
||||
this.repository.findAndCount({
|
||||
where: { usuario },
|
||||
skip: (pagina - 1) * 25,
|
||||
take: 25,
|
||||
@@ -322,7 +322,7 @@ export class PrestamoService {
|
||||
|
||||
async findAllByIdEquipo(id_equipo: number, pagina: number) {
|
||||
return this.equipoService.findById(id_equipo).then((equipo) =>
|
||||
this.repository.find({
|
||||
this.repository.findAndCount({
|
||||
where: { equipo },
|
||||
skip: (pagina - 1) * 25,
|
||||
take: 25,
|
||||
|
||||
Reference in New Issue
Block a user