modifying

This commit is contained in:
Kallesh B S 2025-06-06 12:20:22 +05:30
parent eaea8de3a5
commit 8837e88a9b
9 changed files with 107 additions and 1476 deletions

View File

@ -1,5 +1,5 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger"; import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { Type } from "class-transformer"; import { Transform, Type } from "class-transformer";
import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator"; import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator";
import { import {
@ -11,12 +11,13 @@ import {
export class CLIENTID_DTO { export class CLIENTID_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@Max(999999999, { @Max(999999999, {
message: 'Property p_clientid must not exceed 999999999', message: 'Property P_CLIENTID must not exceed 999999999',
}) })
@Min(0, { message: 'Property p_clientid must be at least 0 or more' }) @Min(0, { message: 'Property P_CLIENTID must be at least 0 or more' })
@IsInt({ message: 'Property p_clientid allows only whole numbers' }) @IsInt({ message: 'Property P_CLIENTID allows only whole numbers' })
@IsNumber({}, { message: 'Property p_clientid must be a number' }) @IsNumber({}, { message: 'Property P_CLIENTID must be a number' })
@IsDefined({ message: 'Property p_clientid is required' }) @Transform(({ value }) => Number(value))
@IsDefined({ message: 'Property P_CLIENTID is required' })
P_CLIENTID: number; P_CLIENTID: number;
} }

View File

@ -9,12 +9,16 @@ import {
CONTACTSTABLE_ROW_DTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, CONTACTSTABLE_ROW_DTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO,
HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO
} from 'src/dto/property.dto'; } from 'src/dto/property.dto';
import { OracleService } from '../oracle.service';
@Injectable() @Injectable()
export class ManageHoldersService { export class ManageHoldersService {
private readonly logger = new Logger(ManageHoldersService.name); private readonly logger = new Logger(ManageHoldersService.name);
constructor(private readonly oracleDBService: OracleDBService) { } constructor(
private readonly oracleDBService: OracleDBService,
private readonly OracleService: OracleService
) { }
// CreateHoldersX = async (body: CreateHoldersDTO) => { // CreateHoldersX = async (body: CreateHoldersDTO) => {
// const newBody = { // const newBody = {
@ -390,8 +394,8 @@ export class ManageHoldersService {
) )
: []; : [];
// Create an instance of GLTABLE // const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSARRAY);
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSARRAY); const CONTACTSTABLE_INSTANCE = await this.OracleService.get_CONTACTS_TABLE_INSTANCE(finalBody)
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN

View File

@ -1,6 +1,6 @@
import { Injectable, Logger } from "@nestjs/common"; import { Injectable, Logger } from "@nestjs/common";
import { OracleDBService } from "src/db/db.service"; import { OracleDBService } from "src/db/db.service";
import { COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO } from "src/dto/property.dto"; import { CONTACTSTABLE_ROW_DTO, COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO } from "src/dto/property.dto";
import { InternalServerException } from "src/exceptions/internalServerError.exception"; import { InternalServerException } from "src/exceptions/internalServerError.exception";
import { closeOracleDbConnection, handleError } from "src/utils/helper"; import { closeOracleDbConnection, handleError } from "src/utils/helper";
@ -118,4 +118,65 @@ export class OracleService {
await closeOracleDbConnection(connection, OracleService.name) await closeOracleDbConnection(connection, OracleService.name)
} }
} }
async get_CONTACTS_TABLE_INSTANCE(finalBody: any) {
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' }
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }
let connection;
try {
connection = await this.oracleDBService.getConnection();
const CONTACTSTABLE = await connection.getDbObjectClass('CARNETSYS.CONTACTSTABLE');
if (typeof CONTACTSTABLE !== 'function') {
throw new Error('CONTACTSTABLE is not a constructor');
}
async function CREATECONTACTSTABLE_INSTANCE(
connection, FirstName, LastName, MiddleInitial,
Title, EmailAddress, PhoneNo, MobileNo, FaxNo,
) {
const result = await connection.execute(
`SELECT CARNETSYS.CONTACTSARRAY(
:FirstName, :LastName, :MiddleInitial, :Title,
:EmailAddress, :PhoneNo, :MobileNo, :FaxNo
) FROM dual`,
{
FirstName, LastName, MiddleInitial, Title,
EmailAddress, PhoneNo, MobileNo, FaxNo,
},
);
return result.rows?.[0]?.[0] ?? [];
}
const CONTACTSARRAY = finalBody.P_CONTACTSTABLE
? await Promise.all(
finalBody.P_CONTACTSTABLE.map(async (x: CONTACTSTABLE_ROW_DTO) => {
return await CREATECONTACTSTABLE_INSTANCE(
connection,
x.P_FIRSTNAME,
x.P_LASTNAME,
x.P_MIDDLEINITIAL,
x.P_TITLE,
x.P_EMAILADDRESS,
x.P_PHONENO,
x.P_MOBILENO,
x.P_FAXNO,
);
}),
)
: [];
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSARRAY);
return CONTACTSTABLE_INSTANCE;
} catch (error) {
throw new Error("Error occured completing this process")
} finally {
await closeOracleDbConnection(connection, OracleService.name)
}
}
} }

