added three api's
This commit is contained in:
parent
a9ed1bbdf0
commit
03e8568fa2
@ -1,4 +1,4 @@
|
|||||||
GET http://localhost:3000/oracle/GetCarnetDetailsbyCarnetStatus/1/v/false
|
GET http://localhost:3000/oracle/GetHolderRecord/d/d
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { Module } from '@nestjs/common';
|
|||||||
import { DbModule } from './db/db.module';
|
import { DbModule } from './db/db.module';
|
||||||
import { OracleModule } from './oracle/oracle.module';
|
import { OracleModule } from './oracle/oracle.module';
|
||||||
import { AuthModule } from './auth/auth.module';
|
import { AuthModule } from './auth/auth.module';
|
||||||
|
import { CustomPipeModule } from './custom-pipe/custom-pipe.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ AuthModule, DbModule, OracleModule],
|
imports: [ AuthModule, DbModule, OracleModule],
|
||||||
|
|||||||
11
src/custom-pipe/custom-parseInt-pipe.service.ts
Normal file
11
src/custom-pipe/custom-parseInt-pipe.service.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
import { ArgumentMetadata, Injectable, PipeTransform, BadRequestException } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CustomParseIntPipe implements PipeTransform {
|
||||||
|
transform(value: any, metadata: ArgumentMetadata) {
|
||||||
|
const parsedValue = parseInt(value, 10);
|
||||||
|
|
||||||
|
return parsedValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/custom-pipe/custom-pipe.module.ts
Normal file
9
src/custom-pipe/custom-pipe.module.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CustomParseIntPipe } from './custom-parseInt-pipe.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports:[],
|
||||||
|
providers: [CustomParseIntPipe],
|
||||||
|
exports:[CustomParseIntPipe]
|
||||||
|
})
|
||||||
|
export class CustomPipeModule {}
|
||||||
18
src/main.ts
18
src/main.ts
@ -14,13 +14,6 @@ async function bootstrap() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const returnErrorChildren = (x: any) => {
|
|
||||||
if (x.children.length !== 0) {
|
|
||||||
return x.children;
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractConstraints(validationErrors: ValidationError[]) {
|
function extractConstraints(validationErrors: ValidationError[]) {
|
||||||
const constraints: { [key: string]: string }[] = [];
|
const constraints: { [key: string]: string }[] = [];
|
||||||
|
|
||||||
@ -30,8 +23,8 @@ async function bootstrap() {
|
|||||||
for (const error of errors) {
|
for (const error of errors) {
|
||||||
// If the error has constraints, add them to the list
|
// If the error has constraints, add them to the list
|
||||||
|
|
||||||
console.log(error);
|
// console.log(error);
|
||||||
console.log("--------------");
|
// console.log("--------------");
|
||||||
|
|
||||||
if (error.constraints) {
|
if (error.constraints) {
|
||||||
constraints.push(error.constraints);
|
constraints.push(error.constraints);
|
||||||
@ -52,14 +45,14 @@ async function bootstrap() {
|
|||||||
let res = extractConstraints(validationErrors);
|
let res = extractConstraints(validationErrors);
|
||||||
|
|
||||||
let newResult = res.map(x => {
|
let newResult = res.map(x => {
|
||||||
return {message:x[Object.keys(x)[0]]}
|
const errorMessage = x[Object.keys(x)[0]];
|
||||||
|
|
||||||
|
return { message: errorMessage };
|
||||||
}).filter(Boolean);
|
}).filter(Boolean);
|
||||||
|
|
||||||
return new BadRequestException({ message: 'Validation failed', errors: newResult });
|
return new BadRequestException({ message: 'Validation failed', errors: newResult });
|
||||||
};
|
};
|
||||||
|
|
||||||
// app.useGlobalPipes(new ValidationPipe({ exceptionFactory:customExceptionFactory, whitelist: true, forbidNonWhitelisted: true, transform: true }));
|
|
||||||
|
|
||||||
app.useGlobalPipes(new ValidationPipe({
|
app.useGlobalPipes(new ValidationPipe({
|
||||||
exceptionFactory: customExceptionFactory,
|
exceptionFactory: customExceptionFactory,
|
||||||
stopAtFirstError: true,
|
stopAtFirstError: true,
|
||||||
@ -68,6 +61,7 @@ async function bootstrap() {
|
|||||||
transform: true
|
transform: true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// app.useGlobalPipes(new ValidationPipe({ exceptionFactory:customExceptionFactory, whitelist: true, forbidNonWhitelisted: true, transform: true }));
|
||||||
const config = new DocumentBuilder()
|
const config = new DocumentBuilder()
|
||||||
.setTitle('API')
|
.setTitle('API')
|
||||||
.setDescription('API description')
|
.setDescription('API description')
|
||||||
|
|||||||
@ -1,12 +1,35 @@
|
|||||||
import { Controller, Get } from '@nestjs/common';
|
import { Body, Controller, Get, Param, ParseIntPipe, 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 { ManageHoldersService } from './manage-holders.service';
|
||||||
|
import { CustomParseIntPipe } from 'src/custom-pipe/custom-parseInt-pipe.service';
|
||||||
|
|
||||||
@Controller()
|
@Controller('oracle')
|
||||||
export class ManageHoldersController {
|
export class ManageHoldersController {
|
||||||
|
|
||||||
|
constructor(private readonly manageHoldersService: ManageHoldersService) { }
|
||||||
|
|
||||||
@ApiTags('Manage Holders - Oracle')
|
@ApiTags('Manage Holders - Oracle')
|
||||||
@Get()
|
@Post('/CreateHolderData')
|
||||||
GetHolderMaster(){
|
CreateHolders(@Body() body: CreateHoldersDTO) {
|
||||||
return {message:"Request received.."}
|
return this.manageHoldersService.CreateHolders(body);
|
||||||
|
// return {message:"Request received.."}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Put('/UpdateHolder')
|
||||||
|
UpdateHolder(@Body() body: UpdateHolderDTO) {
|
||||||
|
return this.manageHoldersService.UpdateHolder(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('Manage Holders - Oracle')
|
||||||
|
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
||||||
|
GetHolderMaster(
|
||||||
|
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||||
|
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||||
|
){
|
||||||
|
const reqParams:GetHolderRecordDTO = {p_spid,p_holderid}
|
||||||
|
|
||||||
|
return this.manageHoldersService.GetHolderRecord(reqParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
362
src/oracle/manage-holders/manage-holders.dto.ts
Normal file
362
src/oracle/manage-holders/manage-holders.dto.ts
Normal file
@ -0,0 +1,362 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { Type } from 'class-transformer';
|
||||||
|
import { IsString, IsNumber, IsOptional, ValidateNested, IsArray, IsDefined, Length, Max, Min, IsInt } from 'class-validator';
|
||||||
|
|
||||||
|
export class p_contactstableDTO {
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property FirstName must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property FirstName must be a string" })
|
||||||
|
@IsDefined({ message: "Property FirstName is required" })
|
||||||
|
FirstName: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property LastName must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property LastName must be a string" })
|
||||||
|
@IsDefined({ message: "Property LastName is required" })
|
||||||
|
LastName: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 3, { message: "Property MiddleInitial must be between 0 to 3 characters" })
|
||||||
|
@IsString({ message: "Property MiddleInitial must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
MiddleInitial?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 50, { message: "Property Title must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property Title must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
Title?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 100, { message: "Property EmailAddress must be between 0 to 100 characters" })
|
||||||
|
@IsString({ message: "Property EmailAddress must be a string" })
|
||||||
|
@IsDefined({ message: "Property EmailAddress is required" })
|
||||||
|
EmailAddress: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 20, { message: "Property PhoneNo must be between 0 to 20 characters" })
|
||||||
|
@IsString({ message: "Property PhoneNo must be a string" })
|
||||||
|
@IsDefined({ message: "Property PhoneNo is required" })
|
||||||
|
PhoneNo: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 20, { message: "Property MobileNo must be between 0 to 20 characters" })
|
||||||
|
@IsString({ message: "Property MobileNo must be a string" })
|
||||||
|
@IsDefined({ message: "Property MobileNo is required" })
|
||||||
|
MobileNo: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 20, { message: "Property FaxNo must be between 0 to 20 characters" })
|
||||||
|
@IsString({ message: "Property FaxNo must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
FaxNo?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CreateHoldersDTO {
|
||||||
|
@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_clientlocationid must not exceed 999999999" })
|
||||||
|
@Min(0, { message: "Property p_clientlocationid must be at least 0 or more" })
|
||||||
|
@IsInt({ message: "Property p_clientlocationid allows only whole numbers" })
|
||||||
|
@IsNumber({}, { message: "Property p_clientlocationid must be a number" })
|
||||||
|
@IsDefined({ message: "Property p_clientlocationid is required" })
|
||||||
|
p_clientlocationid: number;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 15, { message: "Property p_holderno must be between 0 to 15 characters" })
|
||||||
|
@IsString({ message: "Property p_holderno must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_holderno is required" })
|
||||||
|
p_holderno: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 3, { message: "Property p_holdertype must be between 0 to 3 characters" })
|
||||||
|
@IsString({ message: "Property p_holdertype must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_holdertype is required" })
|
||||||
|
p_holdertype: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 1, { message: "Property p_uscibmemberflag must be between 0 to 1 character" })
|
||||||
|
@IsString({ message: "Property p_uscibmemberflag must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_uscibmemberflag is required" })
|
||||||
|
p_uscibmemberflag: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 1, { message: "Property p_govagencyflag must be between 0 to 1 character" })
|
||||||
|
@IsString({ message: "Property p_govagencyflag must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_govagencyflag is required" })
|
||||||
|
p_govagencyflag: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_holdername must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_holdername must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_holdername is required" })
|
||||||
|
p_holdername: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 10, { message: "Property p_namequalifier must be between 0 to 10 characters" })
|
||||||
|
@IsString({ message: "Property p_namequalifier must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_namequalifier?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 50, { message: "Property p_addlname must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_addlname must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_addlname?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_address1 must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_address1 must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_address1 is required" })
|
||||||
|
p_address1: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 50, { message: "Property p_address2 must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_address2 must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_address2?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 30, { message: "Property p_city must be between 0 to 30 characters" })
|
||||||
|
@IsString({ message: "Property p_city must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_city is required" })
|
||||||
|
p_city: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 2, { message: "Property p_state must be between 0 to 2 characters" })
|
||||||
|
@IsString({ message: "Property p_state must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_state is required" })
|
||||||
|
p_state: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 10, { message: "Property p_zip must be between 0 to 10 characters" })
|
||||||
|
@IsString({ message: "Property p_zip must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_zip is required" })
|
||||||
|
p_zip: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_country must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_country must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_country is required" })
|
||||||
|
p_country: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_userid must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_userid must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_userid is required" })
|
||||||
|
p_userid: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false, type: () => [p_contactstableDTO] })
|
||||||
|
@Type(() => p_contactstableDTO)
|
||||||
|
@ValidateNested({ each: true })
|
||||||
|
@IsArray({ message: "Property p_contactstable allows only array type" })
|
||||||
|
@IsOptional()
|
||||||
|
p_contactstable?: p_contactstableDTO[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UpdateHolderDTO {
|
||||||
|
@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_holderid: number;
|
||||||
|
|
||||||
|
@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_locationid must not exceed 999999999" })
|
||||||
|
@Min(0, { message: "Property p_locationid must be at least 0 or more" })
|
||||||
|
@IsInt({ message: "Property p_locationid allows only whole numbers" })
|
||||||
|
@IsNumber({}, { message: "Property p_locationid must be a number" })
|
||||||
|
@IsDefined({ message: "Property p_locationid is required" })
|
||||||
|
p_locationid: number;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 15, { message: "Property p_holderno must be between 0 to 15 characters" })
|
||||||
|
@IsString({ message: "Property p_holderno must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_holderno is required" })
|
||||||
|
p_holderno: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 3, { message: "Property p_holdertype must be between 0 to 3 characters" })
|
||||||
|
@IsString({ message: "Property p_holdertype must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_holdertype is required" })
|
||||||
|
p_holdertype: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 1, { message: "Property p_uscibmemberflag must be between 0 to 1 character" })
|
||||||
|
@IsString({ message: "Property p_uscibmemberflag must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_uscibmemberflag is required" })
|
||||||
|
p_uscibmemberflag: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 1, { message: "Property p_govagencyflag must be between 0 to 1 character" })
|
||||||
|
@IsString({ message: "Property p_govagencyflag must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_govagencyflag is required" })
|
||||||
|
p_govagencyflag: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_holdername must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_holdername must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_holdername is required" })
|
||||||
|
p_holdername: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 10, { message: "Property p_namequalifier must be between 0 to 10 characters" })
|
||||||
|
@IsString({ message: "Property p_namequalifier must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_namequalifier?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 50, { message: "Property p_addlname must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_addlname must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_addlname?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_address1 must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_address1 must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_address1 is required" })
|
||||||
|
p_address1: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 50, { message: "Property p_address2 must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_address2 must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_address2?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 30, { message: "Property p_city must be between 0 to 30 characters" })
|
||||||
|
@IsString({ message: "Property p_city must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_city is required" })
|
||||||
|
p_city: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 2, { message: "Property p_state must be between 0 to 2 characters" })
|
||||||
|
@IsString({ message: "Property p_state must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_state is required" })
|
||||||
|
p_state: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 10, { message: "Property p_zip must be between 0 to 10 characters" })
|
||||||
|
@IsString({ message: "Property p_zip must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_zip is required" })
|
||||||
|
p_zip: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 2, { message: "Property p_country must be between 0 to 2 characters" })
|
||||||
|
@IsString({ message: "Property p_country must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_country is required" })
|
||||||
|
p_country: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 100, { message: "Property p_userid must be between 0 to 100 characters" })
|
||||||
|
@IsString({ message: "Property p_userid must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_userid is required" })
|
||||||
|
p_userid: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class UpdateHolderContactDTO {
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Max(999999999, { message: "Property p_holdercontactid must not exceed 999999999" })
|
||||||
|
@Min(0, { message: "Property p_holdercontactid must be at least 0 or more" })
|
||||||
|
@IsInt({ message: "Property p_holdercontactid allows only whole numbers" })
|
||||||
|
@IsNumber({}, { message: "Property p_holdercontactid must be a number" })
|
||||||
|
@IsDefined({ message: "Property p_holdercontactid is required" })
|
||||||
|
p_holdercontactid: number;
|
||||||
|
|
||||||
|
@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 })
|
||||||
|
@Length(0, 50, { message: "Property p_firstname must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_firstname must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_firstname is required" })
|
||||||
|
p_firstname: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 50, { message: "Property p_lastname must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_lastname must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_lastname is required" })
|
||||||
|
p_lastname: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 3, { message: "Property p_middleinitial must be between 0 to 3 characters" })
|
||||||
|
@IsString({ message: "Property p_middleinitial must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_middleinitial?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 50, { message: "Property p_title must be between 0 to 50 characters" })
|
||||||
|
@IsString({ message: "Property p_title must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_title?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 20, { message: "Property p_phone must be between 0 to 20 characters" })
|
||||||
|
@IsString({ message: "Property p_phone must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_phone is required" })
|
||||||
|
p_phone: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 20, { message: "Property p_mobile must be between 0 to 20 characters" })
|
||||||
|
@IsString({ message: "Property p_mobile must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_mobile is required" })
|
||||||
|
p_mobile: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: false })
|
||||||
|
@Length(0, 20, { message: "Property p_fax must be between 0 to 20 characters" })
|
||||||
|
@IsString({ message: "Property p_fax must be a string" })
|
||||||
|
@IsOptional()
|
||||||
|
p_fax?: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 100, { message: "Property p_emailaddress must be between 0 to 100 characters" })
|
||||||
|
@IsString({ message: "Property p_emailaddress must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_emailaddress is required" })
|
||||||
|
p_emailaddress: string;
|
||||||
|
|
||||||
|
@ApiProperty({ required: true })
|
||||||
|
@Length(0, 100, { message: "Property p_userid must be between 0 to 100 characters" })
|
||||||
|
@IsString({ message: "Property p_userid must be a string" })
|
||||||
|
@IsDefined({ message: "Property p_userid is required" })
|
||||||
|
p_userid: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetHolderRecordDTO {
|
||||||
|
@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_holderid: number;
|
||||||
|
}
|
||||||
@ -1,8 +1,11 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { Module } from '@nestjs/common';
|
||||||
import { ManageHoldersService } from './manage-holders.service';
|
import { ManageHoldersService } from './manage-holders.service';
|
||||||
import { ManageHoldersController } from './manage-holders.controller';
|
import { ManageHoldersController } from './manage-holders.controller';
|
||||||
|
import { DbModule } from 'src/db/db.module';
|
||||||
|
import { CustomPipeModule } from 'src/custom-pipe/custom-pipe.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
|
imports:[DbModule],
|
||||||
providers: [ManageHoldersService],
|
providers: [ManageHoldersService],
|
||||||
controllers: [ManageHoldersController]
|
controllers: [ManageHoldersController]
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,4 +1,467 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { OracleDBService } from 'src/db/db.service';
|
||||||
|
import { CreateHoldersDTO, GetHolderRecordDTO, p_contactstableDTO, UpdateHolderDTO } from './manage-holders.dto';
|
||||||
|
import * as oracledb from 'oracledb'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ManageHoldersService {}
|
export class ManageHoldersService {
|
||||||
|
|
||||||
|
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||||
|
|
||||||
|
CreateHolders = async (body: CreateHoldersDTO) => {
|
||||||
|
|
||||||
|
let newBody = {
|
||||||
|
"p_spid": null,
|
||||||
|
"p_clientlocationid": null,
|
||||||
|
"p_holderno": null,
|
||||||
|
"p_holdertype": null,
|
||||||
|
"p_uscibmemberflag": null,
|
||||||
|
"p_govagencyflag": null,
|
||||||
|
"p_holdername": null,
|
||||||
|
"p_namequalifier": null,
|
||||||
|
"p_addlname": null,
|
||||||
|
"p_address1": null,
|
||||||
|
"p_address2": null,
|
||||||
|
"p_city": null,
|
||||||
|
"p_state": null,
|
||||||
|
"p_zip": null,
|
||||||
|
"p_country": null,
|
||||||
|
"p_userid": null,
|
||||||
|
"p_contactstable": 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: CreateHoldersDTO = { ...newBody, ...reqBody };
|
||||||
|
|
||||||
|
let connection;
|
||||||
|
let p_holdercursor_rows = [];
|
||||||
|
let p_holdercontactcursor_rows = [];
|
||||||
|
try {
|
||||||
|
|
||||||
|
connection = await this.oracleDBService.getConnection()
|
||||||
|
if (!connection) {
|
||||||
|
throw new Error('No DB Connected')
|
||||||
|
}
|
||||||
|
|
||||||
|
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
|
||||||
|
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name LIKE '%CONTACT%'`);
|
||||||
|
|
||||||
|
// return { res:res.rows };
|
||||||
|
|
||||||
|
// contactstable
|
||||||
|
|
||||||
|
const CONTACTSARRAY = await connection.getDbObjectClass('CARNETSYS.CONTACTSARRAY');
|
||||||
|
const CONTACTSTABLE = await connection.getDbObjectClass('CARNETSYS.CONTACTSTABLE');
|
||||||
|
|
||||||
|
// Check if GLTABLE is a constructor
|
||||||
|
if (typeof CONTACTSTABLE !== 'function') {
|
||||||
|
throw new Error('CONTACTSTABLE is not a constructor');
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONTACTSTABLE_ARRAY = finalBody.p_contactstable ? finalBody.p_contactstable.map((x: p_contactstableDTO) => {
|
||||||
|
return new CONTACTSARRAY(x.FirstName, x.LastName, x.MiddleInitial, x.Title, x.EmailAddress, x.PhoneNo, x.MobileNo, x.FaxNo)
|
||||||
|
}) : [];
|
||||||
|
|
||||||
|
// Create an instance of GLTABLE
|
||||||
|
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSTABLE_ARRAY);
|
||||||
|
|
||||||
|
const result = await connection.execute(
|
||||||
|
`BEGIN
|
||||||
|
MANAGEHOLDER_PKG.CreateHolderData(
|
||||||
|
:p_spid,
|
||||||
|
:p_clientlocationid,
|
||||||
|
:p_holderno,
|
||||||
|
:p_holdertype,
|
||||||
|
:p_uscibmemberflag,
|
||||||
|
:p_govagencyflag,
|
||||||
|
:p_holdername,
|
||||||
|
:p_namequalifier,
|
||||||
|
:p_addlname,
|
||||||
|
:p_address1,
|
||||||
|
:p_address2,
|
||||||
|
:p_city,
|
||||||
|
:p_state,
|
||||||
|
:p_zip,
|
||||||
|
:p_country,
|
||||||
|
:p_userid,
|
||||||
|
:p_contactstable,
|
||||||
|
:p_holdercursor,
|
||||||
|
:p_holdercontactcursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
p_spid: {
|
||||||
|
val: finalBody.p_spid ? finalBody.p_spid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
p_clientlocationid: {
|
||||||
|
val: finalBody.p_clientlocationid ? finalBody.p_clientlocationid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
|
||||||
|
p_holderno: {
|
||||||
|
val: finalBody.p_holderno ? finalBody.p_holderno : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_holdertype: {
|
||||||
|
val: finalBody.p_holdertype ? finalBody.p_holdertype : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_uscibmemberflag: {
|
||||||
|
val: finalBody.p_uscibmemberflag ? finalBody.p_uscibmemberflag : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_govagencyflag: {
|
||||||
|
val: finalBody.p_govagencyflag ? finalBody.p_govagencyflag : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_holdername: {
|
||||||
|
val: finalBody.p_holdername ? finalBody.p_holdername : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_namequalifier: {
|
||||||
|
val: finalBody.p_namequalifier ? finalBody.p_namequalifier : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_addlname: {
|
||||||
|
val: finalBody.p_addlname ? finalBody.p_addlname : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_address1: {
|
||||||
|
val: finalBody.p_address1 ? finalBody.p_address1 : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_address2: {
|
||||||
|
val: finalBody.p_address2 ? finalBody.p_address2 : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_city: {
|
||||||
|
val: finalBody.p_city ? finalBody.p_city : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_state: {
|
||||||
|
val: finalBody.p_state ? finalBody.p_state : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_zip: {
|
||||||
|
val: finalBody.p_zip ? finalBody.p_zip : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_country: {
|
||||||
|
val: finalBody.p_country ? finalBody.p_country : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_userid: {
|
||||||
|
val: finalBody.p_userid ? finalBody.p_userid : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_contactstable: {
|
||||||
|
val: CONTACTSTABLE_INSTANCE,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_holdercursor: {
|
||||||
|
type: oracledb.CURSOR,
|
||||||
|
dir: oracledb.BIND_OUT
|
||||||
|
},
|
||||||
|
p_holdercontactcursor: {
|
||||||
|
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_holdercursor) {
|
||||||
|
const cursor = result.outBinds.p_holdercursor;
|
||||||
|
let rowsBatch;
|
||||||
|
|
||||||
|
do {
|
||||||
|
rowsBatch = await cursor.getRows(100);
|
||||||
|
p_holdercursor_rows = p_holdercursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
} else {
|
||||||
|
throw new Error('No cursor returned from the stored procedure');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.outBinds && result.outBinds.p_holdercontactcursor) {
|
||||||
|
const cursor = result.outBinds.p_holdercontactcursor;
|
||||||
|
let rowsBatch;
|
||||||
|
|
||||||
|
do {
|
||||||
|
rowsBatch = await cursor.getRows(100);
|
||||||
|
p_holdercontactcursor_rows = p_holdercontactcursor_rows.concat(rowsBatch);
|
||||||
|
} while (rowsBatch.length > 0);
|
||||||
|
|
||||||
|
|
||||||
|
await cursor.close();
|
||||||
|
} else {
|
||||||
|
throw new Error('No cursor returned from the stored procedure');
|
||||||
|
}
|
||||||
|
|
||||||
|
return { p_holdercursor: p_holdercursor_rows, p_holdercontactcursor: p_holdercontactcursor_rows };
|
||||||
|
|
||||||
|
// return fres
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching users: ', err);
|
||||||
|
return { error: err.message }
|
||||||
|
} finally { }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateHolder = async (body: UpdateHolderDTO) => {
|
||||||
|
let newBody = {
|
||||||
|
"p_holderid": null,
|
||||||
|
"p_spid": null,
|
||||||
|
"p_locationid": null,
|
||||||
|
"p_holderno": null,
|
||||||
|
"p_holdertype": null,
|
||||||
|
"p_uscibmemberflag": null,
|
||||||
|
"p_govagencyflag": null,
|
||||||
|
"p_holdername": null,
|
||||||
|
"p_namequalifier": null,
|
||||||
|
"p_addlname": null,
|
||||||
|
"p_address1": null,
|
||||||
|
"p_address2": null,
|
||||||
|
"p_city": null,
|
||||||
|
"p_state": null,
|
||||||
|
"p_zip": null,
|
||||||
|
"p_country": 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 = { ...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_holderid,
|
||||||
|
:p_spid,
|
||||||
|
:p_locationid,
|
||||||
|
:p_holderno,
|
||||||
|
:p_holdertype,
|
||||||
|
:p_uscibmemberflag,
|
||||||
|
:p_govagencyflag,
|
||||||
|
:p_holdername,
|
||||||
|
:p_namequalifier,
|
||||||
|
:p_addlname,
|
||||||
|
:p_address1,
|
||||||
|
:p_address2,
|
||||||
|
:p_city,
|
||||||
|
:p_state,
|
||||||
|
:p_zip,
|
||||||
|
:p_country,
|
||||||
|
:p_userid,
|
||||||
|
:P_cursor
|
||||||
|
);
|
||||||
|
END;`,
|
||||||
|
{
|
||||||
|
p_holderid: {
|
||||||
|
val: finalBody.p_holderid ? finalBody.p_holderid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
p_spid: {
|
||||||
|
val: finalBody.p_spid ? finalBody.p_spid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
p_locationid: {
|
||||||
|
val: finalBody.p_locationid ? finalBody.p_locationid : null,
|
||||||
|
type: oracledb.DB_TYPE_NUMBER
|
||||||
|
},
|
||||||
|
p_holderno: {
|
||||||
|
val: finalBody.p_holderno ? finalBody.p_holderno : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_holdertype: {
|
||||||
|
val: finalBody.p_holdertype ? finalBody.p_holdertype : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_uscibmemberflag: {
|
||||||
|
val: finalBody.p_uscibmemberflag ? finalBody.p_uscibmemberflag : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_govagencyflag: {
|
||||||
|
val: finalBody.p_govagencyflag ? finalBody.p_govagencyflag : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_holdername: {
|
||||||
|
val: finalBody.p_holdername ? finalBody.p_holdername : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_namequalifier: {
|
||||||
|
val: finalBody.p_namequalifier ? finalBody.p_namequalifier : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_addlname: {
|
||||||
|
val: finalBody.p_addlname ? finalBody.p_addlname : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_address1: {
|
||||||
|
val: finalBody.p_address1 ? finalBody.p_address1 : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_address2: {
|
||||||
|
val: finalBody.p_address2 ? finalBody.p_address2 : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_city: {
|
||||||
|
val: finalBody.p_city ? finalBody.p_city : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_state: {
|
||||||
|
val: finalBody.p_state ? finalBody.p_state : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_zip: {
|
||||||
|
val: finalBody.p_zip ? finalBody.p_zip : null,
|
||||||
|
type: oracledb.DB_TYPE_NVARCHAR
|
||||||
|
},
|
||||||
|
p_country: {
|
||||||
|
val: finalBody.p_country ? finalBody.p_country : 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 { }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
GetHolderRecord = async (body: GetHolderRecordDTO) => {
|
||||||
|
|
||||||
|
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.GetHolderMaster(
|
||||||
|
: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 { }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user