filtrado
This commit is contained in:
@@ -6,7 +6,6 @@ const Carrera = require('../../db/tablas/Carrera');
|
||||
const validar = require('../../helper/validar');
|
||||
|
||||
const nuevo = async (body) => {
|
||||
console.log('hola');
|
||||
let idUsuario = validar.validarId(body.idUsuario);
|
||||
let idPrograma = validar.validarId(body.idPrograma);
|
||||
let idCarrera = validar.validarId(body.idCarrera);
|
||||
@@ -19,7 +18,7 @@ const nuevo = async (body) => {
|
||||
let cartaAceptacion = '';
|
||||
|
||||
return Usuario.findOne({
|
||||
where: { [Op.and]: [{ idUsuario }, { idTipoUsuario: 3 }] },
|
||||
where: { idUsuario, idTipoUsuario: 3 },
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Este alumno no existe en la db.');
|
||||
@@ -32,7 +31,7 @@ const nuevo = async (body) => {
|
||||
.then((res) => {
|
||||
if (!res) throw new Error('Esta carrera no existe en la db.');
|
||||
return Servicio.findOne({
|
||||
where: { [Op.and]: [{ idUsuario }, { idStatus: { [Op.ne]: 10 } }] },
|
||||
where: { idUsuario, idStatus: { [Op.ne]: 10 } },
|
||||
});
|
||||
})
|
||||
.then((res) => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const { Op } = require('sequelize');
|
||||
const validar = require('../../helper/validar');
|
||||
const Servicio = require('../../db/tablas/Servicio');
|
||||
const Usuario = require('../../db/tablas/Usuario');
|
||||
@@ -7,13 +8,24 @@ const TipoUsuario = require('../../db/tablas/TipoUsuario');
|
||||
|
||||
const serviciosAdmin = async (body) => {
|
||||
let pagina = body.pagina;
|
||||
let nombre = body.nombre;
|
||||
let numeroCuenta = body.numeroCuenta;
|
||||
let idStatus = body.idStatus;
|
||||
let idStatus = body.idStatus ? validar.validarId(body.idStatus) : null;
|
||||
let nombre = body.nombre
|
||||
? validar.validarTexto(body.nombre, 'El nombre')
|
||||
: '';
|
||||
let numeroCuenta = body.numeroCuenta
|
||||
? validar.validarNumeroCuenta(body.numeroCuenta)
|
||||
: '';
|
||||
let where = { nombre: { [Op.like]: `%${nombre}%` } };
|
||||
|
||||
if (idStatus) where.idStatus = idStatus;
|
||||
return Servicio.findAll({
|
||||
where,
|
||||
include: [
|
||||
{ model: Usuario, include: { model: TipoUsuario } },
|
||||
{
|
||||
model: Usuario,
|
||||
include: { model: TipoUsuario },
|
||||
where: { usuario: { [Op.like]: `%${numeroCuenta}%` } },
|
||||
},
|
||||
{ model: Carrera },
|
||||
{ model: Status },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user