View File

@ -17,80 +17,6 @@ export class ParamTableService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
// async GETPARAMVALUESX(body: getParamValuesDTO) {
// const finalBody = {
// P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null,
// P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null,
// };
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.GETPARAMVALUES(:P_SPID,:P_PARAMTYPE,:P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: finalBody.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMTYPE: {
// val: finalBody.P_PARAMTYPE,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// return rows;
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// this.logger.warn(error.message);
// throw new BadRequestException();
// }
// this.logger.error('GETPARAMVALUES failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async GETPARAMVALUES(body: getParamValuesDTO) { async GETPARAMVALUES(body: getParamValuesDTO) {
const finalBody = { const finalBody = {
P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null, P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null,
@ -137,65 +63,6 @@ export class ParamTableService {
} }
} }
// async CREATETABLERECORDX(body: CreateTableRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.CREATETABLERECORD(:P_USERID,:P_TABLEFULLDESC,:P_CURSOR);
// END;`,
// {
// P_TABLEFULLDESC: {
// val: body.P_TABLEFULLDESC,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('CREATETABLERECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async CREATETABLERECORD(body: CreateTableRecordDTO) { async CREATETABLERECORD(body: CreateTableRecordDTO) {
let connection; let connection;
@ -238,115 +105,6 @@ export class ParamTableService {
} }
} }
// async CREATEPARAMRECORDX(body: CreateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD(
// :P_SPID,
// :P_PARAMTYPE,
// :P_PARAMDESC,
// :P_PARAMVALUE,
// :P_ADDLPARAMVALUE1,
// :P_ADDLPARAMVALUE2,
// :P_ADDLPARAMVALUE3,
// :P_ADDLPARAMVALUE4,
// :P_ADDLPARAMVALUE5,
// :P_SORTSEQ,
// :P_USERID,
// :P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMTYPE: {
// val: body.P_PARAMTYPE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_PARAMDESC: {
// val: body.P_PARAMDESC,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_PARAMVALUE: {
// val: body.P_PARAMVALUE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE1: {
// val: body.P_ADDLPARAMVALUE1,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE2: {
// val: body.P_ADDLPARAMVALUE2,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE3: {
// val: body.P_ADDLPARAMVALUE3,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE4: {
// val: body.P_ADDLPARAMVALUE4,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE5: {
// val: body.P_ADDLPARAMVALUE5,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_SORTSEQ: {
// val: body.P_SORTSEQ,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// throw new BadRequestException();
// }
// this.logger.error('CREATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async CREATEPARAMRECORD(body: CreateParamRecordDTO) { async CREATEPARAMRECORD(body: CreateParamRecordDTO) {
let connection; let connection;
@ -410,108 +168,6 @@ export class ParamTableService {
} }
} }
// async UPDATEPARAMRECORDX(body: UpdateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD(
// :P_SPID,
// :P_PARAMID,
// :P_PARAMDESC,
// :P_ADDLPARAMVALUE1,
// :P_ADDLPARAMVALUE2,
// :P_ADDLPARAMVALUE3,
// :P_ADDLPARAMVALUE4,
// :P_ADDLPARAMVALUE5,
// :P_SORTSEQ,
// :P_USERID,
// :P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMID: {
// val: body.P_PARAMID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMDESC: {
// val: body.P_PARAMDESC,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE1: {
// val: body.P_ADDLPARAMVALUE1,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE2: {
// val: body.P_ADDLPARAMVALUE2,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE3: {
// val: body.P_ADDLPARAMVALUE3,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE4: {
// val: body.P_ADDLPARAMVALUE4,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE5: {
// val: body.P_ADDLPARAMVALUE5,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_SORTSEQ: {
// val: body.P_SORTSEQ,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('UPDATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) { async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) {
let connection; let connection;
@ -573,48 +229,6 @@ export class ParamTableService {
} }
} }
// async INACTIVATEPARAMRECORDX(body: ActivateOrInactivateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.INACTIVATEPARAMRECORD(
// :P_PARAMID,
// :P_USERID);
// END;`,
// {
// P_PARAMID: {
// val: body.P_PARAMID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Inactivated Successfully' };
// } catch (error) {
// this.logger.error('INACTIVATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) { async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
let connection; let connection;
@ -649,48 +263,6 @@ export class ParamTableService {
} }
} }
// async REACTIVATEPARAMRECORDX(body: ActivateOrInactivateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD(
// :P_PARAMID,
// :P_USERID);
// END;`,
// {
// P_PARAMID: {
// val: body.P_PARAMID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Reactivated Successfully' };
// } catch (error) {
// this.logger.error('REACTIVATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) { async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
let connection; let connection;

