inprogress

This commit is contained in:
Kallesh B S 2025-05-26 17:27:36 +05:30
parent 0f54934bb4
commit 39a4ebba5f
56 changed files with 3753 additions and 2815 deletions

View File

@ -1,5 +1,15 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import { APPLICATIONNAME_DTO, AUTHREP_DTO, AUTO_FLAG_DTO, CLIENTID_DTO, COMMERCIAL_SAMPLE_FLAG_DTO, COUNTRYTABLE_DTO, CUSTCOURIERNO_DTO, DELIVERYMETHOD_DTO, DELIVERYTYPE_DTO, EXIBITIONS_FAIR_FLAG_DTO, FORMOFSECURITY_DTO, GLTABLE_DTO, HEADERID_DTO, HOLDERID_DTO, HORSE_FLAG_DTO, INSPROTECTION_DTO, LDIPROTECTION_DTO, LOCATIONID_DTO, NOTES_DTO, PAYMENTMETHOD_DTO, PROF_EQUIPMENT_FLAG_DTO, REFNO_DTO, SHIPADDRID_DTO, SHIPTOTYPE_DTO, SPID_DTO, USERID_DTO, USSETS_DTO } from "../property.dto";
import {
APPLICATIONNAME_DTO, AUTHREP_DTO, AUTO_FLAG_DTO, CLIENTID_DTO,
COMMERCIAL_SAMPLE_FLAG_DTO, COUNTRYTABLE_DTO, CUSTCOURIERNO_DTO,
DELIVERYMETHOD_DTO, DELIVERYTYPE_DTO, EXIBITIONS_FAIR_FLAG_DTO,
FORMOFSECURITY_DTO, GLTABLE_DTO, HEADERID_DTO, HOLDERID_DTO,
HORSE_FLAG_DTO, INSPROTECTION_DTO, LDIPROTECTION_DTO,
LOCATIONID_DTO, NOTES_DTO, PAYMENTMETHOD_DTO,
PROF_EQUIPMENT_FLAG_DTO, REFNO_DTO, SHIPADDRID_DTO,
SHIPTOTYPE_DTO, USERID_DTO, USSETS_DTO
} from "../property.dto";
import { SPID_DTO } from "../sp/sp-property.dto";
export class SaveCarnetApplicationDTO extends IntersectionType(

View File

@ -1,5 +1,7 @@
import { IntersectionType } from '@nestjs/swagger';
import { CARNET_TYPE_DTO, END_NUMBER_DTO, REGIONID_DTO, SPID_DTO, START_NUMBER_DTO } from 'src/dto/property.dto';
import { CARNET_TYPE_DTO, END_NUMBER_DTO, START_NUMBER_DTO } from '../carnet/carnet-property.dto';
import { SPID_DTO } from '../sp/sp-property.dto';
import { REGIONID_DTO } from '../region/region-property.dto';
export class CreateCarnetSequenceDTO extends IntersectionType(
SPID_DTO, REGIONID_DTO, START_NUMBER_DTO, END_NUMBER_DTO, CARNET_TYPE_DTO

View File

@ -0,0 +1,27 @@
// carnet
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsString, Min } from "class-validator";
export class START_NUMBER_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_startnumber must be a number' })
@IsDefined({ message: 'Property p_startnumber is required' })
@Min(0, { message: 'Property p_startnumber must be at least 0' })
P_STARTNUMBER: number;
}
export class END_NUMBER_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_endnumber must be a number' })
@IsDefined({ message: 'Property p_endnumber is required' })
@Min(0, { message: 'Property p_endnumber must be at least 0' })
P_ENDNUMBER: number;
}
export class CARNET_TYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_carnettype must be a string' })
@IsDefined({ message: 'Property p_carnettype is required' })
P_CARNETTYPE: string;
}

View File

@ -0,0 +1,146 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsString, Length, Min } from "class-validator";
import { YON } from "../property.dto";
// CONTACT
// export class SP_CONTACTID_DTO {
// @ApiProperty({ required: true })
// @Min(0, { message: 'Property p_spcontactid must be at least 0' })
// @IsInt({ message: 'Property p_SPid must be a whole number' })
// @Transform(({ value }) => Number(value))
// @IsNumber({}, { message: 'Property p_spcontactid must be a number' })
// @IsDefined({ message: 'Property p_spcontactid is required' })
// P_SPCONTACTID: number;
// }
// export class DEFAULT_CONTACT_FLAG_DTO {
// @ApiProperty({ required: true, enum: YON })
// @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
// @IsEnum(YON, { message: 'P_EnablePasswordPolicy must be either "Y" or "N"' })
// @Length(1, 1, { message: 'P_EnablePasswordPolicy must be between 5 and 6 characters' })
// @IsString()
// @IsDefined({ message: "Invalid Request" })
// p_defcontactflag: YON;
// }
// export class FIRSTNAME_DTO {
// @ApiProperty({ required: true })
// @IsString()
// p_firstname: string;
// }
// export class LASTNAME_DTO {
// @ApiProperty({ required: true })
// @IsString()
// p_lastname: string;
// }
// export class MIDDLE_INITIAL_DTO {
// @ApiProperty({ required: false })
// @IsString()
// P_MIDDLEINITIAL: string;
// }
// export class TITLE_DTO {
// @ApiProperty({ required: true })
// @IsString()
// p_title: string;
// }
// export class PHONE_NO_DTO {
// @ApiProperty({ required: true })
// @IsString()
// p_phoneno: string;
// }
// export class MOBILE_NO_DTO {
// @ApiProperty({ required: true })
// @IsString()
// p_mobileno: string;
// }
// export class FAX_NO_DTO {
// @ApiProperty({ required: true })
// @IsString()
// p_faxno: string;
// }
// export class EMAIL_ADDRESS_DTO {
// @ApiProperty({ required: true })
// @IsEmail()
// p_emailaddress: string;
// }
export class SP_CONTACTID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property P_SPCONTACTID must be at least 0' })
@IsInt({ message: 'Property P_SPCONTACTID must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SPCONTACTID must be a number' })
@IsDefined({ message: 'Property P_SPCONTACTID is required' })
P_SPCONTACTID: number;
}
export class DEFAULT_CONTACT_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_DEFCONTACTFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_DEFCONTACTFLAG must be between 5 and 6 characters' }) // Note: This message may not match actual length constraint
@IsString()
@IsDefined({ message: "Invalid Request" })
P_DEFCONTACTFLAG: YON;
}
export class FIRSTNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, { message: 'Property P_FIRSTNAME must be between 0 to 50 characters' })
@IsString({ message: 'Property FirP_FIRSTNAMEstName must be a string' })
@IsDefined({ message: 'Property P_FIRSTNAME is required' })
P_FIRSTNAME: string;
}
export class LASTNAME_DTO {
@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;
}
export class MIDDLE_INITIAL_DTO {
@ApiProperty({ required: true })
@Length(0, 3, { message: 'Property P_MIDDLEINITIAL must be between 0 to 3 characters' })
@IsString({ message: 'Property P_MIDDLEINITIAL must be a string' })
P_MIDDLEINITIAL: string;
}
export class TITLE_DTO {
@ApiProperty({ required: true })
@Length(0, 50, { message: 'Property P_TITLE must be between 0 to 50 characters' })
@IsString({ message: 'Property P_TITLE must be a string' })
P_TITLE: string;
}
export class PHONE_NO_DTO {
@ApiProperty({ required: true })
@Length(0, 20, { message: 'Property P_PHONENO must be between 0 to 20 characters' })
@IsString({ message: 'Property P_PHONENO must be a string' })
@IsDefined({ message: 'Property P_PHONENO is required' })
P_PHONENO: string;
}
export class MOBILE_NO_DTO {
@ApiProperty({ required: true })
@Length(0, 20, { message: 'Property P_MOBILENO must be between 0 to 20 characters' })
@IsString({ message: 'Property P_MOBILENO must be a string' })
@IsDefined({ message: 'Property P_MOBILENO is required' })
P_MOBILENO: string;
}
export class FAX_NO_DTO {
@ApiProperty({ required: true })
@Length(0, 20, { message: 'Property FAXNO must be between 0 to 20 characters' })
@IsString({ message: 'Property FAXNO must be a string' })
P_FAXNO: string;
}
export class EMAIL_ADDRESS_DTO {
@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;
}

View File

@ -0,0 +1 @@

8
src/dto/fee/fee.dto.ts Normal file
View File

@ -0,0 +1,8 @@
import { IntersectionType } from "@nestjs/swagger";
import { SPID_DTO } from "../sp/sp-property.dto";
import { ACTIVE_INACTIVE_STATUS_DTO } from "../property.dto";
export class GetFeeGeneralDTO extends IntersectionType(
SPID_DTO,
ACTIVE_INACTIVE_STATUS_DTO
) {}

View File

@ -0,0 +1,20 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsString, Length } from "class-validator";
export class USCIBMEMBERFLAG_DTO {
@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;
}
export class GOVAGENCYFLAG_DTO {
@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;
}

View File

@ -0,0 +1,65 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator";
import { CONTACTSTABLE_ROW_DTO } from "./holder.dto";
import { Type } from "class-transformer";
export class HOLDERNO_DTO {
@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;
}
export class HOLDERTYPE_DTO {
@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;
}
export class HOLDERNAME_DTO {
@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;
}
export class NAMEQUALIFIER_DTO {
@ApiProperty({ required: true })
@Length(0, 10, { message: 'Property P_NAMEQUALIFIER must be between 0 to 10 characters' })
@IsString({ message: 'Property P_NAMEQUALIFIER must be a string' })
P_NAMEQUALIFIER: string;
}
export class ADDLNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_ADDLNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_ADDLNAME must be a string' })
P_ADDLNAME: string;
}
export class CONTACTSTABLE_DTO {
@ApiProperty({ required: true, type: () => [CONTACTSTABLE_ROW_DTO] })
@Type(() => CONTACTSTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({ message: 'Property P_CONTACTSTABLE allows only array type' })
P_CONTACTSTABLE: CONTACTSTABLE_ROW_DTO[];
}
export class HOLDERCONTACTID_DTO {
@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;
}

View File

@ -0,0 +1,92 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import { SPID_DTO } from "../sp/sp-property.dto";
import { CLIENTLOCATIONID_DTO } from "../location/location-property.dto";
import { ADDLNAME_DTO, CONTACTSTABLE_DTO, HOLDERCONTACTID_DTO, HOLDERNAME_DTO, HOLDERNO_DTO, HOLDERTYPE_DTO, NAMEQUALIFIER_DTO } from "./holder-property.dto";
import { GOVAGENCYFLAG_DTO, USCIBMEMBERFLAG_DTO } from "../flag/flag-property.dto";
import { ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, EMAIL_DTO, HOLDERID_DTO, LOCATIONID_DTO, STATE_DTO, USERID_DTO, ZIP_DTO } from "../property.dto";
import { EMAIL_ADDRESS_DTO, FAX_NO_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, MOBILE_NO_DTO, PHONE_NO_DTO, TITLE_DTO } from "../contact/contact-property.dto";
export class CONTACTSTABLE_ROW_DTO extends IntersectionType(
FIRSTNAME_DTO,
LASTNAME_DTO,
PartialType(MIDDLE_INITIAL_DTO),
PartialType(TITLE_DTO),
EMAIL_ADDRESS_DTO,
PHONE_NO_DTO,
MOBILE_NO_DTO,
FAX_NO_DTO
) { }
export class CreateHoldersDTO extends IntersectionType(
SPID_DTO,
CLIENTLOCATIONID_DTO,
HOLDERNO_DTO,
HOLDERTYPE_DTO,
USCIBMEMBERFLAG_DTO,
GOVAGENCYFLAG_DTO,
HOLDERNAME_DTO,
PartialType(NAMEQUALIFIER_DTO),
ADDLNAME_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
USERID_DTO,
PartialType(CONTACTSTABLE_DTO)
) { }
export class UpdateHolderDTO extends IntersectionType(
HOLDERID_DTO,
SPID_DTO,
LOCATIONID_DTO,
HOLDERNO_DTO,
HOLDERTYPE_DTO,
USCIBMEMBERFLAG_DTO,
GOVAGENCYFLAG_DTO,
HOLDERNAME_DTO,
PartialType(NAMEQUALIFIER_DTO),
PartialType(ADDLNAME_DTO),
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
USERID_DTO
) { }
export class UpdateHolderContactDTO extends IntersectionType(
HOLDERCONTACTID_DTO,
SPID_DTO,
FIRSTNAME_DTO,
LASTNAME_DTO,
PartialType(MIDDLE_INITIAL_DTO),
TITLE_DTO,
PHONE_NO_DTO,
MOBILE_NO_DTO,
PartialType(FAX_NO_DTO),
EMAIL_ADDRESS_DTO,
USERID_DTO
) { }
export class GetHolderDTO extends IntersectionType(
SPID_DTO,
HOLDERID_DTO
) { }
export class HolderActivateOrInactivateDTO extends IntersectionType(
SPID_DTO,
HOLDERID_DTO,
USERID_DTO
) { }
export class HolderContactActivateOrInactivateDTO extends IntersectionType(
SPID_DTO,
HOLDERCONTACTID_DTO,
USERID_DTO
) {
}

View File

@ -0,0 +1,14 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsInt, IsNumber, Max, Min } from "class-validator";
export class CLIENTLOCATIONID_DTO {
@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;
}

