trabajando en confirmacion
This commit is contained in:
@@ -44,7 +44,6 @@ import { Contacto } from './contacto/entity/contacto.entity';
|
||||
import { Equipo } from './equipo/entity/equipo.entity';
|
||||
import { EquipoEvento } from './equipo-evento/entity/equipo_evento.entity';
|
||||
import { EquipoMiembro } from './equipo-miembro/entity/equipo_miembro.entity';
|
||||
import { SybaseModule } from './sybase/sybase.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@@ -89,17 +88,6 @@ import { SybaseModule } from './sybase/sybase.module';
|
||||
synchronize: true,
|
||||
}),
|
||||
}),
|
||||
SybaseModule.forRootAsync({
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => {
|
||||
return {
|
||||
host: configService.get('DB_HOST_DSC'),
|
||||
database: configService.get('DB_NAME_DSC'),
|
||||
username: configService.get('DB_USER_DSC'),
|
||||
password: configService.get('DB_PASS_DSC'),
|
||||
};
|
||||
},
|
||||
}),
|
||||
EventosModule,
|
||||
ParticipanteModule,
|
||||
EventoParticipanteModule,
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import * as mysql from 'mysql2/promise';
|
||||
|
||||
@Injectable()
|
||||
export class MysqlService {
|
||||
private mysqlPool: mysql.Pool;
|
||||
private mysqlConnection: mysql.Connection;
|
||||
private mysqlConnectionDscConfirmation: mysql.Connection;
|
||||
|
||||
constructor() {
|
||||
/* this.mysqlPool = mysql.createPool({
|
||||
connectionLimit: 20,
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME,
|
||||
});
|
||||
|
||||
this.mysqlConnection = mysql.createConnection({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASS,
|
||||
database: process.env.DB_NAME,
|
||||
});
|
||||
|
||||
this.mysqlConnectionDscConfirmation = mysql.createPool({
|
||||
connectionLimit: 20,
|
||||
host: process.env.DB_HOST_DSC,
|
||||
user: process.env.DB_USER_DSC,
|
||||
password: process.env.DB_PASS_DSC,
|
||||
database: process.env.DB_NAME_DSC,
|
||||
}); */
|
||||
|
||||
/* this.mysqlConnection.connect((err) => {
|
||||
if (err) console.log(err);
|
||||
else console.log('base conectada');
|
||||
}); */
|
||||
}
|
||||
|
||||
getMysqlConnection(): mysql.Connection {
|
||||
return this.mysqlConnection;
|
||||
}
|
||||
|
||||
getMysqlPool(): mysql.Pool {
|
||||
return this.mysqlPool;
|
||||
}
|
||||
|
||||
getMysqlConnectionDscConfirmation(): mysql.Connection {
|
||||
return this.mysqlConnectionDscConfirmation;
|
||||
}
|
||||
}
|
||||
@@ -16,21 +16,13 @@ export class InscripcionDscController {
|
||||
async confirmacionDsc(@Body() body: any) {
|
||||
const { accountNumber } = body;
|
||||
|
||||
/* this.inscripcionService
|
||||
.userVerification({ accountNumber })
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
})
|
||||
.catch((err) => {
|
||||
return(err)
|
||||
}); */
|
||||
const verificado = await this.inscripcionService.userVerification(accountNumber)
|
||||
console.log(verificado)
|
||||
|
||||
try {
|
||||
/* try {
|
||||
const userVerificationResponse =
|
||||
await this.inscripcionService.userVerification({
|
||||
accountNumber,
|
||||
});
|
||||
console.log(userVerificationResponse)
|
||||
await this.inscripcionService.userVerification(accountNumber);
|
||||
console.log(userVerificationResponse);
|
||||
if (userVerificationResponse.length === 0) {
|
||||
return {
|
||||
error: true,
|
||||
@@ -64,11 +56,6 @@ export class InscripcionDscController {
|
||||
msj: `No se pudo realizar la confirmación del usuario`,
|
||||
desc: `${err}`,
|
||||
};
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
/* @Get(":id")
|
||||
getUsuarioById(@Param('id', ParseIntPipe)id: number){
|
||||
|
||||
} */
|
||||
}
|
||||
|
||||
@@ -1,13 +1,32 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { SybaseService } from 'src/sybase/sybase.service';
|
||||
|
||||
@Injectable()
|
||||
export class InscripcionDscService {
|
||||
constructor(private sybaseService: SybaseService) {}
|
||||
async userVerification(accountNumber: string): Promise<any> {
|
||||
|
||||
async userVerification(data: { accountNumber: string }): Promise<any> {
|
||||
const { accountNumber } = data;
|
||||
/* console.log(accountNumber) */
|
||||
const mysql = require('mysql2');
|
||||
|
||||
const connection = mysql.createConnection({
|
||||
host: process.env.DB_HOST_DSC,
|
||||
user: process.env.DB_USER_DSC,
|
||||
password: process.env.DB_PASS_DSC,
|
||||
database: process.env.DB_NAME_DSC,
|
||||
});
|
||||
|
||||
const userInformationQuery = `SELECT A.id_cuenta, nombre, if(AI.platica=true,1,0) as confirmacion FROM alumno A
|
||||
JOIN alumno_inscrito AI ON (A.id_cuenta = AI.id_cuenta)
|
||||
JOIN periodo P ON (P.id_periodo = AI.id_periodo)
|
||||
WHERE A.id_cuenta = "${accountNumber}" and P.activo=true`;
|
||||
|
||||
console.log(userInformationQuery);
|
||||
|
||||
connection.connect();
|
||||
connection.query(userInformationQuery, function (error, results, fields) {
|
||||
if (error) throw error;
|
||||
console.log('The solution is: ', results);
|
||||
});
|
||||
connection.end();
|
||||
/*
|
||||
|
||||
try {
|
||||
|
||||
@@ -32,7 +51,7 @@ export class InscripcionDscService {
|
||||
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
validarNumeroCuenta = (numeroCuenta) => {
|
||||
@@ -41,6 +60,15 @@ export class InscripcionDscService {
|
||||
};
|
||||
|
||||
async userConfirmation(data: { accountNumber: string }): Promise<any> {
|
||||
const mysql = require('mysql2');
|
||||
|
||||
const connection = mysql.createConnection({
|
||||
host: process.env.DB_HOST_DSC,
|
||||
user: process.env.DB_USER_DSC,
|
||||
password: process.env.DB_PASS_DSC,
|
||||
database: process.env.DB_NAME_DSC,
|
||||
});
|
||||
|
||||
const { accountNumber } = data;
|
||||
|
||||
try {
|
||||
@@ -53,7 +81,7 @@ export class InscripcionDscService {
|
||||
WHERE id_cuenta="${accountNumber}" and id_periodo=(SELECT id_periodo FROM periodo WHERE activo=true)`;
|
||||
|
||||
try {
|
||||
const responseUserConfirmation = await this.sybaseService.queryDsc(
|
||||
const responseUserConfirmation = await connection.query(
|
||||
userConfirmationQuery,
|
||||
);
|
||||
return responseUserConfirmation;
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
export interface SybaseConfig {
|
||||
|
||||
database: string;
|
||||
|
||||
host: string;
|
||||
|
||||
password: string;
|
||||
|
||||
username: string;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { ConfigurableModuleBuilder } from '@nestjs/common';
|
||||
import { SybaseConfig } from './sybase.config';
|
||||
|
||||
export const { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN } =
|
||||
new ConfigurableModuleBuilder<SybaseConfig>()
|
||||
.setClassMethodName('forRoot')
|
||||
.build();
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ConfigurableModuleClass } from './sybase.module-definition';
|
||||
import { SybaseService } from './sybase.service';
|
||||
|
||||
@Global()
|
||||
@Module({ providers: [SybaseService], exports: [SybaseService] })
|
||||
export class SybaseModule extends ConfigurableModuleClass {}
|
||||
@@ -1,35 +0,0 @@
|
||||
import * as Sybase from 'sybase';
|
||||
import {
|
||||
Inject,
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
} from '@nestjs/common';
|
||||
import { SybaseConfig } from './sybase.config';
|
||||
import { MODULE_OPTIONS_TOKEN } from './sybase.module-definition';
|
||||
|
||||
@Injectable()
|
||||
export class SybaseService {
|
||||
private db;
|
||||
|
||||
constructor(@Inject(MODULE_OPTIONS_TOKEN) private options: SybaseConfig) {
|
||||
this.db = new Sybase(
|
||||
options.host,
|
||||
options.database,
|
||||
options.username,
|
||||
options.password,
|
||||
);
|
||||
}
|
||||
|
||||
queryDsc(consulta: string): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.db.query(consulta, (err, data) => {
|
||||
console.log(consulta);
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user