View File

@ -140,67 +140,43 @@ export class CarnetSequenceService {
async getCarnetSequenceX(body: SPID_DTO) { async getCarnetSequenceX(body: SPID_DTO) {
let connection; let connection;
let rows = [];
try { try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR); USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR);
END;`, END;`,
{ {
P_SPID: { P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
val: body.P_SPID, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
type: oracledb.DB_TYPE_NUMBER,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
}, },
{ {
outFormat: oracledb.OUT_FORMAT_OBJECT, outFormat: oracledb.OUT_FORMAT_OBJECT,
}, }
); );
if (result.outBinds && result.outBinds.P_CURSOR) { // await connection.commit();
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do { const outBinds = result.outBinds;
rowsBatch = await cursor.getRows(100); if (!outBinds?.P_CURSOR) {
rows = rows.concat(rowsBatch); this.logger.error('One or more expected cursors are missing from stored procedure output.');
} while (rowsBatch.length > 0); throw new InternalServerException("Incomplete data received from the database.");
await cursor.close();
} else {
throw new BadRequestException();
} }
return rows; let fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetSequenceService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return fres;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, CarnetSequenceService.name)
this.logger.warn(error.message);
throw error;
}
else if (error.message === "NJS-107: invalid cursor") {
this.logger.warn(error.message);
throw new BadRequestException();
}
this.logger.error('getCarnetSequence failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, CarnetSequenceService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }

View File

@ -13,64 +13,6 @@ export class RegionService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
// async insertRegionsX(body: InsertRegionsDto) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
// END;`,
// {
// P_REGION: {
// val: body.P_REGION,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_NAME: {
// val: body.P_NAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('insertRegions failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async insertRegions(body: InsertRegionsDto) { async insertRegions(body: InsertRegionsDto) {
let connection; let connection;
@ -113,65 +55,6 @@ export class RegionService {
} }
} }
// async updateRegionsX(body: UpdateRegionDto) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.UpdateRegion(:P_REGIONID,:P_NAME,:P_CURSOR);
// END;`,
// {
// P_REGIONID: {
// val: body.P_REGIONID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_NAME: {
// val: body.P_NAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('updateRegions failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async updateRegions(body: UpdateRegionDto) { async updateRegions(body: UpdateRegionDto) {
let connection; let connection;
try { try {
@ -211,68 +94,6 @@ export class RegionService {
await closeOracleDbConnection(connection, RegionService.name) await closeOracleDbConnection(connection, RegionService.name)
} }
} }
// async getRegionsX() {
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException()
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
// END;`,
// {
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// return rows;
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// this.logger.warn(error.message);
// throw new BadRequestException();
// }
// this.logger.error('GETBASICFEERATES failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getRegions() { async getRegions() {
let connection; let connection;