View File

@ -0,0 +1,80 @@
import { ApiProperty, IntersectionType } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsDefined, IsInt, IsNumber, IsString, Min } from "class-validator";
export class TABLEFULLDESC_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_TABLEFULLDESC must be a string' })
@IsDefined({ message: 'Property P_TABLEFULLDESC is required' })
P_TABLEFULLDESC: string;
}
export class PARAMTYPE_DTO {
@ApiProperty({ required: true })
@IsString()
P_PARAMTYPE: string;
}
export class PARAMDESC_DTO {
@ApiProperty({ required: true })
@IsString()
P_PARAMDESC: string;
}
export class PARAMVALUE_DTO {
@ApiProperty({ required: true })
@IsString()
P_PARAMVALUE: string;
}
export class ADDPAAMVALUE1_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE1: string;
}
export class ADDPAAMVALUE2_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE2: string;
}
export class ADDPAAMVALUE3_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE3: string;
}
export class ADDPAAMVALUE4_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE4: string;
}
export class ADDPAAMVALUE5_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE5: string;
}
export class SORTSEQ_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property P_SORTSEQ must be at least 0' })
@IsInt({ message: 'Property P_SORTSEQ must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SORTSEQ must be a number' })
@IsDefined({ message: 'Property P_SORTSEQ is required' })
P_SORTSEQ: number;
}
export class PARAMID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property P_PARAMID must be at least 0' })
@IsInt({ message: 'Property P_PARAMID must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_PARAMID must be a number' })
@IsDefined({ message: 'Property P_PARAMID is required' })
P_PARAMID: number;
}

View File

@ -0,0 +1,44 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsOptional, IsString } from "class-validator";
import { USERID_DTO } from "../property.dto";
import { ADDPAAMVALUE1_DTO, ADDPAAMVALUE2_DTO, ADDPAAMVALUE3_DTO, ADDPAAMVALUE4_DTO, ADDPAAMVALUE5_DTO, PARAMDESC_DTO, PARAMID_DTO, PARAMTYPE_DTO, PARAMVALUE_DTO, SORTSEQ_DTO, TABLEFULLDESC_DTO } from "./param-table-property.dto";
import { SPID_DTO } from "../sp/sp-property.dto";
export class CreateTableRecordDTO extends IntersectionType(USERID_DTO, TABLEFULLDESC_DTO) { }
export class CreateParamRecordDTO extends IntersectionType(
PartialType(SPID_DTO),
PARAMTYPE_DTO,
PARAMDESC_DTO,
PARAMVALUE_DTO,
PartialType(ADDPAAMVALUE1_DTO),
PartialType(ADDPAAMVALUE2_DTO),
PartialType(ADDPAAMVALUE3_DTO),
PartialType(ADDPAAMVALUE4_DTO),
PartialType(ADDPAAMVALUE5_DTO),
SORTSEQ_DTO,
USERID_DTO
) { }
export class UpdateParamRecordDTO extends IntersectionType(
PartialType(SPID_DTO),
PARAMID_DTO,
PARAMDESC_DTO,
PartialType(ADDPAAMVALUE1_DTO),
PartialType(ADDPAAMVALUE2_DTO),
PartialType(ADDPAAMVALUE3_DTO),
PartialType(ADDPAAMVALUE4_DTO),
PartialType(ADDPAAMVALUE5_DTO),
SORTSEQ_DTO,
USERID_DTO
) { }
export class getParamValuesDTO extends IntersectionType(
PartialType(SPID_DTO),
PartialType(PARAMTYPE_DTO)
) { }
export class ActivateOrInactivateParamRecordDTO extends IntersectionType(
PARAMID_DTO,
USERID_DTO
) { }

View File

@ -1,35 +1,36 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString, Length, Max, MaxLength, Min, ValidateNested } from "class-validator";
import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString, Length, Matches, Max, MaxLength, Min, ValidateNested } from "class-validator";
// General
export class USERID_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_userid: string;
@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;
}
export class USER_ID_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_user_id must be a string' })
@IsDefined({ message: 'Property p_user_id is required' })
p_user_id: string;
@IsString({ message: 'Property P_USER_ID must be a string' })
@IsDefined({ message: 'Property P_USER_ID is required' })
P_USER_ID: string;
}
export class EMAIL_DTO {
@ApiProperty({ required: true })
@IsEmail({}, { message: "Invalid p_emailaddr property" })
@IsEmail({}, { message: "Invalid P_EMAILADDR property" })
@Length(0, 50, {
message: 'Property p_emailaddr must be between 0 to 50 characters',
message: 'Property P_EMAILADDR must be between 0 to 50 characters',
})
@IsString({ message: 'p_emailaddr p_userid must be string' })
@IsDefined({ message: 'p_emailaddr p_userid is required' })
p_emailaddr: string;
@IsString({ message: 'P_EMAILADDR p_userid must be string' })
@IsDefined({ message: 'P_EMAILADDR p_userid is required' })
P_EMAILADDR: string;
}
@ -37,14 +38,14 @@ export class LOOKUP_CODE_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_lookupCode: string;
P_LOOKUPCODE: string;
}
export class PASSWORD_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_password: string;
P_PASSWORD: string;
}
export enum YON {
@ -52,94 +53,100 @@ export enum YON {
NO = "N",
}
export class Name_DTO {
export class NAME_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_name must be a string' })
@IsDefined({ message: 'Property p_name is required' })
@IsString({ message: 'Property P_NAME must be a string' })
@IsDefined({ message: 'Property P_NAME is required' })
P_NAME: string;
}
export class ADDRESS1_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_address1 must be a string' })
@IsDefined({ message: 'Property p_address1 is required' })
p_address1: string;
@IsString({ message: 'Property P_ADDRESS1 must be a string' })
@IsDefined({ message: 'Property P_ADDRESS1 is required' })
P_ADDRESS1: string;
}
export class ADDRESS2_DTO {
@ApiProperty({ required: false })
@IsString({ message: 'Property p_address2 must be a string' })
@IsOptional()
p_address2?: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ADDRESS2 must be a string' })
@IsDefined({ message: 'Property P_ADDRESS2 is required' })
P_ADDRESS2: string;
}
export class CITY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_city must be a string' })
@IsDefined({ message: 'Property p_city is required' })
p_city: string;
@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;
}
export class STATE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_state must be a string' })
@IsDefined({ message: 'Property p_state is required' })
p_state: string;
@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;
}
export class COUNTRY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_country must be a string' })
@IsDefined({ message: 'Property p_country is required' })
p_country: string;
@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;
}
export class ZIP_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_zip must be a string' })
@IsDefined({ message: 'Property p_zip is required' })
p_zip: string;
@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;
}
export class ISSUING_REGION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_issuingregion must be a string' })
@IsDefined({ message: 'Property p_issuingregion is required' })
p_issuingregion: string;
@IsString({ message: 'Property P_ISSUINGREGION must be a string' })
@IsDefined({ message: 'Property P_ISSUINGREGION is required' })
P_ISSUINGREGION: string;
}
export class REPLACEMENT_REGION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_replacementregion must be a string' })
@IsDefined({ message: 'Property p_replacementregion is required' })
p_replacementregion: string;
@IsString({ message: 'Property P_REPLACEMENTREGION must be a string' })
@IsDefined({ message: 'Property P_REPLACEMENTREGION is required' })
P_REPLACEMENTREGION: string;
}
export class BOND_SURETY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_bondsurety must be a string' })
@IsDefined({ message: 'Property p_bondsurety is required' })
p_bondsurety: string;
@IsString({ message: 'Property P_BONDSURETY must be a string' })
@IsDefined({ message: 'Property P_BONDSURETY is required' })
P_BONDSURETY: string;
}
export class CARGO_POLICY_NO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_cargopolicyno must be a string' })
@IsDefined({ message: 'Property p_cargopolicyno is required' })
p_cargopolicyno: string;
@IsString({ message: 'Property P_CARGOPOLICYNO must be a string' })
@IsDefined({ message: 'Property P_CARGOPOLICYNO is required' })
P_CARGOPOLICYNO: string;
}
export class CARGO_SURETY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_cargosurety must be a string' })
@IsDefined({ message: 'Property p_cargosurety is required' })
p_cargosurety: string;
@IsString({ message: 'Property P_CARGOSURETY must be a string' })
@IsDefined({ message: 'Property P_CARGOSURETY is required' })
P_CARGOSURETY: string;
}
export class NOTES_DTO {
@ -156,49 +163,40 @@ export class FILE_ID_DTO {
}
export class ACTIVE_INACTIVE_STATUS_DTO {
@ApiProperty({ required: true })
@Matches(/^.{6}$|^.{8}$/, {
message: 'Property P_ACTIVE_INACTIVE is invalid',
})
@IsString({ message: 'Property P_ACTIVE_INACTIVE must be a string' })
@IsDefined({ message: 'Property P_ACTIVE_INACTIVE is required' })
P_ACTIVE_INACTIVE: string;
}
// user maintenance
export class ENABLE_PASSWORD_POLICY_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_EnablePasswordPolicy must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_EnablePasswordPolicy must be between 5 and 6 characters' })
@IsEnum(YON, { message: 'P_ENABLEPASSWORDPOLICY must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_ENABLEPASSWORDPOLICY must be between 5 and 6 characters' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_EnablePasswordPolicy: YON;
P_ENABLEPASSWORDPOLICY: YON;
}
export class DOMAIN_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property p_domain must be between 0 to 50 characters',
message: 'Property P_DOMAIN must be between 0 to 50 characters',
})
@IsString({ message: 'Property p_domain must be a string' })
@IsDefined({ message: 'Property p_domain is required' })
p_domain: string;
@IsString({ message: 'Property P_DOMAIN must be a string' })
@IsDefined({ message: 'Property P_DOMAIN is required' })
P_DOMAIN: string;
}
// SP
export class SPID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property p_spid must be at least 0' })
@IsInt({ message: 'Property p_spid must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_spid must be a number' })
@IsDefined({ message: 'Property p_spid is required' })
p_spid: number;
}
export class SP_ID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property p_SPid must be at least 0' })
@IsInt({ message: 'Property p_SPid must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_SPid must be a number' })
@IsDefined({ message: 'Property p_SPid is required' })
p_SPid: number;
}
// client
export class CLIENTID_DTO {
@ -216,125 +214,31 @@ export class CLIENTID_DTO {
export class CLIENT_CONTACTID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property p_clientcontactid must not exceed 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;
@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;
}
// Region
export class REGION_CODE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_region must be a string' })
@IsDefined({ message: 'Property p_region is required' })
P_REGION: string;
}
export class REGIONID_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_regionID must be a number' })
@IsDefined({ message: 'Property p_regionID is required' })
P_REGIONID: number;
}
// CONTACT
export class SP_CONTACTID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property p_spcontactid must be at least 0' })
@IsInt({ message: 'Property p_SPid must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_spcontactid must be a number' })
@IsDefined({ message: 'Property p_spcontactid is required' })
p_spcontactid: number;
}
export class DEFAULT_CONTACT_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_EnablePasswordPolicy must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_EnablePasswordPolicy must be between 5 and 6 characters' })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_defcontactflag: YON;
}
export class FIRSTNAME_DTO {
@ApiProperty({ required: true })
@IsString()
p_firstname: string;
}
export class LASTNAME_DTO {
@ApiProperty({ required: true })
@IsString()
p_lastname: string;
}
export class MIDDLE_INITIAL_DTO {
@ApiProperty({ required: false })
@IsString()
P_MIDDLEINITIAL: string;
}
export class TITLE_DTO {
@ApiProperty({ required: true })
@IsString()
p_title: string;
}
export class PHONE_NO_DTO {
@ApiProperty({ required: true })
@IsString()
p_phoneno: string;
}
export class MOBILE_NO_DTO {
@ApiProperty({ required: true })
@IsString()
p_mobileno: string;
}
export class FAX_NO_DTO {
@ApiProperty({ required: true })
@IsString()
p_faxno: string;
}
export class EMAIL_ADDRESS_DTO {
@ApiProperty({ required: true })
@IsEmail()
p_emailaddress: string;
}
// carnet
export class START_NUMBER_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_startnumber must be a number' })
@IsDefined({ message: 'Property p_startnumber is required' })
@Min(0, { message: 'Property p_startnumber must be at least 0' })
p_startnumber: number;
}
export class END_NUMBER_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_endnumber must be a number' })
@IsDefined({ message: 'Property p_endnumber is required' })
@Min(0, { message: 'Property p_endnumber must be at least 0' })
p_endnumber: number;
}
export class CARNET_TYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_carnettype must be a string' })
@IsDefined({ message: 'Property p_carnettype is required' })
p_carnettype: string;
}
//Location
export class LOCATIONID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property p_locationid must not exceed 999999999',
})
@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' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_locationid must be a number' })
@IsDefined({ message: 'Property p_locationid is required' })
P_LOCATIONID: number;

