soap client module
This commit is contained in:
parent
3d8a1c3f44
commit
3b3948135c
@ -54,6 +54,7 @@ import { TipoCarrito } from './institucion-tipo-carrito/entity/tipo-carrito.enti
|
||||
import { TipoEntrada } from './tipo-entrada/entity/tipo-entrada.entity';
|
||||
import { TipoUsuario } from './tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { Usuario } from './usuario/entity/usuario.entity';
|
||||
import { SoapClientModule } from './soap-client/soap-client.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@ -124,6 +125,7 @@ import { Usuario } from './usuario/entity/usuario.entity';
|
||||
TipoUsuarioModule,
|
||||
UploadFileModule,
|
||||
UsuarioModule,
|
||||
SoapClientModule,
|
||||
],
|
||||
// providers: [AppGateway],
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ import { InstitucionCarreraController } from './institucion-carrera.controller';
|
||||
import { InstitucionCarreraService } from './institucion-carrera.service';
|
||||
import { InstitucionCarrera } from './entity/institucion-carrera.entity';
|
||||
import { Nivel } from './entity/nivel.entity';
|
||||
import { InstitucionModule } from 'src/institucion/institucion.module';
|
||||
import { InstitucionModule } from '../institucion/institucion.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Repository } from 'typeorm';
|
||||
import { Institucion } from 'src/institucion/entity/institucion.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { Modulo } from './entity/modulo.entity';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
import { Between, FindOperator, Like, Repository } from 'typeorm';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { Operador } from './entity/operador.entity';
|
||||
import { TipoUsuario } from 'src/tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { TipoUsuario } from '../tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { BcryptService } from '../bcrypt/bcrypt.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
|
||||
|
32
src/soap-client/soap-client.module.ts
Normal file
32
src/soap-client/soap-client.module.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { SoapModule, SoapModuleOptions } from 'nestjs-soap';
|
||||
import { SoapClientService } from './soap-client.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
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'),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
providers: [SoapClientService],
|
||||
exports: [SoapClientService],
|
||||
})
|
||||
export class SoapClientModule {}
|
18
src/soap-client/soap-client.service.spec.ts
Normal file
18
src/soap-client/soap-client.service.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { SoapClientService } from './soap-client.service';
|
||||
|
||||
describe('SoapClientService', () => {
|
||||
let service: SoapClientService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SoapClientService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<SoapClientService>(SoapClientService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
51
src/soap-client/soap-client.service.ts
Normal file
51
src/soap-client/soap-client.service.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import * as sha1 from 'sha1';
|
||||
import * as md5 from 'md5';
|
||||
import { Injectable, Inject } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { Client } from 'nestjs-soap';
|
||||
|
||||
@Injectable()
|
||||
export class SoapClientService {
|
||||
constructor(
|
||||
@Inject('DGAE') private readonly soapDgae: Client,
|
||||
@Inject('DGP') private readonly soapDpg: Client,
|
||||
private configService: ConfigService,
|
||||
) {}
|
||||
|
||||
dgae(cta: string, plt: string, crr: string, nvl: string) {
|
||||
return this.soapDgae.return_vigencia(
|
||||
{
|
||||
key: sha1(this.configService.get<string>('SOAP_DGAE_KEY')),
|
||||
cta,
|
||||
plt,
|
||||
crr,
|
||||
nvl,
|
||||
},
|
||||
(err, res) => {
|
||||
console.log(res);
|
||||
if (err) return err;
|
||||
return res;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
dgp(rfcNumEmp: string) {
|
||||
return this.soapDpg.PlazaTrab(
|
||||
{
|
||||
rfcNumEmp,
|
||||
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') +
|
||||
rfcNumEmp +
|
||||
this.configService.get<string>('SOAP_DGP_MD5_FIN') +
|
||||
this.configService.get<string>('SOAP_DGP_USERNAME'),
|
||||
),
|
||||
},
|
||||
(err, res) => {
|
||||
console.log(err);
|
||||
console.log(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -6,9 +6,9 @@ import { EquipoService } from '../equipo/equipo.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
|
||||
import { UsuarioService } from '../usuario/usuario.service';
|
||||
import { Carrera } from 'src/carrera/entity/carrera.entity';
|
||||
import { Institucion } from 'src/institucion/entity/institucion.entity';
|
||||
import { TipoUsuario } from 'src/tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { Carrera } from '../carrera/entity/carrera.entity';
|
||||
import { Institucion } from '../institucion/entity/institucion.entity';
|
||||
import { TipoUsuario } from '../tipo-usuario/entity/tipo-usuario.entity';
|
||||
import { UploadFileCargaMasivaUsuarioDto } from './dto/upload-file-carga-masiva-usuario.dto';
|
||||
|
||||
@Injectable()
|
||||
|
@ -1,15 +1,14 @@
|
||||
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';
|
||||
import { BcryptModule } from '../bcrypt/bcrypt.module';
|
||||
import { NodemailerModule } from '../nodemailer/nodemailer.module';
|
||||
import { InstitucionModule } from '../institucion/institucion.module';
|
||||
import { InstitucionCarreraModule } from 'src/institucion-carrera/institucion-carrera.module';
|
||||
import { InstitucionCarreraModule } from '../institucion-carrera/institucion-carrera.module';
|
||||
import { SoapClientModule } from '../soap-client/soap-client.module';
|
||||
import { TipoUsuarioModule } from '../tipo-usuario/tipo-usuario.module';
|
||||
|
||||
@Module({
|
||||
@ -19,26 +18,7 @@ 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'),
|
||||
}),
|
||||
}),
|
||||
SoapClientModule,
|
||||
TipoUsuarioModule,
|
||||
TypeOrmModule.forFeature([Usuario]),
|
||||
],
|
||||
|
@ -1,15 +1,10 @@
|
||||
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';
|
||||
@ -18,19 +13,18 @@ import { BcryptService } from '../bcrypt/bcrypt.service';
|
||||
import { InstitucionCarreraService } from '../institucion-carrera/institucion-carrera.service';
|
||||
import { InstitucionService } from '../institucion/institucion.service';
|
||||
import { NodemailerService } from '../nodemailer/nodemailer.service';
|
||||
import { SoapClientService } from '../soap-client/soap-client.service';
|
||||
import { TipoUsuarioService } from '../tipo-usuario/tipo-usuario.service';
|
||||
|
||||
@Injectable()
|
||||
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,
|
||||
private soapClientService: SoapClientService,
|
||||
private tipoUsuarioService: TipoUsuarioService,
|
||||
) {}
|
||||
|
||||
@ -85,39 +79,7 @@ export class UsuarioService {
|
||||
<p>Pc Puma Solicita</p>`;
|
||||
}
|
||||
|
||||
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 dgaeDgp(usuario: string) {}
|
||||
|
||||
async findAll(filtros: {
|
||||
pagina: string;
|
||||
|
Loading…
Reference in New Issue
Block a user