modifying...

This commit is contained in:
Kallesh B S 2025-06-06 16:21:32 +05:30
parent eaea8de3a5
commit f210641618
13 changed files with 479 additions and 3299 deletions

View File

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

View File

@ -1,613 +0,0 @@
// import { ApiProperty } from '@nestjs/swagger';
// import {
// IsDefined,
// IsInt,
// IsNumber,
// IsOptional,
// IsString,
// Length,
// Max,
// Min,
// ValidateNested,
// IsArray,
// IsEmail,
// } from 'class-validator';
// import { Transform, Type } from 'class-transformer';
// import { CONTACTSTABLE_ROW_DTO } from 'src/dto/holder/holder.dto';
// export class p_clientlocaddresstableDTO {
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property Nameof must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property Nameof must be a string' })
// @IsDefined({ message: 'Property Nameof is required' })
// Nameof: string;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property Address1 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property Address1 must be a string' })
// @IsDefined({ message: 'Property Address1 is required' })
// Address1: string;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property Address2 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property Address2 must be a string' })
// @IsOptional()
// Address2?: string;
// @ApiProperty({ required: true })
// @Length(0, 30, {
// message: 'Property City must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property City must be a string' })
// @IsDefined({ message: 'Property City is required' })
// City: string;
// @ApiProperty({ required: true })
// @Length(0, 2, { message: 'Property State must be between 0 to 2 characters' })
// @IsString({ message: 'Property State must be a string' })
// @IsDefined({ message: 'Property State is required' })
// State: string;
// @ApiProperty({ required: true })
// @Length(0, 10, { message: 'Property Zip must be between 0 to 10 characters' })
// @IsString({ message: 'Property Zip must be a string' })
// @IsDefined({ message: 'Property Zip is required' })
// Zip: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property Country must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property Country must be a string' })
// @IsDefined({ message: 'Property Country is required' })
// Country: string;
// }
// export class CreateClientDataDTO {
// @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_clientname must not exceed 999999999" })
// // @Min(0, { message: "Property p_clientname must be at least 0 or more" })
// // @IsInt({ message: "Property p_clientname allows only whole numbers" })
// // @IsNumber({}, { message: "Property p_clientname must be a number" })
// // @IsDefined({ message: "Property p_clientname is required" })
// @Length(0, 50, {
// message: 'Property p_clientname must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_clientname must be a string' })
// @IsDefined({ message: 'Property p_clientname is required' })
// p_clientname: string;
// @ApiProperty({ required: true })
// @Length(0, 20, {
// message: 'Property p_lookupcode must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_lookupcode must be a string' })
// @IsDefined({ message: 'Property p_lookupcode is required' })
// p_lookupcode: 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: false })
// @Length(0, 10, {
// message: 'Property p_zip must be between 0 to 10 characters',
// })
// @IsString({ message: 'Property p_zip must be a string' })
// @IsOptional()
// p_zip?: string;
// @ApiProperty({ required: false })
// @Length(0, 2, {
// message: 'Property p_country must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_country must be a string' })
// @IsOptional()
// p_country?: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_issuingregion must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_issuingregion must be a string' })
// @IsDefined({ message: 'Property p_issuingregion is required' })
// p_issuingregion: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_revenuelocation must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_revenuelocation must be a string' })
// @IsDefined({ message: 'Property p_revenuelocation is required' })
// p_revenuelocation: 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;
// // @ApiProperty({ required: true, type: () => [p_contactstableDTO] })
// // @Type(() => p_contactstableDTO)
// // @ValidateNested({ each: true })
// // @IsArray({ message: 'Property p_contactstable allows only array type' })
// // @IsDefined({ message: 'Property p_contactstable is required' })
// // p_contactstable: p_contactstableDTO[];
// // @ApiProperty({ required: true, type: () => [p_clientlocaddresstableDTO] })
// // @Type(() => p_clientlocaddresstableDTO)
// // @ValidateNested({ each: true })
// // @IsArray({
// // message: 'Property p_clientlocaddresstable allows only array type',
// // })
// // @IsDefined({ message: 'Property p_clientlocaddresstable is required' })
// // p_clientlocaddresstable: p_clientlocaddresstableDTO[];
// }
// export class UpdateClientDTO {
// @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_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_preparername must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_preparername must be a string' })
// @IsDefined({ message: 'Property p_preparername is required' })
// p_preparername: 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, 2, {
// message: 'Property p_revenuelocation must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_revenuelocation must be a string' })
// @IsDefined({ message: 'Property p_revenuelocation is required' })
// p_revenuelocation: 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 UpdateClientContactsDTO {
// @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_clientcontactid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_clientcontactid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientcontactid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientcontactid must be a number' })
// @IsDefined({ message: 'Property p_clientcontactid is required' })
// p_clientcontactid: 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_fax must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_fax must be a string' })
// @IsDefined({ message: 'Property p_fax is required' })
// p_fax: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_mobileno must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_mobileno must be a string' })
// @IsOptional()
// p_mobileno?: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_emailaddress must be between 0 to 100 characters',
// })
// @IsEmail(
// {},
// { message: 'Property p_emailaddress must be a valid email address' },
// )
// @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 GetPreparersDTO {
// @ApiProperty({ required: true })
// @Transform(({ value }) => Number(value))
// @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: false })
// @Length(0, 50, {
// message: 'Property p_name must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_name must be a string' })
// @IsOptional()
// p_name?: string;
// @ApiProperty({ required: false })
// @Length(0, 30, {
// message: 'Property p_lookupcode must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property p_lookupcode must be a string' })
// @IsOptional()
// p_lookupcode?: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_city must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_city must be a string' })
// @IsOptional()
// p_city?: string;
// @ApiProperty({ required: false })
// @Length(0, 2, {
// message: 'Property p_state must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_state must be a string' })
// @IsOptional()
// p_state?: string;
// @ApiProperty({ required: true })
// @Length(0, 10, {
// message: 'Property p_status must be between 0 to 10 characters',
// })
// @IsString({ message: 'Property p_status must be a string' })
// @IsDefined({ message: 'Property p_status is required' })
// p_status: string;
// }
// export class UpdateClientLocationsDTO {
// @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, 50, {
// message: 'Property p_lcoationname must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_lcoationname must be a string' })
// @IsDefined({ message: 'Property p_lcoationname is required' })
// p_lcoationname: 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: false })
// @Length(0, 30, {
// message: 'Property p_city must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property p_city must be a string' })
// @IsOptional()
// 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 CreateClientContactsDTO {
// @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_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// @ApiProperty({ required: true, type: () => [CONTACTSTABLE_ROW_DTO] })
// @Type(() => CONTACTSTABLE_ROW_DTO)
// @ValidateNested({ each: true })
// @IsArray({ message: 'Property p_contactstable allows only array type' })
// @IsDefined({ message: 'Property p_contactstable is required' })
// p_contactstable: CONTACTSTABLE_ROW_DTO[];
// @ApiProperty({ required: true })
// @Length(0, 1, {
// message: 'Property p_defcontactflag must be exactly 1 character',
// })
// @IsString({ message: 'Property p_defcontactflag must be a string' })
// @IsDefined({ message: 'Property p_defcontactflag is required' })
// p_defcontactflag: 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 CreateClientLocationsDTO {
// @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_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// @ApiProperty({ required: true, type: () => [p_clientlocaddresstableDTO] })
// @Type(() => p_clientlocaddresstableDTO)
// @ValidateNested({ each: true })
// @IsArray({
// message: 'Property p_clientlocaddresstable allows only array type',
// })
// @IsDefined({ message: 'Property p_clientlocaddresstable is required' })
// p_clientlocaddresstable: p_clientlocaddresstableDTO[];
// // @ApiProperty({ required: true })
// // @Length(0, 1, {
// // message: 'Property p_defcontactflag must be exactly 1 character',
// // })
// // @IsString({ message: 'Property p_defcontactflag must be a string' })
// // @IsDefined({ message: 'Property p_defcontactflag is required' })
// // p_defcontactflag: 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 GetPreparerByClientidContactsByClientidLocByClientidDTO {
// @ApiProperty({ required: true })
// @Transform(({ value }) => Number(value))
// @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 })
// @Transform(({ value }) => Number(value))
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// }

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ export class ManageHoldersController {
@Post('/CreateHolderData')
CreateHolders(@Body() body: CreateHoldersDTO) {
return this.manageHoldersService.CreateHolders(body);
// return this.manageHoldersService.CreateHoldersX();
// return {message:"Request received.."}
}

View File

@ -9,12 +9,16 @@ import {
CONTACTSTABLE_ROW_DTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO,
HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO
} from 'src/dto/property.dto';
import { OracleService } from '../oracle.service';
@Injectable()
export class ManageHoldersService {
private readonly logger = new Logger(ManageHoldersService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
constructor(
private readonly oracleDBService: OracleDBService,
private readonly oracleService: OracleService
) { }
// CreateHoldersX = async (body: CreateHoldersDTO) => {
// const newBody = {
@ -336,164 +340,38 @@ export class ManageHoldersService {
connection = await this.oracleDBService.getConnection();
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');
}
async function CREATECONTACTSTABLE_INSTANCE(
connection,
FirstName,
LastName,
MiddleInitial,
Title,
EmailAddress,
PhoneNo,
MobileNo,
FaxNo,
) {
const result: Result<any> = await connection.execute(
`SELECT CARNETSYS.CONTACTSARRAY(:FirstName, :LastName, :MiddleInitial, :Title, :EmailAddress, :PhoneNo, :MobileNo, :FaxNo) FROM dual`,
{
FirstName,
LastName,
MiddleInitial,
Title,
EmailAddress,
PhoneNo,
MobileNo,
FaxNo,
},
);
return result.rows?.[0]?.[0] ?? [];
}
const CONTACTSARRAY = finalBody.P_CONTACTSTABLE
? await Promise.all(
finalBody.P_CONTACTSTABLE.map(async (x: CONTACTSTABLE_ROW_DTO) => {
return await CREATECONTACTSTABLE_INSTANCE(
connection,
x.P_FIRSTNAME,
x.P_LASTNAME,
x.P_MIDDLEINITIAL,
x.P_TITLE,
x.P_EMAILADDRESS,
x.P_PHONENO,
x.P_MOBILENO,
x.P_FAXNO,
);
}),
)
: [];
// Create an instance of GLTABLE
const CONTACTSTABLE_INSTANCE = new CONTACTSTABLE(CONTACTSARRAY);
const CONTACTSTABLE_INSTANCE = await this.oracleService.get_CONTACTS_TABLE_INSTANCE(finalBody)
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
: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,
},
P_SPID: { val: finalBody.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTLOCATIONID: { val: finalBody.P_CLIENTLOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_HOLDERNO: { val: finalBody.P_HOLDERNO, type: oracledb.DB_TYPE_NVARCHAR },
P_HOLDERTYPE: { val: finalBody.P_HOLDERTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_USCIBMEMBERFLAG: { val: finalBody.P_USCIBMEMBERFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_GOVAGENCYFLAG: { val: finalBody.P_GOVAGENCYFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_HOLDERNAME: { val: finalBody.P_HOLDERNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_NAMEQUALIFIER: { val: finalBody.P_NAMEQUALIFIER, type: oracledb.DB_TYPE_NVARCHAR },
P_ADDLNAME: { val: finalBody.P_ADDLNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_ADDRESS1: { val: finalBody.P_ADDRESS1, type: oracledb.DB_TYPE_NVARCHAR },
P_ADDRESS2: { val: finalBody.P_ADDRESS2, type: oracledb.DB_TYPE_NVARCHAR },
P_CITY: { val: finalBody.P_CITY, type: oracledb.DB_TYPE_NVARCHAR },
P_STATE: { val: finalBody.P_STATE, type: oracledb.DB_TYPE_NVARCHAR },
P_ZIP: { val: finalBody.P_ZIP, type: oracledb.DB_TYPE_NVARCHAR },
P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_NVARCHAR },
P_USERID: { val: finalBody.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CONTACTSTABLE: { val: CONTACTSTABLE_INSTANCE, type: 'CARNETSYS.CONTACTSTABLE' },
P_HOLDERCURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
P_HOLDERCONTACTCURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -47,3 +47,13 @@ export const fetchCursor = async <T>(cursor: oracledb.ResultSet<T>, context: str
throw new InternalServerErrorException('Error reading data from database.');
}
};
export const setEmptyStringsToNull = (obj: any): void => {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}