View File

@ -0,0 +1,18 @@
// Region
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsString } from "class-validator";
export class REGION_CODE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_region must be a string' })
@IsDefined({ message: 'Property p_region is required' })
P_REGION: string;
}
export class REGIONID_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_regionID must be a number' })
@IsDefined({ message: 'Property p_regionID is required' })
P_REGIONID: number;
}

View File

@ -1,6 +1,7 @@
import { IntersectionType } from '@nestjs/swagger';
import { Name_DTO, REGION_CODE_DTO, REGIONID_DTO } from 'src/dto/property.dto';
import { REGION_CODE_DTO, REGIONID_DTO } from './region-property.dto';
import { NAME_DTO } from '../property.dto';
export class InsertRegionsDto extends IntersectionType(REGION_CODE_DTO, Name_DTO) { }
export class InsertRegionsDto extends IntersectionType(REGION_CODE_DTO, NAME_DTO) { }
export class UpdateRegionDto extends IntersectionType(REGIONID_DTO, Name_DTO) { }
export class UpdateRegionDto extends IntersectionType(REGIONID_DTO, NAME_DTO) { }

View File

@ -1,6 +1,12 @@
import { IntersectionType } from '@nestjs/swagger';
import { DEFAULT_CONTACT_FLAG_DTO, EMAIL_ADDRESS_DTO, FAX_NO_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, MOBILE_NO_DTO, PHONE_NO_DTO, SP_CONTACTID_DTO, SPID_DTO, TITLE_DTO, USER_ID_DTO } from 'src/dto/property.dto';
import {
DEFAULT_CONTACT_FLAG_DTO, EMAIL_ADDRESS_DTO, FAX_NO_DTO,
FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, MOBILE_NO_DTO, PHONE_NO_DTO,
SP_CONTACTID_DTO, TITLE_DTO
} from 'src/dto/contact/contact-property.dto';
import { USER_ID_DTO } from '../property.dto';
import { SPID_DTO } from '../sp/sp-property.dto';
export class InsertSPContactsDTO extends IntersectionType(
SPID_DTO, DEFAULT_CONTACT_FLAG_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, TITLE_DTO,

View File

@ -0,0 +1,16 @@
// SP
import { ApiProperty } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsDefined, IsInt, IsNumber, Max, Min } from "class-validator";
export class SPID_DTO {
@ApiProperty({ required: true })
@Max(999999999, { message: 'Property P_SPID must not exceed 999999999' })
@Min(0, { message: 'Property P_SPID must be at least 0' })
@IsInt({ message: 'Property P_SPID must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SPID must be a number' })
@IsDefined({ message: 'Property P_SPID is required' })
P_SPID: number;
}

View File

@ -1,15 +1,21 @@
import { IntersectionType, PartialType } from '@nestjs/swagger';
import { ADDRESS1_DTO, ADDRESS2_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO, CARGO_SURETY_DTO, CITY_DTO, COUNTRY_DTO, FILE_ID_DTO, ISSUING_REGION_DTO, LOOKUP_CODE_DTO, Name_DTO, NOTES_DTO, REPLACEMENT_REGION_DTO, SPID_DTO, STATE_DTO, USER_ID_DTO, ZIP_DTO } from 'src/dto/property.dto';
import {
ADDRESS1_DTO, ADDRESS2_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO,
CARGO_SURETY_DTO, CITY_DTO, COUNTRY_DTO, FILE_ID_DTO,
ISSUING_REGION_DTO, LOOKUP_CODE_DTO, NAME_DTO, NOTES_DTO,
REPLACEMENT_REGION_DTO, STATE_DTO, USER_ID_DTO, ZIP_DTO
} from 'src/dto/property.dto';
import { SPID_DTO } from './sp-property.dto';
export class InsertNewServiceProviderDTO extends IntersectionType(
Name_DTO, LOOKUP_CODE_DTO, ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, STATE_DTO, COUNTRY_DTO, ZIP_DTO,
NAME_DTO, LOOKUP_CODE_DTO, ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, STATE_DTO, COUNTRY_DTO, ZIP_DTO,
ISSUING_REGION_DTO, REPLACEMENT_REGION_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO, CARGO_SURETY_DTO,
USER_ID_DTO, PartialType(NOTES_DTO), FILE_ID_DTO
) { }
export class UpdateServiceProviderDTO extends IntersectionType(
SPID_DTO, Name_DTO, LOOKUP_CODE_DTO, ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, STATE_DTO, COUNTRY_DTO,
SPID_DTO, NAME_DTO, LOOKUP_CODE_DTO, ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, STATE_DTO, COUNTRY_DTO,
ISSUING_REGION_DTO, REPLACEMENT_REGION_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO, CARGO_SURETY_DTO,
ZIP_DTO, USER_ID_DTO, PartialType(NOTES_DTO), FILE_ID_DTO
) { }

View File

@ -1,5 +1,6 @@
import { IntersectionType } from "@nestjs/swagger";
import { CLIENT_CONTACTID_DTO, CLIENTID_DTO, DOMAIN_DTO, EMAIL_DTO, ENABLE_PASSWORD_POLICY_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO, SPID_DTO, USERID_DTO } from "src/dto/property.dto";
import { CLIENT_CONTACTID_DTO, CLIENTID_DTO, DOMAIN_DTO, EMAIL_DTO, ENABLE_PASSWORD_POLICY_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO, USERID_DTO } from "src/dto/property.dto";
import { SPID_DTO } from "../sp/sp-property.dto";
export class SPID_CLIENTID_DTO extends IntersectionType(SPID_DTO, CLIENTID_DTO) { }

View File

