updated uscib apis
This commit is contained in:
parent
2012144f62
commit
fbf3de8cdc
69
api.http
69
api.http
@ -1,9 +1,3 @@
|
||||
// GetRegions
|
||||
|
||||
GET http://localhost:3000/oracle/GetRegions
|
||||
|
||||
###
|
||||
|
||||
// InsertRegions
|
||||
|
||||
POST http://localhost:3000/oracle/InsertRegions
|
||||
@ -28,17 +22,12 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
// GetAllServiceproviders
|
||||
// GetRegions
|
||||
|
||||
GET http://localhost:3000/oracle/GetAllServiceproviders
|
||||
GET http://localhost:3000/oracle/GetRegions
|
||||
|
||||
###
|
||||
|
||||
//GetSelectedServiceprovider
|
||||
|
||||
GET http://localhost:3000/oracle/GetSelectedServiceprovider/12
|
||||
|
||||
###
|
||||
|
||||
//InsertNewServiceProvider
|
||||
|
||||
@ -64,6 +53,7 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
|
||||
//UpdateServiceProvider
|
||||
|
||||
PUT http://localhost:3000/oracle/UpdateServiceProvider
|
||||
@ -89,15 +79,15 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
//GetSPcontacts
|
||||
// GetAllServiceproviders
|
||||
|
||||
GET http://localhost:3000/oracle/GetSPcontacts/12
|
||||
GET http://localhost:3000/oracle/GetAllServiceproviders
|
||||
|
||||
###
|
||||
|
||||
//GetSPDefaultcontact
|
||||
//GetSelectedServiceprovider
|
||||
|
||||
GET http://localhost:3000/oracle/GetSPDefaultcontact/12
|
||||
GET http://localhost:3000/oracle/GetSelectedServiceprovider/12
|
||||
|
||||
###
|
||||
|
||||
@ -120,6 +110,12 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
//SetSPDefaultcontact
|
||||
|
||||
POST http://localhost:3000/oracle/SetSPDefaultcontact/12
|
||||
|
||||
###
|
||||
|
||||
//UpdateSPContacts
|
||||
|
||||
PUT http://localhost:3000/oracle/UpdateSPContacts
|
||||
@ -139,9 +135,9 @@ Content-Type: application/json
|
||||
|
||||
###
|
||||
|
||||
//SetSPDefaultcontact
|
||||
//GetSPcontacts
|
||||
|
||||
POST http://localhost:3000/oracle/SetSPDefaultcontact/12
|
||||
GET http://localhost:3000/oracle/GetSPcontacts/12
|
||||
|
||||
###
|
||||
|
||||
@ -151,4 +147,39 @@ POST http://localhost:3000/oracle/InactivateSPContact/12
|
||||
|
||||
###
|
||||
|
||||
//GetSPDefaultcontact
|
||||
|
||||
GET http://localhost:3000/oracle/GetSPDefaultcontact/12
|
||||
|
||||
###
|
||||
|
||||
//GetAllSPcontacts
|
||||
|
||||
GET http://localhost:3000/oracle/GetAllSPcontacts
|
||||
|
||||
###
|
||||
|
||||
//CreateCarnetSequence
|
||||
|
||||
POST http://localhost:3000/oracle/CreateCarnetSequence
|
||||
Content-Type: application/json
|
||||
|
||||
{}
|
||||
|
||||
###
|
||||
|
||||
//GetCarnetSequence
|
||||
|
||||
GET http://localhost:3000/oracle/GetCarnetSequence/12
|
||||
|
||||
###
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put } from '@nestjs/common';
|
||||
import { OracleService } from './oracle.service';
|
||||
import { GetSelectedServiceProviderDTO, GetSPcontactsDTO, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto';
|
||||
import { CreateCarnetSequenceDTO, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto';
|
||||
|
||||
@Controller('oracle')
|
||||
export class OracleController {
|
||||
constructor(private readonly oarcleService: OracleService) { }
|
||||
|
||||
@Get('/GetRegions')
|
||||
getRegions() {
|
||||
return this.oarcleService.getRegions();
|
||||
}
|
||||
// Regions
|
||||
|
||||
@Post('/InsertRegions')
|
||||
insertRegions(@Body() body: InsertRegionsDto) {
|
||||
@ -21,15 +18,12 @@ export class OracleController {
|
||||
return this.oarcleService.updateRegions(body.p_regionID, body.p_name);
|
||||
}
|
||||
|
||||
@Get('GetAllServiceproviders')
|
||||
getAllServiceproviders() {
|
||||
return this.oarcleService.getAllServiceproviders();
|
||||
@Get('/GetRegions')
|
||||
getRegions() {
|
||||
return this.oarcleService.getRegions();
|
||||
}
|
||||
|
||||
@Get('/GetSelectedServiceprovider/:id')
|
||||
getSelectedServiceprovider(@Param('id', ParseIntPipe) id:number) {
|
||||
return this.oarcleService.getSelectedServiceprovider(id);
|
||||
}
|
||||
// Service Provider [ SP ]
|
||||
|
||||
@Post('/InsertNewServiceProvider')
|
||||
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
|
||||
@ -72,35 +66,24 @@ export class OracleController {
|
||||
)
|
||||
}
|
||||
|
||||
@Get('/GetSPcontacts/:id')
|
||||
getSPcontacts(@Param('id', ParseIntPipe) id:number) {
|
||||
return this.oarcleService.getSPcontacts(id);
|
||||
@Get('GetAllServiceproviders')
|
||||
getAllServiceproviders() {
|
||||
return this.oarcleService.getAllServiceproviders();
|
||||
}
|
||||
|
||||
@Get('/GetSPDefaultcontact/:id')
|
||||
getSPDefaultcontact(@Param('id', ParseIntPipe) id:number){
|
||||
return this.oarcleService.getSPDefaultcontact(id)
|
||||
@Get('/GetSelectedServiceprovider/:id')
|
||||
getSelectedServiceprovider(@Param('id', ParseIntPipe) id:number) {
|
||||
return this.oarcleService.getServiceproviderByID(id);
|
||||
}
|
||||
|
||||
|
||||
// SPContacts
|
||||
|
||||
@Post('/InsertSPContacts')
|
||||
insertSPContacts(@Body() body: InsertSPContactsDTO){
|
||||
return this.oarcleService.insertSPContacts(
|
||||
body.p_spid,
|
||||
body.p_firstname,
|
||||
body.p_lastname,
|
||||
body.p_title,
|
||||
body.p_phoneno,
|
||||
body.p_mobileno,
|
||||
body.p_faxno,
|
||||
body.p_emailaddress,
|
||||
body.p_user_id
|
||||
)
|
||||
}
|
||||
|
||||
@Put('/UpdateSPContacts')
|
||||
updateSPContacts(@Body() body: UpdateSPContactsDTO){
|
||||
return this.oarcleService.updateSPContacts(
|
||||
body.p_spcontactid,
|
||||
body.p_defcontactflag,
|
||||
body.p_firstname,
|
||||
body.p_lastname,
|
||||
body.p_title,
|
||||
@ -116,11 +99,52 @@ export class OracleController {
|
||||
setSPDefaultcontact(@Param('id', ParseIntPipe) id:number){
|
||||
return this.oarcleService.setSPDefaultcontact(id)
|
||||
}
|
||||
|
||||
@Put('/UpdateSPContacts')
|
||||
updateSPContacts(@Body() body: UpdateSPContactsDTO){
|
||||
return this.oarcleService.updateSPContacts(
|
||||
body.p_spcontactid,
|
||||
body.p_firstname,
|
||||
body.p_lastname,
|
||||
body.p_title,
|
||||
body.p_phoneno,
|
||||
body.p_mobileno,
|
||||
body.p_faxno,
|
||||
body.p_emailaddress,
|
||||
body.p_user_id
|
||||
)
|
||||
}
|
||||
|
||||
@Post('/InactivateSPContact/:id')
|
||||
inactivateSPContact(@Param('id', ParseIntPipe) id:number){
|
||||
return this.oarcleService.inactivateSPContact(id)
|
||||
}
|
||||
|
||||
|
||||
@Get('/GetSPDefaultcontact/:id')
|
||||
getSPDefaultcontact(@Param('id', ParseIntPipe) id:number){
|
||||
return this.oarcleService.getSPDefaultcontacts(id)
|
||||
}
|
||||
|
||||
@Get('/GetAllSPcontacts')
|
||||
getSPcontacts() {
|
||||
return this.oarcleService.getSPcontacts();
|
||||
}
|
||||
|
||||
// Carnet Sequence
|
||||
|
||||
@Post('/CreateCarnetSequence/')
|
||||
createCarnetSequence(@Body() body:CreateCarnetSequenceDTO){
|
||||
return this.oarcleService.createCarnetSequence(
|
||||
body.p_spid,
|
||||
body.p_regionid,
|
||||
body.p_startnumber,
|
||||
body.p_endnumber,
|
||||
body.p_carnettype
|
||||
)
|
||||
}
|
||||
|
||||
@Get('/GetCarnetSequence/:id')
|
||||
getCarnetSequence(@Param('id', ParseIntPipe) id:number){
|
||||
return this.oarcleService.getCarnetSequence(id)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { IsEmail, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||
import { IsEmail, IsNumber, IsString } from 'class-validator';
|
||||
|
||||
export class InsertRegionsDto {
|
||||
@IsString()
|
||||
@ -16,10 +16,10 @@ export class UpdateRegionDto {
|
||||
p_name: string;
|
||||
}
|
||||
|
||||
export class GetSelectedServiceProviderDTO {
|
||||
@IsNumber()
|
||||
p_spid: number;
|
||||
}
|
||||
// export class GetSelectedServiceProviderDTO {
|
||||
// @IsNumber()
|
||||
// p_spid: number;
|
||||
// }
|
||||
|
||||
export class InsertNewServiceProviderDTO {
|
||||
@IsString()
|
||||
@ -112,15 +112,18 @@ export class UpdateServiceProviderDTO {
|
||||
p_user_id: string;
|
||||
}
|
||||
|
||||
export class GetSPcontactsDTO {
|
||||
@IsNumber()
|
||||
p_SPid: number;
|
||||
}
|
||||
// export class GetSPcontactsDTO {
|
||||
// @IsNumber()
|
||||
// p_SPid: number;
|
||||
// }
|
||||
|
||||
export class InsertSPContactsDTO {
|
||||
@IsNumber()
|
||||
p_spid: number;
|
||||
|
||||
@IsString()
|
||||
p_defcontactflag: string;
|
||||
|
||||
@IsString()
|
||||
p_firstname: string;
|
||||
|
||||
@ -146,7 +149,6 @@ export class InsertSPContactsDTO {
|
||||
p_user_id: string;
|
||||
}
|
||||
|
||||
|
||||
export class UpdateSPContactsDTO {
|
||||
@IsNumber()
|
||||
p_spcontactid: number;
|
||||
@ -174,4 +176,17 @@ export class UpdateSPContactsDTO {
|
||||
|
||||
@IsString()
|
||||
p_user_id: string;
|
||||
}
|
||||
|
||||
export class CreateCarnetSequenceDTO {
|
||||
@IsNumber()
|
||||
p_spid: number;
|
||||
@IsNumber()
|
||||
p_regionid: number;
|
||||
@IsNumber()
|
||||
p_startnumber: number;
|
||||
@IsNumber()
|
||||
p_endnumber: number;
|
||||
@IsString()
|
||||
p_carnettype: string
|
||||
}
|
||||
@ -6,6 +6,92 @@ import * as oracledb from 'oracledb'
|
||||
export class OracleService {
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
// Regions API
|
||||
|
||||
async insertRegions(p_region: String, p_name: String) {
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor);
|
||||
END;`, {
|
||||
p_region: {
|
||||
val: p_region,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
p_name: {
|
||||
val: p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
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();
|
||||
|
||||
return fres
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async updateRegions(p_regionID: Number, p_name: String) {
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:p_name,:p_cursor);
|
||||
END;`, {
|
||||
p_regionID: {
|
||||
val: p_regionID,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_name: {
|
||||
val: p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
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();
|
||||
|
||||
return fres
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async getRegions() {
|
||||
let connection;
|
||||
let rows = [];
|
||||
@ -52,92 +138,10 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async insertRegions(p_region: String, p_name: String) {
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor);
|
||||
END;`, {
|
||||
p_region: {
|
||||
val: p_region,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
p_name: {
|
||||
val: p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
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();
|
||||
|
||||
return fres
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async updateRegions(p_regionID: Number, p_name: String) {
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:p_name,:p_cursor);
|
||||
END;`, {
|
||||
p_regionID: {
|
||||
val: p_regionID,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_name: {
|
||||
val: p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
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();
|
||||
|
||||
return fres
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
}
|
||||
// Servipe provider [ SP ]
|
||||
|
||||
async insertNewServiceProvider(
|
||||
p_name: String,
|
||||
@ -255,7 +259,7 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
@ -380,7 +384,7 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
@ -430,11 +434,11 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
async getSelectedServiceprovider(p_spid: Number) {
|
||||
async getServiceproviderByID(p_spid: Number) {
|
||||
|
||||
let connection;
|
||||
let rows = [];
|
||||
@ -486,66 +490,15 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
async getSPcontacts(p_SPid: number) {
|
||||
let connection;
|
||||
let rows = [];
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetSPAllContacts(:p_SPid,:p_cursor);
|
||||
END;`,
|
||||
{
|
||||
p_SPid: {
|
||||
val: 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; // The OUT cursor
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
|
||||
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
console.log('Rows fetched:', rows);
|
||||
|
||||
// Close the cursor after you're done
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new Error('No cursor returned from the stored procedure');
|
||||
}
|
||||
|
||||
return rows;
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
}
|
||||
// Service provider contacts [ SPContacts ]
|
||||
|
||||
async insertSPContacts(
|
||||
p_spid: number,
|
||||
p_defcontactflag: string,
|
||||
p_firstname: string,
|
||||
p_lastname: string,
|
||||
p_title: string,
|
||||
@ -567,6 +520,7 @@ export class OracleService {
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InsertSPContacts(
|
||||
:p_spid,
|
||||
:p_defcontactflag,
|
||||
:p_firstname,
|
||||
:p_lastname,
|
||||
:p_title,
|
||||
@ -581,6 +535,10 @@ export class OracleService {
|
||||
val: p_spid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_defcontactflag: {
|
||||
val: p_defcontactflag,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
p_firstname: {
|
||||
val: p_firstname,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
@ -628,7 +586,40 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async setSPDefaultcontact(p_spcontactid: number) {
|
||||
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid);
|
||||
END;`,
|
||||
{
|
||||
p_spcontactid: {
|
||||
val: p_spcontactid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
return "SP executed successfully"
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
async updateSPContacts(
|
||||
@ -715,10 +706,42 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async getSPDefaultcontact(p_SPid: number) {
|
||||
async inactivateSPContact(p_spcontactid: number) {
|
||||
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid);
|
||||
END;`, {
|
||||
p_spcontactid: {
|
||||
val: p_spcontactid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
return "SP executed successfully"
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
async getSPDefaultcontacts(p_SPid: number) {
|
||||
|
||||
let connection;
|
||||
let rows = [];
|
||||
@ -748,6 +771,55 @@ export class OracleService {
|
||||
}
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor; // The OUT cursor
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
|
||||
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
// Close the cursor after you're done
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new Error('No cursor returned from the stored procedure');
|
||||
}
|
||||
|
||||
return rows;
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
async getSPcontacts() {
|
||||
let connection;
|
||||
let rows = [];
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetSPAllContacts(: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; // The OUT cursor
|
||||
let rowsBatch;
|
||||
@ -770,12 +842,18 @@ export class OracleService {
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async setSPDefaultcontact(p_spcontactid: number) {
|
||||
// CarnetSequence
|
||||
|
||||
async createCarnetSequence(
|
||||
p_spid: number,
|
||||
p_regionid: number,
|
||||
p_startnumber: number,
|
||||
p_endnumber: number,
|
||||
p_carnettype: string
|
||||
) {
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
@ -786,56 +864,101 @@ export class OracleService {
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid);
|
||||
USCIB_Managed_Pkg.CreateCarnetSequence(
|
||||
:p_spid,
|
||||
:p_regionid,
|
||||
:p_startnumber,
|
||||
:p_endnumber,
|
||||
:p_carnettype,
|
||||
:p_cursor);
|
||||
END;`, {
|
||||
p_spid: {
|
||||
val: p_spid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_regionid: {
|
||||
val: p_regionid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_startnumber: {
|
||||
val: p_startnumber,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_endnumber: {
|
||||
val: p_endnumber,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
},
|
||||
p_carnettype: {
|
||||
val: p_carnettype,
|
||||
type: oracledb.DB_TYPE_VARCHAR
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT
|
||||
}
|
||||
}, {
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT
|
||||
}
|
||||
);
|
||||
let fres = await result.outBinds.p_cursor.getRows();
|
||||
|
||||
return fres
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
}
|
||||
|
||||
async getCarnetSequence(p_spid: number) {
|
||||
let connection;
|
||||
let rows = [];
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetCarnetSequence(:p_spid,:p_cursor);
|
||||
END;`,
|
||||
{
|
||||
p_spcontactid: {
|
||||
val: p_spcontactid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
p_spid: {
|
||||
val: p_spid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT
|
||||
}
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT
|
||||
}
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor; // The OUT cursor
|
||||
let rowsBatch;
|
||||
|
||||
return "SP executed successfully"
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
|
||||
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
// Close the cursor after you're done
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new Error('No cursor returned from the stored procedure');
|
||||
}
|
||||
|
||||
return rows;
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
|
||||
}
|
||||
|
||||
async inactivateSPContact(p_spcontactid: number) {
|
||||
|
||||
let connection;
|
||||
try {
|
||||
// Connect to the Oracle database using oracledb
|
||||
connection = await this.oracleDBService.getConnection()
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected')
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid);
|
||||
END;`, {
|
||||
p_spcontactid: {
|
||||
val: p_spcontactid,
|
||||
type: oracledb.DB_TYPE_NUMBER
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
return "SP executed successfully"
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error fetching users: ', err);
|
||||
throw new Error('Error fetching users');
|
||||
} finally { }
|
||||
|
||||
} finally { }
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user