View File

@ -5,10 +5,11 @@ import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper'; import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO, import {
SPID_DTO,
SP_CONTACTID_DTO, SP_CONTACTID_DTO,
InsertSPContactsDTO,UpdateSPContactsDTO InsertSPContactsDTO, UpdateSPContactsDTO
} from 'src/dto/property.dto'; } from 'src/dto/property.dto';
@Injectable() @Injectable()
export class SpContactsService { export class SpContactsService {
@ -16,111 +17,6 @@ export class SpContactsService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
// async insertSPContactsX(body: InsertSPContactsDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.InsertSPContacts(
// :P_SPID,
// :P_DEFCONTACTFLAG,
// :P_FIRSTNAME,
// :P_LASTNAME,
// :P_MIDDLEINITIAL,
// :P_TITLE,
// :P_PHONENO,
// :P_MOBILENO,
// :P_FAXNO,
// :P_EMAILADDRESS,
// :P_USER_ID,
// :P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_DEFCONTACTFLAG: {
// val: body.P_DEFCONTACTFLAG,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_FIRSTNAME: {
// val: body.P_FIRSTNAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_LASTNAME: {
// val: body.P_LASTNAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_MIDDLEINITIAL: {
// val: body.P_MIDDLEINITIAL,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_TITLE: {
// val: body.P_TITLE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_PHONENO: {
// val: body.P_PHONENO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_MOBILENO: {
// val: body.P_MOBILENO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_FAXNO: {
// val: body.P_FAXNO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_EMAILADDRESS: {
// val: body.P_EMAILADDRESS,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_USER_ID: {
// val: body.P_USER_ID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// throw error;
// }
// this.logger.error('insertSPContacts failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async insertSPContacts(body: InsertSPContactsDTO) { async insertSPContacts(body: InsertSPContactsDTO) {
@ -131,17 +27,9 @@ export class SpContactsService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.InsertSPContacts( USCIB_Managed_Pkg.InsertSPContacts(
:P_SPID, :P_SPID, :P_DEFCONTACTFLAG, :P_FIRSTNAME, :P_LASTNAME,
:P_DEFCONTACTFLAG, :P_MIDDLEINITIAL, :P_TITLE, :P_PHONENO, :P_MOBILENO,
:P_FIRSTNAME, :P_FAXNO, :P_EMAILADDRESS, :P_USER_ID,
:P_LASTNAME,
:P_MIDDLEINITIAL,
:P_TITLE,
:P_PHONENO,
:P_MOBILENO,
:P_FAXNO,
:P_EMAILADDRESS,
:P_USER_ID,
:P_CURSOR); :P_CURSOR);
END;`, END;`,
{ {
@ -185,43 +73,6 @@ export class SpContactsService {
} }
} }
// async setSPDefaultcontactX(body: SP_CONTACTID_DTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.SetDefaultContact(:P_SPCONTACTID);
// END;`,
// {
// P_SPCONTACTID: {
// val: body.P_SPCONTACTID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Default contact was added successfully for SP' };
// } catch (error) {
// this.logger.error('setSPDefaultcontact failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async setSPDefaultcontact(body: SP_CONTACTID_DTO) { async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
let connection; let connection;
@ -255,108 +106,6 @@ export class SpContactsService {
} }
} }
// async updateSPContactsX(body: UpdateSPContactsDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.UpdateSPContacts(
// :P_SPCONTACTID,
// :P_FIRSTNAME,
// :P_LASTNAME,
// :P_MIDDLEINITIAL,
// :P_TITLE,
// :P_PHONENO,
// :P_MOBILENO,
// :P_FAXNO,
// :P_EMAILADDRESS,
// :P_USER_ID,
// :P_CURSOR);
// END;`,
// {
// P_SPCONTACTID: {
// val: body.P_SPCONTACTID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_FIRSTNAME: {
// val: body.P_FIRSTNAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_LASTNAME: {
// val: body.P_LASTNAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_MIDDLEINITIAL: {
// val: body.P_MIDDLEINITIAL,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_TITLE: {
// val: body.P_TITLE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_PHONENO: {
// val: body.P_PHONENO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_MOBILENO: {
// val: body.P_MOBILENO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_FAXNO: {
// val: body.P_FAXNO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_EMAILADDRESS: {
// val: body.P_EMAILADDRESS,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_USER_ID: {
// val: body.P_USER_ID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 200, message: "Updated Successfully" };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('updateSPContacts failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async updateSPContacts(body: UpdateSPContactsDTO) { async updateSPContacts(body: UpdateSPContactsDTO) {
let connection; let connection;
@ -366,17 +115,9 @@ export class SpContactsService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.UpdateSPContacts( USCIB_Managed_Pkg.UpdateSPContacts(
:P_SPCONTACTID, :P_SPCONTACTID, :P_FIRSTNAME, :P_LASTNAME, :P_MIDDLEINITIAL,
:P_FIRSTNAME, :P_TITLE, :P_PHONENO, :P_MOBILENO, :P_FAXNO,
:P_LASTNAME, :P_EMAILADDRESS, :P_USER_ID, :P_CURSOR);
:P_MIDDLEINITIAL,
:P_TITLE,
:P_PHONENO,
:P_MOBILENO,
:P_FAXNO,
:P_EMAILADDRESS,
:P_USER_ID,
:P_CURSOR);
END;`, END;`,
{ {
P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }, P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER },
@ -418,43 +159,6 @@ export class SpContactsService {
} }
} }
// async inactivateSPContactX(body: SP_CONTACTID_DTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.InActivateSPContacts(:P_SPCONTACTID);
// END;`,
// {
// P_SPCONTACTID: {
// val: body.P_SPCONTACTID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Inactivated SP contact successfully' };
// } catch (error) {
// this.logger.error('inactivateSPContact failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async inactivateSPContact(body: SP_CONTACTID_DTO) { async inactivateSPContact(body: SP_CONTACTID_DTO) {
let connection; let connection;
@ -488,63 +192,6 @@ export class SpContactsService {
} }
} }
// async getSPDefaultcontactsX(body: SPID_DTO) {
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetSPDefaultContacts(:P_SPID,:P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// return rows;
// } catch (error) {
// this.logger.error('getSPDefaultcontacts failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getSPDefaultcontacts(body: SPID_DTO) { async getSPDefaultcontacts(body: SPID_DTO) {
let connection; let connection;
@ -553,7 +200,7 @@ export class SpContactsService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetSPDefaultContacts(:P_SPID,:P_CURSOR); USCIB_Managed_Pkg.GetSPDefaultContacts(:P_SPID, :P_CURSOR);
END;`, END;`,
{ {
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
@ -579,64 +226,6 @@ export class SpContactsService {
} }
} }
// async getSPAllContactsX(body: SPID_DTO) {
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetSPAllContacts(:P_SPID,:P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// return rows;
// } catch (error) {
// this.logger.error('getSPAllContacts failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getSPAllContacts(body: SPID_DTO) { async getSPAllContacts(body: SPID_DTO) {
let connection; let connection;
@ -645,7 +234,7 @@ export class SpContactsService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetSPAllContacts(:P_SPID,:P_CURSOR); USCIB_Managed_Pkg.GetSPAllContacts(:P_SPID, :P_CURSOR);
END;`, END;`,
{ {
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },

View File

@ -16,87 +16,6 @@ export class SpService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
// async insertNewServiceProviderX(body: InsertNewServiceProviderDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.InsertNewSP(
// :P_NAME,
// :P_LOOKUPCODE,
// :P_ADDRESS1,
// :P_ADDRESS2,
// :P_CITY,
// :P_STATE,
// :P_ZIP,
// :P_COUNTRY,
// :P_ISSUINGREGION,
// :P_REPLACEMENTREGION,
// :P_BONDSURETY,
// :P_CARGOPOLICYNO,
// :P_CARGOSURETY,
// :P_USER_ID,
// :P_NOTES,
// :P_FILEIDS,
// :P_CURSOR);
// END;`,
// {
// P_NAME: { val: body.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
// P_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
// P_ADDRESS1: { val: body.P_ADDRESS1, type: oracledb.DB_TYPE_VARCHAR },
// P_ADDRESS2: { val: body.P_ADDRESS2, type: oracledb.DB_TYPE_VARCHAR },
// P_CITY: { val: body.P_CITY, type: oracledb.DB_TYPE_VARCHAR },
// P_STATE: { val: body.P_STATE, type: oracledb.DB_TYPE_VARCHAR },
// P_ZIP: { val: body.P_ZIP, type: oracledb.DB_TYPE_VARCHAR },
// P_COUNTRY: { val: body.P_COUNTRY, type: oracledb.DB_TYPE_VARCHAR },
// P_ISSUINGREGION: { val: body.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
// P_REPLACEMENTREGION: { val: body.P_REPLACEMENTREGION, type: oracledb.DB_TYPE_VARCHAR },
// P_BONDSURETY: { val: body.P_BONDSURETY, type: oracledb.DB_TYPE_VARCHAR },
// P_CARGOPOLICYNO: { val: body.P_CARGOPOLICYNO, type: oracledb.DB_TYPE_VARCHAR },
// P_CARGOSURETY: { val: body.P_CARGOSURETY, type: oracledb.DB_TYPE_VARCHAR },
// P_USER_ID: { val: body.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
// P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
// P_FILEIDS: { val: body.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// // return fres[0];
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('insertNewServiceProvider failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async insertNewServiceProvider(body: InsertNewServiceProviderDTO) { async insertNewServiceProvider(body: InsertNewServiceProviderDTO) {
const newBody = { const newBody = {
@ -202,177 +121,6 @@ export class SpService {
} }
} }
// async updateServiceProviderX(body: UpdateServiceProviderDTO) {
// const newBody = {
// p_spid: null,
// p_name: null,
// P_LOOKUPCODE: null,
// P_ADDRESS1: null,
// P_ADDRESS2: null,
// P_CITY: null,
// P_STATE: null,
// P_ZIP: null,
// P_COUNTRY: null,
// P_ISSUINGREGION: null,
// P_REPLACEMENTREGION: null,
// P_BONDSURETY: null,
// P_CARGOPOLICYNO: null,
// P_CARGOSURETY: null,
// P_USER_ID: null
// };
// const reqBody = JSON.parse(JSON.stringify(body));
// function setEmptyStringsToNull(obj) {
// Object.keys(obj).forEach((key) => {
// if (typeof obj[key] === 'object' && obj[key] !== null) {
// setEmptyStringsToNull(obj[key]);
// } else if (obj[key] === '') {
// obj[key] = null;
// }
// });
// }
// setEmptyStringsToNull(reqBody);
// const finalBody: UpdateServiceProviderDTO = { ...newBody, ...reqBody };
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.UpdateSP(
// :P_SPID,
// :P_NAME,
// :P_LOOKUPCODE,
// :P_ADDRESS1,
// :P_ADDRESS2,
// :P_CITY,
// :P_STATE,
// :P_ZIP,
// :P_COUNTRY,
// :P_BONDSURETY,
// :P_CARGOPOLICYNO,
// :P_CARGOSURETY,
// :P_REPLACEMENTREGION,
// :P_ISSUINGREGION,
// :P_USER_ID,
// :P_NOTES,
// :P_FILEIDS,
// :P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: finalBody.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_NAME: {
// val: finalBody.P_NAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_LOOKUPCODE: {
// val: finalBody.P_LOOKUPCODE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDRESS1: {
// val: finalBody.P_ADDRESS1,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDRESS2: {
// val: finalBody.P_ADDRESS2,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CITY: {
// val: finalBody.P_CITY,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_STATE: {
// val: finalBody.P_STATE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ZIP: {
// val: finalBody.P_ZIP,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_COUNTRY: {
// val: finalBody.P_COUNTRY,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_BONDSURETY: {
// val: finalBody.P_BONDSURETY,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CARGOPOLICYNO: {
// val: finalBody.P_CARGOPOLICYNO,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CARGOSURETY: {
// val: finalBody.P_CARGOSURETY,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_REPLACEMENTREGION: {
// val: finalBody.P_REPLACEMENTREGION,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ISSUINGREGION: {
// val: finalBody.P_ISSUINGREGION,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_USER_ID: {
// val: finalBody.P_USER_ID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_NOTES: {
// val: finalBody.P_NOTES,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_FILEIDS: {
// val: finalBody.P_FILEIDS,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 200, message: "Updated Successfully" };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('updateServiceProvider failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async updateServiceProvider(body: UpdateServiceProviderDTO) { async updateServiceProvider(body: UpdateServiceProviderDTO) {
const newBody = { const newBody = {
@ -480,66 +228,6 @@ export class SpService {
} }
} }
// async getAllServiceprovidersX() {
// let connection;
// let rows: any = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetAllSPs(:P_CURSOR);
// END;`,
// {
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// if (rows.length > 0 && rows[0].ERRORMESG) {
// throw new BadRequestException(rows[0].ERRORMESG);
// }
// return rows;
// } else {
// throw new BadRequestException();
// }
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('getAllServiceproviders failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getAllServiceproviders() { async getAllServiceproviders() {
@ -572,74 +260,6 @@ export class SpService {
} }
} }
// async getServiceproviderByIDX(body: SPID_DTO) {
// let connection;
// let rows: any = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetSPbySPID(:P_SPID,:P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// if (rows.length > 0 && rows[0].ERRORMESG) {
// throw new BadRequestException(rows[0].ERRORMESG);
// }
// return rows;
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// this.logger.warn(error.message);
// throw new BadRequestException();
// }
// this.logger.error('getServiceproviderByID failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getServiceproviderByID(body: SPID_DTO) { async getServiceproviderByID(body: SPID_DTO) {

View File

@ -30,19 +30,6 @@ export class UserMaintenanceService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
// private async fetchCursor<T>(cursor: oracledb.ResultSet<T>): Promise<T[]> {
// try {
// const rows = await cursor.getRows(); // or getRows(1000) if needed
// await cursor.close();
// return rows;
// } catch (err) {
// this.logger.error('Failed to fetch from cursor', err.stack || err);
// throw new InternalServerException("Error reading data from database.");
// }
// }
// SP_USER_DETAILS
async GetSPUserDetails(body: USERID_DTO): Promise<any> { async GetSPUserDetails(body: USERID_DTO): Promise<any> {
let connection; let connection;