From 9c7353a91ea31358dcd43092e4d99650681ae8ec Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Wed, 4 May 2022 22:23:55 -0500 Subject: [PATCH] save --- src/soap-client/soap-client.service.ts | 59 ++++++++++++-------------- src/usuario/usuario.service.ts | 26 +++++++++++- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/src/soap-client/soap-client.service.ts b/src/soap-client/soap-client.service.ts index 09b5508..b472aae 100644 --- a/src/soap-client/soap-client.service.ts +++ b/src/soap-client/soap-client.service.ts @@ -13,39 +13,36 @@ export class SoapClientService { ) {} dgae(cta: string, plt: string, crr: string, nvl: string) { - return this.soapDgae.return_vigencia( - { - key: sha1(this.configService.get('SOAP_DGAE_KEY')), - cta, - plt, - crr, - nvl, - }, - (err, res) => { - console.log(res); - if (err) return err; - return res; - }, - ); + return new Promise((resolve, reject) => { + this.soapDgae.return_vigencia( + { + key: sha1(this.configService.get('SOAP_DGAE_KEY')), + cta, + plt, + crr, + nvl, + }, + (err, res) => (err ? reject(err) : resolve(res)), + ); + }); } dgp(rfcNumEmp: string) { - return this.soapDpg.PlazaTrab( - { - rfcNumEmp, - usuario: this.configService.get('SOAP_DGP_USERNAME'), - contrasenia: this.configService.get('SOAP_DGP_PASSWORD'), - hash: md5( - this.configService.get('SOAP_DGP_MD5_INI') + - rfcNumEmp + - this.configService.get('SOAP_DGP_MD5_FIN') + - this.configService.get('SOAP_DGP_USERNAME'), - ), - }, - (err, res) => { - console.log(err); - console.log(res); - }, - ); + return new Promise((resolve, reject) => { + this.soapDpg.PlazaTrab( + { + rfcNumEmp, + usuario: this.configService.get('SOAP_DGP_USERNAME'), + contrasenia: this.configService.get('SOAP_DGP_PASSWORD'), + hash: md5( + this.configService.get('SOAP_DGP_MD5_INI') + + rfcNumEmp + + this.configService.get('SOAP_DGP_MD5_FIN') + + this.configService.get('SOAP_DGP_USERNAME'), + ), + }, + (err, res) => (err ? reject(err) : resolve(res)), + ); + }); } } diff --git a/src/usuario/usuario.service.ts b/src/usuario/usuario.service.ts index b0c8e5e..eb92078 100644 --- a/src/usuario/usuario.service.ts +++ b/src/usuario/usuario.service.ts @@ -79,7 +79,31 @@ export class UsuarioService {

Pc Puma Solicita

`; } - async dgaeDgp(usuario: string) {} + dgaeDgp(usuario: string) { + return this.findByUsuario(usuario).then(async (existeUsuario) => { + if (!existeUsuario) { + let esAlumno = false; + + await this.soapClientService + .dgp(usuario) + .then((res) => { + if (!res) return this.soapClientService.dgp(usuario); + esAlumno = true; + return res; + }) + .then((res) => { + if (!res) + throw new ConflictException('No es un número de cuenta válido.'); + + // const data = {usuario,id_institucion:200,}; + // return this.create(usuario,, 5); + }); + } + if (existeUsuario.password) + throw new ConflictException('Ya fue regisrado este usuario.'); + return existeUsuario; + }); + } async findAll(filtros: { pagina: string;