listo operador
This commit is contained in:
@@ -45,7 +45,7 @@ export class JwtStrategyService extends PassportStrategy(Strategy) {
|
||||
else if ('Operador' in payload)
|
||||
// Buscar a ese operador en la db y lo asigna al objeto user
|
||||
await this.operadorService
|
||||
.findInfoOperadorById(payload.Operador.id_operador)
|
||||
.findById(payload.Operador.id_operador)
|
||||
.then(async (operador) => {
|
||||
// Valida que la cuena del operador este activa
|
||||
if (!operador.activo)
|
||||
|
||||
@@ -30,7 +30,7 @@ export class EquipoMotivoService {
|
||||
const ahora = moment();
|
||||
const operador =
|
||||
typeof id_operador === 'number'
|
||||
? await this.operadorService.findInfoOperadorById(id_operador)
|
||||
? await this.operadorService.findById(id_operador)
|
||||
: id_operador;
|
||||
const status =
|
||||
typeof id_status === 'number'
|
||||
|
||||
@@ -46,7 +46,7 @@ export class MultaService {
|
||||
: id_prestamo;
|
||||
const operador =
|
||||
typeof id_operador === 'number'
|
||||
? await this.operadorService.findInfoOperadorById(id_operador)
|
||||
? await this.operadorService.findById(id_operador)
|
||||
: id_operador;
|
||||
const data: DeepPartial<Multa> = {
|
||||
descripcion,
|
||||
|
||||
@@ -133,7 +133,7 @@ export class OperadorController {
|
||||
const admin: Operador = req.user.operador;
|
||||
|
||||
this.validarUsuarioService.validarSuperAdminAdmin(admin);
|
||||
return this.operadorService.findFullInfoOperadorAll(query);
|
||||
return this.operadorService.findAll(query);
|
||||
}
|
||||
|
||||
@Serealize(OperadorOutputDto)
|
||||
|
||||
@@ -104,14 +104,26 @@ export class OperadorService {
|
||||
}));
|
||||
}
|
||||
|
||||
findAllByInstitucion(operador: Operador) {
|
||||
return this.repository.find({
|
||||
select: ['id_operador', 'operador'],
|
||||
where: { institucion: operador.institucion },
|
||||
});
|
||||
findAdmin(admin: string) {
|
||||
return this.repository
|
||||
.findOne({
|
||||
select: {
|
||||
id_operador: true,
|
||||
activo: true,
|
||||
nombre: true,
|
||||
password: true,
|
||||
id_institucion: true,
|
||||
id_tipo_usuario: true,
|
||||
},
|
||||
where: {
|
||||
operador: admin,
|
||||
tipoUsuario: { id_tipo_usuario: Between(2, 3) },
|
||||
},
|
||||
})
|
||||
.then((admin) => this.llenarIds(admin));
|
||||
}
|
||||
|
||||
async findFullInfoOperadorAll(filtros: {
|
||||
async findAll(filtros: {
|
||||
pagina: string;
|
||||
id_institucion?: string;
|
||||
id_tipo_usuario?: string;
|
||||
@@ -162,23 +174,11 @@ export class OperadorService {
|
||||
});
|
||||
}
|
||||
|
||||
findAdmin(admin: string) {
|
||||
return this.repository
|
||||
.findOne({
|
||||
select: {
|
||||
id_operador: true,
|
||||
activo: true,
|
||||
nombre: true,
|
||||
password: true,
|
||||
id_institucion: true,
|
||||
id_tipo_usuario: true,
|
||||
},
|
||||
where: {
|
||||
operador: admin,
|
||||
tipoUsuario: { id_tipo_usuario: Between(2, 3) },
|
||||
},
|
||||
})
|
||||
.then((admin) => this.llenarIds(admin));
|
||||
findAllByInstitucion(operador: Operador) {
|
||||
return this.repository.find({
|
||||
select: ['id_operador', 'operador'],
|
||||
where: { institucion: operador.institucion },
|
||||
});
|
||||
}
|
||||
|
||||
findOperador(institucion: Institucion, operador: string) {
|
||||
@@ -197,7 +197,7 @@ export class OperadorService {
|
||||
.then((operador) => this.llenarIds(operador));
|
||||
}
|
||||
|
||||
findInfoOperadorById(id_operador: number) {
|
||||
findById(id_operador: number) {
|
||||
return this.repository
|
||||
.findOne({
|
||||
select: {
|
||||
@@ -227,7 +227,7 @@ export class OperadorService {
|
||||
}
|
||||
|
||||
passwordReset(admin: Operador, id_operador: number, password?: string) {
|
||||
return this.findInfoOperadorById(id_operador)
|
||||
return this.findById(id_operador)
|
||||
.then((operador) => {
|
||||
this.validarUpdate(admin, operador);
|
||||
// Si no se manda una password se genera una
|
||||
@@ -258,7 +258,7 @@ export class OperadorService {
|
||||
}
|
||||
|
||||
update(admin: Operador, attrs: Partial<Operador>) {
|
||||
return this.findInfoOperadorById(attrs.id_operador)
|
||||
return this.findById(attrs.id_operador)
|
||||
.then((operador) => {
|
||||
this.validarUpdate(admin, operador);
|
||||
// Paso los valores enviados del front a mi objeto
|
||||
|
||||
@@ -452,12 +452,12 @@ export class PrestamoService {
|
||||
? await this.moduloService.findById(parseInt(filtros.id_modulo))
|
||||
: null;
|
||||
const operadorEntrega = filtros.id_operador_entrega
|
||||
? await this.operadorService.findInfoOperadorById(
|
||||
? await this.operadorService.findById(
|
||||
parseInt(filtros.id_operador_entrega),
|
||||
)
|
||||
: null;
|
||||
const operadorRegreso = filtros.id_operador_regreso
|
||||
? await this.operadorService.findInfoOperadorById(
|
||||
? await this.operadorService.findById(
|
||||
parseInt(filtros.id_operador_regreso),
|
||||
)
|
||||
: null;
|
||||
|
||||
Reference in New Issue
Block a user