Compare commits
2 Commits
d3c943d574
...
e2afb25681
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2afb25681 | ||
|
|
1f49012644 |
4406
package-lock.json
generated
4406
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,6 @@
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs-modules/mailer": "^2.0.2",
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/config": "^4.0.2",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
@ -29,6 +28,7 @@
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/swagger": "^11.0.6",
|
||||
"@nestjs/typeorm": "^11.0.0",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
"axios": "^1.10.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.1",
|
||||
@ -37,7 +37,7 @@
|
||||
"joi": "^17.13.3",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"jwk-to-pem": "^2.0.7",
|
||||
"mssql": "^10.0.4",
|
||||
"mssql": "^11.0.1",
|
||||
"mysql2": "^3.12.0",
|
||||
"nodemailer": "^7.0.3",
|
||||
"oracledb": "^6.7.2",
|
||||
@ -66,7 +66,7 @@
|
||||
"@types/oracledb": "^6.5.4",
|
||||
"@types/supertest": "^6.0.2",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"eslint": "^9.18.0",
|
||||
"eslint": "^9.31.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-prettier": "^5.2.2",
|
||||
"globals": "^15.14.0",
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform, Type } from 'class-transformer';
|
||||
import { IsEmail, IsEnum, IsString, ValidateNested } from 'class-validator';
|
||||
import { IsEmail, IsEnum, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
|
||||
|
||||
export class AuthLoginDTO {
|
||||
@ApiProperty({ required: true })
|
||||
@ -51,16 +51,11 @@ export class MailTemplateDTO {
|
||||
@IsString()
|
||||
subject: string;
|
||||
|
||||
// @ApiProperty({ required: true })
|
||||
// @IsString()
|
||||
// text: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsString()
|
||||
template: string;
|
||||
templateName: string;
|
||||
|
||||
@ApiProperty({ type: () => MailContextDTO, required: true })
|
||||
@ValidateNested()
|
||||
@Type(() => MailContextDTO)
|
||||
context: MailContextDTO;
|
||||
@IsOptional()
|
||||
@IsObject()
|
||||
variables?: Record<string, any>;
|
||||
}
|
||||
@ -5,9 +5,10 @@ import { DbModule } from 'src/db/db.module';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { OracleModule } from 'src/oracle/oracle.module';
|
||||
import { MailModule } from 'src/mail/mail.module';
|
||||
|
||||
@Module({
|
||||
imports: [DbModule, forwardRef(() => OracleModule)],
|
||||
imports: [DbModule,MailModule, forwardRef(() => OracleModule)],
|
||||
providers: [
|
||||
AuthService,
|
||||
{
|
||||
|
||||
@ -10,10 +10,10 @@ import * as jwt from "jsonwebtoken"
|
||||
import { UnauthorizedException } from 'src/exceptions/unauthorized.exception';
|
||||
import { ConflictException } from 'src/exceptions/conflict.exception';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { MailerService } from '@nestjs-modules/mailer';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { UserMaintenanceService } from 'src/oracle/user-maintenance/user-maintenance.service';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { MailService } from 'src/mail/mail.service';
|
||||
|
||||
|
||||
interface DecodedToken {
|
||||
@ -43,7 +43,7 @@ export class AuthService {
|
||||
constructor(
|
||||
private readonly oracleDBService: OracleDBService,
|
||||
private readonly configService: ConfigService,
|
||||
private readonly mailService: MailerService,
|
||||
private readonly mailService: MailService,
|
||||
private readonly userMaintenanceService: UserMaintenanceService,
|
||||
@Inject("REGISTER_SIGN_JWT") readonly REGISTER_SIGN_JWT: JwtService,
|
||||
@Inject("REGISTER_VERIFY_JWT") readonly REGISTER_VERIFY_JWT: JwtService
|
||||
@ -759,47 +759,6 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
async getMailTemplate(body: SendMailDTO, token: string, source: string): Promise<MailTemplateDTO | null> {
|
||||
|
||||
switch (body.P_MAIL_TYPE) {
|
||||
case MailTypeDTO.REGISTER_CLIENT:
|
||||
return {
|
||||
to: body.P_TO,
|
||||
subject: `🔐 Register Your Account`,
|
||||
template: 'a',
|
||||
context: {
|
||||
to: body.P_TO,
|
||||
url: `https://client.alphaomegainfosys.com/register`
|
||||
}
|
||||
}
|
||||
case MailTypeDTO.FORGOT_PASSWORD:
|
||||
return {
|
||||
to: body.P_TO,
|
||||
subject: `Reset your password`,
|
||||
template: 'b',
|
||||
context: {
|
||||
to: body.P_TO,
|
||||
url: `${source === 'ua' ? `https://policy.alphaomegainfosys.com/forgot-password/${token}`
|
||||
: source === 'sa' ? `https://sp.alphaomegainfosys.com/forgot-password/${token}`
|
||||
: source === 'ca' ? `https://client.alphaomegainfosys.com/forgot-password/${token}` : ''}`
|
||||
}
|
||||
}
|
||||
|
||||
// case MailTypeDTO.DEMO_MAIL:
|
||||
// return {
|
||||
// to: body.P_TO,
|
||||
// subject: `Testing`,
|
||||
// template: 'demo',
|
||||
// context: {
|
||||
// to: body.P_TO,
|
||||
// url: `https://client.alphaomegainfosys.com/register/${token}`
|
||||
// }
|
||||
// }
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async generateUUID() {
|
||||
try {
|
||||
const uuid = uuidv4();
|
||||
@ -882,6 +841,36 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
async getMailTemplate(body: SendMailDTO, token: string, source: string): Promise<MailTemplateDTO | null> {
|
||||
|
||||
switch (body.P_MAIL_TYPE) {
|
||||
case MailTypeDTO.REGISTER_CLIENT:
|
||||
return {
|
||||
to: body.P_TO,
|
||||
subject: `🔐 Register Your Account`,
|
||||
templateName: 'a',
|
||||
variables: {
|
||||
to: body.P_TO,
|
||||
url: `https://client.alphaomegainfosys.com/register`
|
||||
}
|
||||
}
|
||||
case MailTypeDTO.FORGOT_PASSWORD:
|
||||
return {
|
||||
to: body.P_TO,
|
||||
subject: `Reset your password`,
|
||||
templateName: 'b',
|
||||
variables: {
|
||||
to: body.P_TO,
|
||||
url: `${source === 'ua' ? `https://policy.alphaomegainfosys.com/forgot-password/${token}`
|
||||
: source === 'sa' ? `https://sp.alphaomegainfosys.com/forgot-password/${token}`
|
||||
: source === 'ca' ? `https://client.alphaomegainfosys.com/forgot-password/${token}` : ''}`
|
||||
}
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async sendMail(body: SendMailDTO) {
|
||||
console.log("mail body : ", body);
|
||||
let token: string;
|
||||
|
||||
@ -1,34 +1,10 @@
|
||||
// import { MssqlConfig, OracleConfig } from 'ormconfig';
|
||||
import { createPool, Pool, Connection as cob } from 'oracledb';
|
||||
import { Connection, ConnectionPool } from 'mssql';
|
||||
import { createPool, Pool, Connection } from 'oracledb';
|
||||
import { ConnectionPool } from 'mssql';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { getMssqlConfig, getOracleConfig } from './db.config';
|
||||
|
||||
// @Injectable()
|
||||
// export class OracleDBService {
|
||||
// private pool: Pool;
|
||||
|
||||
// constructor() {
|
||||
// this.initializePool();
|
||||
// }
|
||||
|
||||
// private async initializePool() {
|
||||
// this.pool = await createPool({
|
||||
// ...OracleConfig,
|
||||
// poolMin: 1,
|
||||
// poolMax: 10,
|
||||
// poolIncrement: 1,
|
||||
// });
|
||||
// }
|
||||
|
||||
// async getConnection(): Promise<cob> {
|
||||
// const connection = await this.pool.getConnection();
|
||||
// return connection;
|
||||
// }
|
||||
// }
|
||||
|
||||
@Injectable()
|
||||
export class OracleDBService {
|
||||
private pool: Pool | null = null;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
import { MailerModule } from '@nestjs-modules/mailer';
|
||||
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { join } from 'path';
|
||||
import * as Joi from 'joi';
|
||||
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter';
|
||||
import { MailService } from './mail.service';
|
||||
import * as nodemailer from 'nodemailer';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
@ -14,15 +15,15 @@ import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handleba
|
||||
MAIL_PASS: Joi.string().required(),
|
||||
}),
|
||||
}),
|
||||
],
|
||||
|
||||
MailerModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: (configService: ConfigService) => {
|
||||
const templatePath = join(__dirname, '../../..', 'public', 'mail-templates');
|
||||
console.log('Resolved mail template path:', templatePath);
|
||||
|
||||
return {
|
||||
transport: {
|
||||
providers: [
|
||||
{
|
||||
provide: 'MAIL_TRANSPORTER',
|
||||
useFactory: async (configService: ConfigService) => {
|
||||
return nodemailer.createTransport(
|
||||
{
|
||||
// service: "gmail",
|
||||
host: 'smtp.gmail.com',
|
||||
port: 587,
|
||||
secure: false,
|
||||
@ -31,21 +32,18 @@ import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handleba
|
||||
pass: configService.get<string>('MAIL_PASS'),
|
||||
},
|
||||
},
|
||||
defaults: {
|
||||
{
|
||||
from: `"Carnet APP" <${configService.get<string>('MAIL_USER')}>`,
|
||||
},
|
||||
template: {
|
||||
dir: templatePath,
|
||||
adapter: new HandlebarsAdapter(),
|
||||
options: {
|
||||
strict: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
},
|
||||
inject: [ConfigService],
|
||||
}),
|
||||
},
|
||||
MailService,
|
||||
],
|
||||
exports: [MailService],
|
||||
|
||||
|
||||
})
|
||||
|
||||
export class MailModule { }
|
||||
|
||||
42
src/mail/mail.service.ts
Normal file
42
src/mail/mail.service.ts
Normal file
@ -0,0 +1,42 @@
|
||||
// mailer.service.ts
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { Transporter } from 'nodemailer';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as Handlebars from 'handlebars';
|
||||
import { MailTemplateDTO } from 'src/auth/auth.dto';
|
||||
|
||||
@Injectable()
|
||||
export class MailService {
|
||||
private templatesCache = new Map<string, Handlebars.TemplateDelegate>();
|
||||
|
||||
constructor(@Inject('MAIL_TRANSPORTER') private readonly transporter: Transporter) {
|
||||
console.log(path.join(process.cwd(), 'public', 'mail-templates', 'a.hbs'));
|
||||
|
||||
}
|
||||
|
||||
private loadTemplate(templateName: string): Handlebars.TemplateDelegate {
|
||||
if (this.templatesCache.has(templateName)) {
|
||||
return this.templatesCache.get(templateName)!;
|
||||
}
|
||||
|
||||
const templatePath = path.join(process.cwd(), 'public', 'mail-templates', `${templateName}.hbs`);
|
||||
const source = fs.readFileSync(templatePath, 'utf8');
|
||||
const compiled = Handlebars.compile(source);
|
||||
this.templatesCache.set(templateName, compiled);
|
||||
return compiled;
|
||||
}
|
||||
|
||||
async sendMail(data: MailTemplateDTO) {
|
||||
const template = this.loadTemplate(data.templateName);
|
||||
const html = template(data.variables);
|
||||
|
||||
const mailOptions = {
|
||||
to: data.to,
|
||||
subject: data.subject,
|
||||
html,
|
||||
};
|
||||
|
||||
return this.transporter.sendMail(mailOptions);
|
||||
}
|
||||
}
|
||||
@ -47,7 +47,7 @@ export class ManageClientsService {
|
||||
|
||||
const finalBody: CreateClientDataDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection: Connection; // Fixed duplicate declaration
|
||||
let connection: mssql.ConnectionPool; // Fixed duplicate declaration
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -98,7 +98,7 @@ export class ManageClientsService {
|
||||
};
|
||||
|
||||
GetPreparerByClientid = async (body: GetClientDTO) => {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -142,7 +142,7 @@ export class ManageClientsService {
|
||||
|
||||
const finalBody: UpdateClientDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
@ -196,7 +196,7 @@ export class ManageClientsService {
|
||||
...reqBody,
|
||||
};
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -272,7 +272,7 @@ export class ManageClientsService {
|
||||
|
||||
const finalBody: UpdateClientContactsDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -327,7 +327,7 @@ export class ManageClientsService {
|
||||
|
||||
const finalBody: UpdateClientLocationsDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -379,7 +379,7 @@ export class ManageClientsService {
|
||||
...reqBody,
|
||||
};
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -452,7 +452,7 @@ export class ManageClientsService {
|
||||
...reqBody,
|
||||
};
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -505,7 +505,7 @@ export class ManageClientsService {
|
||||
...reqBody,
|
||||
};
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -553,7 +553,7 @@ export class ManageClientsService {
|
||||
...reqBody,
|
||||
};
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -20,7 +20,7 @@ export class ManageFeeService {
|
||||
// Basic Fee Setup
|
||||
|
||||
async GETBASICFEERATES(body: GetFeeGeneralDTO): Promise<any[] | Object> {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -41,7 +41,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async CREATEBASICFEE(body: CreateBasicFeeDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -63,7 +63,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async UPDATEBASICFEE(body: UpdateBasicFeeDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -86,7 +86,7 @@ export class ManageFeeService {
|
||||
|
||||
async GETBONDRATES(body: GetFeeGeneralDTO): Promise<any[] | object> {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -111,7 +111,7 @@ export class ManageFeeService {
|
||||
|
||||
async CREATEBONDRATE(body: CreateBondRateDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -138,7 +138,7 @@ export class ManageFeeService {
|
||||
|
||||
async UPDATEBONDRATE(body: UpdateBondRateDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -161,7 +161,7 @@ export class ManageFeeService {
|
||||
// CArgo Rate
|
||||
|
||||
async GETCARGORATES(body: GetFeeGeneralDTO): Promise<any[] | object> {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -185,7 +185,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async CREATECARGORATE(body: CreateCargoRateDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -209,7 +209,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async UPDATECARGORATE(body: UpdateCargoRateDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -233,7 +233,7 @@ export class ManageFeeService {
|
||||
|
||||
async GETCFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -258,7 +258,7 @@ export class ManageFeeService {
|
||||
|
||||
async CREATECFFEE(body: CreateCfFeeDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -285,7 +285,7 @@ export class ManageFeeService {
|
||||
|
||||
async UPDATECFFEE(body: UpdateCfFeeDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -308,7 +308,7 @@ export class ManageFeeService {
|
||||
// Continuation sheet
|
||||
|
||||
async GETCSFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -333,7 +333,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async CREATECSFEE(body: CreateCsFeeDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -357,7 +357,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async UPDATECSFEE(body: UpdateCsFeeDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -381,7 +381,7 @@ export class ManageFeeService {
|
||||
|
||||
async GETEFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -405,7 +405,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async CREATEEFFEE(body: CreateEfFeeDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -432,7 +432,7 @@ export class ManageFeeService {
|
||||
|
||||
async UPDATEEFFEE(body: UpdateEfFeeDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -456,7 +456,7 @@ export class ManageFeeService {
|
||||
|
||||
async GETFEECOMM(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -483,7 +483,7 @@ export class ManageFeeService {
|
||||
|
||||
async CREATEFEECOMM(body: CreateFeeCommDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -507,7 +507,7 @@ export class ManageFeeService {
|
||||
}
|
||||
|
||||
async UPDATEFEECOMM(body: UpdateFeeCommDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -45,7 +45,7 @@ export class ManageHoldersService {
|
||||
|
||||
const finalBody: CreateHoldersDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
@ -103,7 +103,7 @@ export class ManageHoldersService {
|
||||
};
|
||||
|
||||
GetHolderRecord = async (body: GetHolderDTO) => {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
@ -119,7 +119,7 @@ export class ManageHoldersService {
|
||||
};
|
||||
|
||||
UpdateHolder = async (body: UpdateHolderDTO) => {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new mssql.Request(connection);
|
||||
@ -153,7 +153,7 @@ export class ManageHoldersService {
|
||||
|
||||
UpdateHolderContact = async (body: UpdateHolderContactDTO) => {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new mssql.Request(connection);
|
||||
@ -181,7 +181,7 @@ export class ManageHoldersService {
|
||||
|
||||
GetHolderContacts = async (body: GetHolderDTO) => {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
@ -200,7 +200,7 @@ export class ManageHoldersService {
|
||||
|
||||
console.log(body);
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
@ -216,7 +216,7 @@ export class ManageHoldersService {
|
||||
};
|
||||
|
||||
ReactivateHolder = async (body: HolderActivateOrInactivateDTO) => {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
@ -233,7 +233,7 @@ export class ManageHoldersService {
|
||||
};
|
||||
|
||||
InactivateHolderContact = async (body: HolderContactActivateOrInactivateDTO) => {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
@ -250,7 +250,7 @@ export class ManageHoldersService {
|
||||
};
|
||||
|
||||
ReactivateHolderContact = async (body: HolderContactActivateOrInactivateDTO) => {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import * as mssql from 'mssql';
|
||||
|
||||
@Injectable()
|
||||
export class MssqlService {
|
||||
@ -8,7 +9,7 @@ export class MssqlService {
|
||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||
|
||||
async checkConnection() {
|
||||
let connection : Connection;
|
||||
let connection : mssql.ConnectionPool;
|
||||
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
|
||||
@ -20,7 +20,7 @@ export class ParamTableService {
|
||||
console.log(finalBody);
|
||||
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -35,7 +35,7 @@ export class ParamTableService {
|
||||
}
|
||||
|
||||
async CREATETABLERECORD(body: CreateTableRecordDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -57,7 +57,7 @@ export class ParamTableService {
|
||||
}
|
||||
|
||||
async CREATEPARAMRECORD(body: CreateParamRecordDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -87,7 +87,7 @@ export class ParamTableService {
|
||||
}
|
||||
|
||||
async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -116,7 +116,7 @@ export class ParamTableService {
|
||||
|
||||
async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -136,7 +136,7 @@ export class ParamTableService {
|
||||
}
|
||||
|
||||
async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -12,7 +12,7 @@ export class CarnetSequenceService {
|
||||
|
||||
async getCarnetSequence(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -26,7 +26,7 @@ export class CarnetSequenceService {
|
||||
}
|
||||
|
||||
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -11,7 +11,7 @@ export class RegionService {
|
||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||
|
||||
async getRegions() {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -24,7 +24,7 @@ export class RegionService {
|
||||
|
||||
async insetNewRegions(body: InsertRegionsDto) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -39,7 +39,7 @@ export class RegionService {
|
||||
}
|
||||
|
||||
async updateRegions(body: UpdateRegionDto){
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -15,7 +15,7 @@ export class SpContactsService {
|
||||
|
||||
async getSpAllContacts(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -30,7 +30,7 @@ export class SpContactsService {
|
||||
|
||||
async getSPDefaultcontacts(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -45,7 +45,7 @@ export class SpContactsService {
|
||||
|
||||
async inactivateSPContact(body: SP_CONTACTID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -59,7 +59,7 @@ export class SpContactsService {
|
||||
}
|
||||
|
||||
async insertSPContacts(body: InsertSPContactsDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -83,7 +83,7 @@ export class SpContactsService {
|
||||
}
|
||||
|
||||
async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -97,7 +97,7 @@ export class SpContactsService {
|
||||
}
|
||||
|
||||
async updateSPContacts(body: UpdateSPContactsDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -12,7 +12,7 @@ export class SpService {
|
||||
|
||||
async getAllServiceproviders() {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -26,7 +26,7 @@ export class SpService {
|
||||
|
||||
async getSpBySpid(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -40,7 +40,7 @@ export class SpService {
|
||||
}
|
||||
|
||||
async insertNewServiceProvider(body: InsertNewServiceProviderDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
@ -69,7 +69,7 @@ export class SpService {
|
||||
}
|
||||
|
||||
async updateServiceProvider(body: UpdateServiceProviderDTO) {
|
||||
let connection: Connection;
|
||||
let connection: mssql.ConnectionPool;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
|
||||
@ -36,6 +36,11 @@ export class ParamTableController {
|
||||
return this.paramTableService.GETPARAMVALUES(body);
|
||||
}
|
||||
|
||||
@Get('GetCountriesAndMessages')
|
||||
GET_COUNTRIES_AND_MESSAGES() {
|
||||
return this.GET_COUNTRIES_AND_MESSAGES();
|
||||
}
|
||||
|
||||
@Post('/CreateTableRecord')
|
||||
createTableRecord(@Body() body: CreateTableRecordDTO) {
|
||||
return this.paramTableService.CREATETABLERECORD(body);
|
||||
|
||||
@ -63,6 +63,38 @@ export class ParamTableService {
|
||||
}
|
||||
}
|
||||
|
||||
async GET_COUNTRIES_AND_MESSAGES() {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
MANAGEPARAMTABLE_PKG.GetCountriesAndMessages(:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
|
||||
|
||||
} catch (error) {
|
||||
handleError(error, ParamTableService.name)
|
||||
} finally {
|
||||
await closeOracleDbConnection(connection, ParamTableService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async CREATETABLERECORD(body: CreateTableRecordDTO) {
|
||||
|
||||
let connection;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user