From cbd0c4fe3cd3d94d620c29762e1dc98455e0c789 Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Sun, 17 Apr 2022 22:51:49 -0500 Subject: [PATCH] listo prestamo --- src/app.module.ts | 2 +- src/equipo/entity/equipo.entity.ts | 2 +- src/multa/entity/multa.entity.ts | 2 +- src/operador/entity/operador.entity.ts | 2 +- src/prestamo/{ => entity}/prestamo.entity.ts | 58 ++++++++++---------- src/prestamo/prestamo.controller.ts | 41 +++++++++++++- src/prestamo/prestamo.module.ts | 2 +- src/prestamo/prestamo.service.ts | 4 +- src/usuario/usuario.entity.ts | 2 +- 9 files changed, 77 insertions(+), 38 deletions(-) rename src/prestamo/{ => entity}/prestamo.entity.ts (62%) diff --git a/src/app.module.ts b/src/app.module.ts index f60e085..5775580 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -42,7 +42,7 @@ import { Modulo } from './modulo/entity/modulo.entity'; import { Motivo } from './motivo/entity/motivo.entity'; import { Multa } from './multa/entity/multa.entity'; import { Operador } from './operador/entity/operador.entity'; -import { Prestamo } from './prestamo/prestamo.entity'; +import { Prestamo } from './prestamo/entity/prestamo.entity'; import { Programa } from './programa/programa.entity'; import { Status } from './status/status.entity'; import { TipoCarrito } from './tipo-carrito/tipo-carrito.entity'; diff --git a/src/equipo/entity/equipo.entity.ts b/src/equipo/entity/equipo.entity.ts index e94a0f2..774abd8 100644 --- a/src/equipo/entity/equipo.entity.ts +++ b/src/equipo/entity/equipo.entity.ts @@ -9,7 +9,7 @@ import { import { Carrito } from '../../carrito/entity/carrito.entity'; import { EquipoTipoEntrada } from '../../equipo-tipo-entrada/entity/equipo-tipo-entrada.entity'; import { Motivo } from '../../motivo/entity/motivo.entity'; -import { Prestamo } from '../../prestamo/prestamo.entity'; +import { Prestamo } from '../../prestamo/entity/prestamo.entity'; import { Programa } from '../../programa/programa.entity'; import { Status } from '../../status/status.entity'; diff --git a/src/multa/entity/multa.entity.ts b/src/multa/entity/multa.entity.ts index 9769756..429334e 100644 --- a/src/multa/entity/multa.entity.ts +++ b/src/multa/entity/multa.entity.ts @@ -7,7 +7,7 @@ import { PrimaryGeneratedColumn, } from 'typeorm'; import { InstitucionInfraccion } from '../../institucion-infraccion/entity/institucion-infraccion.entity'; -import { Prestamo } from '../../prestamo/prestamo.entity'; +import { Prestamo } from '../../prestamo/entity/prestamo.entity'; @Entity() export class Multa { diff --git a/src/operador/entity/operador.entity.ts b/src/operador/entity/operador.entity.ts index 82860fb..85eb6f3 100644 --- a/src/operador/entity/operador.entity.ts +++ b/src/operador/entity/operador.entity.ts @@ -8,7 +8,7 @@ import { } from 'typeorm'; import { Institucion } from '../../institucion/entity/institucion.entity'; import { Motivo } from '../../motivo/entity/motivo.entity'; -import { Prestamo } from '../../prestamo/prestamo.entity'; +import { Prestamo } from '../../prestamo/entity/prestamo.entity'; import { TipoUsuario } from '../../tipo-usuario/tipo-usuario.entity'; @Entity() diff --git a/src/prestamo/prestamo.entity.ts b/src/prestamo/entity/prestamo.entity.ts similarity index 62% rename from src/prestamo/prestamo.entity.ts rename to src/prestamo/entity/prestamo.entity.ts index d986350..148a9fd 100644 --- a/src/prestamo/prestamo.entity.ts +++ b/src/prestamo/entity/prestamo.entity.ts @@ -1,46 +1,42 @@ import { - Entity, Column, - PrimaryGeneratedColumn, - ManyToOne, + Entity, JoinColumn, + ManyToOne, + PrimaryGeneratedColumn, } from 'typeorm'; -import { Equipo } from '../equipo/entity/equipo.entity'; -import { Operador } from '../operador/entity/operador.entity'; -import { Usuario } from '../usuario/usuario.entity'; +import { Equipo } from '../../equipo/entity/equipo.entity'; +import { Operador } from '../../operador/entity/operador.entity'; +import { Usuario } from '../../usuario/usuario.entity'; @Entity() export class Prestamo { @PrimaryGeneratedColumn() id_prestamo: number; - @Column() + @Column({ type: Boolean, nullable: false, default: true }) activo: boolean; - @Column() - fecha_inicio: Date; - - @Column() - hora_max_recoger: Date; - - @Column() - hora_inicio: Date; - - @Column() - hora_fin: Date; - - @Column() - fecha_entrega: Date; - - @Column() - cancelado_usuario: boolean; - - @Column() + @Column({ type: Boolean, nullable: false, default: false }) cancelado_operador: boolean; - @ManyToOne(() => Usuario, (usuario) => usuario.prestamos) - @JoinColumn({ name: 'id_usuario' }) - usuario: Usuario; + @Column({ type: Boolean, nullable: false, default: false }) + cancelado_usuario: boolean; + + @Column({ type: Date, nullable: false }) + fecha_entrega: Date; + + @Column({ type: Date, nullable: false }) + fecha_inicio: Date; + + @Column({ type: Date, nullable: false }) + hora_fin: Date; + + @Column({ type: Date, nullable: false }) + hora_inicio: Date; + + @Column({ type: Date, nullable: false }) + hora_max_recoger: Date; @ManyToOne(() => Equipo, (equipo) => equipo.prestamos) @JoinColumn({ name: 'id_equipo' }) @@ -59,4 +55,8 @@ export class Prestamo { ) @JoinColumn({ name: 'id_operador_regreso' }) operadorRegreso: Operador; + + @ManyToOne(() => Usuario, (usuario) => usuario.prestamos) + @JoinColumn({ name: 'id_usuario' }) + usuario: Usuario; } diff --git a/src/prestamo/prestamo.controller.ts b/src/prestamo/prestamo.controller.ts index be06f4a..0abcfb2 100644 --- a/src/prestamo/prestamo.controller.ts +++ b/src/prestamo/prestamo.controller.ts @@ -1,7 +1,46 @@ -import { Controller } from '@nestjs/common'; +import { Controller, Get, Post, Put } from '@nestjs/common'; import { PrestamoService } from './prestamo.service'; @Controller('prestamo') export class PrestamoController { constructor(private prestamoService: PrestamoService) {} + + @Get('activos') + activos() {} + + @Put('cancelar_operador') + cancelarOperador() {} + + @Put('cancelar_usuario') + cancelarUsuario() {} + + @Put('entregar') + entregar() {} + + @Get('historial') + historial() {} + + @Get('historial_equipo') + historialEquipo() {} + + @Get('historial_usuario') + historialUsuario() {} + + @Post() + pedir() {} + + @Get('prestamo_id_prestamo') + prestamoIdPrestamo() {} + + @Get('prestamo_id_usuario') + prestamoIdUsuario() {} + + @Get('prestamo_numero_inventario') + prestamoNumeroInventario() {} + + @Put('regresar') + regresar() {} + + @Get('reporte') + reporte() {} } diff --git a/src/prestamo/prestamo.module.ts b/src/prestamo/prestamo.module.ts index 3062e0e..84478c7 100644 --- a/src/prestamo/prestamo.module.ts +++ b/src/prestamo/prestamo.module.ts @@ -1,8 +1,8 @@ import { Module } from '@nestjs/common'; import { TypeOrmModule } from '@nestjs/typeorm'; import { PrestamoController } from './prestamo.controller'; -import { Prestamo } from './prestamo.entity'; import { PrestamoService } from './prestamo.service'; +import { Prestamo } from './entity/prestamo.entity'; @Module({ imports: [TypeOrmModule.forFeature([Prestamo])], diff --git a/src/prestamo/prestamo.service.ts b/src/prestamo/prestamo.service.ts index 06588db..594a749 100644 --- a/src/prestamo/prestamo.service.ts +++ b/src/prestamo/prestamo.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@nestjs/common'; -import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; -import { Prestamo } from './prestamo.entity'; +import { Repository } from 'typeorm'; +import { Prestamo } from './entity/prestamo.entity'; @Injectable() export class PrestamoService { diff --git a/src/usuario/usuario.entity.ts b/src/usuario/usuario.entity.ts index 519f265..3cfb21c 100644 --- a/src/usuario/usuario.entity.ts +++ b/src/usuario/usuario.entity.ts @@ -8,7 +8,7 @@ import { } from 'typeorm'; import { Carrera } from '../carrera/entity/carrera.entity'; import { Institucion } from '../institucion/entity/institucion.entity'; -import { Prestamo } from '../prestamo/prestamo.entity'; +import { Prestamo } from '../prestamo/entity/prestamo.entity'; import { TipoUsuario } from '../tipo-usuario/tipo-usuario.entity'; @Entity()