@ -236,14 +236,14 @@ export class ManageClientsService {
finalBody.p_contactstable.forEach((contact) => {
contactTable.rows.add(
contact.FirstName,
contact.LastName,
contact.MiddleInitial,
contact.Title,
contact.EmailAddress,
contact.PhoneNo,
contact.MobileNo,
contact.FaxNo,
contact.P_FIRSTNAME,
contact.P_LASTNAME,
contact.P_MIDDLEINITIAL,
contact.P_TITLE,
contact.P_EMAILADDRESS,
contact.P_PHONENO,
contact.P_MOBILENO,
contact.P_FAXNO,
);
});

View File

@ -1,7 +1,8 @@
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
import { ManageFeeService } from './manage-fee.service';
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { ApiTags } from '@nestjs/swagger';
import { GetFeeGeneralDTO } from 'src/dto/fee/fee.dto';
@Controller('mssql')
export class ManageFeeController {

View File

@ -1,10 +1,11 @@
import { Injectable, Logger } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { Connection, Request } from 'mssql';
import * as mssql from 'mssql';
import { GetFeeGeneralDTO } from 'src/dto/fee/fee.dto';
@Injectable()
export class ManageFeeService {

View File

@ -1,7 +1,7 @@
import { BadRequestException, Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/oracle/manage-holders/manage-holders.dto';
import { ManageHoldersService } from './manage-holders.service';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/holder/holder.dto';
@Controller('mssql')
export class ManageHoldersController {
@ -29,10 +29,10 @@ export class ManageHoldersController {
@ApiTags('Manage Holders - Mssql')
@Get('/GetHolderRecord/:p_spid/:p_holderid')
GetHolderMaster(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { p_spid, p_holderid };
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderRecord(reqParams);
}
@ -40,81 +40,81 @@ export class ManageHoldersController {
@ApiTags('Manage Holders - Mssql')
@Get('/GetHolderContacts/:p_spid/:p_holderid')
GetHolderContacts(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { p_spid, p_holderid };
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderContacts(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/InactivateHolder/:p_spid/:p_holderid/:p_userid')
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
InactivateHolder(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if(!p_userid){
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.InactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/ReactivateHolder/:p_spid/:p_holderid/:p_userid')
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
ReactivateHolder(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if(!p_userid){
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.ReactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/InactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
InactivateHolderContact(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if(!p_userid){
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
p_spid,
p_holderContactid,
p_userid
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.InactivateHolderContact(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/ReactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
ReactivateHolderContact(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if(!p_userid){
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
p_spid,
p_holderContactid,
p_userid
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.ReactivateHolderContact(reqParams);

View File

@ -1,8 +1,8 @@
import { Injectable } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/oracle/manage-holders/manage-holders.dto';
import * as mssql from 'mssql';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/holder/holder.dto';
@Injectable()
export class ManageHoldersService {
@ -49,22 +49,23 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, finalBody.p_spid);
request.input('p_clientlocationid', mssql.Int, finalBody.p_clientlocationid);
request.input('p_holderno', mssql.VarChar(15), finalBody.p_holderno);
request.input('p_holdertype', mssql.VarChar(3), finalBody.p_holdertype);
request.input('p_uscibmemberflag', mssql.VarChar(1), finalBody.p_uscibmemberflag);
request.input('p_govagencyflag', mssql.VarChar(1), finalBody.p_govagencyflag);
request.input('p_holdername', mssql.VarChar(50), finalBody.p_holdername);
request.input('p_namequalifier', mssql.VarChar(10), finalBody.p_namequalifier);
request.input('p_addlname', mssql.VarChar(50), finalBody.p_addlname);
request.input('p_address1', mssql.VarChar(50), finalBody.p_address1);
request.input('p_address2', mssql.VarChar(50), finalBody.p_address2);
request.input('p_city', mssql.VarChar(30), finalBody.p_city);
request.input('p_state', mssql.VarChar(2), finalBody.p_state);
request.input('p_zip', mssql.VarChar(10), finalBody.p_zip);
request.input('p_country', mssql.VarChar(2), finalBody.p_country);
request.input('p_userid', mssql.VarChar(50), finalBody.p_userid);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTLOCATIONID', mssql.Int, finalBody.P_CLIENTLOCATIONID);
request.input('P_HOLDERNO', mssql.VarChar(15), finalBody.P_HOLDERNO);
request.input('P_HOLDERTYPE', mssql.VarChar(3), finalBody.P_HOLDERTYPE);
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(1), finalBody.P_USCIBMEMBERFLAG);
request.input('P_GOVAGENCYFLAG', mssql.VarChar(1), finalBody.P_GOVAGENCYFLAG);
request.input('P_HOLDERNAME', mssql.VarChar(50), finalBody.P_HOLDERNAME);
request.input('P_NAMEQUALIFIER', mssql.VarChar(10), finalBody.P_NAMEQUALIFIER);
request.input('P_ADDLNAME', mssql.VarChar(50), finalBody.P_ADDLNAME);
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
request.input('P_USERID', mssql.VarChar(50), finalBody.P_USERID);
const contactTable = new mssql.Table('carnetsys.ContactsTable');
contactTable.create = true;
@ -77,16 +78,16 @@ export class ManageHoldersService {
contactTable.columns.add('MobileNo', mssql.VarChar(20));
contactTable.columns.add('FaxNo', mssql.VarChar(20));
finalBody.p_contactstable && finalBody.p_contactstable.forEach((contact) => {
finalBody.P_CONTACTSTABLE && finalBody.P_CONTACTSTABLE.forEach((contact) => {
contactTable.rows.add(
contact.FirstName,
contact.LastName,
contact.MiddleInitial,
contact.Title,
contact.EmailAddress,
contact.PhoneNo,
contact.MobileNo,
contact.FaxNo,
contact.P_FIRSTNAME,
contact.P_LASTNAME,
contact.P_MIDDLEINITIAL,
contact.P_TITLE,
contact.P_EMAILADDRESS,
contact.P_PHONENO,
contact.P_MOBILENO,
contact.P_FAXNO,
);
});
@ -106,8 +107,8 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_holderid', mssql.Int, body.p_holderid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
const result = await request.execute('carnetsys.GetHolderMaster');
return { data: result.recordset };
@ -123,23 +124,24 @@ export class ManageHoldersService {
connection = await this.mssqlDBService.getConnection();
const request: Request = new mssql.Request(connection);
request.input('p_holderid', mssql.Int, body.p_holderid);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_locationid', mssql.Int, body.p_locationid);
request.input('p_holderno', mssql.VarChar(15), body.p_holderno);
request.input('p_holdertype', mssql.VarChar(3), body.p_holdertype);
request.input('p_uscibmemberflag', mssql.VarChar(1), body.p_uscibmemberflag);
request.input('p_govagencyflag', mssql.VarChar(1), body.p_govagencyflag);
request.input('p_holdername', mssql.VarChar(50), body.p_holdername);
request.input('p_namequalifier', mssql.VarChar(10), body.p_namequalifier);
request.input('p_addlname', mssql.VarChar(50), body.p_addlname);
request.input('p_address1', mssql.VarChar(50), body.p_address1);
request.input('p_address2', mssql.VarChar(50), body.p_address2);
request.input('p_city', mssql.VarChar(30), body.p_city);
request.input('p_state', mssql.VarChar(2), body.p_state);
request.input('p_zip', mssql.VarChar(10), body.p_zip);
request.input('p_country', mssql.VarChar(2), body.p_country);
request.input('p_userid', mssql.VarChar(100), body.p_userid);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_LOCATIONID', mssql.Int, body.P_LOCATIONID);
request.input('P_HOLDERNO', mssql.VarChar(15), body.P_HOLDERNO);
request.input('P_HOLDERTYPE', mssql.VarChar(3), body.P_HOLDERTYPE);
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(1), body.P_USCIBMEMBERFLAG);
request.input('P_GOVAGENCYFLAG', mssql.VarChar(1), body.P_GOVAGENCYFLAG);
request.input('P_HOLDERNAME', mssql.VarChar(50), body.P_HOLDERNAME);
request.input('P_NAMEQUALIFIER', mssql.VarChar(10), body.P_NAMEQUALIFIER);
request.input('P_ADDLNAME', mssql.VarChar(50), body.P_ADDLNAME);
request.input('P_ADDRESS1', mssql.VarChar(50), body.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), body.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), body.P_CITY);
request.input('P_STATE', mssql.VarChar(2), body.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), body.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), body.P_COUNTRY);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateHolders');
return { data: result.recordset };
@ -156,17 +158,17 @@ export class ManageHoldersService {
connection = await this.mssqlDBService.getConnection();
const request: Request = new mssql.Request(connection);
request.input('p_holdercontactid', mssql.Int, body.p_holdercontactid);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_firstname', mssql.VarChar(50), body.p_firstname);
request.input('p_lastname', mssql.VarChar(50), body.p_lastname);
request.input('p_middleinitial', mssql.VarChar(3), body.p_middleinitial);
request.input('p_title', mssql.VarChar(50), body.p_title);
request.input('p_phone', mssql.VarChar(20), body.p_phone);
request.input('p_mobile', mssql.VarChar(20), body.p_mobile);
request.input('p_fax', mssql.VarChar(20), body.p_fax);
request.input('p_emailaddress', mssql.VarChar(100), body.p_emailaddress);
request.input('p_userid', mssql.VarChar(100), body.p_userid);
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_FIRSTNAME', mssql.VarChar(50), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(50), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(3), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(50), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(20), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(20), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(20), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(100), body.P_EMAILADDRESS);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateHolderContacts');
@ -183,8 +185,8 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_holderid', mssql.Int, body.p_holderid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
const result = await request.execute('carnetsys.GetHolderContacts');
return { data: result.recordset };
@ -202,9 +204,9 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_holderid', mssql.Int, body.p_holderid);
request.input('p_userid', mssql.VarChar(100), body.p_userid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.InactivateHolder');
return { data: result.recordset };
} catch (error) {
@ -218,9 +220,9 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_holderid', mssql.Int, body.p_holderid);
request.input('p_userid', mssql.VarChar(100), body.p_userid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.ReactivateHolder');
return { data: result.recordset };
@ -235,9 +237,9 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_holderContactid', mssql.Int, body.p_holderContactid);
request.input('p_userid', mssql.VarChar(100), body.p_userid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.InactivateHolderContact');
return { data: result.recordset };
@ -252,9 +254,9 @@ export class ManageHoldersService {
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('p_spid', mssql.Int, body.p_spid);
request.input('p_holderContactid', mssql.Int, body.p_holderContactid);
request.input('p_userid', mssql.VarChar(100), body.p_userid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.ReactivateHolderContact');
return { data: result.recordset };

View File

@ -1,17 +1,11 @@
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { ParamTableService } from './param-table.service';
import {
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from '../../oracle/param-table/param-table.dto';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@Controller('mssql')
export class ParamTableController {
constructor(private readonly paramTableService: ParamTableService) {}
constructor(private readonly paramTableService: ParamTableService) { }
@ApiTags('Param Table - Mssql')
@Get('/GetParamValues')

View File

@ -2,16 +2,10 @@ import { Injectable } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql';
import { Request } from 'mssql';
import {
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from '../../oracle/param-table/param-table.dto';
import { Connection } from 'mssql';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@Injectable()
export class ParamTableService {

View File

@ -2,20 +2,20 @@ import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { CarnetSequenceService } from './carnet-sequence.service';
import { ApiTags } from '@nestjs/swagger';
import { CreateCarnetSequenceDTO } from 'src/dto/carnet-sequence/carnet-sequence.dto';
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ApiTags('Carnet Sequence - Mssql')
@Controller('mssql')
export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
@ApiTags('Carnet Sequence - Mssql')
@Get('/GetCarnetSequence')
getCarnetSequence(@Query() body: SPID_DTO) {
return this.carnetSequenceService.getCarnetSequence(body);
}
@ApiTags('Carnet Sequence - Mssql')
@Post('/CreateCarnetSequence/')
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
return this.carnetSequenceService.createCarnetSequence(body);

View File

@ -3,7 +3,7 @@ import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql'
import { CreateCarnetSequenceDTO } from 'src/dto/carnet-sequence/carnet-sequence.dto';
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@Injectable()
export class CarnetSequenceService {
@ -16,7 +16,7 @@ export class CarnetSequenceService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_spid);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETCARNETSEQUENCE');
return { data: result.recordset };
@ -30,11 +30,11 @@ export class CarnetSequenceService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_spid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_REGIONID', mssql.Float, body.P_REGIONID);
request.input('P_STARTNUMBER', mssql.Int, body.p_startnumber);
request.input('P_ENDNUMBER', mssql.Int, body.p_endnumber);
request.input('P_CARNETTYPE', mssql.VarChar(4000), body.p_carnettype);
request.input('P_STARTNUMBER', mssql.Int, body.P_STARTNUMBER);
request.input('P_ENDNUMBER', mssql.Int, body.P_ENDNUMBER);
request.input('P_CARNETTYPE', mssql.VarChar(4000), body.P_CARNETTYPE);
const result = await request.execute('carnetsys.CREATECARNETSEQUENCE');
return { data: result.recordset };

View File

@ -2,7 +2,8 @@ import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { SpContactsService } from './sp-contacts.service';
import { ApiTags } from '@nestjs/swagger';
import { InsertSPContactsDTO, UpdateSPContactsDTO } from 'src/dto/sp-contacts/sp-contacts.dto';
import { SP_CONTACTID_DTO, SP_ID_DTO } from 'src/dto/property.dto';
import { SP_CONTACTID_DTO } from 'src/dto/contact/contact-property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@Controller('mssql')
export class SpContactsController {
@ -18,13 +19,13 @@ export class SpContactsController {
@ApiTags('SPContacts - Mssql')
@Get('/GetSPDefaultContact')
getSPDefaultcontact(@Query() body: SP_ID_DTO) {
getSPDefaultcontact(@Query() body: SPID_DTO) {
return this.spContactsService.getSPDefaultcontacts(body);
}
@ApiTags('SPContacts - Mssql')
@Get('/GetSPAllContacts')
getSPAllContacts(@Query() body: SP_ID_DTO) {
getSPAllContacts(@Query() body: SPID_DTO) {
return this.spContactsService.getSpAllContacts(body);
}

View File

@ -3,20 +3,21 @@ import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql'
import { Connection, Request } from 'mssql';
import { InsertSPContactsDTO, UpdateSPContactsDTO } from 'src/dto/sp-contacts/sp-contacts.dto';
import { SP_CONTACTID_DTO, SP_ID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
import { SP_CONTACTID_DTO } from 'src/dto/contact/contact-property.dto';
@Injectable()
export class SpContactsService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async getSpAllContacts(body: SP_ID_DTO) {
async getSpAllContacts(body: SPID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_SPid);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETSPALLCONTACTS');
return { data: result.recordset };
@ -25,13 +26,13 @@ export class SpContactsService {
}
}
async getSPDefaultcontacts(body: SP_ID_DTO) {
async getSPDefaultcontacts(body: SPID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_SPid);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETSPDEFAULTCONTACTS');
return { data: result.recordset };
@ -46,7 +47,7 @@ export class SpContactsService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPCONTACTID', mssql.Int, body.p_spcontactid);
request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
const result = await request.execute('carnetsys.INACTIVATESPCONTACTS');
return { data: result.recordset };
@ -60,17 +61,17 @@ export class SpContactsService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_spid);
request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.p_defcontactflag);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname);
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.P_DEFCONTACTFLAG);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(4000), body.p_title);
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno);
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno);
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress);
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.P_EMAILADDRESS);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
const result = await request.execute('carnetsys.INSERTSPCONTACTS');
return { data: result.recordset };
@ -84,7 +85,7 @@ export class SpContactsService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spContactid', mssql.Int, body.p_spcontactid);
request.input('p_spContactid', mssql.Int, body.P_SPCONTACTID);
const result = await request.execute('carnetsys.SETDEFAULTCONTACT');
return { data: result.recordset };
@ -98,16 +99,16 @@ export class SpContactsService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPCONTACTID', mssql.Int, body.p_spcontactid);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname);
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname);
request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(4000), body.p_title);
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno);
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno);
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress);
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.P_EMAILADDRESS);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
const result = await request.execute('carnetsys.UPDATESPCONTACTS');
return { data: result.recordset };

View File

@ -2,7 +2,7 @@ import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { SpService } from './sp.service';
import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/dto/sp/sp.dto';
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@Controller('mssql')
export class SpController {

View File

@ -3,7 +3,7 @@ import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/dto/sp/sp.dto';
import * as mssql from 'mssql'
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@Injectable()
export class SpService {
@ -30,7 +30,7 @@ export class SpService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_spid);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETSPBYSPID');
return { data: result.recordset };
@ -45,19 +45,19 @@ export class SpService {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_NAME', mssql.VarChar(4000), body.P_NAME);
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.p_lookupCode);
request.input('P_ADDRESS1', mssql.VarChar(4000), body.p_address1);
request.input('P_ADDRESS2', mssql.VarChar(4000), body.p_address2);
request.input('P_CITY', mssql.VarChar(4000), body.p_city);
request.input('P_STATE', mssql.VarChar(4000), body.p_state);
request.input('P_ZIP', mssql.VarChar(4000), body.p_zip);
request.input('P_COUNTRY', mssql.VarChar(4000), body.p_country);
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.p_issuingregion);
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.p_replacementregion);
request.input('P_BONDSURETY', mssql.VarChar(4000), body.p_bondsurety);
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.p_cargopolicyno);
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.p_cargosurety);
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.P_LOOKUPCODE);
request.input('P_ADDRESS1', mssql.VarChar(4000), body.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(4000), body.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(4000), body.P_CITY);
request.input('P_STATE', mssql.VarChar(4000), body.P_STATE);
request.input('P_ZIP', mssql.VarChar(4000), body.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(4000), body.P_COUNTRY);
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.P_ISSUINGREGION);
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.P_REPLACEMENTREGION);
request.input('P_BONDSURETY', mssql.VarChar(4000), body.P_BONDSURETY);
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.P_CARGOPOLICYNO);
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.P_CARGOSURETY);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
const result = await request.execute('carnetsys.INSERTNEWSP');
@ -73,21 +73,21 @@ export class SpService {
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.p_spid);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_NAME', mssql.VarChar(4000), body.P_NAME);
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.p_lookupCode);
request.input('P_ADDRESS1', mssql.VarChar(4000), body.p_address1);
request.input('P_ADDRESS2', mssql.VarChar(4000), body.p_address2);
request.input('P_CITY', mssql.VarChar(4000), body.p_city);
request.input('P_STATE', mssql.VarChar(4000), body.p_state);
request.input('P_ZIP', mssql.VarChar(4000), body.p_zip);
request.input('P_COUNTRY', mssql.VarChar(4000), body.p_country);
request.input('P_BONDSURETY', mssql.VarChar(4000), body.p_bondsurety);
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.p_cargopolicyno);
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.p_cargosurety);
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.p_replacementregion);
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.p_issuingregion);
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.P_LOOKUPCODE);
request.input('P_ADDRESS1', mssql.VarChar(4000), body.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(4000), body.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(4000), body.P_CITY);
request.input('P_STATE', mssql.VarChar(4000), body.P_STATE);
request.input('P_ZIP', mssql.VarChar(4000), body.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(4000), body.P_COUNTRY);
request.input('P_BONDSURETY', mssql.VarChar(4000), body.P_BONDSURETY);
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.P_CARGOPOLICYNO);
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.P_CARGOSURETY);
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.P_REPLACEMENTREGION);
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.P_ISSUINGREGION);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
const result = await request.execute('carnetsys.UPDATESP');

