update librerias

This commit is contained in:
lemuel 2022-08-23 17:12:09 -05:00
parent 7f7dfbe9c1
commit 2a031a7658
25 changed files with 2775 additions and 3297 deletions

5684
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,59 +21,55 @@
"test:e2e": "jest --config ./test/jest-e2e.json" "test:e2e": "jest --config ./test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@nestjs/common": "^8.0.0", "@nestjs/config": "^2.2.0",
"@nestjs/config": "^2.0.0", "@nestjs/jwt": "^9.0.0",
"@nestjs/core": "^8.0.0", "@nestjs/passport": "^9.0.0",
"@nestjs/jwt": "^8.0.0", "@nestjs/platform-express": "^9.0.11",
"@nestjs/passport": "^8.2.1", "@nestjs/platform-socket.io": "^9.0.11",
"@nestjs/platform-express": "^8.0.0", "@nestjs/schedule": "^2.1.0",
"@nestjs/platform-socket.io": "^8.4.4", "@nestjs/swagger": "^6.0.5",
"@nestjs/schedule": "^1.1.0", "@nestjs/typeorm": "^9.0.1",
"@nestjs/swagger": "^5.2.1", "@nestjs/websockets": "^9.0.11",
"@nestjs/typeorm": "^8.0.3", "@nestlab/google-recaptcha": "^3.1.2",
"@nestjs/websockets": "^8.4.4",
"@nestlab/google-recaptcha": "^3.0.3",
"bcrypt": "^5.0.1", "bcrypt": "^5.0.1",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.13.2", "class-validator": "^0.13.2",
"csvtojson": "^2.0.10", "csvtojson": "^2.0.10",
"md5": "^2.3.0", "moment": "^2.29.4",
"moment": "^2.29.3",
"mysql2": "^2.3.3", "mysql2": "^2.3.3",
"nodemailer": "^6.7.3", "nodemailer": "^6.7.8",
"passport": "^0.5.2", "passport": "^0.6.0",
"passport-jwt": "^4.0.0", "passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.2.0", "rxjs": "^7.5.6",
"sha1": "^1.1.1", "swagger-ui-express": "^4.5.0",
"swagger-ui-express": "^4.3.0", "typeorm": "^0.3.7"
"typeorm": "^0.2.45"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^8.0.0", "@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^8.0.0", "@nestjs/schematics": "^9.0.1",
"@nestjs/testing": "^8.0.0", "@nestjs/testing": "^9.0.11",
"@types/bcrypt": "^5.0.0", "@types/bcrypt": "^5.0.0",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/jest": "27.4.1", "@types/jest": "28.1.7",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "^16.0.0", "@types/node": "^18.7.11",
"@types/supertest": "^2.0.11", "@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.0.0", "@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.0.0", "@typescript-eslint/parser": "^5.34.0",
"eslint": "^8.0.1", "eslint": "^8.22.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.2.1",
"jest": "^27.2.5", "jest": "^28.1.3",
"prettier": "^2.3.2", "prettier": "^2.7.1",
"source-map-support": "^0.5.20", "source-map-support": "^0.5.21",
"supertest": "^6.1.3", "supertest": "^6.2.4",
"ts-jest": "^27.0.3", "ts-jest": "^28.0.8",
"ts-loader": "^9.2.3", "ts-loader": "^9.3.1",
"ts-node": "^10.0.0", "ts-node": "^10.9.1",
"tsconfig-paths": "^3.10.1", "tsconfig-paths": "^4.1.0",
"typescript": "^4.3.5" "typescript": "^4.7.4"
}, },
"jest": { "jest": {
"moduleFileExtensions": [ "moduleFileExtensions": [

View File

@ -43,7 +43,7 @@ export class CarreraProgramaService {
'Esta carrera no pertenece a tu institución.', 'Esta carrera no pertenece a tu institución.',
); );
return this.repository return this.repository
.findOne({ institucionCarrera, programa }) .findOne({ where: { institucionCarrera, programa } })
.then((existeCarretaPrograma) => { .then((existeCarretaPrograma) => {
if (existeCarretaPrograma) if (existeCarretaPrograma)
throw new ConflictException( throw new ConflictException(
@ -80,7 +80,7 @@ export class CarreraProgramaService {
findById(id_carrera_programa: number) { findById(id_carrera_programa: number) {
return this.repository return this.repository
.findOne({ id_carrera_programa }) .findOne({ where: { id_carrera_programa } })
.then((carreraPrograma) => { .then((carreraPrograma) => {
if (!carreraPrograma) if (!carreraPrograma)
throw new NotFoundException('No existe este id carrera programa.'); throw new NotFoundException('No existe este id carrera programa.');

View File

@ -52,7 +52,7 @@ export class CarritoService {
'No puedes crear un carrito para este módulo porque no pertenece a tu institución.', 'No puedes crear un carrito para este módulo porque no pertenece a tu institución.',
); );
return this.repository return this.repository
.count({ modulo, tipoCarrito }) .count({ where: { modulo, tipoCarrito } })
.then((carritos) => .then((carritos) =>
this.repository.save( this.repository.save(
this.repository.create({ this.repository.create({
@ -151,7 +151,9 @@ export class CarritoService {
} }
findById(id_carrito: number) { findById(id_carrito: number) {
return this.repository.findOne({ id_carrito }).then((carrito) => { return this.repository
.findOne({ where: { id_carrito } })
.then((carrito) => {
if (!carrito) throw new NotFoundException('No existe este id carrito.'); if (!carrito) throw new NotFoundException('No existe este id carrito.');
return carrito; return carrito;
}); });
@ -175,7 +177,7 @@ export class CarritoService {
: id_tipo_carrito; : id_tipo_carrito;
return this.repository return this.repository
.findOne({ carrito, modulo, tipoCarrito }) .findOne({ where: { carrito, modulo, tipoCarrito } })
.then((carrito) => { .then((carrito) => {
if (validarNoExiste && !carrito) if (validarNoExiste && !carrito)
throw new ConflictException('No existe este carrito.'); throw new ConflictException('No existe este carrito.');

View File

@ -69,7 +69,7 @@ export class EquipoProgramaService {
'No puedes eliminar el software de este equipo porque no pertenece a tu institución.', 'No puedes eliminar el software de este equipo porque no pertenece a tu institución.',
); );
return this.repository return this.repository
.count({ equipo: equipoPrograma.equipo }) .count({ where: { equipo: equipoPrograma.equipo } })
.then(async (n) => { .then(async (n) => {
if (n === 1) { if (n === 1) {
if (equipoPrograma.programa.id_programa === 1) if (equipoPrograma.programa.id_programa === 1)
@ -111,7 +111,7 @@ export class EquipoProgramaService {
validarExistencia = true, validarExistencia = true,
) { ) {
return this.repository return this.repository
.findOne({ equipo, programa }) .findOne({ where: { equipo, programa } })
.then((equipoPrograma) => { .then((equipoPrograma) => {
if (validarExistencia && equipoPrograma) if (validarExistencia && equipoPrograma)
throw new ConflictException( throw new ConflictException(

View File

@ -51,7 +51,7 @@ export class EquipoTipoEntradaService {
findById(id_equipo_tipo_entrada: number) { findById(id_equipo_tipo_entrada: number) {
return this.repository return this.repository
.findOne({ id_equipo_tipo_entrada }) .findOne({ where: { id_equipo_tipo_entrada } })
.then((equipoTipoEntrada) => { .then((equipoTipoEntrada) => {
if (!equipoTipoEntrada) if (!equipoTipoEntrada)
throw new ConflictException('No existe este id equipo tipo entrada.'); throw new ConflictException('No existe este id equipo tipo entrada.');
@ -65,7 +65,7 @@ export class EquipoTipoEntradaService {
validarExistencia = true, validarExistencia = true,
) { ) {
return this.repository return this.repository
.findOne({ equipo, tipoEntrada }) .findOne({ where: { equipo, tipoEntrada } })
.then((equipoTipoEntrada) => { .then((equipoTipoEntrada) => {
if (validarExistencia && equipoTipoEntrada) if (validarExistencia && equipoTipoEntrada)
throw new ConflictException( throw new ConflictException(

View File

@ -0,0 +1,22 @@
// import { ViewEntity, ViewColumn, DataSource } from 'typeorm';
// @ViewEntity({
// expression: (dataSource: DataSource) =>
// dataSource
// .createQueryBuilder()
// .select('post.id', 'id')
// .addSelect('post.name', 'name')
// .addSelect('category.name', 'categoryName')
// .from(Post, 'post')
// .leftJoin(Category, 'category', 'category.id = post.categoryId'),
// })
// export class PostCategory {
// @ViewColumn()
// id: number;
// @ViewColumn()
// name: string;
// @ViewColumn()
// categoryName: string;
// }

View File

@ -213,7 +213,7 @@ export class EquipoService {
} }
findById(id_equipo: number) { findById(id_equipo: number) {
return this.repository.findOne({ id_equipo }).then((equipo) => { return this.repository.findOne({ where: { id_equipo } }).then((equipo) => {
if (!equipo) throw new NotFoundException('No existe este id equipo.'); if (!equipo) throw new NotFoundException('No existe este id equipo.');
return equipo; return equipo;
}); });
@ -348,7 +348,9 @@ export class EquipoService {
? await this.carritoService.findById(id_carrito) ? await this.carritoService.findById(id_carrito)
: id_carrito; : id_carrito;
return this.repository.findOne({ carrito, equipo }).then((equipo) => { return this.repository
.findOne({ where: { carrito, equipo } })
.then((equipo) => {
if (validarNoExiste && !equipo) if (validarNoExiste && !equipo)
throw new NotFoundException('No existe este equipo.'); throw new NotFoundException('No existe este equipo.');
return equipo; return equipo;

View File

@ -105,7 +105,9 @@ export class HoraExcepcionService {
findAllByIdInstitucionDia(id_institucion_dia: number) { findAllByIdInstitucionDia(id_institucion_dia: number) {
return this.institucionDiaService return this.institucionDiaService
.findById(id_institucion_dia) .findById(id_institucion_dia)
.then((institucionDia) => this.repository.find({ institucionDia })); .then((institucionDia) =>
this.repository.find({ where: { institucionDia } }),
);
} }
findById(id_hora_excepcion: number) { findById(id_hora_excepcion: number) {

View File

@ -24,14 +24,14 @@ export class InstitucionCarreraService {
carrera: { id_carrera: Not(1) }, carrera: { id_carrera: Not(1) },
institucion, institucion,
}, },
order: { carrera: 'ASC' }, order: { carrera: { carrera: 'ASC' } },
}), }),
); );
} }
findById(id_institucion_carrera: number) { findById(id_institucion_carrera: number) {
return this.institucionCarreraRepository return this.institucionCarreraRepository
.findOne({ id_institucion_carrera }) .findOne({ where: { id_institucion_carrera } })
.then((institucionCarrera) => { .then((institucionCarrera) => {
if (!institucionCarrera) if (!institucionCarrera)
throw new NotFoundException('No existe este id institución carrera.'); throw new NotFoundException('No existe este id institución carrera.');
@ -52,18 +52,24 @@ export class InstitucionCarreraService {
? await this.institucionService.findById(id_institucion) ? await this.institucionService.findById(id_institucion)
: id_institucion; : id_institucion;
return this.institucionCarreraRepository.findOne({ carrera, institucion }); return this.institucionCarreraRepository.findOne({
where: { carrera, institucion },
});
} }
findCarreraByIdCarrera(id_carrera: number) { findCarreraByIdCarrera(id_carrera: number) {
return this.carreraRepository.findOne({ id_carrera }).then((carrera) => { return this.carreraRepository
.findOne({ where: { id_carrera } })
.then((carrera) => {
if (!carrera) throw new NotFoundException('No existe este id carrera.'); if (!carrera) throw new NotFoundException('No existe este id carrera.');
return carrera; return carrera;
}); });
} }
findCarreraByCarrera(carrera: string, validarNoExiste = true) { findCarreraByCarrera(carrera: string, validarNoExiste = true) {
return this.carreraRepository.findOne({ carrera }).then((carrera) => { return this.carreraRepository
.findOne({ where: { carrera } })
.then((carrera) => {
if (validarNoExiste && !carrera) if (validarNoExiste && !carrera)
throw new NotFoundException('No existe esta carrera.'); throw new NotFoundException('No existe esta carrera.');
return carrera; return carrera;
@ -75,8 +81,7 @@ export class InstitucionCarreraService {
.findById(id_institucion) .findById(id_institucion)
.then((institucion) => .then((institucion) =>
this.institucionCarreraRepository.findOne({ this.institucionCarreraRepository.findOne({
carrera: { id_carrera: 1 }, where: { carrera: { id_carrera: 1 }, institucion },
institucion,
}), }),
); );
} }

View File

@ -6,12 +6,7 @@ import {
NotFoundException, NotFoundException,
} from '@nestjs/common'; } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm'; import { InjectRepository } from '@nestjs/typeorm';
import { import { Repository } from 'typeorm';
FindOperator,
LessThanOrEqual,
MoreThanOrEqual,
Repository,
} from 'typeorm';
import { Institucion } from '../institucion/entity/institucion.entity'; import { Institucion } from '../institucion/entity/institucion.entity';
import { InstitucionDia } from './entity/institucion-dia.entity'; import { InstitucionDia } from './entity/institucion-dia.entity';
import { Operador } from '../operador/entity/operador.entity'; import { Operador } from '../operador/entity/operador.entity';
@ -29,7 +24,10 @@ export class InstitucionDiaService {
return this.institucionService return this.institucionService
.findById(id_institucion) .findById(id_institucion)
.then((institucion) => .then((institucion) =>
this.repository.find({ where: { institucion }, order: { dia: 'ASC' } }), this.repository.find({
where: { institucion },
order: { id_institucion_dia: 'ASC' },
}),
); );
} }
@ -53,7 +51,7 @@ export class InstitucionDiaService {
} }
findByInstitucionDia(institucion: Institucion, id_dia: number) { findByInstitucionDia(institucion: Institucion, id_dia: number) {
return this.repository.findOne({ institucion, dia: { id_dia } }); return this.repository.findOne({ where: { institucion, dia: { id_dia } } });
} }
async hoy(id_institucion: number) { async hoy(id_institucion: number) {

View File

@ -22,7 +22,7 @@ export class InstitucionInfraccionService {
create(infraccion: string) { create(infraccion: string) {
return this.infraccionRepository return this.infraccionRepository
.findOne({ infraccion }) .findOne({ where: { infraccion } })
.then((existeInfraccion) => { .then((existeInfraccion) => {
if (existeInfraccion) if (existeInfraccion)
throw new ConflictException('Ya existe esta infracción.'); throw new ConflictException('Ya existe esta infracción.');

View File

@ -22,7 +22,7 @@ export class InstitucionProgramaService {
create(programa: string) { create(programa: string) {
return this.programaRepository return this.programaRepository
.findOne({ programa }) .findOne({ where: { programa } })
.then((existePrograma) => { .then((existePrograma) => {
if (existePrograma) if (existePrograma)
throw new ConflictException('Ya existe este programa.'); throw new ConflictException('Ya existe este programa.');
@ -85,14 +85,18 @@ export class InstitucionProgramaService {
} }
findProgramaById(id_programa: number) { findProgramaById(id_programa: number) {
return this.programaRepository.findOne({ id_programa }).then((programa) => { return this.programaRepository
.findOne({ where: { id_programa } })
.then((programa) => {
if (!programa) throw new NotFoundException('No existe este programa.'); if (!programa) throw new NotFoundException('No existe este programa.');
return programa; return programa;
}); });
} }
findProgramaByPrograma(programa: string, validarNoExiste = true) { findProgramaByPrograma(programa: string, validarNoExiste = true) {
return this.programaRepository.findOne({ programa }).then((programa) => { return this.programaRepository
.findOne({ where: { programa } })
.then((programa) => {
if (validarNoExiste && !programa) if (validarNoExiste && !programa)
throw new NotFoundException('No existe este programa.'); throw new NotFoundException('No existe este programa.');
return programa; return programa;

View File

@ -93,7 +93,7 @@ export class InstitucionTipoCarritoService {
findTipoCarritoById(id_tipo_carrito: number) { findTipoCarritoById(id_tipo_carrito: number) {
return this.tipoCarritoRepository return this.tipoCarritoRepository
.findOne({ id_tipo_carrito }) .findOne({ where: { id_tipo_carrito } })
.then((tipoCarrito) => { .then((tipoCarrito) => {
if (!tipoCarrito) if (!tipoCarrito)
throw new NotFoundException('No existe este id tipo carrito.'); throw new NotFoundException('No existe este id tipo carrito.');
@ -103,7 +103,7 @@ export class InstitucionTipoCarritoService {
findTipoCarritoByTipoCarrito(tipo_carrito: string, validarNoExiste = true) { findTipoCarritoByTipoCarrito(tipo_carrito: string, validarNoExiste = true) {
return this.tipoCarritoRepository return this.tipoCarritoRepository
.findOne({ tipo_carrito }) .findOne({ where: { tipo_carrito } })
.then((tipoCarrito) => { .then((tipoCarrito) => {
if (validarNoExiste && !tipoCarrito) if (validarNoExiste && !tipoCarrito)
throw new NotFoundException('No existe este tipo de carrito.'); throw new NotFoundException('No existe este tipo de carrito.');

View File

@ -22,7 +22,7 @@ export class InstitucionTipoEntradaService {
async create(tipo_entrada: string) { async create(tipo_entrada: string) {
return this.tipoEntradaRepository return this.tipoEntradaRepository
.findOne({ tipo_entrada }) .findOne({ where: { tipo_entrada } })
.then((existeTipoEntrada) => { .then((existeTipoEntrada) => {
if (existeTipoEntrada) if (existeTipoEntrada)
throw new ConflictException('Ya existe este tipo de entrada.'); throw new ConflictException('Ya existe este tipo de entrada.');
@ -89,7 +89,7 @@ export class InstitucionTipoEntradaService {
findTipoEntradaById(id_tipo_entrada: number) { findTipoEntradaById(id_tipo_entrada: number) {
return this.tipoEntradaRepository return this.tipoEntradaRepository
.findOne({ id_tipo_entrada }) .findOne({ where: { id_tipo_entrada } })
.then((tipoEntrada) => { .then((tipoEntrada) => {
if (!tipoEntrada) if (!tipoEntrada)
throw new NotFoundException('No existe este id tipo de entrada.'); throw new NotFoundException('No existe este id tipo de entrada.');
@ -99,7 +99,7 @@ export class InstitucionTipoEntradaService {
findTipoEntradaByTipoEntrada(tipo_entrada: string, validarNoExiste = true) { findTipoEntradaByTipoEntrada(tipo_entrada: string, validarNoExiste = true) {
return this.tipoEntradaRepository return this.tipoEntradaRepository
.findOne({ tipo_entrada }) .findOne({ where: { tipo_entrada } })
.then((tipoEntrada) => { .then((tipoEntrada) => {
if (validarNoExiste && !tipoEntrada) if (validarNoExiste && !tipoEntrada)
throw new NotFoundException('No existe este tipo de entrada.'); throw new NotFoundException('No existe este tipo de entrada.');

View File

@ -23,7 +23,7 @@ export class InstitucionUsuarioService {
findById(id_institucion_usuario: number) { findById(id_institucion_usuario: number) {
return this.repository return this.repository
.findOne({ id_institucion_usuario }) .findOne({ where: { id_institucion_usuario } })
.then((institucionUsuario) => { .then((institucionUsuario) => {
if (!institucionUsuario) if (!institucionUsuario)
throw new ConflictException('No existe este id institución usuario.'); throw new ConflictException('No existe este id institución usuario.');
@ -37,9 +37,7 @@ export class InstitucionUsuarioService {
) { ) {
return this.repository return this.repository
.findOne({ .findOne({
activo: true, where: { activo: true, institucionCarrera, usuario },
institucionCarrera,
usuario,
}) })
.then((institucionUsuario) => { .then((institucionUsuario) => {
if (!institucionUsuario) if (!institucionUsuario)

View File

@ -25,7 +25,9 @@ export class InstitucionService {
} }
findById(id_institucion: number) { findById(id_institucion: number) {
return this.repository.findOne({ id_institucion }).then((institucion) => { return this.repository
.findOne({ where: { id_institucion } })
.then((institucion) => {
if (!institucion) if (!institucion)
throw new NotFoundException('No existe este id institución.'); throw new NotFoundException('No existe este id institución.');
return institucion; return institucion;

View File

@ -23,7 +23,9 @@ export class MarcaService {
} }
findById(id_marca: number, tipo: string, validarExistencia = true) { findById(id_marca: number, tipo: string, validarExistencia = true) {
return this.repository.findOne({ id_marca, tipo }).then((marca) => { return this.repository
.findOne({ where: { id_marca, tipo } })
.then((marca) => {
if (validarExistencia && !marca) if (validarExistencia && !marca)
throw new ConflictException('No existe esta marca.'); throw new ConflictException('No existe esta marca.');
return marca; return marca;
@ -31,7 +33,7 @@ export class MarcaService {
} }
findByMarca(marca: string, tipo: string, validarExistencia = true) { findByMarca(marca: string, tipo: string, validarExistencia = true) {
return this.repository.findOne({ marca, tipo }).then((marca) => { return this.repository.findOne({ where: { marca, tipo } }).then((marca) => {
if (validarExistencia && !marca) if (validarExistencia && !marca)
throw new ConflictException('No existe esta marca.'); throw new ConflictException('No existe esta marca.');
return marca; return marca;

View File

@ -25,14 +25,18 @@ export class ModeloService {
} }
findById(id_modelo: number, tipo: string, validarExistencia = true) { findById(id_modelo: number, tipo: string, validarExistencia = true) {
return this.repository.findOne({ id_modelo, tipo }).then((modelo) => { return this.repository
.findOne({ where: { id_modelo, tipo } })
.then((modelo) => {
if (validarExistencia && !modelo) if (validarExistencia && !modelo)
throw new ConflictException('No existe este modelo.'); throw new ConflictException('No existe este modelo.');
return modelo; return modelo;
}); });
} }
findByModelo(modelo: string, tipo: string, validarExistencia = true) { findByModelo(modelo: string, tipo: string, validarExistencia = true) {
return this.repository.findOne({ modelo, tipo }).then((modelo) => { return this.repository
.findOne({ where: { modelo, tipo } })
.then((modelo) => {
if (validarExistencia && !modelo) if (validarExistencia && !modelo)
throw new ConflictException('No existe este modelo.'); throw new ConflictException('No existe este modelo.');
return modelo; return modelo;

View File

@ -39,7 +39,7 @@ export class ModuloService {
: id_institucion; : id_institucion;
return this.repository return this.repository
.findOne({ institucion, modulo }) .findOne({ where: { institucion, modulo } })
.then((existeModulo) => { .then((existeModulo) => {
if (existeModulo) if (existeModulo)
throw new ConflictException( throw new ConflictException(
@ -69,7 +69,7 @@ export class ModuloService {
} }
findById(id_modulo: number) { findById(id_modulo: number) {
return this.repository.findOne({ id_modulo }).then((modulo) => { return this.repository.findOne({ where: { id_modulo } }).then((modulo) => {
if (!modulo) throw new NotFoundException('No existe este id módulo.'); if (!modulo) throw new NotFoundException('No existe este id módulo.');
return modulo; return modulo;
}); });
@ -85,7 +85,9 @@ export class ModuloService {
? await this.institucionService.findById(id_institucion) ? await this.institucionService.findById(id_institucion)
: id_institucion; : id_institucion;
return this.repository.findOne({ institucion, modulo }).then((modulo) => { return this.repository
.findOne({ where: { institucion, modulo } })
.then((modulo) => {
if (validarNoExiste && !modulo) if (validarNoExiste && !modulo)
throw new ConflictException('No existe este módulo.'); throw new ConflictException('No existe este módulo.');
return modulo; return modulo;

View File

@ -72,7 +72,7 @@ export class MultaService {
'No se mandó ningún motivo para multar a este alumno.', 'No se mandó ningún motivo para multar a este alumno.',
); );
return this.repository return this.repository
.findOne({ prestamo }) .findOne({ where: { prestamo } })
.then((existeMulta) => { .then((existeMulta) => {
if (existeMulta) if (existeMulta)
throw new ConflictException( throw new ConflictException(
@ -107,7 +107,9 @@ export class MultaService {
desactivarMultas() { desactivarMultas() {
const ahora = moment(); const ahora = moment();
return this.repository.find({ activo: true }).then(async (multas) => { return this.repository
.find({ where: { activo: true } })
.then(async (multas) => {
for (let i = 0; i < multas.length; i++) for (let i = 0; i < multas.length; i++)
if (ahora.diff(moment(multas[i].fecha_fin)) > 0) { if (ahora.diff(moment(multas[i].fecha_fin)) > 0) {
const instituciones = multas[i].prestamo.usuario.instituciones; const instituciones = multas[i].prestamo.usuario.instituciones;

View File

@ -89,8 +89,10 @@ export class OperadorService {
findAdmin(admin: string, validarNoExiste = true) { findAdmin(admin: string, validarNoExiste = true) {
return this.repository return this.repository
.findOne({ .findOne({
where: {
operador: admin, operador: admin,
tipoUsuario: { id_tipo_usuario: Between(2, 3) }, tipoUsuario: { id_tipo_usuario: Between(2, 3) },
},
}) })
.then((admin) => { .then((admin) => {
if (validarNoExiste && !admin) if (validarNoExiste && !admin)
@ -140,8 +142,11 @@ export class OperadorService {
} }
findById(id_operador: number) { findById(id_operador: number) {
return this.repository.findOne({ id_operador }).then((operador) => { return this.repository
if (!operador) throw new NotFoundException('No existe este id operador.'); .findOne({ where: { id_operador } })
.then((operador) => {
if (!operador)
throw new NotFoundException('No existe este id operador.');
return operador; return operador;
}); });
} }
@ -157,7 +162,7 @@ export class OperadorService {
: id_institucion; : id_institucion;
return this.repository return this.repository
.findOne({ institucion, operador }) .findOne({ where: { institucion, operador } })
.then((operador) => { .then((operador) => {
if (validarNoExiste && !operador) if (validarNoExiste && !operador)
throw new NotFoundException('No existe este operador.'); throw new NotFoundException('No existe este operador.');

View File

@ -111,7 +111,7 @@ export class PrestamoService {
) { ) {
const ahora = moment(); const ahora = moment();
const ahoraStr = ahora.format('YYYY-MM-DD'); const ahoraStr = ahora.format('YYYY-MM-DD');
const sistema = await this.operadorService.findById(1); const sistema = { id_operador: 1 };
const modulo = await this.moduloService.findById(id_modulo); const modulo = await this.moduloService.findById(id_modulo);
const tipoCarrito = const tipoCarrito =
await this.institucionTipoCarritoService.findTipoCarritoById( await this.institucionTipoCarritoService.findTipoCarritoById(
@ -166,7 +166,7 @@ export class PrestamoService {
); );
} }
return this.repository return this.repository
.findOne({ activo: true, usuario }) .findOne({ where: { activo: true, usuario } })
.then((existePrestamo) => { .then((existePrestamo) => {
if (existePrestamo) if (existePrestamo)
throw new ConflictException( throw new ConflictException(

View File

@ -14,7 +14,7 @@ export class StatusService {
} }
findById(id_status: number) { findById(id_status: number) {
return this.repository.findOne({ id_status }).then((status) => { return this.repository.findOne({ where: { id_status } }).then((status) => {
if (!status) throw new NotFoundException('No existe este status.'); if (!status) throw new NotFoundException('No existe este status.');
return status; return status;
}); });

View File

@ -15,7 +15,7 @@ export class TipoUsuarioService {
create(tipo_usuario: string) { create(tipo_usuario: string) {
return this.repository return this.repository
.findOne({ tipo_usuario }) .findOne({ where: { tipo_usuario } })
.then((existeTipoUsuario) => { .then((existeTipoUsuario) => {
if (existeTipoUsuario) if (existeTipoUsuario)
throw new ConflictException('Ya existe este tipo usuario'); throw new ConflictException('Ya existe este tipo usuario');
@ -38,7 +38,9 @@ export class TipoUsuarioService {
} }
findById(id_tipo_usuario: number) { findById(id_tipo_usuario: number) {
return this.repository.findOne({ id_tipo_usuario }).then((tipoUsuario) => { return this.repository
.findOne({ where: { id_tipo_usuario } })
.then((tipoUsuario) => {
if (!tipoUsuario) if (!tipoUsuario)
throw new NotFoundException('No existe este id tipo usuario.'); throw new NotFoundException('No existe este id tipo usuario.');
return tipoUsuario; return tipoUsuario;
@ -46,7 +48,9 @@ export class TipoUsuarioService {
} }
findByTipoUsuario(tipo_usuario: string, validarNoExiste = true) { findByTipoUsuario(tipo_usuario: string, validarNoExiste = true) {
return this.repository.findOne({ tipo_usuario }).then((tipoUsuario) => { return this.repository
.findOne({ where: { tipo_usuario } })
.then((tipoUsuario) => {
if (validarNoExiste && !tipoUsuario) if (validarNoExiste && !tipoUsuario)
throw new NotFoundException('No existe este tipo usuario'); throw new NotFoundException('No existe este tipo usuario');
return tipoUsuario; return tipoUsuario;