listo prestamo
This commit is contained in:
parent
d1124cc2b9
commit
28c1afa8f7
@ -105,7 +105,7 @@ export class CarreraProgramaService {
|
||||
id_institucion: number,
|
||||
) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then(async (institucion) => {
|
||||
// Si es un Operador
|
||||
if (usuarioOperador instanceof Operador) {
|
||||
|
@ -153,9 +153,7 @@ export class CarritoService {
|
||||
}) {
|
||||
const carritos: Carrito[] = [];
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findInfoInstitucionById(
|
||||
parseInt(filtros.id_institucion),
|
||||
)
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const marca = filtros.id_marca
|
||||
? await this.marcaService.findById(parseInt(filtros.id_marca), 'c')
|
||||
|
@ -109,9 +109,7 @@ export class EquipoService {
|
||||
? await this.carritoService.findById(parseInt(filtros.id_carrito))
|
||||
: null;
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findInfoInstitucionById(
|
||||
parseInt(filtros.id_institucion),
|
||||
)
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const marca = filtros.id_marca
|
||||
? await this.marcaService.findById(parseInt(filtros.id_marca), 'e')
|
||||
@ -385,7 +383,7 @@ export class EquipoService {
|
||||
numero_inventario: string,
|
||||
) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.fullInformacionEquipoView.findOne({
|
||||
where: {
|
||||
|
@ -21,7 +21,7 @@ export class InstitucionCarreraService {
|
||||
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.institucionCarreraRepository.find({
|
||||
where: {
|
||||
@ -53,7 +53,7 @@ export class InstitucionCarreraService {
|
||||
: id_carrera;
|
||||
const institucion =
|
||||
typeof id_institucion === 'number'
|
||||
? await this.institucionService.findInfoInstitucionById(id_institucion)
|
||||
? await this.institucionService.findById(id_institucion)
|
||||
: id_institucion;
|
||||
|
||||
return this.institucionCarreraRepository.findOne({
|
||||
@ -82,7 +82,7 @@ export class InstitucionCarreraService {
|
||||
|
||||
findInstitucionProfesor(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.institucionCarreraRepository.findOne({
|
||||
where: { carrera: { id_carrera: 1 }, institucion },
|
||||
|
@ -22,7 +22,7 @@ export class InstitucionDiaService {
|
||||
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.repository.find({
|
||||
where: { institucion },
|
||||
@ -60,7 +60,7 @@ export class InstitucionDiaService {
|
||||
if (ahora.weekday() === 0)
|
||||
throw new ConflictException('No hay servicio los días domingo.');
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.findByInstitucionDia(institucion, ahora.weekday()),
|
||||
);
|
||||
|
@ -33,7 +33,7 @@ export class InstitucionInfraccionService {
|
||||
})
|
||||
.then(async (infraccion) => {
|
||||
const instituciones =
|
||||
await this.institucionService.findInfoInstitucionAll();
|
||||
await this.institucionService.findAll();
|
||||
|
||||
for (let i = 0; i < instituciones.length; i++)
|
||||
await this.institucionInfraccionRepository.save(
|
||||
@ -55,7 +55,7 @@ export class InstitucionInfraccionService {
|
||||
|
||||
findAllByIdInstitucion(id_institucion: number) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.institucionInfraccionRepository
|
||||
.createQueryBuilder('ii')
|
||||
|
@ -32,7 +32,7 @@ export class InstitucionProgramaService {
|
||||
})
|
||||
.then(async (programa) => {
|
||||
const instituciones =
|
||||
await this.institucionService.findInfoInstitucionAll();
|
||||
await this.institucionService.findAll();
|
||||
|
||||
for (let i = 0; i < instituciones.length; i++)
|
||||
await this.institucionProgramaRepository.save(
|
||||
@ -50,9 +50,7 @@ export class InstitucionProgramaService {
|
||||
}
|
||||
|
||||
async findAllByIdInstitucion(id_institucion: number, mostrar = false) {
|
||||
const institucion = await this.institucionService.findInfoInstitucionById(
|
||||
id_institucion,
|
||||
);
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
const query = this.institucionProgramaRepository
|
||||
.createQueryBuilder('ip')
|
||||
.innerJoinAndSelect('ip.programa', 'p', 'p.id_programa != 1')
|
||||
|
@ -40,7 +40,7 @@ export class InstitucionTipoCarritoService {
|
||||
})
|
||||
.then(async (tipoCarrito) => {
|
||||
const instituciones =
|
||||
await this.institucionService.findInfoInstitucionAll();
|
||||
await this.institucionService.findAll();
|
||||
|
||||
for (let i = 0; i < instituciones.length; i++)
|
||||
await this.institucionTipoCarritoRepository.save(
|
||||
@ -58,9 +58,7 @@ export class InstitucionTipoCarritoService {
|
||||
}
|
||||
|
||||
async findAllByIdInstitucion(id_institucion: number, mostrar = false) {
|
||||
const institucion = await this.institucionService.findInfoInstitucionById(
|
||||
id_institucion,
|
||||
);
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
const query = this.institucionTipoCarritoRepository
|
||||
.createQueryBuilder('itc')
|
||||
.innerJoinAndSelect(
|
||||
|
@ -33,8 +33,7 @@ export class InstitucionTipoEntradaService {
|
||||
);
|
||||
})
|
||||
.then(async (tipoEntrada) => {
|
||||
const instituciones =
|
||||
await this.institucionService.findInfoInstitucionAll();
|
||||
const instituciones = await this.institucionService.findAll();
|
||||
|
||||
for (let i = 0; i < instituciones.length; i++)
|
||||
await this.institucionTipoEntradaRepository.save(
|
||||
@ -54,9 +53,7 @@ export class InstitucionTipoEntradaService {
|
||||
}
|
||||
|
||||
async findAllByIdInstitucion(id_institucion: number, mostrar = false) {
|
||||
const institucion = await this.institucionService.findInfoInstitucionById(
|
||||
id_institucion,
|
||||
);
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
const query = await this.institucionTipoEntradaRepository
|
||||
.createQueryBuilder('ite')
|
||||
.innerJoinAndSelect(
|
||||
|
@ -42,7 +42,7 @@ export class InstitucionController {
|
||||
description: 'Endpoint que retorna todas las instituciones activas.',
|
||||
})
|
||||
activas() {
|
||||
return this.institucionService.findMinInfoInstitucionAll(true);
|
||||
return this.institucionService.findMinInfoAll(true);
|
||||
}
|
||||
|
||||
@Serealize(InstitucionMinOutputDto)
|
||||
@ -56,7 +56,7 @@ export class InstitucionController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
this.validarUsuarioService.validarSuperAdmin(superAdmin);
|
||||
return this.institucionService.findMinInfoInstitucionAll();
|
||||
return this.institucionService.findMinInfoAll();
|
||||
}
|
||||
|
||||
@Serealize(InstitucionOutputDto)
|
||||
@ -76,7 +76,7 @@ export class InstitucionController {
|
||||
|
||||
this.validarUsuarioService.validarSuperAdminAdmin(admin);
|
||||
return this.institucionService
|
||||
.findById(parseInt(query.id_institucion))
|
||||
.findFullInfoById(parseInt(query.id_institucion))
|
||||
.then((institucion) => {
|
||||
if (
|
||||
admin.tipoUsuario.id_tipo_usuario === 3 &&
|
||||
@ -100,7 +100,7 @@ export class InstitucionController {
|
||||
const superAdmin: Operador = req.user.operador;
|
||||
|
||||
this.validarUsuarioService.validarSuperAdmin(superAdmin);
|
||||
return this.institucionService.findMinInfoInstitucionAll(false, true);
|
||||
return this.institucionService.findMinInfoAll(false, true);
|
||||
}
|
||||
|
||||
@Serealize(MessageOutputDto)
|
||||
|
@ -18,17 +18,11 @@ export class InstitucionService {
|
||||
return this.repository.create({ id_institucion });
|
||||
}
|
||||
|
||||
findById(id_institucion: number) {
|
||||
return this.repository
|
||||
.findOne({ where: { id_institucion } })
|
||||
.then((institucion) => {
|
||||
if (!institucion)
|
||||
throw new NotFoundException('No existe este id institución.');
|
||||
return institucion;
|
||||
});
|
||||
findAll() {
|
||||
return this.repository.find({ select: ['id_institucion'] });
|
||||
}
|
||||
|
||||
findInfoInstitucionById(id_institucion: number) {
|
||||
findById(id_institucion: number) {
|
||||
return this.repository
|
||||
.findOne({ select: ['id_institucion'], where: { id_institucion } })
|
||||
.then((institucion) => {
|
||||
@ -38,11 +32,17 @@ export class InstitucionService {
|
||||
});
|
||||
}
|
||||
|
||||
findInfoInstitucionAll() {
|
||||
return this.repository.find({ select: ['id_institucion'] });
|
||||
findFullInfoById(id_institucion: number) {
|
||||
return this.repository
|
||||
.findOne({ where: { id_institucion } })
|
||||
.then((institucion) => {
|
||||
if (!institucion)
|
||||
throw new NotFoundException('No existe este id institución.');
|
||||
return institucion;
|
||||
});
|
||||
}
|
||||
|
||||
findMinInfoInstitucionAll(activo = false, responsable = false) {
|
||||
findMinInfoAll(activo = false, responsable = false) {
|
||||
const busqueda: FindOptionsWhere<Institucion> = {};
|
||||
|
||||
if (activo) busqueda.activo = activo;
|
||||
@ -62,7 +62,7 @@ export class InstitucionService {
|
||||
}
|
||||
|
||||
update(admin: Operador, attrs: Partial<Institucion>) {
|
||||
return this.findInfoInstitucionById(attrs.id_institucion)
|
||||
return this.findById(attrs.id_institucion)
|
||||
.then((institucion) => {
|
||||
if (
|
||||
admin.tipoUsuario.id_tipo_usuario === 3 &&
|
||||
@ -74,8 +74,6 @@ export class InstitucionService {
|
||||
Object.assign(institucion, attrs);
|
||||
return this.repository.save(institucion);
|
||||
})
|
||||
.then((_) => ({
|
||||
message: 'Se guardaron los cambios correctamente.',
|
||||
}));
|
||||
.then((_) => ({ message: 'Se guardaron los cambios correctamente.' }));
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ export class ModuloService {
|
||||
|
||||
async findMinInfoModuloAll(id_institucion: number, activo = 0) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) => {
|
||||
const busqueda: FindOptionsWhere<MinInformacionModuloView> = {
|
||||
id_institucion: institucion.id_institucion,
|
||||
|
@ -135,9 +135,7 @@ export class MultaService {
|
||||
usuario?: string;
|
||||
}) {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findInfoInstitucionById(
|
||||
parseInt(filtros.id_institucion),
|
||||
)
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const busqueda: FindOptionsWhere<FullInformacionMultaView> = {};
|
||||
|
||||
|
@ -35,7 +35,7 @@ export class OperadorService {
|
||||
) {
|
||||
const institucion =
|
||||
typeof id_institucion === 'number'
|
||||
? await this.institucionService.findInfoInstitucionById(id_institucion)
|
||||
? await this.institucionService.findById(id_institucion)
|
||||
: id_institucion;
|
||||
const tipoUsuario = await this.tipoUsuarioService.findById(id_tipo_usuario);
|
||||
|
||||
@ -111,9 +111,7 @@ export class OperadorService {
|
||||
operador?: string;
|
||||
}) {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findInfoInstitucionById(
|
||||
parseInt(filtros.id_institucion),
|
||||
)
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const tipoUsuario = filtros.id_tipo_usuario
|
||||
? await this.tipoUsuarioService.findById(
|
||||
|
@ -446,9 +446,7 @@ export class PrestamoService {
|
||||
usuario?: string;
|
||||
}) {
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findInfoInstitucionById(
|
||||
parseInt(filtros.id_institucion),
|
||||
)
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const modulo = filtros.id_modulo
|
||||
? await this.moduloService.findInfoModuloById(parseInt(filtros.id_modulo))
|
||||
@ -694,7 +692,7 @@ export class PrestamoService {
|
||||
numero_inventario: string,
|
||||
) {
|
||||
return this.institucionService
|
||||
.findInfoInstitucionById(id_institucion)
|
||||
.findById(id_institucion)
|
||||
.then((institucion) =>
|
||||
this.equipoService.findByNumeroInventario(
|
||||
institucion,
|
||||
|
@ -45,9 +45,7 @@ export class UploadFileService {
|
||||
) {}
|
||||
|
||||
async createEquipos(path: string, id_institucion: number) {
|
||||
const institucion = await this.institucionService.findInfoInstitucionById(
|
||||
id_institucion,
|
||||
);
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
let errores: string[] = [];
|
||||
let mensajes: string[] = [];
|
||||
let equiposNuevos: Equipo[] = [];
|
||||
@ -81,9 +79,7 @@ export class UploadFileService {
|
||||
}
|
||||
|
||||
async createUsuarios(path: string, id_institucion: number) {
|
||||
const institucion = await this.institucionService.findInfoInstitucionById(
|
||||
id_institucion,
|
||||
);
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
let errores: string[] = [];
|
||||
let mensajes: string[] = [];
|
||||
let usuariosNuevos: InstitucionUsuario[] = [];
|
||||
@ -484,9 +480,7 @@ export class UploadFileService {
|
||||
|
||||
async uploadLogo(file: Express.Multer.File, id_institucion: number) {
|
||||
const path = file ? `${file.destination}/${file.filename}` : null;
|
||||
const institucion = await this.institucionService.findInfoInstitucionById(
|
||||
id_institucion,
|
||||
);
|
||||
const institucion = await this.institucionService.findById(id_institucion);
|
||||
|
||||
if (!file) throw new BadRequestException('No se mandó ningún logo.');
|
||||
institucion.logo = path;
|
||||
|
@ -72,9 +72,7 @@ export class UsuarioService {
|
||||
)
|
||||
: null;
|
||||
const institucion = filtros.id_institucion
|
||||
? await this.institucionService.findInfoInstitucionById(
|
||||
parseInt(filtros.id_institucion),
|
||||
)
|
||||
? await this.institucionService.findById(parseInt(filtros.id_institucion))
|
||||
: null;
|
||||
const tipoUsuario = filtros.id_tipo_usuario
|
||||
? await this.tipoUsuarioService.findById(
|
||||
|
Loading…
Reference in New Issue
Block a user