update librerias
This commit is contained in:
@@ -43,7 +43,7 @@ export class CarreraProgramaService {
|
||||
'Esta carrera no pertenece a tu institución.',
|
||||
);
|
||||
return this.repository
|
||||
.findOne({ institucionCarrera, programa })
|
||||
.findOne({ where: { institucionCarrera, programa } })
|
||||
.then((existeCarretaPrograma) => {
|
||||
if (existeCarretaPrograma)
|
||||
throw new ConflictException(
|
||||
@@ -80,7 +80,7 @@ export class CarreraProgramaService {
|
||||
|
||||
findById(id_carrera_programa: number) {
|
||||
return this.repository
|
||||
.findOne({ id_carrera_programa })
|
||||
.findOne({ where: { id_carrera_programa } })
|
||||
.then((carreraPrograma) => {
|
||||
if (!carreraPrograma)
|
||||
throw new NotFoundException('No existe este id carrera programa.');
|
||||
|
||||
@@ -52,7 +52,7 @@ export class CarritoService {
|
||||
'No puedes crear un carrito para este módulo porque no pertenece a tu institución.',
|
||||
);
|
||||
return this.repository
|
||||
.count({ modulo, tipoCarrito })
|
||||
.count({ where: { modulo, tipoCarrito } })
|
||||
.then((carritos) =>
|
||||
this.repository.save(
|
||||
this.repository.create({
|
||||
@@ -151,10 +151,12 @@ export class CarritoService {
|
||||
}
|
||||
|
||||
findById(id_carrito: number) {
|
||||
return this.repository.findOne({ id_carrito }).then((carrito) => {
|
||||
if (!carrito) throw new NotFoundException('No existe este id carrito.');
|
||||
return carrito;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { id_carrito } })
|
||||
.then((carrito) => {
|
||||
if (!carrito) throw new NotFoundException('No existe este id carrito.');
|
||||
return carrito;
|
||||
});
|
||||
}
|
||||
|
||||
async findCarrito(
|
||||
@@ -175,7 +177,7 @@ export class CarritoService {
|
||||
: id_tipo_carrito;
|
||||
|
||||
return this.repository
|
||||
.findOne({ carrito, modulo, tipoCarrito })
|
||||
.findOne({ where: { carrito, modulo, tipoCarrito } })
|
||||
.then((carrito) => {
|
||||
if (validarNoExiste && !carrito)
|
||||
throw new ConflictException('No existe este carrito.');
|
||||
|
||||
@@ -69,7 +69,7 @@ export class EquipoProgramaService {
|
||||
'No puedes eliminar el software de este equipo porque no pertenece a tu institución.',
|
||||
);
|
||||
return this.repository
|
||||
.count({ equipo: equipoPrograma.equipo })
|
||||
.count({ where: { equipo: equipoPrograma.equipo } })
|
||||
.then(async (n) => {
|
||||
if (n === 1) {
|
||||
if (equipoPrograma.programa.id_programa === 1)
|
||||
@@ -111,7 +111,7 @@ export class EquipoProgramaService {
|
||||
validarExistencia = true,
|
||||
) {
|
||||
return this.repository
|
||||
.findOne({ equipo, programa })
|
||||
.findOne({ where: { equipo, programa } })
|
||||
.then((equipoPrograma) => {
|
||||
if (validarExistencia && equipoPrograma)
|
||||
throw new ConflictException(
|
||||
|
||||
@@ -51,7 +51,7 @@ export class EquipoTipoEntradaService {
|
||||
|
||||
findById(id_equipo_tipo_entrada: number) {
|
||||
return this.repository
|
||||
.findOne({ id_equipo_tipo_entrada })
|
||||
.findOne({ where: { id_equipo_tipo_entrada } })
|
||||
.then((equipoTipoEntrada) => {
|
||||
if (!equipoTipoEntrada)
|
||||
throw new ConflictException('No existe este id equipo tipo entrada.');
|
||||
@@ -65,7 +65,7 @@ export class EquipoTipoEntradaService {
|
||||
validarExistencia = true,
|
||||
) {
|
||||
return this.repository
|
||||
.findOne({ equipo, tipoEntrada })
|
||||
.findOne({ where: { equipo, tipoEntrada } })
|
||||
.then((equipoTipoEntrada) => {
|
||||
if (validarExistencia && equipoTipoEntrada)
|
||||
throw new ConflictException(
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
@@ -213,7 +213,7 @@ export class EquipoService {
|
||||
}
|
||||
|
||||
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.');
|
||||
return equipo;
|
||||
});
|
||||
@@ -348,11 +348,13 @@ export class EquipoService {
|
||||
? await this.carritoService.findById(id_carrito)
|
||||
: id_carrito;
|
||||
|
||||
return this.repository.findOne({ carrito, equipo }).then((equipo) => {
|
||||
if (validarNoExiste && !equipo)
|
||||
throw new NotFoundException('No existe este equipo.');
|
||||
return equipo;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { carrito, equipo } })
|
||||
.then((equipo) => {
|
||||
if (validarNoExiste && !equipo)
|
||||
throw new NotFoundException('No existe este equipo.');
|
||||
return equipo;
|
||||
});
|
||||
}
|
||||
|
||||
async update(
|
||||
|
||||
@@ -105,7 +105,9 @@ export class HoraExcepcionService {
|
||||
findAllByIdInstitucionDia(id_institucion_dia: number) {
|
||||
return this.institucionDiaService
|
||||
.findById(id_institucion_dia)
|
||||
.then((institucionDia) => this.repository.find({ institucionDia }));
|
||||
.then((institucionDia) =>
|
||||
this.repository.find({ where: { institucionDia } }),
|
||||
);
|
||||
}
|
||||
|
||||
findById(id_hora_excepcion: number) {
|
||||
|
||||
@@ -24,14 +24,14 @@ export class InstitucionCarreraService {
|
||||
carrera: { id_carrera: Not(1) },
|
||||
institucion,
|
||||
},
|
||||
order: { carrera: 'ASC' },
|
||||
order: { carrera: { carrera: 'ASC' } },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
findById(id_institucion_carrera: number) {
|
||||
return this.institucionCarreraRepository
|
||||
.findOne({ id_institucion_carrera })
|
||||
.findOne({ where: { id_institucion_carrera } })
|
||||
.then((institucionCarrera) => {
|
||||
if (!institucionCarrera)
|
||||
throw new NotFoundException('No existe este id institución carrera.');
|
||||
@@ -52,22 +52,28 @@ export class InstitucionCarreraService {
|
||||
? await this.institucionService.findById(id_institucion)
|
||||
: id_institucion;
|
||||
|
||||
return this.institucionCarreraRepository.findOne({ carrera, institucion });
|
||||
return this.institucionCarreraRepository.findOne({
|
||||
where: { carrera, institucion },
|
||||
});
|
||||
}
|
||||
|
||||
findCarreraByIdCarrera(id_carrera: number) {
|
||||
return this.carreraRepository.findOne({ id_carrera }).then((carrera) => {
|
||||
if (!carrera) throw new NotFoundException('No existe este id carrera.');
|
||||
return carrera;
|
||||
});
|
||||
return this.carreraRepository
|
||||
.findOne({ where: { id_carrera } })
|
||||
.then((carrera) => {
|
||||
if (!carrera) throw new NotFoundException('No existe este id carrera.');
|
||||
return carrera;
|
||||
});
|
||||
}
|
||||
|
||||
findCarreraByCarrera(carrera: string, validarNoExiste = true) {
|
||||
return this.carreraRepository.findOne({ carrera }).then((carrera) => {
|
||||
if (validarNoExiste && !carrera)
|
||||
throw new NotFoundException('No existe esta carrera.');
|
||||
return carrera;
|
||||
});
|
||||
return this.carreraRepository
|
||||
.findOne({ where: { carrera } })
|
||||
.then((carrera) => {
|
||||
if (validarNoExiste && !carrera)
|
||||
throw new NotFoundException('No existe esta carrera.');
|
||||
return carrera;
|
||||
});
|
||||
}
|
||||
|
||||
findInstitucionProfesor(id_institucion: number) {
|
||||
@@ -75,8 +81,7 @@ export class InstitucionCarreraService {
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.institucionCarreraRepository.findOne({
|
||||
carrera: { id_carrera: 1 },
|
||||
institucion,
|
||||
where: { carrera: { id_carrera: 1 }, institucion },
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,12 +6,7 @@ import {
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import {
|
||||
FindOperator,
|
||||
LessThanOrEqual,
|
||||
MoreThanOrEqual,
|
||||
Repository,
|
||||
} from 'typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { InstitucionDia } from './entity/institucion-dia.entity';
|
||||
import { Operador } from '../operador/entity/operador.entity';
|
||||
@@ -29,7 +24,10 @@ export class InstitucionDiaService {
|
||||
return this.institucionService
|
||||
.findById(id_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) {
|
||||
return this.repository.findOne({ institucion, dia: { id_dia } });
|
||||
return this.repository.findOne({ where: { institucion, dia: { id_dia } } });
|
||||
}
|
||||
|
||||
async hoy(id_institucion: number) {
|
||||
|
||||
@@ -22,7 +22,7 @@ export class InstitucionInfraccionService {
|
||||
|
||||
create(infraccion: string) {
|
||||
return this.infraccionRepository
|
||||
.findOne({ infraccion })
|
||||
.findOne({ where: { infraccion } })
|
||||
.then((existeInfraccion) => {
|
||||
if (existeInfraccion)
|
||||
throw new ConflictException('Ya existe esta infracción.');
|
||||
|
||||
@@ -22,7 +22,7 @@ export class InstitucionProgramaService {
|
||||
|
||||
create(programa: string) {
|
||||
return this.programaRepository
|
||||
.findOne({ programa })
|
||||
.findOne({ where: { programa } })
|
||||
.then((existePrograma) => {
|
||||
if (existePrograma)
|
||||
throw new ConflictException('Ya existe este programa.');
|
||||
@@ -85,18 +85,22 @@ export class InstitucionProgramaService {
|
||||
}
|
||||
|
||||
findProgramaById(id_programa: number) {
|
||||
return this.programaRepository.findOne({ id_programa }).then((programa) => {
|
||||
if (!programa) throw new NotFoundException('No existe este programa.');
|
||||
return programa;
|
||||
});
|
||||
return this.programaRepository
|
||||
.findOne({ where: { id_programa } })
|
||||
.then((programa) => {
|
||||
if (!programa) throw new NotFoundException('No existe este programa.');
|
||||
return programa;
|
||||
});
|
||||
}
|
||||
|
||||
findProgramaByPrograma(programa: string, validarNoExiste = true) {
|
||||
return this.programaRepository.findOne({ programa }).then((programa) => {
|
||||
if (validarNoExiste && !programa)
|
||||
throw new NotFoundException('No existe este programa.');
|
||||
return programa;
|
||||
});
|
||||
return this.programaRepository
|
||||
.findOne({ where: { programa } })
|
||||
.then((programa) => {
|
||||
if (validarNoExiste && !programa)
|
||||
throw new NotFoundException('No existe este programa.');
|
||||
return programa;
|
||||
});
|
||||
}
|
||||
|
||||
update(admin: Operador, attrs: Partial<InstitucionPrograma>) {
|
||||
|
||||
@@ -93,7 +93,7 @@ export class InstitucionTipoCarritoService {
|
||||
|
||||
findTipoCarritoById(id_tipo_carrito: number) {
|
||||
return this.tipoCarritoRepository
|
||||
.findOne({ id_tipo_carrito })
|
||||
.findOne({ where: { id_tipo_carrito } })
|
||||
.then((tipoCarrito) => {
|
||||
if (!tipoCarrito)
|
||||
throw new NotFoundException('No existe este id tipo carrito.');
|
||||
@@ -103,7 +103,7 @@ export class InstitucionTipoCarritoService {
|
||||
|
||||
findTipoCarritoByTipoCarrito(tipo_carrito: string, validarNoExiste = true) {
|
||||
return this.tipoCarritoRepository
|
||||
.findOne({ tipo_carrito })
|
||||
.findOne({ where: { tipo_carrito } })
|
||||
.then((tipoCarrito) => {
|
||||
if (validarNoExiste && !tipoCarrito)
|
||||
throw new NotFoundException('No existe este tipo de carrito.');
|
||||
|
||||
@@ -22,7 +22,7 @@ export class InstitucionTipoEntradaService {
|
||||
|
||||
async create(tipo_entrada: string) {
|
||||
return this.tipoEntradaRepository
|
||||
.findOne({ tipo_entrada })
|
||||
.findOne({ where: { tipo_entrada } })
|
||||
.then((existeTipoEntrada) => {
|
||||
if (existeTipoEntrada)
|
||||
throw new ConflictException('Ya existe este tipo de entrada.');
|
||||
@@ -89,7 +89,7 @@ export class InstitucionTipoEntradaService {
|
||||
|
||||
findTipoEntradaById(id_tipo_entrada: number) {
|
||||
return this.tipoEntradaRepository
|
||||
.findOne({ id_tipo_entrada })
|
||||
.findOne({ where: { id_tipo_entrada } })
|
||||
.then((tipoEntrada) => {
|
||||
if (!tipoEntrada)
|
||||
throw new NotFoundException('No existe este id tipo de entrada.');
|
||||
@@ -99,7 +99,7 @@ export class InstitucionTipoEntradaService {
|
||||
|
||||
findTipoEntradaByTipoEntrada(tipo_entrada: string, validarNoExiste = true) {
|
||||
return this.tipoEntradaRepository
|
||||
.findOne({ tipo_entrada })
|
||||
.findOne({ where: { tipo_entrada } })
|
||||
.then((tipoEntrada) => {
|
||||
if (validarNoExiste && !tipoEntrada)
|
||||
throw new NotFoundException('No existe este tipo de entrada.');
|
||||
|
||||
@@ -23,7 +23,7 @@ export class InstitucionUsuarioService {
|
||||
|
||||
findById(id_institucion_usuario: number) {
|
||||
return this.repository
|
||||
.findOne({ id_institucion_usuario })
|
||||
.findOne({ where: { id_institucion_usuario } })
|
||||
.then((institucionUsuario) => {
|
||||
if (!institucionUsuario)
|
||||
throw new ConflictException('No existe este id institución usuario.');
|
||||
@@ -37,9 +37,7 @@ export class InstitucionUsuarioService {
|
||||
) {
|
||||
return this.repository
|
||||
.findOne({
|
||||
activo: true,
|
||||
institucionCarrera,
|
||||
usuario,
|
||||
where: { activo: true, institucionCarrera, usuario },
|
||||
})
|
||||
.then((institucionUsuario) => {
|
||||
if (!institucionUsuario)
|
||||
|
||||
@@ -25,11 +25,13 @@ export class InstitucionService {
|
||||
}
|
||||
|
||||
findById(id_institucion: number) {
|
||||
return this.repository.findOne({ id_institucion }).then((institucion) => {
|
||||
if (!institucion)
|
||||
throw new NotFoundException('No existe este id institución.');
|
||||
return institucion;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { id_institucion } })
|
||||
.then((institucion) => {
|
||||
if (!institucion)
|
||||
throw new NotFoundException('No existe este id institución.');
|
||||
return institucion;
|
||||
});
|
||||
}
|
||||
|
||||
update(admin: Operador, attrs: Partial<Institucion>) {
|
||||
|
||||
@@ -23,15 +23,17 @@ export class MarcaService {
|
||||
}
|
||||
|
||||
findById(id_marca: number, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ id_marca, tipo }).then((marca) => {
|
||||
if (validarExistencia && !marca)
|
||||
throw new ConflictException('No existe esta marca.');
|
||||
return marca;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { id_marca, tipo } })
|
||||
.then((marca) => {
|
||||
if (validarExistencia && !marca)
|
||||
throw new ConflictException('No existe esta marca.');
|
||||
return marca;
|
||||
});
|
||||
}
|
||||
|
||||
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)
|
||||
throw new ConflictException('No existe esta marca.');
|
||||
return marca;
|
||||
|
||||
@@ -25,17 +25,21 @@ export class ModeloService {
|
||||
}
|
||||
|
||||
findById(id_modelo: number, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ id_modelo, tipo }).then((modelo) => {
|
||||
if (validarExistencia && !modelo)
|
||||
throw new ConflictException('No existe este modelo.');
|
||||
return modelo;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { id_modelo, tipo } })
|
||||
.then((modelo) => {
|
||||
if (validarExistencia && !modelo)
|
||||
throw new ConflictException('No existe este modelo.');
|
||||
return modelo;
|
||||
});
|
||||
}
|
||||
findByModelo(modelo: string, tipo: string, validarExistencia = true) {
|
||||
return this.repository.findOne({ modelo, tipo }).then((modelo) => {
|
||||
if (validarExistencia && !modelo)
|
||||
throw new ConflictException('No existe este modelo.');
|
||||
return modelo;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { modelo, tipo } })
|
||||
.then((modelo) => {
|
||||
if (validarExistencia && !modelo)
|
||||
throw new ConflictException('No existe este modelo.');
|
||||
return modelo;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class ModuloService {
|
||||
: id_institucion;
|
||||
|
||||
return this.repository
|
||||
.findOne({ institucion, modulo })
|
||||
.findOne({ where: { institucion, modulo } })
|
||||
.then((existeModulo) => {
|
||||
if (existeModulo)
|
||||
throw new ConflictException(
|
||||
@@ -69,7 +69,7 @@ export class ModuloService {
|
||||
}
|
||||
|
||||
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.');
|
||||
return modulo;
|
||||
});
|
||||
@@ -85,11 +85,13 @@ export class ModuloService {
|
||||
? await this.institucionService.findById(id_institucion)
|
||||
: id_institucion;
|
||||
|
||||
return this.repository.findOne({ institucion, modulo }).then((modulo) => {
|
||||
if (validarNoExiste && !modulo)
|
||||
throw new ConflictException('No existe este módulo.');
|
||||
return modulo;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { institucion, modulo } })
|
||||
.then((modulo) => {
|
||||
if (validarNoExiste && !modulo)
|
||||
throw new ConflictException('No existe este módulo.');
|
||||
return modulo;
|
||||
});
|
||||
}
|
||||
|
||||
update(admin: Operador, attrs: Partial<Modulo>) {
|
||||
|
||||
+20
-18
@@ -72,7 +72,7 @@ export class MultaService {
|
||||
'No se mandó ningún motivo para multar a este alumno.',
|
||||
);
|
||||
return this.repository
|
||||
.findOne({ prestamo })
|
||||
.findOne({ where: { prestamo } })
|
||||
.then((existeMulta) => {
|
||||
if (existeMulta)
|
||||
throw new ConflictException(
|
||||
@@ -107,27 +107,29 @@ export class MultaService {
|
||||
desactivarMultas() {
|
||||
const ahora = moment();
|
||||
|
||||
return this.repository.find({ activo: true }).then(async (multas) => {
|
||||
for (let i = 0; i < multas.length; i++)
|
||||
if (ahora.diff(moment(multas[i].fecha_fin)) > 0) {
|
||||
const instituciones = multas[i].prestamo.usuario.instituciones;
|
||||
return this.repository
|
||||
.find({ where: { activo: true } })
|
||||
.then(async (multas) => {
|
||||
for (let i = 0; i < multas.length; i++)
|
||||
if (ahora.diff(moment(multas[i].fecha_fin)) > 0) {
|
||||
const instituciones = multas[i].prestamo.usuario.instituciones;
|
||||
|
||||
multas[i].activo = false;
|
||||
await this.repository.save(multas[i]);
|
||||
for (let j = 0; j < instituciones.length; j++) {
|
||||
const institucionUsuario = instituciones[j];
|
||||
multas[i].activo = false;
|
||||
await this.repository.save(multas[i]);
|
||||
for (let j = 0; j < instituciones.length; j++) {
|
||||
const institucionUsuario = instituciones[j];
|
||||
|
||||
if (
|
||||
institucionUsuario.institucionCarrera.institucion
|
||||
.id_institucion ===
|
||||
multas[i].opeardorMulta.institucion.id_institucion
|
||||
) {
|
||||
institucionUsuario.multa = false;
|
||||
await this.institucionUsuarioService.update(institucionUsuario);
|
||||
if (
|
||||
institucionUsuario.institucionCarrera.institucion
|
||||
.id_institucion ===
|
||||
multas[i].opeardorMulta.institucion.id_institucion
|
||||
) {
|
||||
institucionUsuario.multa = false;
|
||||
await this.institucionUsuarioService.update(institucionUsuario);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async findAll(filtros: {
|
||||
|
||||
@@ -89,8 +89,10 @@ export class OperadorService {
|
||||
findAdmin(admin: string, validarNoExiste = true) {
|
||||
return this.repository
|
||||
.findOne({
|
||||
operador: admin,
|
||||
tipoUsuario: { id_tipo_usuario: Between(2, 3) },
|
||||
where: {
|
||||
operador: admin,
|
||||
tipoUsuario: { id_tipo_usuario: Between(2, 3) },
|
||||
},
|
||||
})
|
||||
.then((admin) => {
|
||||
if (validarNoExiste && !admin)
|
||||
@@ -140,10 +142,13 @@ export class OperadorService {
|
||||
}
|
||||
|
||||
findById(id_operador: number) {
|
||||
return this.repository.findOne({ id_operador }).then((operador) => {
|
||||
if (!operador) throw new NotFoundException('No existe este id operador.');
|
||||
return operador;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { id_operador } })
|
||||
.then((operador) => {
|
||||
if (!operador)
|
||||
throw new NotFoundException('No existe este id operador.');
|
||||
return operador;
|
||||
});
|
||||
}
|
||||
|
||||
async findByOperador(
|
||||
@@ -157,7 +162,7 @@ export class OperadorService {
|
||||
: id_institucion;
|
||||
|
||||
return this.repository
|
||||
.findOne({ institucion, operador })
|
||||
.findOne({ where: { institucion, operador } })
|
||||
.then((operador) => {
|
||||
if (validarNoExiste && !operador)
|
||||
throw new NotFoundException('No existe este operador.');
|
||||
|
||||
@@ -111,7 +111,7 @@ export class PrestamoService {
|
||||
) {
|
||||
const ahora = moment();
|
||||
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 tipoCarrito =
|
||||
await this.institucionTipoCarritoService.findTipoCarritoById(
|
||||
@@ -166,7 +166,7 @@ export class PrestamoService {
|
||||
);
|
||||
}
|
||||
return this.repository
|
||||
.findOne({ activo: true, usuario })
|
||||
.findOne({ where: { activo: true, usuario } })
|
||||
.then((existePrestamo) => {
|
||||
if (existePrestamo)
|
||||
throw new ConflictException(
|
||||
|
||||
@@ -14,7 +14,7 @@ export class StatusService {
|
||||
}
|
||||
|
||||
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.');
|
||||
return status;
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ export class TipoUsuarioService {
|
||||
|
||||
create(tipo_usuario: string) {
|
||||
return this.repository
|
||||
.findOne({ tipo_usuario })
|
||||
.findOne({ where: { tipo_usuario } })
|
||||
.then((existeTipoUsuario) => {
|
||||
if (existeTipoUsuario)
|
||||
throw new ConflictException('Ya existe este tipo usuario');
|
||||
@@ -38,18 +38,22 @@ export class TipoUsuarioService {
|
||||
}
|
||||
|
||||
findById(id_tipo_usuario: number) {
|
||||
return this.repository.findOne({ id_tipo_usuario }).then((tipoUsuario) => {
|
||||
if (!tipoUsuario)
|
||||
throw new NotFoundException('No existe este id tipo usuario.');
|
||||
return tipoUsuario;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { id_tipo_usuario } })
|
||||
.then((tipoUsuario) => {
|
||||
if (!tipoUsuario)
|
||||
throw new NotFoundException('No existe este id tipo usuario.');
|
||||
return tipoUsuario;
|
||||
});
|
||||
}
|
||||
|
||||
findByTipoUsuario(tipo_usuario: string, validarNoExiste = true) {
|
||||
return this.repository.findOne({ tipo_usuario }).then((tipoUsuario) => {
|
||||
if (validarNoExiste && !tipoUsuario)
|
||||
throw new NotFoundException('No existe este tipo usuario');
|
||||
return tipoUsuario;
|
||||
});
|
||||
return this.repository
|
||||
.findOne({ where: { tipo_usuario } })
|
||||
.then((tipoUsuario) => {
|
||||
if (validarNoExiste && !tipoUsuario)
|
||||
throw new NotFoundException('No existe este tipo usuario');
|
||||
return tipoUsuario;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user