added remaining manage holders api
This commit is contained in:
parent
03e8568fa2
commit
284c323235
@ -1,6 +1,6 @@
|
|||||||
import { Body, Controller, Get, Param, ParseIntPipe, Post, Put, UsePipes, ValidationPipe } from '@nestjs/common';
|
import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put, UsePipes, ValidationPipe } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { CreateHoldersDTO, GetHolderRecordDTO, UpdateHolderDTO } from './manage-holders.dto';
|
import { CreateHoldersDTO, GetHolderContactActivateOrInactivateDTO, GetHolderOrContactDTO, UpdateHolderContactDTO, UpdateHolderDTO } from './manage-holders.dto';
|
||||||
import { ManageHoldersService } from './manage-holders.service';
|
import { ManageHoldersService } from './manage-holders.service';
|
||||||
import { CustomParseIntPipe } from 'src/custom-pipe/custom-parseInt-pipe.service';
|
import { CustomParseIntPipe } from 'src/custom-pipe/custom-parseInt-pipe.service';
|
||||||
|
|
||||||
@ -22,14 +22,75 @@ export class ManageHoldersController {
|
|||||||
return this.manageHoldersService.UpdateHolder(body);
|
return this.manageHoldersService.UpdateHolder(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Put('/UpdateHolderContact')
|
||||||
|
UpdateHolderContact(@Body() body: UpdateHolderContactDTO) {
|
||||||
|
return this.manageHoldersService.UpdateHolderContact(body);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiTags('Manage Holders - Oracle')
|
@ApiTags('Manage Holders - Oracle')
|
||||||
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
||||||
GetHolderMaster(
|
GetHolderMaster(
|
||||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||||
){
|
){
|
||||||
const reqParams:GetHolderRecordDTO = {p_spid,p_holderid}
|
const reqParams:GetHolderOrContactDTO = {p_spid,p_holderid}
|
||||||
|
|
||||||
return this.manageHoldersService.GetHolderRecord(reqParams);
|
return this.manageHoldersService.GetHolderRecord(reqParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Get('/GetHolderContacts/:p_spid/:p_holderid')
|
||||||
|
GetHolderContacts(
|
||||||
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
|
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||||
|
){
|
||||||
|
const reqParams:GetHolderOrContactDTO = {p_spid,p_holderid}
|
||||||
|
|
||||||
|
return this.manageHoldersService.GetHolderContacts(reqParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Patch('/InactivateHolder/:p_spid/:p_holderid')
|
||||||
|
InactivateHolder(
|
||||||
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
|
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||||
|
){
|
||||||
|
const reqParams:GetHolderOrContactDTO = {p_spid,p_holderid}
|
||||||
|
|
||||||
|
return this.manageHoldersService.InactivateHolder(reqParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Patch('/ReactivateHolder/:p_spid/:p_holderid')
|
||||||
|
ReactivateHolder(
|
||||||
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
|
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||||
|
){
|
||||||
|
const reqParams:GetHolderOrContactDTO = {p_spid,p_holderid}
|
||||||
|
|
||||||
|
return this.manageHoldersService.ReactivateHolder(reqParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Patch('/InactivateHolderContact/:p_spid/:p_holderContactid')
|
||||||
|
InactivateHolderContact(
|
||||||
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
|
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
|
||||||
|
){
|
||||||
|
const reqParams:GetHolderContactActivateOrInactivateDTO = {p_spid,p_holderContactid}
|
||||||
|
|
||||||
|
return this.manageHoldersService.InactivateHolderContact(reqParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Patch('/ReactivateHolderContact/:p_spid/:p_holderContactid')
|
||||||
|
ReactivateHolderContact(
|
||||||
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
|
@Param('p_holderid', ParseIntPipe) p_holderContactid: number,
|
||||||
|
){
|
||||||
|
const reqParams:GetHolderContactActivateOrInactivateDTO = {p_spid,p_holderContactid}
|
||||||
|
|
||||||
|
return this.manageHoldersService.ReactivateHolderContact(reqParams);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -343,7 +343,7 @@ export class UpdateHolderContactDTO {
|
|||||||
p_userid: string;
|
p_userid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GetHolderRecordDTO {
|
export class GetHolderOrContactDTO {
|
||||||
@ApiProperty({ required: true })
|
@ApiProperty({ required: true })
|
||||||
@Max(999999999, { message: "Property p_spid must not exceed 999999999" })
|
@Max(999999999, { message: "Property p_spid must not exceed 999999999" })
|
||||||
@Min(0, { message: "Property p_spid must be at least 0 or more" })
|
@Min(0, { message: "Property p_spid must be at least 0 or more" })
|
||||||
@ -359,4 +359,23 @@ export class GetHolderRecordDTO {
|
|||||||
@IsNumber({}, { message: "Property p_holderid must be a number" })
|
@IsNumber({}, { message: "Property p_holderid must be a number" })
|
||||||
@IsDefined({ message: "Property p_holderid is required" })
|
@IsDefined({ message: "Property p_holderid is required" })
|
||||||
p_holderid: number;
|
p_holderid: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GetHolderContactActivateOrInactivateDTO {
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Max(999999999, { message: "Property p_spid must not exceed 999999999" })
|
||||||
|
@Min(0, { message: "Property p_spid must be at least 0 or more" })
|
||||||
|
@IsInt({ message: "Property p_spid allows only whole numbers" })
|
||||||
|
@IsNumber({}, { message: "Property p_spid must be a number" })
|
||||||
|
@IsDefined({ message: "Property p_spid is required" })
|
||||||
|
p_spid: number;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Max(999999999, { message: "Property p_holderid must not exceed 999999999" })
|
||||||
|
@Min(0, { message: "Property p_holderid must be at least 0 or more" })
|
||||||
|
@IsInt({ message: "Property p_holderid allows only whole numbers" })
|
||||||
|
@IsNumber({}, { message: "Property p_holderid must be a number" })
|
||||||
|
@IsDefined({ message: "Property p_holderid is required" })
|
||||||
|
p_holderContactid: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { OracleDBService } from 'src/db/db.service';
|
import { OracleDBService } from 'src/db/db.service';
|
||||||
import { CreateHoldersDTO, GetHolderRecordDTO, p_contactstableDTO, UpdateHolderDTO } from './manage-holders.dto';
|
import { CreateHoldersDTO, GetHolderContactActivateOrInactivateDTO, GetHolderOrContactDTO, p_contactstableDTO, UpdateHolderContactDTO, UpdateHolderDTO } from './manage-holders.dto';
|
||||||
import * as oracledb from 'oracledb'
|
import * as oracledb from 'oracledb'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -228,7 +228,6 @@ export class ManageHoldersService {
|
|||||||
} finally { }
|
} finally { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateHolder = async (body: UpdateHolderDTO) => {
|
UpdateHolder = async (body: UpdateHolderDTO) => {
|
||||||
let newBody = {
|
let newBody = {
|
||||||
"p_holderid": null,
|
"p_holderid": null,
|
||||||
@ -404,8 +403,7 @@ export class ManageHoldersService {
|
|||||||
} finally { }
|
} finally { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
GetHolderRecord = async (body: GetHolderOrContactDTO) => {
|
||||||
GetHolderRecord = async (body: GetHolderRecordDTO) => {
|
|
||||||
|
|
||||||
let connection;
|
let connection;
|
||||||
let p_cursor_rows = [];
|
let p_cursor_rows = [];
|
||||||
@ -463,5 +461,428 @@ export class ManageHoldersService {
|
|||||||
return { error: err.message }
|
return { error: err.message }
|
||||||
} finally { }
|
} finally { }
|
||||||
}
|
}
|
||||||
|
UpdateHolderContact = async (body: UpdateHolderContactDTO) => {
|
||||||
|
|
||||||
|
let newBody = {
|
||||||
|
"p_holdercontactid": null,
|
||||||
|
"p_spid": null,
|
||||||
|
"p_firstname": null,
|
||||||
|
"p_lastname": null,
|
||||||
|
"p_middleinitial": null,
|
||||||
|
"p_title": null,
|
||||||
|
"p_phone": null,
|
||||||
|
"p_mobile": null,
|
||||||
|
"p_fax": null,
|
||||||
|
"p_emailaddress": null,
|
||||||
|
"p_userid": null
|
||||||
|
}
|
||||||
|
|
||||||
|
let 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: UpdateHolderContactDTO = { ...newBody, ...reqBody };
|
||||||
|
|
||||||
|
let connection;
|
||||||
|
let P_cursor_rows = [];
|
||||||
|
try {
|
||||||
|
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
MANAGEHOLDER_PKG.UpdateHolders(
|
||||||
|
:p_holdercontactid,
|
||||||
|
:p_spid,
|
||||||
|
:p_firstname,
|
||||||
|
:p_lastname,
|
||||||
|
:p_middleinitial,
|
||||||
|
:p_title,
|
||||||
|
:p_phone,
|
||||||
|
:p_mobile,
|
||||||
|
:p_fax,
|
||||||
|
:p_emailaddress,
|
||||||
|
:p_userid,
|
||||||
|
:P_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
p_holdercontactid: {
|
||||||
|
val: finalBody.p_holdercontactid ? finalBody.p_holdercontactid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
p_spid: {
|
||||||
|
val: finalBody.p_spid ? finalBody.p_spid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
p_firstname: {
|
||||||
|
val: finalBody.p_firstname ? finalBody.p_firstname : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_lastname: {
|
||||||
|
val: finalBody.p_lastname ? finalBody.p_lastname : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_middleinitial: {
|
||||||
|
val: finalBody.p_middleinitial ? finalBody.p_middleinitial : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_title: {
|
||||||
|
val: finalBody.p_title ? finalBody.p_title : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_phone: {
|
||||||
|
val: finalBody.p_phone ? finalBody.p_phone : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_mobile: {
|
||||||
|
val: finalBody.p_mobile ? finalBody.p_mobile : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_fax: {
|
||||||
|
val: finalBody.p_fax ? finalBody.p_fax : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_emailaddress: {
|
||||||
|
val: finalBody.p_emailaddress ? finalBody.p_emailaddress : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_userid: {
|
||||||
|
val: finalBody.p_userid ? finalBody.p_userid : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
P_cursor: {
|
||||||
|
type: oracledb.CURSOR,
|
||||||
|
dir: oracledb.BIND_OUT
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
outFormat: oracledb.OUT_FORMAT_OBJECT
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await connection.commit();
|
||||||
|
|
||||||
|
// let fres = await result.outBinds.P_cursor.getRows();
|
||||||
|
|
||||||
|
if (result.outBinds && result.outBinds.P_cursor) {
|
||||||
|
const cursor = result.outBinds.P_cursor;
|
||||||
|
let rowsBatch;
|
||||||
|
|
||||||
|
do {
|
||||||
|
rowsBatch = await cursor.getRows(100);
|
||||||
|
P_cursor_rows = P_cursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
} else {
|
||||||
|
throw new Error('No cursor returned from the stored procedure');
|
||||||
|
}
|
||||||
|
|
||||||
|
return { P_cursor: P_cursor_rows };
|
||||||
|
|
||||||
|
// return fres
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
}
|
||||||
|
GetHolderContacts = async (body: GetHolderOrContactDTO) => {
|
||||||
|
let connection;
|
||||||
|
let p_cursor_rows = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
MANAGEHOLDER_PKG.GetHolderContacts(
|
||||||
|
:p_spid,
|
||||||
|
:p_holderid,
|
||||||
|
:p_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
P_spid: {
|
||||||
|
val: body.p_spid,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER,
|
||||||
|
},
|
||||||
|
p_holderid: {
|
||||||
|
val: body.p_holderid,
|
||||||
|
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);
|
||||||
|
p_cursor_rows = p_cursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { p_cursor: p_cursor_rows };
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
}
|
||||||
|
InactivateHolder = async (body: GetHolderOrContactDTO) => {
|
||||||
|
let connection;
|
||||||
|
let p_cursor_rows = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
ManageHolder_Pkg.InactivateHolder(
|
||||||
|
:p_spid,
|
||||||
|
:p_holderid,
|
||||||
|
:p_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
P_spid: {
|
||||||
|
val: body.p_spid,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER,
|
||||||
|
},
|
||||||
|
p_holderid: {
|
||||||
|
val: body.p_holderid,
|
||||||
|
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);
|
||||||
|
p_cursor_rows = p_cursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { p_cursor: p_cursor_rows };
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
}
|
||||||
|
ReactivateHolder = async (body: GetHolderOrContactDTO) => {
|
||||||
|
let connection;
|
||||||
|
let p_cursor_rows = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
ManageHolder_Pkg.ReactivateHolder(
|
||||||
|
:p_spid,
|
||||||
|
:p_holderid,
|
||||||
|
:p_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
P_spid: {
|
||||||
|
val: body.p_spid,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER,
|
||||||
|
},
|
||||||
|
p_holderid: {
|
||||||
|
val: body.p_holderid,
|
||||||
|
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);
|
||||||
|
p_cursor_rows = p_cursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { p_cursor: p_cursor_rows };
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
}
|
||||||
|
InactivateHolderContact = async (body: GetHolderContactActivateOrInactivateDTO) => {
|
||||||
|
let connection;
|
||||||
|
let p_cursor_rows = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
ManageHolder_Pkg.InactivateHolderContact(
|
||||||
|
:p_spid,
|
||||||
|
:p_holderid,
|
||||||
|
:p_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
P_spid: {
|
||||||
|
val: body.p_spid,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER,
|
||||||
|
},
|
||||||
|
p_holderid: {
|
||||||
|
val: body.p_holderContactid,
|
||||||
|
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);
|
||||||
|
p_cursor_rows = p_cursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { p_cursor: p_cursor_rows };
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
}
|
||||||
|
ReactivateHolderContact = async (body: GetHolderContactActivateOrInactivateDTO) => {
|
||||||
|
let connection;
|
||||||
|
let p_cursor_rows = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
ManageHolder_Pkg.ReactivateHolderContact(
|
||||||
|
:p_spid,
|
||||||
|
:p_holderid,
|
||||||
|
:p_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
P_spid: {
|
||||||
|
val: body.p_spid,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER,
|
||||||
|
},
|
||||||
|
p_holderid: {
|
||||||
|
val: body.p_holderContactid,
|
||||||
|
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);
|
||||||
|
p_cursor_rows = p_cursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return { p_cursor: p_cursor_rows };
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user