View File

@ -168,10 +168,10 @@ export class CarnetApplicationService {
);
END;`,
{
P_SPID: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.p_userid, type: oracledb.DB_TYPE_VARCHAR },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_VARCHAR },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
@ -231,8 +231,8 @@ export class CarnetApplicationService {
);
END;`,
{
P_SPID: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }

View File

@ -17,26 +17,23 @@ import {
GetCarnetDetailsbyCarnetStatusDTO,
} from './home-page.dto';
@Controller()
@ApiTags('HomePage - Oracle')
@Controller('oracle')
export class HomePageController {
constructor(private readonly homePageService: HomePageService) {}
constructor(private readonly homePageService: HomePageService) { }
@ApiTags('HomePage - Oracle')
@Get('/oracle/GetHomePageData/:id')
@Get('GetHomePageData/:id')
GetHomePageData(@Param('id', ParseIntPipe) id: number) {
return this.homePageService.GetHomePageData(id);
}
@ApiTags('HomePage - Oracle')
@Get('/oracle/GetCarnetSummaryData/:userid')
@Get('GetCarnetSummaryData/:userid')
GetCarnetSummaryData(@Param('userid') id: string) {
return this.homePageService.GetCarnetSummaryData(id);
}
@ApiTags('HomePage - Oracle')
@Get(
'/oracle/GetCarnetDetailsbyCarnetStatus/:p_spid/:p_userid/:p_CarnetStatus',
)
@Get('GetCarnetDetailsbyCarnetStatus/:p_spid/:p_userid/:p_CarnetStatus')
GetCarnetDetailsbyCarnetStatus(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_userid') p_userid: string,
@ -67,13 +64,15 @@ export class HomePageController {
}
}
// @ApiTags('HomePage - Oracle')
// NOTE : this has been moved to carent-application module
// @Post('/oracle/SaveCarnetApplication')
SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
return this.homePageService.SaveCarnetApplication(body);
}
// @ApiTags('HomePage - Oracle')
// NOTE : this has been moved to carent-application module
// @Post('/oracle/TransmitApplicationtoProcess')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.homePageService.TransmitApplicationtoProcess(body);

View File

