soap listo

This commit is contained in:
lemuel 2022-05-03 17:36:11 -05:00
parent 5d3181d67e
commit 3d8a1c3f44
6 changed files with 150 additions and 5 deletions

79
package-lock.json generated
View File

@ -24,6 +24,7 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"csvtojson": "^2.0.10",
"md5": "^2.3.0",
"moment": "^2.29.3",
"mysql2": "^2.3.3",
"nestjs-soap": "^2.0.1",
@ -33,6 +34,7 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"sha1": "^1.1.1",
"swagger-ui-express": "^4.3.0",
"typeorm": "^0.2.45"
},
@ -3308,6 +3310,14 @@
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
"dev": true
},
"node_modules/charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=",
"engines": {
"node": "*"
}
},
"node_modules/chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
@ -3741,6 +3751,14 @@
"node": ">= 8"
}
},
"node_modules/crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=",
"engines": {
"node": "*"
}
},
"node_modules/cssom": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz",
@ -5539,6 +5557,11 @@
"node": ">=8"
}
},
"node_modules/is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"node_modules/is-core-module": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz",
@ -7007,6 +7030,16 @@
"tmpl": "1.0.5"
}
},
"node_modules/md5": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
"dependencies": {
"charenc": "0.0.2",
"crypt": "0.0.2",
"is-buffer": "~1.1.6"
}
},
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -8352,6 +8385,18 @@
"sha.js": "bin.js"
}
},
"node_modules/sha1": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz",
"integrity": "sha1-rdqnqTFo85PxnrKxUJFhjicA+Eg=",
"dependencies": {
"charenc": ">= 0.0.1",
"crypt": ">= 0.0.1"
},
"engines": {
"node": "*"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@ -12657,6 +12702,11 @@
"integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
"dev": true
},
"charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc="
},
"chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
@ -13006,6 +13056,11 @@
"which": "^2.0.1"
}
},
"crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs="
},
"cssom": {
"version": "0.4.4",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz",
@ -14351,6 +14406,11 @@
"binary-extensions": "^2.0.0"
}
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"is-core-module": {
"version": "2.8.1",
"resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz",
@ -15496,6 +15556,16 @@
"tmpl": "1.0.5"
}
},
"md5": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
"requires": {
"charenc": "0.0.2",
"crypt": "0.0.2",
"is-buffer": "~1.1.6"
}
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@ -16500,6 +16570,15 @@
"safe-buffer": "^5.0.1"
}
},
"sha1": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz",
"integrity": "sha1-rdqnqTFo85PxnrKxUJFhjicA+Eg=",
"requires": {
"charenc": ">= 0.0.1",
"crypt": ">= 0.0.1"
}
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",

View File

@ -36,6 +36,7 @@
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"csvtojson": "^2.0.10",
"md5": "^2.3.0",
"moment": "^2.29.3",
"mysql2": "^2.3.3",
"nestjs-soap": "^2.0.1",
@ -45,6 +46,7 @@
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.2.0",
"sha1": "^1.1.1",
"swagger-ui-express": "^4.3.0",
"typeorm": "^0.2.45"
},

View File

@ -1,7 +1,7 @@
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AppGateway } from './app.gateway';
// import { AppGateway } from './app.gateway';
import { AuthModule } from './auth/auth.module';
import { BcryptModule } from './bcrypt/bcrypt.module';
@ -125,6 +125,6 @@ import { Usuario } from './usuario/entity/usuario.entity';
UploadFileModule,
UsuarioModule,
],
providers: [AppGateway],
// providers: [AppGateway],
})
export class AppModule {}

View File

@ -22,8 +22,10 @@ export class UsuarioController {
constructor(private usuarioService: UsuarioService) {}
/* Pendiente por conexión */
// @Get('escolares')
// escolares(@Query() query: UsuarioEscolaresDto) {}
@Get('dgae-dgp')
dgaeDgp(@Query() query: UsuarioEscolaresDto) {
return this.usuarioService.dgaeDgp(query.usuario);
}
@Post('registrar')
registrar(@Body() body: UsuarioRegistrarDto) {

View File

@ -1,6 +1,8 @@
import { Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { PassportModule } from '@nestjs/passport';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SoapModule, SoapModuleOptions } from 'nestjs-soap';
import { UsuarioController } from './usuario.controller';
import { UsuarioService } from './usuario.service';
import { Usuario } from './entity/usuario.entity';
@ -17,6 +19,26 @@ import { TipoUsuarioModule } from '../tipo-usuario/tipo-usuario.module';
InstitucionCarreraModule,
NodemailerModule,
PassportModule.register({ defaultStrategy: 'jwt' }),
SoapModule.forRootAsync({
clientName: 'DGAE',
inject: [ConfigService],
useFactory: async (
configService: ConfigService,
): Promise<SoapModuleOptions> => ({
clientName: 'DGAE',
uri: configService.get<string>('SOAP_DGAE_URI'),
}),
}),
SoapModule.forRootAsync({
clientName: 'DGP',
inject: [ConfigService],
useFactory: async (
configService: ConfigService,
): Promise<SoapModuleOptions> => ({
clientName: 'DGP',
uri: configService.get<string>('SOAP_DGP_URI'),
}),
}),
TipoUsuarioModule,
TypeOrmModule.forFeature([Usuario]),
],

View File

@ -1,10 +1,15 @@
import * as sha1 from 'sha1';
import * as md5 from 'md5';
import {
ConflictException,
Inject,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { InjectRepository } from '@nestjs/typeorm';
import { FindOperator, Like, Repository } from 'typeorm';
import { Client } from 'nestjs-soap';
import { InstitucionCarrera } from '../institucion-carrera/entity/institucion-carrera.entity';
import { Institucion } from '../institucion/entity/institucion.entity';
import { TipoUsuario } from '../tipo-usuario/entity/tipo-usuario.entity';
@ -19,7 +24,10 @@ import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
export class UsuarioService {
constructor(
@InjectRepository(Usuario) private repository: Repository<Usuario>,
@Inject('DGAE') private readonly soapDgae: Client,
@Inject('DGP') private readonly soapDpg: Client,
private bcryptService: BcryptService,
private configService: ConfigService,
private institucionService: InstitucionService,
private institucionCarreraService: InstitucionCarreraService,
private nodemailerService: NodemailerService,
@ -77,7 +85,39 @@ export class UsuarioService {
<p>Pc Puma Solicita</p>`;
}
escolares() {}
async dgaeDgp(usuario: string) {
// return this.soapDgae.return_vigencia(
// {
// key: sha1(this.configService.get<string>('SOAP_DGAE_KEY')),
// cta: usuario,
// plt: '240',
// crr: '121',
// nvl: 'L',
// },
// (err, res) => {
// console.log(res);
// if (err) return err;
// return res;
// },
// );
const data = {
rfcNumEmp: usuario,
usuario: this.configService.get<string>('SOAP_DGP_USERNAME'),
contrasenia: this.configService.get<string>('SOAP_DGP_PASSWORD'),
hash: md5(
this.configService.get<string>('SOAP_DGP_MD5_INI') +
usuario +
this.configService.get<string>('SOAP_DGP_MD5_FIN') +
this.configService.get<string>('SOAP_DGP_USERNAME'),
),
};
// console.log(data);
return this.soapDpg.PlazaTrab(data, (err, res) => {
console.log(err);
console.log(res);
});
}
async findAll(filtros: {
pagina: string;