holder api
This commit is contained in:
parent
0539c17ced
commit
33fe41101e
@ -1,6 +1,6 @@
|
||||
import { Body, Controller, Get, Param, ParseIntPipe, Post } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { CreateHoldersDTO, GetHolderOrContactDTO } from 'src/oracle/manage-holders/manage-holders.dto';
|
||||
import { CreateHoldersDTO, GetHolderContactActivateOrInactivateDTO, GetHolderOrContactDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/oracle/manage-holders/manage-holders.dto';
|
||||
import { ManageHoldersService } from './manage-holders.service';
|
||||
|
||||
@Controller('mssql')
|
||||
@ -9,20 +9,92 @@ export class ManageHoldersController {
|
||||
constructor(private readonly manageHoldersService: ManageHoldersService) { }
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Post('/CreateHolderData')
|
||||
CreateHolders(@Body() body: CreateHoldersDTO) {
|
||||
@Post('/CreateHolderData')
|
||||
CreateHolders(@Body() body: CreateHoldersDTO) {
|
||||
return this.manageHoldersService.CreateHolders(body);
|
||||
// return {message:"Request received.."}
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
||||
GetHolderMaster(
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Put('/UpdateHolder')
|
||||
UpdateHolder(@Body() body: UpdateHolderDTO) {
|
||||
return this.manageHoldersService.UpdateHolder(body);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Put('/UpdateHolderContact')
|
||||
UpdateHolderContact(@Body() body: UpdateHolderContactDTO) {
|
||||
return this.manageHoldersService.UpdateHolderContact(body);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
||||
GetHolderMaster(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
) {
|
||||
) {
|
||||
const reqParams: GetHolderOrContactDTO = { p_spid, p_holderid };
|
||||
|
||||
|
||||
return this.manageHoldersService.GetHolderRecord(reqParams);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@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 - Mssql')
|
||||
@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 - Mssql')
|
||||
@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 - Mssql')
|
||||
@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 - Mssql')
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import { CreateHoldersDTO, GetHolderOrContactDTO } from 'src/oracle/manage-holders/manage-holders.dto';
|
||||
import { CreateHoldersDTO, GetHolderContactActivateOrInactivateDTO, GetHolderOrContactDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/oracle/manage-holders/manage-holders.dto';
|
||||
import * as mssql from 'mssql';
|
||||
|
||||
@Injectable()
|
||||
@ -48,7 +48,7 @@ export class ManageHoldersService {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientlocationid', mssql.Int, finalBody.p_clientlocationid);
|
||||
request.input('p_holderno', mssql.VarChar(15), finalBody.p_holderno);
|
||||
@ -109,7 +109,7 @@ export class ManageHoldersService {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
|
||||
@ -124,4 +124,173 @@ export class ManageHoldersService {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UpdateHolder = async (body: UpdateHolderDTO) => {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new mssql.Request(connection);
|
||||
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_locationid', mssql.Int, body.p_locationid);
|
||||
request.input('p_holderno', mssql.VarChar(15), body.p_holderno);
|
||||
request.input('p_holdertype', mssql.VarChar(3), body.p_holdertype);
|
||||
request.input('p_uscibmemberflag', mssql.VarChar(1), body.p_uscibmemberflag);
|
||||
request.input('p_govagencyflag', mssql.VarChar(1), body.p_govagencyflag);
|
||||
request.input('p_holdername', mssql.VarChar(50), body.p_holdername);
|
||||
request.input('p_namequalifier', mssql.VarChar(10), body.p_namequalifier);
|
||||
request.input('p_addlname', mssql.VarChar(50), body.p_addlname);
|
||||
request.input('p_address1', mssql.VarChar(50), body.p_address1);
|
||||
request.input('p_address2', mssql.VarChar(50), body.p_address2);
|
||||
request.input('p_city', mssql.VarChar(30), body.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), body.p_state);
|
||||
request.input('p_zip', mssql.VarChar(10), body.p_zip);
|
||||
request.input('p_country', mssql.VarChar(2), body.p_country);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateHolders');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UpdateHolderContact = async (body: UpdateHolderContactDTO) => {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new mssql.Request(connection);
|
||||
|
||||
request.input('p_holdercontactid', mssql.Int, body.p_holdercontactid);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_firstname', mssql.VarChar(50), body.p_firstname);
|
||||
request.input('p_lastname', mssql.VarChar(50), body.p_lastname);
|
||||
request.input('p_middleinitial', mssql.VarChar(3), body.p_middleinitial);
|
||||
request.input('p_title', mssql.VarChar(50), body.p_title);
|
||||
request.input('p_phone', mssql.VarChar(20), body.p_phone);
|
||||
request.input('p_mobile', mssql.VarChar(20), body.p_mobile);
|
||||
request.input('p_fax', mssql.VarChar(20), body.p_fax);
|
||||
request.input('p_emailaddress', mssql.VarChar(100), body.p_emailaddress);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateHolders');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GetHolderContacts = async (body: GetHolderOrContactDTO) => {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
|
||||
const result = await request.execute('carnetsys.GetHolderContacts');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
InactivateHolder = async (body: GetHolderOrContactDTO) => {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
|
||||
const result = await request.execute('carnetsys.InactivateHolder');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ReactivateHolder = async (body: GetHolderOrContactDTO) => {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
|
||||
const result = await request.execute('carnetsys.ReactivateHolder');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
InactivateHolderContact = async (body: GetHolderContactActivateOrInactivateDTO) => {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderContactid', mssql.Int, body.p_holderContactid);
|
||||
|
||||
const result = await request.execute('carnetsys.InactivateHolderContact');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ReactivateHolderContact = async (body: GetHolderContactActivateOrInactivateDTO) => {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request:Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderContactid', mssql.Int, body.p_holderContactid);
|
||||
|
||||
const result = await request.execute('carnetsys.ReactivateHolderContact');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
console.error('Error executing stored procedure:', error);
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import {
|
||||
UpdateHolderDTO,
|
||||
} from './manage-holders.dto';
|
||||
import * as oracledb from 'oracledb';
|
||||
import { Connection, Result } from 'oracledb';
|
||||
|
||||
@Injectable()
|
||||
export class ManageHoldersService {
|
||||
@ -51,7 +52,7 @@ export class ManageHoldersService {
|
||||
|
||||
const finalBody: CreateHoldersDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let p_holdercursor_rows = [];
|
||||
let p_holdercontactcursor_rows = [];
|
||||
try {
|
||||
@ -85,7 +86,7 @@ export class ManageHoldersService {
|
||||
MobileNo,
|
||||
FaxNo,
|
||||
) {
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`SELECT CARNETSYS.CONTACTSARRAY(:FirstName, :LastName, :MiddleInitial, :Title, :EmailAddress, :PhoneNo, :MobileNo, :FaxNo) FROM dual`,
|
||||
{
|
||||
FirstName,
|
||||
@ -98,7 +99,7 @@ export class ManageHoldersService {
|
||||
FaxNo,
|
||||
},
|
||||
);
|
||||
return result.rows[0][0];
|
||||
return result.rows?.[0]?.[0] ?? [];
|
||||
}
|
||||
|
||||
const CONTACTSARRAY = finalBody.p_contactstable
|
||||
@ -122,7 +123,7 @@ export class ManageHoldersService {
|
||||
// Create an instance of GLTABLE
|
||||
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSARRAY);
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
MANAGEHOLDER_PKG.CreateHolderData(
|
||||
:p_spid,
|
||||
@ -318,7 +319,7 @@ export class ManageHoldersService {
|
||||
|
||||
const finalBody = { ...newBody, ...reqBody };
|
||||
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let P_cursor_rows = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
@ -326,7 +327,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
MANAGEHOLDER_PKG.UpdateHolders(
|
||||
:p_holderid,
|
||||
@ -459,7 +460,7 @@ export class ManageHoldersService {
|
||||
}
|
||||
};
|
||||
GetHolderRecord = async (body: GetHolderOrContactDTO) => {
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let p_cursor_rows = [];
|
||||
|
||||
try {
|
||||
@ -468,7 +469,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
MANAGEHOLDER_PKG.GetHolderMaster(
|
||||
:p_spid,
|
||||
@ -547,7 +548,7 @@ export class ManageHoldersService {
|
||||
|
||||
const finalBody: UpdateHolderContactDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let P_cursor_rows = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
@ -555,7 +556,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
MANAGEHOLDER_PKG.UpdateHolders(
|
||||
:p_holdercontactid,
|
||||
@ -658,7 +659,7 @@ export class ManageHoldersService {
|
||||
}
|
||||
};
|
||||
GetHolderContacts = async (body: GetHolderOrContactDTO) => {
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let p_cursor_rows = [];
|
||||
|
||||
try {
|
||||
@ -667,7 +668,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
MANAGEHOLDER_PKG.GetHolderContacts(
|
||||
:p_spid,
|
||||
@ -716,7 +717,7 @@ export class ManageHoldersService {
|
||||
}
|
||||
};
|
||||
InactivateHolder = async (body: GetHolderOrContactDTO) => {
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let p_cursor_rows = [];
|
||||
|
||||
try {
|
||||
@ -725,7 +726,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
ManageHolder_Pkg.InactivateHolder(
|
||||
:p_spid,
|
||||
@ -774,7 +775,7 @@ export class ManageHoldersService {
|
||||
}
|
||||
};
|
||||
ReactivateHolder = async (body: GetHolderOrContactDTO) => {
|
||||
let connection;
|
||||
let connection:Connection;
|
||||
let p_cursor_rows = [];
|
||||
|
||||
try {
|
||||
@ -783,7 +784,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
ManageHolder_Pkg.ReactivateHolder(
|
||||
:p_spid,
|
||||
@ -831,10 +832,8 @@ export class ManageHoldersService {
|
||||
}
|
||||
}
|
||||
};
|
||||
InactivateHolderContact = async (
|
||||
body: GetHolderContactActivateOrInactivateDTO,
|
||||
) => {
|
||||
let connection;
|
||||
InactivateHolderContact = async (body: GetHolderContactActivateOrInactivateDTO) => {
|
||||
let connection:Connection;
|
||||
let p_cursor_rows = [];
|
||||
|
||||
try {
|
||||
@ -843,7 +842,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
ManageHolder_Pkg.InactivateHolderContact(
|
||||
:p_spid,
|
||||
@ -891,10 +890,8 @@ export class ManageHoldersService {
|
||||
}
|
||||
}
|
||||
};
|
||||
ReactivateHolderContact = async (
|
||||
body: GetHolderContactActivateOrInactivateDTO,
|
||||
) => {
|
||||
let connection;
|
||||
ReactivateHolderContact = async (body: GetHolderContactActivateOrInactivateDTO) => {
|
||||
let connection:Connection;
|
||||
let p_cursor_rows = [];
|
||||
|
||||
try {
|
||||
@ -903,7 +900,7 @@ export class ManageHoldersService {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
const result:Result<any> = await connection.execute(
|
||||
`BEGIN
|
||||
ManageHolder_Pkg.ReactivateHolderContact(
|
||||
:p_spid,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user