@ -392,6 +392,8 @@ export class HomePageService {
}
}
// NOTE : this has been moved to carent-application module
async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
const newBody = {
p_headerid: null,
@ -736,6 +738,8 @@ export class HomePageService {
}
}
// NOTE : this has been moved to carent-application module
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
let connection;
let rows = [];
@ -813,9 +817,7 @@ export class HomePageService {
}
}
async GetCarnetDetailsbyCarnetStatus(
body: GetCarnetDetailsbyCarnetStatusDTO,
) {
async GetCarnetDetailsbyCarnetStatus(body: GetCarnetDetailsbyCarnetStatusDTO) {
let connection;
let rows: any = [];
try {

View File

@ -13,7 +13,7 @@ import {
IsEmail,
} from 'class-validator';
import { Transform, Type } from 'class-transformer';
import { p_contactstableDTO } from '../manage-holders/manage-holders.dto';
import { CONTACTSTABLE_ROW_DTO } from 'src/dto/holder/holder.dto';
export class p_clientlocaddresstableDTO {
@ApiProperty({ required: true })
@ -525,12 +525,12 @@ export class CreateClientContactsDTO {
@IsDefined({ message: 'Property p_clientid is required' })
p_clientid: number;
@ApiProperty({ required: true, type: () => [p_contactstableDTO] })
@Type(() => p_contactstableDTO)
@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: p_contactstableDTO[];
p_contactstable: CONTACTSTABLE_ROW_DTO[];
@ApiProperty({ required: true })
@Length(0, 1, {

View File

@ -11,10 +11,11 @@ import {
UpdateClientDTO,
UpdateClientLocationsDTO,
} from './manage-clients.dto';
import { p_contactstableDTO } from '../manage-holders/manage-holders.dto';
import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { CONTACTSTABLE_ROW_DTO } from 'src/dto/holder/holder.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
@Injectable()
export class ManageClientsService {
@ -325,7 +326,7 @@ export class ManageClientsService {
// throw new Error('No cursor returned from the stored procedure');
// }
if (p_clientcursor_rows.length>0 && p_clientcursor_rows[0].ERRORMESG) {
if (p_clientcursor_rows.length > 0 && p_clientcursor_rows[0].ERRORMESG) {
throw new BadRequestException(p_clientcursor_rows[0].ERRORMESG);
}
@ -381,7 +382,7 @@ export class ManageClientsService {
const finalBody: UpdateClientDTO = { ...newBody, ...reqBody };
let connection;
let p_cursor_rows: any = [];
let P_CURSOR_rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
@ -402,7 +403,7 @@ export class ManageClientsService {
:p_country,
:p_revenuelocation,
:p_userid,
:p_cursor
:P_CURSOR
);
END;`,
{
@ -452,7 +453,7 @@ export class ManageClientsService {
val: finalBody.p_userid ? finalBody.p_userid : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
@ -463,13 +464,13 @@ export class ManageClientsService {
);
await connection.commit();
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
@ -477,8 +478,8 @@ export class ManageClientsService {
throw new Error('No cursor returned from the stored procedure');
}
if (p_cursor_rows.length>0 && p_cursor_rows[0].ERRORMESG) {
throw new BadRequestException(p_cursor_rows[0].ERRORMESG);
if (P_CURSOR_rows.length > 0 && P_CURSOR_rows[0].ERRORMESG) {
throw new BadRequestException(P_CURSOR_rows[0].ERRORMESG);
}
return { statusCode: 200, message: "Updated Successfully" };
@ -533,7 +534,7 @@ export class ManageClientsService {
const finalBody: UpdateClientContactsDTO = { ...newBody, ...reqBody };
let connection;
let p_cursor_rows: any = [];
let P_CURSOR_rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
@ -621,7 +622,7 @@ export class ManageClientsService {
do {
rowsBatch = await cursor.getRows(100);
p_cursor_rows = p_cursor_rows.concat(rowsBatch);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
@ -629,8 +630,8 @@ export class ManageClientsService {
throw new Error('No cursor returned from the stored procedure');
}
if (p_cursor_rows.length>0 && p_cursor_rows[0].ERRORMESG) {
throw new BadRequestException(p_cursor_rows[0].ERRORMESG);
if (P_CURSOR_rows.length > 0 && P_CURSOR_rows[0].ERRORMESG) {
throw new BadRequestException(P_CURSOR_rows[0].ERRORMESG);
}
return { statusCode: 200, message: "Updated Successfully" };
@ -683,7 +684,7 @@ export class ManageClientsService {
const finalBody: UpdateClientLocationsDTO = { ...newBody, ...reqBody };
let connection;
let p_cursor_rows: any = [];
let P_CURSOR_rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
@ -703,7 +704,7 @@ export class ManageClientsService {
:p_zip,
:p_country,
:p_userid,
:p_cursor
:P_CURSOR
);
END;`,
{
@ -749,7 +750,7 @@ export class ManageClientsService {
val: finalBody.p_userid ? finalBody.p_userid : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
@ -760,13 +761,13 @@ export class ManageClientsService {
);
await connection.commit();
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
@ -774,8 +775,8 @@ export class ManageClientsService {
throw new Error('No cursor returned from the stored procedure');
}
if (p_cursor_rows.length>0 && p_cursor_rows[0].ERRORMESG) {
throw new BadRequestException(p_cursor_rows[0].ERRORMESG);
if (P_CURSOR_rows.length > 0 && P_CURSOR_rows[0].ERRORMESG) {
throw new BadRequestException(P_CURSOR_rows[0].ERRORMESG);
}
return { statusCode: 200, message: "Updated Successfully" };
@ -798,13 +799,189 @@ export class ManageClientsService {
}
};
CreateClientContact = async (body: CreateClientContactsDTO) => {
// CreateClientContactX = async (body: CreateClientContactsDTO) => {
// const newBody = {
// p_spid: null,
// p_clientid: null,
// p_contactstable: null,
// p_defcontactflag: null,
// p_userid: 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: CreateClientContactsDTO = {
// ...newBody,
// ...reqBody,
// };
// let connection;
// let P_CURSOR_rows: any = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException('No DB Connected');
// }
// const CONTACTSTABLE = await connection.getDbObjectClass(
// 'CARNETSYS.CONTACTSTABLE',
// );
// // Check if CONTACTSTABLE is a constructor
// if (typeof CONTACTSTABLE !== 'function') {
// throw new InternalServerException('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: p_contactstableDTO) => {
// return await CREATECONTACTSTABLE_INSTANCE(
// connection,
// 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(CONTACTSARRAY);
// const result = await connection.execute(
// `BEGIN
// MANAGEPREPARER_PKG.CreateClientContact(
// :p_spid,
// :p_clientid,
// :p_contactstable,
// :p_defcontactflag,
// :p_userid,
// :P_CURSOR
// );
// END;`,
// {
// p_spid: {
// val: finalBody.p_spid,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_clientid: {
// val: finalBody.p_clientid,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_contactstable: {
// val: CONTACTSTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_defcontactflag: {
// val: finalBody.p_defcontactflag,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_userid: {
// val: finalBody.p_userid,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// 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 InternalServerException('No cursor returned from the stored procedure');
// }
// if (P_CURSOR_rows.length > 0 && P_CURSOR_rows[0].ERRORMESG) {
// throw new BadRequestException(P_CURSOR_rows[0].ERRORMESG);
// }
// return { statusCode: 201, message: "Created Successfully" };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('CreateClientContact 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 CreateClientContact(body: CreateClientContactsDTO) {
const newBody = {
p_spid: null,
p_clientid: null,
p_contactstable: null,
p_defcontactflag: null,
p_userid: null,
P_SPID: null,
P_CLIENTID: null,
P_CONTACTSTABLE: null,
P_DEFCONTACTFLAG: null,
P_USERID: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
@ -821,19 +998,11 @@ export class ManageClientsService {
setEmptyStringsToNull(reqBody);
const finalBody: CreateClientContactsDTO = {
...newBody,
...reqBody,
};
const finalBody: CreateClientContactsDTO = { ...newBody, ...reqBody };
let connection;
let p_cursor_rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException('No DB Connected');
}
const CONTACTSTABLE = await connection.getDbObjectClass(
'CARNETSYS.CONTACTSTABLE',
@ -873,17 +1042,17 @@ export class ManageClientsService {
const CONTACTSARRAY = finalBody.p_contactstable
? await Promise.all(
finalBody.p_contactstable.map(async (x: p_contactstableDTO) => {
finalBody.p_contactstable.map(async (x: CONTACTSTABLE_ROW_DTO) => {
return await CREATECONTACTSTABLE_INSTANCE(
connection,
x.FirstName,
x.LastName,
x.MiddleInitial,
x.Title,
x.EmailAddress,
x.PhoneNo,
x.MobileNo,
x.FaxNo,
x.P_FIRSTNAME,
x.P_LASTNAME,
x.P_MIDDLEINITIAL,
x.P_TITLE,
x.P_EMAILADDRESS,
x.P_PHONENO,
x.P_MOBILENO,
x.P_FAXNO,
);
}),
)
@ -895,84 +1064,35 @@ export class ManageClientsService {
const result = await connection.execute(
`BEGIN
MANAGEPREPARER_PKG.CreateClientContact(
:p_spid,
:p_clientid,
:p_contactstable,
:p_defcontactflag,
:p_userid,
:p_cursor
:P_SPID, :P_CLIENTID, :P_CONTACTSTABLE, :P_DEFCONTACTFLAG, :P_USERID, :P_CURSOR
);
END;`,
{
p_spid: {
val: finalBody.p_spid,
type: oracledb.DB_TYPE_NUMBER,
},
p_clientid: {
val: finalBody.p_clientid,
type: oracledb.DB_TYPE_NUMBER,
},
p_contactstable: {
val: CONTACTSTABLE_INSTANCE,
type: oracledb.DB_TYPE_OBJECT,
},
p_defcontactflag: {
val: finalBody.p_defcontactflag,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_userid: {
val: finalBody.p_userid,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
P_SPID: { val: finalBody.p_spid, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: finalBody.p_clientid, type: oracledb.DB_TYPE_NUMBER },
P_CONTACTSTABLE: { val: CONTACTSTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_DEFCONTACTFLAG: { val: finalBody.p_defcontactflag, type: oracledb.DB_TYPE_NVARCHAR },
P_USERID: { val: finalBody.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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 InternalServerException('No cursor returned from the stored procedure');
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.");
}
if (p_cursor_rows.length>0 && p_cursor_rows[0].ERRORMESG) {
throw new BadRequestException(p_cursor_rows[0].ERRORMESG);
}
return { statusCode: 201, message: "Created Successfully" };
return await fetchCursor(outBinds.P_CURSOR, ManageClientsService.name);
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
}
this.logger.error('CreateClientContact failed', error.stack || error);
throw new InternalServerException();
handleError(error, ManageClientsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
await closeOracleDbConnection(connection, ManageClientsService.name)
}
}
}
};
CreateClientLocation = async (body: CreateClientLocationsDTO) => {
const newBody = {
@ -1002,7 +1122,7 @@ export class ManageClientsService {
};
let connection;
let p_cursor_rows: any = [];
let P_CURSOR_rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
@ -1073,7 +1193,7 @@ export class ManageClientsService {
:p_clientid,
:p_ClientLocAddressTable,
:p_userid,
:p_cursor
:P_CURSOR
);
END;`,
{
@ -1093,7 +1213,7 @@ export class ManageClientsService {
val: finalBody.p_userid,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
}
@ -1105,13 +1225,13 @@ export class ManageClientsService {
await connection.commit();
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
@ -1119,8 +1239,8 @@ export class ManageClientsService {
throw new Error('No cursor returned from the stored procedure');
}
if (p_cursor_rows.length>0 && p_cursor_rows[0].ERRORMESG) {
throw new BadRequestException(p_cursor_rows[0].ERRORMESG);
if (P_CURSOR_rows.length > 0 && P_CURSOR_rows[0].ERRORMESG) {
throw new BadRequestException(P_CURSOR_rows[0].ERRORMESG);
}
return { statusCode: 201, message: "Created Successfully" };
@ -1269,7 +1389,7 @@ export class ManageClientsService {
body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) => {
let connection;
let p_cursor_rows: any = [];
let P_CURSOR_rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
@ -1282,7 +1402,7 @@ export class ManageClientsService {
MANAGEPREPARER_PKG.GetPreparerByClientid(
:p_spid,
:p_clientid,
:p_cursor
:P_CURSOR
);
END;`,
{
@ -1294,7 +1414,7 @@ export class ManageClientsService {
val: body.p_clientid,
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
@ -1304,19 +1424,19 @@ export class ManageClientsService {
},
);
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
return p_cursor_rows;
return P_CURSOR_rows;
} catch (error) {
if (error instanceof BadRequestException) {
@ -1340,7 +1460,7 @@ export class ManageClientsService {
body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) => {
let connection;
let p_cursor_rows = [];
let P_CURSOR_rows = [];
try {
connection = await this.oracleDBService.getConnection();
@ -1353,7 +1473,7 @@ export class ManageClientsService {
MANAGEPREPARER_PKG.GetPreparerContactsByClientid(
:p_spid,
:p_clientid,
:p_cursor
:P_CURSOR
);
END;`,
{
@ -1365,7 +1485,7 @@ export class ManageClientsService {
val: body.p_clientid,
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
@ -1375,19 +1495,19 @@ export class ManageClientsService {
},
);
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
return p_cursor_rows;
return P_CURSOR_rows;
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
@ -1410,7 +1530,7 @@ export class ManageClientsService {
body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) => {
let connection;
let p_cursor_rows = [];
let P_CURSOR_rows = [];
try {
connection = await this.oracleDBService.getConnection();
@ -1423,7 +1543,7 @@ export class ManageClientsService {
MANAGEPREPARER_PKG.GetPreparerLocByClientid(
:p_spid,
:p_clientid,
:p_cursor
:P_CURSOR
);
END;`,
{
@ -1435,7 +1555,7 @@ export class ManageClientsService {
val: body.p_clientid,
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
@ -1445,19 +1565,19 @@ export class ManageClientsService {
},
);
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
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);
P_CURSOR_rows = P_CURSOR_rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
return p_cursor_rows;
return P_CURSOR_rows;
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);

View File

@ -9,7 +9,6 @@ import {
CreateCsFeeDTO,
CreateEfFeeDTO,
CreateFeeCommDTO,
GetFeeGeneralDTO,
UpdateBasicFeeDTO,
UpdateBondRateDTO,
UpdateCargoRateDTO,
@ -19,6 +18,7 @@ import {
UpdateFeeCommBodyDTO,
UpdateFeeCommDTO,
} from './manage-fee.dto';
import { GetFeeGeneralDTO } from 'src/dto/fee/fee.dto';
@Controller('oracle')
export class ManageFeeController {

View File

@ -2,23 +2,6 @@ import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsDefined, IsInt, IsNumber, IsString, Length, Matches, Min } from 'class-validator';
export class GetFeeGeneralDTO {
@ApiProperty({ required: true })
@Transform(({ value }) => Number(value))
@Min(0, { message: 'Property P_SPID must be at least 0' })
@IsInt({ message: 'Property P_SPID must be a whole number' })
@IsNumber({}, { message: 'Property P_SPID must be a number' })
@IsDefined({ message: 'Property P_SPID is required' })
P_SPID: number;
@ApiProperty({ required: true })
@Matches(/^.{6}$|^.{8}$/, {
message: 'Property P_ACTIVE_INACTIVE is invalid',
})
@IsString({ message: 'Property P_ACTIVE_INACTIVE must be a string' })
@IsDefined({ message: 'Property P_ACTIVE_INACTIVE is required' })
P_ACTIVE_INACTIVE: string;
}
export class CreateBasicFeeDTO {
@ApiProperty({ required: true })

View File

@ -9,7 +9,6 @@ import {
CreateCsFeeDTO,
CreateEfFeeDTO,
CreateFeeCommDTO,
GetFeeGeneralDTO,
UpdateBasicFeeDTO,
UpdateBondRateDTO,
UpdateCargoRateDTO,
@ -21,6 +20,7 @@ import {
} from './manage-fee.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { GetFeeGeneralDTO } from 'src/dto/fee/fee.dto';
@Injectable()
export class ManageFeeService {

View File

@ -10,15 +10,8 @@ import {
Put,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import {
CreateHoldersDTO,
GetHolderDTO,
HolderActivateOrInactivateDTO,
HolderContactActivateOrInactivateDTO,
UpdateHolderContactDTO,
UpdateHolderDTO
} from './manage-holders.dto';
import { ManageHoldersService } from './manage-holders.service';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/holder/holder.dto';
@Controller('oracle')
export class ManageHoldersController {
@ -44,94 +37,94 @@ export class ManageHoldersController {
}
@ApiTags('Manage Holders - Oracle')
@Get('/GetHolderRecord/:p_spid/:p_holderid')
@Get('/GetHolderRecord/:P_SPID/:P_HOLDERID')
GetHolderMaster(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { p_spid, p_holderid };
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderRecord(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Get('/GetHolderContacts/:p_spid/:p_holderid')
@Get('/GetHolderContacts/:P_SPID/:P_HOLDERID')
GetHolderContacts(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { p_spid, p_holderid };
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderContacts(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolder/:p_spid/:p_holderid/:p_userid')
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
InactivateHolder(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!p_userid) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.InactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolder/:p_spid/:p_holderid/:p_userid')
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
ReactivateHolder(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!p_userid) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.ReactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
InactivateHolderContact(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!p_userid) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
p_spid,
p_holderContactid,
p_userid
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.InactivateHolderContact(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
ReactivateHolderContact(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_holderid', ParseIntPipe) p_holderContactid: number,
@Param('p_userid') p_userid: string
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!p_userid) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
p_spid,
p_holderContactid,
p_userid
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.ReactivateHolderContact(reqParams);

View File

@ -1,521 +0,0 @@
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 GetHolderDTO {
@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;
}
export class HolderActivateOrInactivateDTO {
@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;
@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 HolderContactActivateOrInactivateDTO {
@ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
@Min(0, { message: 'Property p_spid must be at least 0 or more' })
@IsInt({ message: 'Property p_spid allows only whole numbers' })
@IsNumber({}, { message: 'Property p_spid must be a number' })
@IsDefined({ message: 'Property p_spid is required' })
p_spid: number;
@ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_holderid must not exceed 999999999' })
@Min(0, { message: 'Property p_holderid must be at least 0 or more' })
@IsInt({ message: 'Property p_holderid allows only whole numbers' })
@IsNumber({}, { message: 'Property p_holderid must be a number' })
@IsDefined({ message: 'Property p_holderid is required' })
p_holderContactid: number;
@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;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,14 @@
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { ParamTableService } from './param-table.service';
import {
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from './param-table.dto';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@ApiTags('Param Table - Oracle')
@Controller('oracle')
export class ParamTableController {
constructor(private readonly paramTableService: ParamTableService) {}
constructor(private readonly paramTableService: ParamTableService) { }
@ApiTags('Param Table - Oracle')
@Get('/GetParamValues')
@ApiQuery({
name: 'P_SPID',
@ -31,31 +26,26 @@ export class ParamTableController {
return this.paramTableService.GETPARAMVALUES(body);
}
@ApiTags('Param Table - Oracle')
@Post('/CreateTableRecord')
createTableRecord(@Body() body: CreateTableRecordDTO) {
return this.paramTableService.CREATETABLERECORD(body);
}
@ApiTags('Param Table - Oracle')
@Post('/CreateParamRecord')
createParamRecord(@Body() body: CreateParamRecordDTO) {
return this.paramTableService.CREATEPARAMRECORD(body);
}
@ApiTags('Param Table - Oracle')
@Patch('/UpdateParamRecord')
UpdateParamRecord(@Body() body: UpdateParamRecordDTO) {
return this.paramTableService.UPDATEPARAMRECORD(body);
}
@ApiTags('Param Table - Oracle')
@Patch('/InActivateParamRecord')
inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.INACTIVATEPARAMRECORD(body);
}
@ApiTags('Param Table - Oracle')
@Patch('/ReActivateParamRecord')
reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.REACTIVATEPARAMRECORD(body);

View File

@ -1,147 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import {
IsDefined,
IsInt,
IsNumber,
IsOptional,
IsString,
Min,
} from 'class-validator';
export class CreateTableRecordDTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_USERID must be a string' })
@IsDefined({ message: 'Property P_USERID is required' })
P_USERID: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property P_TABLEFULLDESC must be a string' })
@IsDefined({ message: 'Property P_TABLEFULLDESC is required' })
P_TABLEFULLDESC: string;
}
export class CreateParamRecordDTO {
@ApiProperty({ required: false })
@IsOptional()
@IsNumber()
P_SPID?: number;
@ApiProperty({ required: true })
@IsString()
P_PARAMTYPE: string;
@ApiProperty({ required: true })
@IsString()
P_PARAMDESC: string;
@ApiProperty({ required: true })
@IsString()
P_PARAMVALUE: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE1?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE2?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE3?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE4?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE5?: string;
@ApiProperty({ required: true })
@IsNumber()
P_SORTSEQ: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateParamRecordDTO {
@ApiProperty({ required: false })
@IsOptional()
@IsNumber()
P_SPID?: number;
@ApiProperty({ required: true })
@IsNumber()
P_PARAMID: number;
@ApiProperty({ required: true })
@IsString()
P_PARAMDESC: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE1?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE2?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE3?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE4?: string;
@ApiProperty({ required: false })
@IsOptional()
@IsString()
P_ADDLPARAMVALUE5?: string;
@ApiProperty({ required: true })
@IsNumber()
P_SORTSEQ: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class getParamValuesDTO {
@Min(0, { message: 'Property P_SPID must be at least 0' })
@IsInt({ message: 'Property P_SPID must be a whole number' })
@IsNumber({}, { message: 'Property P_SPID must be a number' })
@Transform(({ value }) => Number(value))
@IsOptional()
P_SPID?: number;
@IsString({ message: 'Property P_PARAMTYPE must be a string' })
@IsOptional()
P_PARAMTYPE?: string;
}
export class ActivateOrInactivateParamRecordDTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property P_PARAMID must be a number' })
@IsDefined({ message: 'Property P_PARAMID is required' })
P_PARAMID: number;
@ApiProperty({ required: true })
@IsString({ message: 'Property P_USERID must be a string' })
@IsDefined({ message: 'Property P_USERID is required' })
P_USERID: string;
}

View File

@ -1,15 +1,10 @@
import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb';
import {
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from './param-table.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@Injectable()
export class ParamTableService {
@ -17,6 +12,80 @@ 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,
@ -24,139 +93,260 @@ export class ParamTableService {
};
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);
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,
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;
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;
// const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
return await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
} 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();
handleError(error, ParamTableService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// 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;
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);
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,
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();
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.");
}
if (fres.length>0 && fres[0].ERRORMESG) {
const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
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();
handleError(error, ParamTableService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// 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;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
@ -172,100 +362,156 @@ export class ParamTableService {
:P_ADDLPARAMVALUE5,
:P_SORTSEQ,
:P_USERID,
:p_cursor);
: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,
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();
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.");
}
if (fres.length>0 && fres[0].ERRORMESG) {
const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
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();
handleError(error, ParamTableService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// 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;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
@ -280,168 +526,197 @@ export class ParamTableService {
:P_ADDLPARAMVALUE5,
:P_SORTSEQ,
:P_USERID,
:p_cursor);
: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,
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();
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.");
}
if (fres.length>0 && fres[0].ERRORMESG) {
const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
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();
handleError(error, ParamTableService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// 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;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.INACTIVATEPARAMRECORD(
:P_PARAMID,
:P_USERID);
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,
},
P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
// 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 { statusCode: 200, message: 'Inactivated Successfully' };
} catch (error) {
this.logger.error('INACTIVATEPARAMRECORD failed', error.stack || error);
throw new InternalServerException();
handleError(error, ParamTableService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// 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;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD(
:P_PARAMID,
:P_USERID);
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,
},
P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
// 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 { statusCode: 200, message: 'Reactivated Successfully' };
} catch (error) {
this.logger.error('REACTIVATEPARAMRECORD failed', error.stack || error);
throw new InternalServerException();
handleError(error, ParamTableService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
}

View File

@ -1,24 +1,23 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import {
CreateCarnetSequenceDTO
} from '../../../dto/carnet-sequence/carnet-sequence.dto';
import { ApiTags } from '@nestjs/swagger';
import { CarnetSequenceService } from './carnet-sequence.service';
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ApiTags('Carnet Sequence - Oracle')
@Controller('oracle')
export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) {}
constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
@ApiTags('Carnet Sequence - Oracle')
@Post('/CreateCarnetSequence/')
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
return this.carnetSequenceService.createCarnetSequence(body);
}
@ApiTags('Carnet Sequence - Oracle')
@Get('/GetCarnetSequence')
getCarnetSequence(@Query() body: SPID_DTO) {
return this.carnetSequenceService.getCarnetSequence(body);
@Get('/GetCarnetSequence/:P_SPID')
getCarnetSequence(@Param() params: SPID_DTO) {
return this.carnetSequenceService.getCarnetSequence(params);
}
}

View File

@ -7,15 +7,16 @@ import {
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { SPID_DTO } from 'src/dto/property.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@Injectable()
export class CarnetSequenceService {
private readonly logger = new Logger(CarnetSequenceService.name);
constructor(private readonly oracleDBService: OracleDBService) {}
constructor(private readonly oracleDBService: OracleDBService) { }
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
async createCarnetSequenceX(body: CreateCarnetSequenceDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
@ -26,51 +27,51 @@ export class CarnetSequenceService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.CreateCarnetSequence(
:p_spid,
:p_regionid,
:p_startnumber,
:p_endnumber,
:p_carnettype,
:p_cursor);
:P_SPID,
:P_REGIONID,
:P_STARTNUMBER,
:P_ENDNUMBER,
:P_CARNETTYPE,
:P_CURSOR);
END;`,
{
p_spid: {
val: body.p_spid,
P_SPID: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
p_regionid: {
P_REGIONID: {
val: body.P_REGIONID,
type: oracledb.DB_TYPE_NUMBER,
},
p_startnumber: {
val: body.p_startnumber,
P_STARTNUMBER: {
val: body.P_STARTNUMBER,
type: oracledb.DB_TYPE_NUMBER,
},
p_endnumber: {
val: body.p_endnumber,
P_ENDNUMBER: {
val: body.P_ENDNUMBER,
type: oracledb.DB_TYPE_NUMBER,
},
p_carnettype: {
val: body.p_carnettype,
P_CARNETTYPE: {
val: body.P_CARNETTYPE,
type: oracledb.DB_TYPE_VARCHAR,
},
p_cursor: {
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();
const fres = await result.outBinds.P_CURSOR.getRows();
await result.outBinds.p_cursor.close();
await result.outBinds.P_CURSOR.close();
if (fres.length>0 && fres[0].ERRORMESG) {
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
@ -94,7 +95,53 @@ export class CarnetSequenceService {
}
}
async getCarnetSequence(body: SPID_DTO) {
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.SaveCarnetApplication(
:P_SPID, :P_REGIONID, :P_STARTNUMBER, :P_ENDNUMBER, :P_CARNETTYPE, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_REGIONID: { val: body.P_REGIONID, type: oracledb.DB_TYPE_NUMBER },
P_STARTNUMBER: { val: body.P_STARTNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_ENDNUMBER: { val: body.P_ENDNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_CARNETTYPE: { val: body.P_CARNETTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
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.");
}
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 { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetSequenceService.name)
} finally {
await closeOracleDbConnection(connection, CarnetSequenceService.name)
}
}
async getCarnetSequenceX(body: SPID_DTO) {
let connection;
let rows = [];
try {
@ -106,14 +153,14 @@ export class CarnetSequenceService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetCarnetSequence(:p_spid,:p_cursor);
USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR);
END;`,
{
p_spid: {
val: body.p_spid,
P_SPID: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
@ -123,8 +170,8 @@ export class CarnetSequenceService {
},
);
if (result.outBinds && result.outBinds.p_cursor) {
const cursor = result.outBinds.p_cursor;
if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do {
@ -159,4 +206,37 @@ export class CarnetSequenceService {
}
}
}
async getCarnetSequence(body: SPID_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
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: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
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 await fetchCursor(outBinds.P_CURSOR, CarnetSequenceService.name);
} catch (error) {
handleError(error, CarnetSequenceService.name)
} finally {
await closeOracleDbConnection(connection, CarnetSequenceService.name)
}
}
}

View File

@ -12,64 +12,64 @@ 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();
}
// 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,
},
);
// 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();
// await connection.commit();
const fres = await result.outBinds.p_cursor.getRows();
// 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)
}
// 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);
}
}
}
}
// 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;
@ -78,12 +78,12 @@ export class RegionService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:P_NAME,:p_cursor);
USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
END;`,
{
p_region: { val: body.P_REGION, type: oracledb.DB_TYPE_VARCHAR },
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 },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
@ -91,12 +91,12 @@ export class RegionService {
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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.");
}
const fres: any = await fetchCursor(outBinds.p_cursor, RegionService.name);
const fres: any = await fetchCursor(outBinds.P_CURSOR, RegionService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
@ -112,64 +112,64 @@ export class RegionService {
}
}
async updateRegionsX(body: UpdateRegionDto) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
// 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,
},
);
// 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();
// await connection.commit();
const fres = await result.outBinds.p_cursor.getRows();
// 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)
}
// 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);
}
}
}
}
// 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;
@ -178,12 +178,12 @@ export class RegionService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:P_NAME,:p_cursor);
USCIB_Managed_Pkg.UpdateRegion(:P_REGIONID,:P_NAME,:P_CURSOR);
END;`,
{
p_regionID: { val: body.P_REGIONID, type: oracledb.DB_TYPE_NUMBER },
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 }
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
@ -191,12 +191,12 @@ export class RegionService {
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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.");
}
const fres: any = await fetchCursor(outBinds.p_cursor, RegionService.name);
const fres: any = await fetchCursor(outBinds.P_CURSOR, RegionService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
@ -211,67 +211,67 @@ export class RegionService {
}
}
async getRegionsX() {
let connection;
let rows = [];
try {
// async getRegionsX() {
// let connection;
// let rows = [];
// try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException()
}
// 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,
},
);
// 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;
// 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);
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new BadRequestException();
}
// 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);
}
}
}
}
// 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;
@ -280,21 +280,21 @@ export class RegionService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetRegions(:p_cursor);
USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
END;`,
{
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, RegionService.name);
return await fetchCursor(outBinds.P_CURSOR, RegionService.name);
} catch (error) {
handleError(error, RegionService.name)
} finally {

View File

@ -1,49 +1,46 @@
import { SpContactsService } from './sp-contacts.service';
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
import {
InsertSPContactsDTO,
UpdateSPContactsDTO,
} from '../../../dto/sp-contacts/sp-contacts.dto';
import { ApiTags } from '@nestjs/swagger';
import { SP_CONTACTID_DTO, SP_ID_DTO } from 'src/dto/property.dto';
import { SP_CONTACTID_DTO } from 'src/dto/contact/contact-property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ApiTags('SPContacts - Oracle')
@Controller('oracle')
export class SpContactsController {
constructor(private readonly spContactsService: SpContactsService) { }
@ApiTags('SPContacts - Oracle')
@Post('/InsertSPContacts')
insertSPContacts(@Body() body: InsertSPContactsDTO) {
return this.spContactsService.insertSPContacts(body);
}
@ApiTags('SPContacts - Oracle')
@Patch('/SetSPDefaultContact')
setSPDefaultcontact(@Query() body: SP_CONTACTID_DTO) {
return this.spContactsService.setSPDefaultcontact(body);
@Patch('/SetSPDefaultContact/:P_SPCONTACTID')
setSPDefaultcontact(@Param() param: SP_CONTACTID_DTO) {
return this.spContactsService.setSPDefaultcontact(param);
}
@ApiTags('SPContacts - Oracle')
@Put('/UpdateSPContacts')
updateSPContacts(@Body() body: UpdateSPContactsDTO) {
return this.spContactsService.updateSPContacts(body);
}
@ApiTags('SPContacts - Oracle')
@Patch('/InactivateSPContact')
inactivateSPContact(@Query() body: SP_CONTACTID_DTO) {
return this.spContactsService.inactivateSPContact(body);
@Patch('/InactivateSPContact/:P_SPID')
inactivateSPContact(@Param() param: SP_CONTACTID_DTO) {
return this.spContactsService.inactivateSPContact(param);
}
@ApiTags('SPContacts - Oracle')
@Get('/GetSPDefaultContact')
getSPDefaultcontact(@Query() body: SP_ID_DTO) {
return this.spContactsService.getSPDefaultcontacts(body);
@Get('/GetSPDefaultContact/:P_SPID')
getSPDefaultcontact(@Param() param: SPID_DTO) {
return this.spContactsService.getSPDefaultcontacts(param);
}
@ApiTags('SPContacts - Oracle')
@Get('/GetSPAllContacts')
getSPAllContacts(@Query() body: SP_ID_DTO) {
return this.spContactsService.getSPAllContacts(body);
@Get('/GetSPAllContacts/:P_SPID')
getSPAllContacts(@Param() param: SPID_DTO) {
return this.spContactsService.getSPAllContacts(param);
}
}

View File

@ -7,7 +7,9 @@ import {
} from '../../../dto/sp-contacts/sp-contacts.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { SP_CONTACTID_DTO, SP_ID_DTO } from 'src/dto/property.dto';
import { SP_CONTACTID_DTO } from 'src/dto/contact/contact-property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
@Injectable()
export class SpContactsService {
@ -15,88 +17,160 @@ 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) {
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_SPID,
:P_DEFCONTACTFLAG,
:P_FIRSTNAME,
:P_LASTNAME,
:P_MIDDLEINITIAL,
:p_title,
:p_phoneno,
:p_mobileno,
:p_faxno,
:p_emailaddress,
:p_user_id,
:p_cursor);
: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,
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();
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.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
@ -104,311 +178,497 @@ export class SpContactsService {
}
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();
handleError(error, SpContactsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpContactsService.name)
}
}
// 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;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid);
USCIB_Managed_Pkg.SetDefaultContact(:P_SPCONTACTID);
END;`,
{
p_spcontactid: {
val: body.p_spcontactid,
type: oracledb.DB_TYPE_NUMBER,
},
P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
// 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 { statusCode: 200, message: 'Default contact was added successfully for SP' };
} catch (error) {
this.logger.error('setSPDefaultcontact failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpContactsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpContactsService.name)
}
}
// 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;
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_SPCONTACTID,
:P_FIRSTNAME,
:P_LASTNAME,
:P_MIDDLEINITIAL,
:p_title,
:p_phoneno,
:p_mobileno,
:p_faxno,
:p_emailaddress,
:p_user_id,
:p_cursor);
: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,
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();
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.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
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" };
return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
}
this.logger.error('updateSPContacts failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpContactsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpContactsService.name)
}
}
// 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;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid);
USCIB_Managed_Pkg.InActivateSPContacts(:P_SPCONTACTID);
END;`,
{
p_spcontactid: {
val: body.p_spcontactid,
type: oracledb.DB_TYPE_NUMBER,
},
P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
// 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 { statusCode: 200, message: 'Inactivated SP contact successfully' };
} catch (error) {
this.logger.error('inactivateSPContact failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpContactsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpContactsService.name)
}
}
async getSPDefaultcontacts(body: SP_ID_DTO) {
// 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;
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);
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,
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;
return await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
} catch (error) {
this.logger.error('getSPDefaultcontacts failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpContactsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpContactsService.name)
}
}
async getSPAllContacts(body: SP_ID_DTO) {
// 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;
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);
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,
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;
return await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
} catch (error) {
this.logger.error('getSPAllContacts failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpContactsService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpContactsService.name)
}
}
}

View File

@ -1,37 +1,35 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
import { SpService } from './sp.service';
import { ApiTags } from '@nestjs/swagger';
import {
InsertNewServiceProviderDTO,
UpdateServiceProviderDTO,
} from '../../../dto/sp/sp.dto';
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ApiTags('SP - Oracle')
@Controller('oracle')
export class SpController {
constructor(private readonly spService: SpService) { }
@ApiTags('SP - Oracle')
@Post('/InsertNewServiceProvider')
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
return this.spService.insertNewServiceProvider(body);
}
@ApiTags('SP - Oracle')
@Put('/UpdateServiceProvider')
updateServiceProider(@Body() body: UpdateServiceProviderDTO) {
return this.spService.updateServiceProvider(body);
}
@ApiTags('SP - Oracle')
@Get('/GetAllServiceproviders')
getAllServiceproviders() {
return this.spService.getAllServiceproviders();
}
@ApiTags('SP - Oracle')
@Get('/GetSelectedServiceprovider')
getSelectedServiceprovider(@Query() body: SPID_DTO) {
return this.spService.getServiceproviderByID(body);
@Get('/GetSelectedServiceprovider/:P_SPID')
getSelectedServiceprovider(@Param() param: SPID_DTO) {
return this.spService.getServiceproviderByID(param);
}
}

View File

@ -7,7 +7,8 @@ import {
} from '../../../dto/sp/sp.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { SPID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
@Injectable()
export class SpService {
@ -15,158 +16,381 @@ 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 = {
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: InsertNewServiceProviderDTO = { ...newBody, ...reqBody };
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_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);
: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,
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_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
P_REPLACEMENTREGION: { val: finalBody.P_REPLACEMENTREGION, 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_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();
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.");
}
if (fres.length>0 && fres[0].ERRORMESG) {
let fres: any = await fetchCursor(outBinds.P_CURSOR, SpService.name);
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();
handleError(error, SpService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpService.name)
}
}
// 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 = {
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
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));
@ -188,266 +412,264 @@ export class SpService {
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_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_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);
: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,
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_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
P_REPLACEMENTREGION: { val: finalBody.P_REPLACEMENTREGION, 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_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 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.");
}
const fres = await result.outBinds.p_cursor.getRows();
let fres: any = await fetchCursor(outBinds.P_CURSOR, SpService.name);
if (fres.length>0 && fres[0].ERRORMESG) {
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" };
return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
}
this.logger.error('updateServiceProvider failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpService.name)
}
}
// 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() {
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);
USCIB_Managed_Pkg.GetAllSPs(:P_CURSOR);
END;`,
{
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
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);
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;
} else {
throw new BadRequestException();
}
return await fetchCursor(outBinds.P_CURSOR, SpService.name);
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
}
this.logger.error('getAllServiceproviders failed', error.stack || error);
throw new InternalServerException();
handleError(error, SpService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpService.name)
}
}
// 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) {
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);
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,
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();
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.");
}
if (rows.length > 0 && rows[0].ERRORMESG) {
throw new BadRequestException(rows[0].ERRORMESG);
}
return await fetchCursor(outBinds.P_CURSOR, SpService.name);
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();
handleError(error, SpService.name)
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
await closeOracleDbConnection(connection, SpService.name)
}
}
}

View File

@ -2,7 +2,8 @@ import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common
import { UserMaintenanceService } from './user-maintenance.service';
import { ApiTags } from '@nestjs/swagger';
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO, SPID_EMAIL_DTO } from '../../dto/user-maintenance/user-maintenance.dto';
import { SPID_DTO, USERID_DTO } from 'src/dto/property.dto';
import { USERID_DTO } from 'src/dto/property.dto';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
@ApiTags('User Maintenance - Oracle')
@Controller('oracle')

View File

@ -1,11 +1,15 @@
import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO, SPID_EMAIL_DTO } from '../../dto/user-maintenance/user-maintenance.dto';
import {
CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO,
SPID_EMAIL_DTO
} from '../../dto/user-maintenance/user-maintenance.dto';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { SPID_DTO, USERID_DTO } from 'src/dto/property.dto';
import { USERID_DTO } from 'src/dto/property.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
interface RoleDetail { [key: string]: any; }
@ -53,7 +57,7 @@ export class UserMaintenanceService {
);
END;`,
{
P_USERID: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ROLECUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
P_MENUCUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
P_MENUPAGECUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
@ -91,24 +95,24 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.LockUserAccount(
:p_spid, :p_emailaddr, :p_cursor
:P_SPID, :P_EMAILADDR, :P_CURSOR
);
END;`,
{
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
p_emailaddr: { val: body.p_emailaddr, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
@ -128,22 +132,22 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetUSCIBLogins(
:p_cursor
:P_CURSOR
);
END;`,
{
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
@ -162,28 +166,28 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.CreateUSCIBLogins(
:p_userid , :p_emailaddr , :p_lookupCode , :p_password , :P_EnablePasswordPolicy, :p_cursor
:P_USERID , :P_EMAILADDR , :P_LOOKUPCODE , :P_PASSWORD , :P_ENABLEPASSWORDPOLICY, :P_CURSOR
);
END;`,
{
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
p_emailaddr: { val: body.p_emailaddr, type: oracledb.DB_TYPE_NVARCHAR },
p_lookupCode: { val: body.p_lookupCode, type: oracledb.DB_TYPE_NVARCHAR },
p_password: { val: body.p_password, type: oracledb.DB_TYPE_NVARCHAR },
P_EnablePasswordPolicy: { val: body.P_EnablePasswordPolicy, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_NVARCHAR },
P_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
P_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 {
data: await fetchCursor(outBinds.p_cursor),
data: await fetchCursor(outBinds.P_CURSOR),
};
} catch (error) {
handleError(error, UserMaintenanceService.name)
@ -205,23 +209,23 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetSPLogins(
:p_spid , :p_cursor
: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 }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
@ -238,29 +242,29 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.CreateSPLogins(
:p_spid, :p_userid, :p_domain, :p_emailaddr, :p_lookupCode, :p_password, :P_EnablePasswordPolicy, :p_cursor
:P_SPID, :P_USERID, :P_DOMAIN, :P_EMAILADDR, :P_LOOKUPCODE, :P_PASSWORD, :P_ENABLEPASSWORDPOLICY, :P_CURSOR
);
END;`,
{
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
p_domain: { val: body.p_domain, type: oracledb.DB_TYPE_NVARCHAR },
p_emailaddr: { val: body.p_emailaddr, type: oracledb.DB_TYPE_NVARCHAR },
p_lookupCode: { val: body.p_lookupCode, type: oracledb.DB_TYPE_NVARCHAR },
p_password: { val: body.p_password, type: oracledb.DB_TYPE_NVARCHAR },
P_EnablePasswordPolicy: { val: body.P_EnablePasswordPolicy, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_DOMAIN: { val: body.P_DOMAIN, type: oracledb.DB_TYPE_NVARCHAR },
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_NVARCHAR },
P_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
P_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
@ -280,23 +284,23 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetClientloginsBySPID(
:p_spid , :p_cursor
: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 }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
@ -315,24 +319,24 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetClientloginsByClientID(
:p_spid, :p_clientid , :p_cursor
:P_SPID, :p_clientid , :P_CURSOR
);
END;`,
{
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
p_clientid: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
@ -349,34 +353,33 @@ export class UserMaintenanceService {
const result = await connection.execute(
`BEGIN
Userlogin_pkg.CreateClientLogins(
:p_spid, :p_userid, :p_clientcontactid, :p_password, :P_EnablePasswordPolicy, :p_cursor
:P_SPID, :P_USERID, :P_CLIENTCONTACTID, :P_PASSWORD, :P_ENABLEPASSWORDPOLICY, :P_CURSOR
);
END;`,
{
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
p_clientcontactid: { val: body.p_clientcontactid, type: oracledb.DB_TYPE_NUMBER },
p_password: { val: body.p_password, type: oracledb.DB_TYPE_NVARCHAR },
P_EnablePasswordPolicy: { val: body.P_EnablePasswordPolicy, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CLIENTCONTACTID: { val: body.P_CLIENTCONTACTID, type: oracledb.DB_TYPE_NUMBER },
P_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
P_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.p_cursor) {
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 await fetchCursor(outBinds.p_cursor, UserMaintenanceService.name);
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
}