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 { 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( export class SaveCarnetApplicationDTO extends IntersectionType(

View File

@ -1,5 +1,7 @@
import { IntersectionType } from '@nestjs/swagger'; 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( export class CreateCarnetSequenceDTO extends IntersectionType(
SPID_DTO, REGIONID_DTO, START_NUMBER_DTO, END_NUMBER_DTO, CARNET_TYPE_DTO 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 { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer"; 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 // General
export class USERID_DTO { export class USERID_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @Length(0, 50, {
@IsDefined({ message: "Invalid Request" }) message: 'Property P_USERID must be between 0 to 50 characters',
p_userid: string; })
@IsString({ message: 'Property P_USERID must be a string' })
@IsDefined({ message: 'Property P_USERID is required' })
P_USERID: string;
} }
export class USER_ID_DTO { export class USER_ID_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_user_id must be a string' }) @IsString({ message: 'Property P_USER_ID must be a string' })
@IsDefined({ message: 'Property p_user_id is required' }) @IsDefined({ message: 'Property P_USER_ID is required' })
p_user_id: string; P_USER_ID: string;
} }
export class EMAIL_DTO { export class EMAIL_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsEmail({}, { message: "Invalid p_emailaddr property" }) @IsEmail({}, { message: "Invalid P_EMAILADDR property" })
@Length(0, 50, { @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' }) @IsString({ message: 'P_EMAILADDR p_userid must be string' })
@IsDefined({ message: 'p_emailaddr p_userid is required' }) @IsDefined({ message: 'P_EMAILADDR p_userid is required' })
p_emailaddr: string; P_EMAILADDR: string;
} }
@ -37,14 +38,14 @@ export class LOOKUP_CODE_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @IsString()
@IsDefined({ message: "Invalid Request" }) @IsDefined({ message: "Invalid Request" })
p_lookupCode: string; P_LOOKUPCODE: string;
} }
export class PASSWORD_DTO { export class PASSWORD_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @IsString()
@IsDefined({ message: "Invalid Request" }) @IsDefined({ message: "Invalid Request" })
p_password: string; P_PASSWORD: string;
} }
export enum YON { export enum YON {
@ -52,94 +53,100 @@ export enum YON {
NO = "N", NO = "N",
} }
export class Name_DTO { export class NAME_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_name must be a string' }) @IsString({ message: 'Property P_NAME must be a string' })
@IsDefined({ message: 'Property p_name is required' }) @IsDefined({ message: 'Property P_NAME is required' })
P_NAME: string; P_NAME: string;
} }
export class ADDRESS1_DTO { export class ADDRESS1_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_address1 must be a string' }) @IsString({ message: 'Property P_ADDRESS1 must be a string' })
@IsDefined({ message: 'Property p_address1 is required' }) @IsDefined({ message: 'Property P_ADDRESS1 is required' })
p_address1: string; P_ADDRESS1: string;
} }
export class ADDRESS2_DTO { export class ADDRESS2_DTO {
@ApiProperty({ required: false }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_address2 must be a string' }) @IsString({ message: 'Property P_ADDRESS2 must be a string' })
@IsOptional() @IsDefined({ message: 'Property P_ADDRESS2 is required' })
p_address2?: string; P_ADDRESS2: string;
} }
export class CITY_DTO { export class CITY_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_city must be a string' }) @Length(0, 30, {
@IsDefined({ message: 'Property p_city is required' }) message: 'Property P_CITY must be between 0 to 30 characters',
p_city: string; })
@IsString({ message: 'Property P_CITY must be a string' })
@IsDefined({ message: 'Property P_CITY is required' })
P_CITY: string;
} }
export class STATE_DTO { export class STATE_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_state must be a string' }) @Length(0, 2, {
@IsDefined({ message: 'Property p_state is required' }) message: 'Property P_STATE must be between 0 to 2 characters',
p_state: string; })
@IsString({ message: 'Property P_STATE must be a string' })
@IsDefined({ message: 'Property P_STATE is required' })
P_STATE: string;
} }
export class COUNTRY_DTO { export class COUNTRY_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_country must be a string' }) @Length(0, 50, {
@IsDefined({ message: 'Property p_country is required' }) message: 'Property P_COUNTRY must be between 0 to 50 characters',
p_country: string; })
@IsString({ message: 'Property P_COUNTRY must be a string' })
@IsDefined({ message: 'Property P_COUNTRY is required' })
P_COUNTRY: string;
} }
export class ZIP_DTO { export class ZIP_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_zip must be a string' }) @Length(0, 10, {
@IsDefined({ message: 'Property p_zip is required' }) message: 'Property P_ZIP must be between 0 to 10 characters',
p_zip: string; })
@IsString({ message: 'Property P_ZIP must be a string' })
@IsDefined({ message: 'Property P_ZIP is required' })
P_ZIP: string;
} }
export class ISSUING_REGION_DTO { export class ISSUING_REGION_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_issuingregion must be a string' }) @IsString({ message: 'Property P_ISSUINGREGION must be a string' })
@IsDefined({ message: 'Property p_issuingregion is required' }) @IsDefined({ message: 'Property P_ISSUINGREGION is required' })
p_issuingregion: string; P_ISSUINGREGION: string;
} }
export class REPLACEMENT_REGION_DTO { export class REPLACEMENT_REGION_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_replacementregion must be a string' }) @IsString({ message: 'Property P_REPLACEMENTREGION must be a string' })
@IsDefined({ message: 'Property p_replacementregion is required' }) @IsDefined({ message: 'Property P_REPLACEMENTREGION is required' })
p_replacementregion: string; P_REPLACEMENTREGION: string;
} }
export class BOND_SURETY_DTO { export class BOND_SURETY_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_bondsurety must be a string' }) @IsString({ message: 'Property P_BONDSURETY must be a string' })
@IsDefined({ message: 'Property p_bondsurety is required' }) @IsDefined({ message: 'Property P_BONDSURETY is required' })
p_bondsurety: string; P_BONDSURETY: string;
} }
export class CARGO_POLICY_NO_DTO { export class CARGO_POLICY_NO_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_cargopolicyno must be a string' }) @IsString({ message: 'Property P_CARGOPOLICYNO must be a string' })
@IsDefined({ message: 'Property p_cargopolicyno is required' }) @IsDefined({ message: 'Property P_CARGOPOLICYNO is required' })
p_cargopolicyno: string; P_CARGOPOLICYNO: string;
} }
export class CARGO_SURETY_DTO { export class CARGO_SURETY_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString({ message: 'Property p_cargosurety must be a string' }) @IsString({ message: 'Property P_CARGOSURETY must be a string' })
@IsDefined({ message: 'Property p_cargosurety is required' }) @IsDefined({ message: 'Property P_CARGOSURETY is required' })
p_cargosurety: string; P_CARGOSURETY: string;
} }
export class NOTES_DTO { 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 // user maintenance
export class ENABLE_PASSWORD_POLICY_DTO { export class ENABLE_PASSWORD_POLICY_DTO {
@ApiProperty({ required: true, enum: YON }) @ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_EnablePasswordPolicy must be either "Y" or "N"' }) @IsEnum(YON, { message: 'P_ENABLEPASSWORDPOLICY must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_EnablePasswordPolicy must be between 5 and 6 characters' }) @Length(1, 1, { message: 'P_ENABLEPASSWORDPOLICY must be between 5 and 6 characters' })
@IsString() @IsString()
@IsDefined({ message: "Invalid Request" }) @IsDefined({ message: "Invalid Request" })
P_EnablePasswordPolicy: YON; P_ENABLEPASSWORDPOLICY: YON;
} }
export class DOMAIN_DTO { export class DOMAIN_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@Length(0, 50, { @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' }) @IsString({ message: 'Property P_DOMAIN must be a string' })
@IsDefined({ message: 'Property p_domain is required' }) @IsDefined({ message: 'Property P_DOMAIN is required' })
p_domain: string; 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 // client
export class CLIENTID_DTO { export class CLIENTID_DTO {
@ -216,125 +214,31 @@ export class CLIENTID_DTO {
export class CLIENT_CONTACTID_DTO { export class CLIENT_CONTACTID_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@Max(999999999, { @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' }) @Min(0, { message: 'Property P_CLIENTCONTACTID must be at least 0 or more' })
@IsInt({ message: 'Property p_clientcontactid allows only whole numbers' }) @IsInt({ message: 'Property P_CLIENTCONTACTID allows only whole numbers' })
@IsNumber({}, { message: 'Property p_clientcontactid must be a number' }) @IsNumber({}, { message: 'Property P_CLIENTCONTACTID must be a number' })
@IsDefined({ message: 'Property p_clientcontactid is required' }) @IsDefined({ message: 'Property P_CLIENTCONTACTID is required' })
p_clientcontactid: number; 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 //Location
export class LOCATIONID_DTO { export class LOCATIONID_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@Max(999999999, { @Max(999999999, { message: 'Property p_locationid must not exceed 999999999' })
message: 'Property p_locationid must not exceed 999999999',
})
@Min(0, { message: 'Property p_locationid must be at least 0 or more' }) @Min(0, { message: 'Property p_locationid must be at least 0 or more' })
@IsInt({ message: 'Property p_locationid allows only whole numbers' }) @IsInt({ message: 'Property p_locationid allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_locationid must be a number' }) @IsNumber({}, { message: 'Property p_locationid must be a number' })
@IsDefined({ message: 'Property p_locationid is required' }) @IsDefined({ message: 'Property p_locationid is required' })
P_LOCATIONID: number; 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 { 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 { 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( export class InsertSPContactsDTO extends IntersectionType(
SPID_DTO, DEFAULT_CONTACT_FLAG_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, TITLE_DTO, 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 { 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( 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, 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 USER_ID_DTO, PartialType(NOTES_DTO), FILE_ID_DTO
) { } ) { }
export class UpdateServiceProviderDTO extends IntersectionType( 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, 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 ZIP_DTO, USER_ID_DTO, PartialType(NOTES_DTO), FILE_ID_DTO
) { } ) { }

View File

@ -1,5 +1,6 @@
import { IntersectionType } from "@nestjs/swagger"; 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) { } export class SPID_CLIENTID_DTO extends IntersectionType(SPID_DTO, CLIENTID_DTO) { }

View File

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

View File

@ -1,7 +1,8 @@
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common'; import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
import { ManageFeeService } from './manage-fee.service'; 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 { ApiTags } from '@nestjs/swagger';
import { GetFeeGeneralDTO } from 'src/dto/fee/fee.dto';
@Controller('mssql') @Controller('mssql')
export class ManageFeeController { export class ManageFeeController {

View File

@ -1,10 +1,11 @@
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service'; import { MssqlDBService } from 'src/db/db.service';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; 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 { BadRequestException } from 'src/exceptions/badRequest.exception';
import { Connection, Request } from 'mssql'; import { Connection, Request } from 'mssql';
import * as mssql from 'mssql'; import * as mssql from 'mssql';
import { GetFeeGeneralDTO } from 'src/dto/fee/fee.dto';
@Injectable() @Injectable()
export class ManageFeeService { export class ManageFeeService {

View File

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

View File

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

View File

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

View File

@ -2,16 +2,10 @@ import { Injectable } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service'; import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql'; import * as mssql from 'mssql';
import { Request } from 'mssql'; import { Request } from 'mssql';
import {
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from '../../oracle/param-table/param-table.dto';
import { Connection } from 'mssql'; import { Connection } from 'mssql';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@Injectable() @Injectable()
export class ParamTableService { 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 { CarnetSequenceService } from './carnet-sequence.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { CreateCarnetSequenceDTO } from 'src/dto/carnet-sequence/carnet-sequence.dto'; 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') @Controller('mssql')
export class CarnetSequenceController { export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) { } constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
@ApiTags('Carnet Sequence - Mssql')
@Get('/GetCarnetSequence') @Get('/GetCarnetSequence')
getCarnetSequence(@Query() body: SPID_DTO) { getCarnetSequence(@Query() body: SPID_DTO) {
return this.carnetSequenceService.getCarnetSequence(body); return this.carnetSequenceService.getCarnetSequence(body);
} }
@ApiTags('Carnet Sequence - Mssql')
@Post('/CreateCarnetSequence/') @Post('/CreateCarnetSequence/')
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) { createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
return this.carnetSequenceService.createCarnetSequence(body); return this.carnetSequenceService.createCarnetSequence(body);

View File

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

View File

@ -49,7 +49,7 @@ export class RegionService {
return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) { } catch (error) {
throw new InternalServerException(); throw new InternalServerException();
} }
} }
} }

View File

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

View File

@ -3,41 +3,42 @@ import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql' import * as mssql from 'mssql'
import { Connection, Request } from 'mssql'; import { Connection, Request } from 'mssql';
import { InsertSPContactsDTO, UpdateSPContactsDTO } from 'src/dto/sp-contacts/sp-contacts.dto'; 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() @Injectable()
export class SpContactsService { export class SpContactsService {
constructor(private readonly mssqlDBService: MssqlDBService) { } constructor(private readonly mssqlDBService: MssqlDBService) { }
async getSpAllContacts(body: SP_ID_DTO) { async getSpAllContacts(body: SPID_DTO) {
let connection: Connection; let connection: Connection;
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();
const request = new Request(connection); 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'); const result = await request.execute('carnetsys.GETSPALLCONTACTS');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
return { error: error.message }; return { error: error.message };
} }
} }
async getSPDefaultcontacts(body: SP_ID_DTO) { async getSPDefaultcontacts(body: SPID_DTO) {
let connection: Connection; let connection: Connection;
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();
const request = new Request(connection); 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'); const result = await request.execute('carnetsys.GETSPDEFAULTCONTACTS');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
return { error: error.message }; return { error: error.message };
} }
} }
async inactivateSPContact(body: SP_CONTACTID_DTO) { async inactivateSPContact(body: SP_CONTACTID_DTO) {
@ -46,13 +47,13 @@ export class SpContactsService {
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();
const request = new Request(connection); 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'); const result = await request.execute('carnetsys.INACTIVATESPCONTACTS');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
return { error: error.message }; return { error: error.message };
} }
} }
async insertSPContacts(body: InsertSPContactsDTO) { async insertSPContacts(body: InsertSPContactsDTO) {
@ -60,23 +61,23 @@ export class SpContactsService {
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();
const request = new Request(connection); 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_DEFCONTACTFLAG', mssql.VarChar(4000), body.p_defcontactflag); request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.P_DEFCONTACTFLAG);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname); request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname); request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL); request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(4000), body.p_title); request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno); request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno); request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno); request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress); 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_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
const result = await request.execute('carnetsys.INSERTSPCONTACTS'); const result = await request.execute('carnetsys.INSERTSPCONTACTS');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
return { error: error.message }; return { error: error.message };
} }
} }
async setSPDefaultcontact(body: SP_CONTACTID_DTO) { async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
@ -84,13 +85,13 @@ export class SpContactsService {
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();
const request = new Request(connection); 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'); const result = await request.execute('carnetsys.SETDEFAULTCONTACT');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
return { error: error.message }; return { error: error.message };
} }
} }
async updateSPContacts(body: UpdateSPContactsDTO) { async updateSPContacts(body: UpdateSPContactsDTO) {
@ -98,21 +99,21 @@ export class SpContactsService {
try { try {
connection = await this.mssqlDBService.getConnection(); connection = await this.mssqlDBService.getConnection();
const request = new Request(connection); const request = new Request(connection);
request.input('P_SPCONTACTID', mssql.Int, body.p_spcontactid); request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname); request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname); request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL); request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(4000), body.p_title); request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno); request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno); request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno); request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress); 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_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
const result = await request.execute('carnetsys.UPDATESPCONTACTS'); const result = await request.execute('carnetsys.UPDATESPCONTACTS');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
return { error: error.message }; return { error: error.message };
} }
} }
} }

View File

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

View File

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

View File

@ -168,10 +168,10 @@ export class CarnetApplicationService {
); );
END;`, 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_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, 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_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_VARCHAR }, P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_VARCHAR },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER }, P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
@ -231,8 +231,8 @@ export class CarnetApplicationService {
); );
END;`, END;`,
{ {
P_SPID: { 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_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_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } // p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }

View File

@ -17,26 +17,23 @@ import {
GetCarnetDetailsbyCarnetStatusDTO, GetCarnetDetailsbyCarnetStatusDTO,
} from './home-page.dto'; } from './home-page.dto';
@Controller() @ApiTags('HomePage - Oracle')
@Controller('oracle')
export class HomePageController { 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) { GetHomePageData(@Param('id', ParseIntPipe) id: number) {
return this.homePageService.GetHomePageData(id); return this.homePageService.GetHomePageData(id);
} }
@ApiTags('HomePage - Oracle') @Get('GetCarnetSummaryData/:userid')
@Get('/oracle/GetCarnetSummaryData/:userid')
GetCarnetSummaryData(@Param('userid') id: string) { GetCarnetSummaryData(@Param('userid') id: string) {
return this.homePageService.GetCarnetSummaryData(id); return this.homePageService.GetCarnetSummaryData(id);
} }
@ApiTags('HomePage - Oracle') @Get('GetCarnetDetailsbyCarnetStatus/:p_spid/:p_userid/:p_CarnetStatus')
@Get(
'/oracle/GetCarnetDetailsbyCarnetStatus/:p_spid/:p_userid/:p_CarnetStatus',
)
GetCarnetDetailsbyCarnetStatus( GetCarnetDetailsbyCarnetStatus(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_userid') p_userid: string, @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') // @Post('/oracle/SaveCarnetApplication')
SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) { SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
return this.homePageService.SaveCarnetApplication(body); return this.homePageService.SaveCarnetApplication(body);
} }
// @ApiTags('HomePage - Oracle') // NOTE : this has been moved to carent-application module
// @Post('/oracle/TransmitApplicationtoProcess') // @Post('/oracle/TransmitApplicationtoProcess')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) { TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.homePageService.TransmitApplicationtoProcess(body); 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) { async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
const newBody = { const newBody = {
p_headerid: null, p_headerid: null,
@ -736,6 +738,8 @@ export class HomePageService {
} }
} }
// NOTE : this has been moved to carent-application module
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) { async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
let connection; let connection;
let rows = []; let rows = [];
@ -813,9 +817,7 @@ export class HomePageService {
} }
} }
async GetCarnetDetailsbyCarnetStatus( async GetCarnetDetailsbyCarnetStatus(body: GetCarnetDetailsbyCarnetStatusDTO) {
body: GetCarnetDetailsbyCarnetStatusDTO,
) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {

View File

@ -13,7 +13,7 @@ import {
IsEmail, IsEmail,
} from 'class-validator'; } from 'class-validator';
import { Transform, Type } from 'class-transformer'; 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 { export class p_clientlocaddresstableDTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@ -525,12 +525,12 @@ export class CreateClientContactsDTO {
@IsDefined({ message: 'Property p_clientid is required' }) @IsDefined({ message: 'Property p_clientid is required' })
p_clientid: number; p_clientid: number;
@ApiProperty({ required: true, type: () => [p_contactstableDTO] }) @ApiProperty({ required: true, type: () => [CONTACTSTABLE_ROW_DTO] })
@Type(() => p_contactstableDTO) @Type(() => CONTACTSTABLE_ROW_DTO)
@ValidateNested({ each: true }) @ValidateNested({ each: true })
@IsArray({ message: 'Property p_contactstable allows only array type' }) @IsArray({ message: 'Property p_contactstable allows only array type' })
@IsDefined({ message: 'Property p_contactstable is required' }) @IsDefined({ message: 'Property p_contactstable is required' })
p_contactstable: p_contactstableDTO[]; p_contactstable: CONTACTSTABLE_ROW_DTO[];
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@Length(0, 1, { @Length(0, 1, {

View File

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

View File

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

View File

@ -2,23 +2,6 @@ import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer'; import { Transform } from 'class-transformer';
import { IsDefined, IsInt, IsNumber, IsString, Length, Matches, Min } from 'class-validator'; 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 { export class CreateBasicFeeDTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })

View File

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

View File

@ -10,15 +10,8 @@ import {
Put, Put,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import {
CreateHoldersDTO,
GetHolderDTO,
HolderActivateOrInactivateDTO,
HolderContactActivateOrInactivateDTO,
UpdateHolderContactDTO,
UpdateHolderDTO
} from './manage-holders.dto';
import { ManageHoldersService } from './manage-holders.service'; import { ManageHoldersService } from './manage-holders.service';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/holder/holder.dto';
@Controller('oracle') @Controller('oracle')
export class ManageHoldersController { export class ManageHoldersController {
@ -44,94 +37,94 @@ export class ManageHoldersController {
} }
@ApiTags('Manage Holders - Oracle') @ApiTags('Manage Holders - Oracle')
@Get('/GetHolderRecord/:p_spid/:p_holderid') @Get('/GetHolderRecord/:P_SPID/:P_HOLDERID')
GetHolderMaster( GetHolderMaster(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('p_holderid', ParseIntPipe) p_holderid: 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); return this.manageHoldersService.GetHolderRecord(reqParams);
} }
@ApiTags('Manage Holders - Oracle') @ApiTags('Manage Holders - Oracle')
@Get('/GetHolderContacts/:p_spid/:p_holderid') @Get('/GetHolderContacts/:P_SPID/:P_HOLDERID')
GetHolderContacts( GetHolderContacts(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('p_holderid', ParseIntPipe) p_holderid: 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); return this.manageHoldersService.GetHolderContacts(reqParams);
} }
@ApiTags('Manage Holders - Oracle') @ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolder/:p_spid/:p_holderid/:p_userid') @Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
InactivateHolder( InactivateHolder(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number, @Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('p_userid') p_userid: string @Param('P_USERID') P_USERID: string
) { ) {
if (!p_userid) { if (!P_USERID) {
throw new BadRequestException("Bad Request"); 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); return this.manageHoldersService.InactivateHolder(reqParams);
} }
@ApiTags('Manage Holders - Oracle') @ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolder/:p_spid/:p_holderid/:p_userid') @Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
ReactivateHolder( ReactivateHolder(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('p_holderid', ParseIntPipe) p_holderid: number, @Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('p_userid') p_userid: string @Param('P_USERID') P_USERID: string
) { ) {
if (!p_userid) { if (!P_USERID) {
throw new BadRequestException("Bad Request"); 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); return this.manageHoldersService.ReactivateHolder(reqParams);
} }
@ApiTags('Manage Holders - Oracle') @ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolderContact/:p_spid/:p_holderContactid/:p_userid') @Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
InactivateHolderContact( InactivateHolderContact(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number, @Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('p_userid') p_userid: string @Param('P_USERID') P_USERID: string
) { ) {
if (!p_userid) { if (!P_USERID) {
throw new BadRequestException("Bad Request"); throw new BadRequestException("Bad Request");
} }
const reqParams: HolderContactActivateOrInactivateDTO = { const reqParams: HolderContactActivateOrInactivateDTO = {
p_spid, P_SPID,
p_holderContactid, P_HOLDERCONTACTID,
p_userid P_USERID
}; };
return this.manageHoldersService.InactivateHolderContact(reqParams); return this.manageHoldersService.InactivateHolderContact(reqParams);
} }
@ApiTags('Manage Holders - Oracle') @ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolderContact/:p_spid/:p_holderContactid/:p_userid') @Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
ReactivateHolderContact( ReactivateHolderContact(
@Param('p_spid', ParseIntPipe) p_spid: number, @Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('p_holderid', ParseIntPipe) p_holderContactid: number, @Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('p_userid') p_userid: string @Param('P_USERID') P_USERID: string
) { ) {
if (!p_userid) { if (!P_USERID) {
throw new BadRequestException("Bad Request"); throw new BadRequestException("Bad Request");
} }
const reqParams: HolderContactActivateOrInactivateDTO = { const reqParams: HolderContactActivateOrInactivateDTO = {
p_spid, P_SPID,
p_holderContactid, P_HOLDERCONTACTID,
p_userid P_USERID
}; };
return this.manageHoldersService.ReactivateHolderContact(reqParams); 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 { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger'; import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { ParamTableService } from './param-table.service'; import { ParamTableService } from './param-table.service';
import { import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from './param-table.dto';
@ApiTags('Param Table - Oracle')
@Controller('oracle') @Controller('oracle')
export class ParamTableController { export class ParamTableController {
constructor(private readonly paramTableService: ParamTableService) {} constructor(private readonly paramTableService: ParamTableService) { }
@ApiTags('Param Table - Oracle')
@Get('/GetParamValues') @Get('/GetParamValues')
@ApiQuery({ @ApiQuery({
name: 'P_SPID', name: 'P_SPID',
@ -31,31 +26,26 @@ export class ParamTableController {
return this.paramTableService.GETPARAMVALUES(body); return this.paramTableService.GETPARAMVALUES(body);
} }
@ApiTags('Param Table - Oracle')
@Post('/CreateTableRecord') @Post('/CreateTableRecord')
createTableRecord(@Body() body: CreateTableRecordDTO) { createTableRecord(@Body() body: CreateTableRecordDTO) {
return this.paramTableService.CREATETABLERECORD(body); return this.paramTableService.CREATETABLERECORD(body);
} }
@ApiTags('Param Table - Oracle')
@Post('/CreateParamRecord') @Post('/CreateParamRecord')
createParamRecord(@Body() body: CreateParamRecordDTO) { createParamRecord(@Body() body: CreateParamRecordDTO) {
return this.paramTableService.CREATEPARAMRECORD(body); return this.paramTableService.CREATEPARAMRECORD(body);
} }
@ApiTags('Param Table - Oracle')
@Patch('/UpdateParamRecord') @Patch('/UpdateParamRecord')
UpdateParamRecord(@Body() body: UpdateParamRecordDTO) { UpdateParamRecord(@Body() body: UpdateParamRecordDTO) {
return this.paramTableService.UPDATEPARAMRECORD(body); return this.paramTableService.UPDATEPARAMRECORD(body);
} }
@ApiTags('Param Table - Oracle')
@Patch('/InActivateParamRecord') @Patch('/InActivateParamRecord')
inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) { inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.INACTIVATEPARAMRECORD(body); return this.paramTableService.INACTIVATEPARAMRECORD(body);
} }
@ApiTags('Param Table - Oracle')
@Patch('/ReActivateParamRecord') @Patch('/ReActivateParamRecord')
reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) { reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.REACTIVATEPARAMRECORD(body); 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;
}

File diff suppressed because it is too large Load Diff

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 { import {
CreateCarnetSequenceDTO CreateCarnetSequenceDTO
} from '../../../dto/carnet-sequence/carnet-sequence.dto'; } from '../../../dto/carnet-sequence/carnet-sequence.dto';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { CarnetSequenceService } from './carnet-sequence.service'; 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') @Controller('oracle')
export class CarnetSequenceController { export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) {} constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
@ApiTags('Carnet Sequence - Oracle')
@Post('/CreateCarnetSequence/') @Post('/CreateCarnetSequence/')
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) { createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
return this.carnetSequenceService.createCarnetSequence(body); return this.carnetSequenceService.createCarnetSequence(body);
} }
@ApiTags('Carnet Sequence - Oracle') @Get('/GetCarnetSequence/:P_SPID')
@Get('/GetCarnetSequence') getCarnetSequence(@Param() params: SPID_DTO) {
getCarnetSequence(@Query() body: SPID_DTO) { return this.carnetSequenceService.getCarnetSequence(params);
return this.carnetSequenceService.getCarnetSequence(body);
} }
} }

View File

@ -7,15 +7,16 @@ import {
import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.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() @Injectable()
export class CarnetSequenceService { export class CarnetSequenceService {
private readonly logger = new Logger(CarnetSequenceService.name); 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; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
@ -26,51 +27,51 @@ export class CarnetSequenceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.CreateCarnetSequence( USCIB_Managed_Pkg.CreateCarnetSequence(
:p_spid, :P_SPID,
:p_regionid, :P_REGIONID,
:p_startnumber, :P_STARTNUMBER,
:p_endnumber, :P_ENDNUMBER,
:p_carnettype, :P_CARNETTYPE,
:p_cursor); :P_CURSOR);
END;`, END;`,
{ {
p_spid: { P_SPID: {
val: body.p_spid, val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
p_regionid: { P_REGIONID: {
val: body.P_REGIONID, val: body.P_REGIONID,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
p_startnumber: { P_STARTNUMBER: {
val: body.p_startnumber, val: body.P_STARTNUMBER,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
p_endnumber: { P_ENDNUMBER: {
val: body.p_endnumber, val: body.P_ENDNUMBER,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
p_carnettype: { P_CARNETTYPE: {
val: body.p_carnettype, val: body.P_CARNETTYPE,
type: oracledb.DB_TYPE_VARCHAR, type: oracledb.DB_TYPE_VARCHAR,
}, },
p_cursor: { P_CURSOR: {
type: oracledb.CURSOR, type: oracledb.CURSOR,
dir: oracledb.BIND_OUT, dir: oracledb.BIND_OUT,
}, },
}, },
{ {
outFormat: oracledb.OUT_FORMAT_OBJECT, 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();
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); this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(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 connection;
let rows = []; let rows = [];
try { try {
@ -106,14 +153,14 @@ export class CarnetSequenceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetCarnetSequence(:p_spid,:p_cursor); USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR);
END;`, END;`,
{ {
p_spid: { P_SPID: {
val: body.p_spid, val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
p_cursor: { P_CURSOR: {
type: oracledb.CURSOR, type: oracledb.CURSOR,
dir: oracledb.BIND_OUT, dir: oracledb.BIND_OUT,
}, },
@ -123,8 +170,8 @@ export class CarnetSequenceService {
}, },
); );
if (result.outBinds && result.outBinds.p_cursor) { if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.p_cursor; const cursor = result.outBinds.P_CURSOR;
let rowsBatch; let rowsBatch;
do { 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) { } constructor(private readonly oracleDBService: OracleDBService) { }
async insertRegionsX(body: InsertRegionsDto) { // async insertRegionsX(body: InsertRegionsDto) {
let connection; // let connection;
try { // try {
connection = await this.oracleDBService.getConnection(); // connection = await this.oracleDBService.getConnection();
if (!connection) { // if (!connection) {
throw new InternalServerException(); // throw new InternalServerException();
} // }
const result = await connection.execute( // const result = await connection.execute(
`BEGIN // `BEGIN
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:P_NAME,:p_cursor); // USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
END;`, // END;`,
{ // {
p_region: { // P_REGION: {
val: body.P_REGION, // val: body.P_REGION,
type: oracledb.DB_TYPE_VARCHAR, // type: oracledb.DB_TYPE_VARCHAR,
}, // },
P_NAME: { // P_NAME: {
val: body.P_NAME, // val: body.P_NAME,
type: oracledb.DB_TYPE_VARCHAR, // type: oracledb.DB_TYPE_VARCHAR,
}, // },
p_cursor: { // P_CURSOR: {
type: oracledb.CURSOR, // type: oracledb.CURSOR,
dir: oracledb.BIND_OUT, // dir: oracledb.BIND_OUT,
}, // },
}, // },
{ // {
outFormat: oracledb.OUT_FORMAT_OBJECT, // 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) { // if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG); // this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG) // throw new BadRequestException(fres[0].ERRORMESG)
} // }
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] }; // return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) { // } catch (error) {
if (error instanceof BadRequestException) { // if (error instanceof BadRequestException) {
this.logger.warn(error.message); // this.logger.warn(error.message);
throw error; // throw error;
} // }
this.logger.error('insertRegions failed', error.stack || error); // this.logger.error('insertRegions failed', error.stack || error);
throw new InternalServerException(); // throw new InternalServerException();
} finally { // } finally {
if (connection) { // if (connection) {
try { // try {
await connection.close(); // await connection.close();
} catch (closeErr) { // } catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr); // this.logger.error('Failed to close DB connection', closeErr);
} // }
} // }
} // }
} // }
async insertRegions(body: InsertRegionsDto) { async insertRegions(body: InsertRegionsDto) {
let connection; let connection;
@ -78,12 +78,12 @@ export class RegionService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:P_NAME,:p_cursor); USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
END;`, 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_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 } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
@ -91,12 +91,12 @@ export class RegionService {
await connection.commit(); await connection.commit();
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG); this.logger.warn(fres[0].ERRORMESG);
@ -112,64 +112,64 @@ export class RegionService {
} }
} }
async updateRegionsX(body: UpdateRegionDto) { // async updateRegionsX(body: UpdateRegionDto) {
let connection; // let connection;
try { // try {
connection = await this.oracleDBService.getConnection(); // connection = await this.oracleDBService.getConnection();
if (!connection) { // if (!connection) {
throw new InternalServerException(); // throw new InternalServerException();
} // }
const result = await connection.execute( // const result = await connection.execute(
`BEGIN // `BEGIN
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:P_NAME,:p_cursor); // USCIB_Managed_Pkg.UpdateRegion(:P_REGIONID,:P_NAME,:P_CURSOR);
END;`, // END;`,
{ // {
p_regionID: { // P_REGIONID: {
val: body.P_REGIONID, // val: body.P_REGIONID,
type: oracledb.DB_TYPE_NUMBER, // type: oracledb.DB_TYPE_NUMBER,
}, // },
P_NAME: { // P_NAME: {
val: body.P_NAME, // val: body.P_NAME,
type: oracledb.DB_TYPE_VARCHAR, // type: oracledb.DB_TYPE_VARCHAR,
}, // },
p_cursor: { // P_CURSOR: {
type: oracledb.CURSOR, // type: oracledb.CURSOR,
dir: oracledb.BIND_OUT, // dir: oracledb.BIND_OUT,
}, // },
}, // },
{ // {
outFormat: oracledb.OUT_FORMAT_OBJECT, // 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) { // if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG); // this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG) // throw new BadRequestException(fres[0].ERRORMESG)
} // }
return { statusCode: 200, message: "Updated Successfully", ...fres[0] }; // return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
} catch (error) { // } catch (error) {
if (error instanceof BadRequestException) { // if (error instanceof BadRequestException) {
this.logger.warn(error.message); // this.logger.warn(error.message);
throw error; // throw error;
} // }
this.logger.error('updateRegions failed', error.stack || error); // this.logger.error('updateRegions failed', error.stack || error);
throw new InternalServerException(); // throw new InternalServerException();
} finally { // } finally {
if (connection) { // if (connection) {
try { // try {
await connection.close(); // await connection.close();
} catch (closeErr) { // } catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr); // this.logger.error('Failed to close DB connection', closeErr);
} // }
} // }
} // }
} // }
async updateRegions(body: UpdateRegionDto) { async updateRegions(body: UpdateRegionDto) {
let connection; let connection;
@ -178,12 +178,12 @@ export class RegionService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:P_NAME,:p_cursor); USCIB_Managed_Pkg.UpdateRegion(:P_REGIONID,:P_NAME,:P_CURSOR);
END;`, 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_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 } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
@ -191,12 +191,12 @@ export class RegionService {
await connection.commit(); await connection.commit();
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG); this.logger.warn(fres[0].ERRORMESG);
@ -211,68 +211,68 @@ export class RegionService {
} }
} }
async getRegionsX() { // async getRegionsX() {
let connection; // let connection;
let rows = []; // let rows = [];
try { // try {
connection = await this.oracleDBService.getConnection(); // connection = await this.oracleDBService.getConnection();
if (!connection) { // if (!connection) {
throw new InternalServerException() // throw new InternalServerException()
} // }
const result = await connection.execute( // const result = await connection.execute(
`BEGIN // `BEGIN
USCIB_Managed_Pkg.GetRegions(:p_cursor); // USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
END;`, // END;`,
{ // {
p_cursor: { // P_CURSOR: {
type: oracledb.CURSOR, // type: oracledb.CURSOR,
dir: oracledb.BIND_OUT, // dir: oracledb.BIND_OUT,
}, // },
}, // },
{ // {
outFormat: oracledb.OUT_FORMAT_OBJECT, // outFormat: oracledb.OUT_FORMAT_OBJECT,
}, // },
); // );
if (result.outBinds && result.outBinds.p_cursor) { // if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.p_cursor; // const cursor = result.outBinds.P_CURSOR;
let rowsBatch; // let rowsBatch;
do { // do {
rowsBatch = await cursor.getRows(100); // rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch); // rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0); // } while (rowsBatch.length > 0);
await cursor.close(); // await cursor.close();
} else { // } else {
throw new BadRequestException(); // 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() { async getRegions() {
let connection; let connection;
try { try {
@ -280,21 +280,21 @@ export class RegionService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetRegions(:p_cursor); USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
END;`, END;`,
{ {
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, RegionService.name) handleError(error, RegionService.name)
} finally { } finally {

View File

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

View File

@ -7,7 +7,9 @@ import {
} from '../../../dto/sp-contacts/sp-contacts.dto'; } from '../../../dto/sp-contacts/sp-contacts.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.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() @Injectable()
export class SpContactsService { export class SpContactsService {
@ -15,88 +17,160 @@ export class SpContactsService {
constructor(private readonly oracleDBService: OracleDBService) { } 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) { async insertSPContacts(body: InsertSPContactsDTO) {
let connection; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.InsertSPContacts( USCIB_Managed_Pkg.InsertSPContacts(
:p_spid, :P_SPID,
:p_defcontactflag, :P_DEFCONTACTFLAG,
:p_firstname, :P_FIRSTNAME,
:p_lastname, :P_LASTNAME,
:P_MIDDLEINITIAL, :P_MIDDLEINITIAL,
:p_title, :P_TITLE,
:p_phoneno, :P_PHONENO,
:p_mobileno, :P_MOBILENO,
:p_faxno, :P_FAXNO,
:p_emailaddress, :P_EMAILADDRESS,
:p_user_id, :P_USER_ID,
:p_cursor); :P_CURSOR);
END;`, END;`,
{ {
p_spid: { P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
val: body.p_spid, P_DEFCONTACTFLAG: { val: body.P_DEFCONTACTFLAG, type: oracledb.DB_TYPE_VARCHAR },
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_defcontactflag: { P_MIDDLEINITIAL: { val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_defcontactflag, P_TITLE: { val: body.P_TITLE, type: oracledb.DB_TYPE_VARCHAR },
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_firstname: { P_FAXNO: { val: body.P_FAXNO, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_firstname, P_EMAILADDRESS: { val: body.P_EMAILADDRESS, type: oracledb.DB_TYPE_VARCHAR },
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 }
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,
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
await connection.commit(); 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) { if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG); this.logger.warn(fres[0].ERRORMESG);
@ -104,311 +178,497 @@ export class SpContactsService {
} }
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] }; return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, SpContactsService.name)
throw error;
}
this.logger.error('insertSPContacts failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpContactsService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// 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) { async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
let connection; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid); USCIB_Managed_Pkg.SetDefaultContact(:P_SPCONTACTID);
END;`, END;`,
{ {
p_spcontactid: { P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }
val: body.p_spcontactid,
type: oracledb.DB_TYPE_NUMBER,
},
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
await connection.commit(); 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' }; return { statusCode: 200, message: 'Default contact was added successfully for SP' };
} catch (error) { } catch (error) {
this.logger.error('setSPDefaultcontact failed', error.stack || error); handleError(error, SpContactsService.name)
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpContactsService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// 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) { async updateSPContacts(body: UpdateSPContactsDTO) {
let connection; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.UpdateSPContacts( USCIB_Managed_Pkg.UpdateSPContacts(
:p_spcontactid, :P_SPCONTACTID,
:p_firstname, :P_FIRSTNAME,
:p_lastname, :P_LASTNAME,
:P_MIDDLEINITIAL, :P_MIDDLEINITIAL,
:p_title, :P_TITLE,
:p_phoneno, :P_PHONENO,
:p_mobileno, :P_MOBILENO,
:p_faxno, :P_FAXNO,
:p_emailaddress, :P_EMAILADDRESS,
:p_user_id, :P_USER_ID,
:p_cursor); :P_CURSOR);
END;`, END;`,
{ {
p_spcontactid: { P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER },
val: body.p_spcontactid, P_FIRSTNAME: { val: body.P_FIRSTNAME, type: oracledb.DB_TYPE_VARCHAR },
type: oracledb.DB_TYPE_NUMBER, P_LASTNAME: { val: body.P_LASTNAME, type: oracledb.DB_TYPE_VARCHAR },
}, P_MIDDLEINITIAL: { val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_VARCHAR },
p_firstname: { P_TITLE: { val: body.P_TITLE, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_firstname, P_PHONENO: { val: body.P_PHONENO, type: oracledb.DB_TYPE_VARCHAR },
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_lastname: { P_EMAILADDRESS: { val: body.P_EMAILADDRESS, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_lastname, P_USER_ID: { val: body.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
type: oracledb.DB_TYPE_VARCHAR, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
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,
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
await connection.commit(); 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) { if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG); this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(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) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, SpContactsService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('updateSPContacts failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpContactsService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// 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) { async inactivateSPContact(body: SP_CONTACTID_DTO) {
let connection; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid); USCIB_Managed_Pkg.InActivateSPContacts(:P_SPCONTACTID);
END;`, END;`,
{ {
p_spcontactid: { P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }
val: body.p_spcontactid,
type: oracledb.DB_TYPE_NUMBER,
},
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
await connection.commit(); 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' }; return { statusCode: 200, message: 'Inactivated SP contact successfully' };
} catch (error) { } catch (error) {
this.logger.error('inactivateSPContact failed', error.stack || error); handleError(error, SpContactsService.name)
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpContactsService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
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 connection;
let rows = [];
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetSPDefaultContacts(:p_SPid,:p_cursor); USCIB_Managed_Pkg.GetSPDefaultContacts(:P_SPID,:P_CURSOR);
END;`, END;`,
{ {
p_SPid: { P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
val: body.p_SPid, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
if (result.outBinds && result.outBinds.p_cursor) { await connection.commit();
const cursor = result.outBinds.p_cursor;
let rowsBatch;
do { const outBinds = result.outBinds;
rowsBatch = await cursor.getRows(100); if (!outBinds?.P_CURSOR) {
rows = rows.concat(rowsBatch); this.logger.error('One or more expected cursors are missing from stored procedure output.');
} while (rowsBatch.length > 0); throw new InternalServerException("Incomplete data received from the database.");
await cursor.close();
} else {
throw new BadRequestException();
} }
return rows; return await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
} catch (error) { } catch (error) {
this.logger.error('getSPDefaultcontacts failed', error.stack || error); handleError(error, SpContactsService.name)
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpContactsService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
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 connection;
let rows = [];
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetSPAllContacts(:p_SPid,:p_cursor); USCIB_Managed_Pkg.GetSPAllContacts(:P_SPID,:P_CURSOR);
END;`, END;`,
{ {
p_SPid: { P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
val: body.p_SPid, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
if (result.outBinds && result.outBinds.p_cursor) { await connection.commit();
const cursor = result.outBinds.p_cursor;
let rowsBatch;
do { const outBinds = result.outBinds;
rowsBatch = await cursor.getRows(100); if (!outBinds?.P_CURSOR) {
rows = rows.concat(rowsBatch); this.logger.error('One or more expected cursors are missing from stored procedure output.');
} while (rowsBatch.length > 0); throw new InternalServerException("Incomplete data received from the database.");
await cursor.close();
} else {
throw new BadRequestException();
} }
return rows; return await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
} catch (error) { } catch (error) {
this.logger.error('getSPAllContacts failed', error.stack || error); handleError(error, SpContactsService.name)
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpContactsService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
} }

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

View File

@ -7,7 +7,8 @@ import {
} from '../../../dto/sp/sp.dto'; } from '../../../dto/sp/sp.dto';
import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.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() @Injectable()
export class SpService { export class SpService {
@ -15,158 +16,381 @@ export class SpService {
constructor(private readonly oracleDBService: OracleDBService) { } 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) { 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; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.InsertNewSP( USCIB_Managed_Pkg.InsertNewSP(
:P_NAME, :P_NAME,
:p_lookupcode, :P_LOOKUPCODE,
:p_address1, :P_ADDRESS1,
:p_address2, :P_ADDRESS2,
:p_city, :P_CITY,
:p_state, :P_STATE,
:p_zip, :P_ZIP,
:p_country, :P_COUNTRY,
:p_issuingregion, :P_ISSUINGREGION,
:p_replacementregion, :P_REPLACEMENTREGION,
:p_bondsurety, :P_BONDSURETY,
:p_cargopolicyno, :P_CARGOPOLICYNO,
:p_cargosurety, :P_CARGOSURETY,
:p_user_id, :P_USER_ID,
:P_NOTES, :P_NOTES,
:P_FILEIDS, :P_FILEIDS,
:p_cursor); :P_CURSOR);
END;`, END;`,
{ {
P_NAME: { P_NAME: { val: finalBody.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
val: body.P_NAME, P_LOOKUPCODE: { val: finalBody.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
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_lookupcode: { P_CITY: { val: finalBody.P_CITY, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_lookupCode, P_STATE: { val: finalBody.P_STATE, type: oracledb.DB_TYPE_VARCHAR },
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_address1: { P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_address1, P_REPLACEMENTREGION: { val: finalBody.P_REPLACEMENTREGION, type: oracledb.DB_TYPE_VARCHAR },
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_address2: { P_CARGOSURETY: { val: finalBody.P_CARGOSURETY, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_address2, P_USER_ID: { val: finalBody.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
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_city: { P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
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,
}, },
{ 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); this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG) throw new BadRequestException(fres[0].ERRORMESG)
} }
// return fres[0];
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] }; return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, SpService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('insertNewServiceProvider failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
async updateServiceProvider(body: UpdateServiceProviderDTO) { // 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 = { const newBody = {
p_spid: null, P_SPID: null,
p_name: null, P_NAME: null,
p_lookupcode: null, P_LOOKUPCODE: null,
p_address1: null, P_ADDRESS1: null,
p_address2: null, P_ADDRESS2: null,
p_city: null, P_CITY: null,
p_state: null, P_STATE: null,
p_zip: null, P_ZIP: null,
p_country: null, P_COUNTRY: null,
p_issuingregion: null, P_ISSUINGREGION: null,
p_replacementregion: null, P_REPLACEMENTREGION: null,
p_bondsurety: null, P_BONDSURETY: null,
p_cargopolicyno: null, P_CARGOPOLICYNO: null,
p_cargosurety: null, P_CARGOSURETY: null,
p_user_id: null P_USER_ID: null
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -188,266 +412,264 @@ export class SpService {
let connection; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.UpdateSP( USCIB_Managed_Pkg.UpdateSP(
:p_spid, :P_SPID,
:P_NAME, :P_NAME,
:p_lookupcode, :P_LOOKUPCODE,
:p_address1, :P_ADDRESS1,
:p_address2, :P_ADDRESS2,
:p_city, :P_CITY,
:p_state, :P_STATE,
:p_zip, :P_ZIP,
:p_country, :P_COUNTRY,
:p_bondsurety, :P_ISSUINGREGION,
:p_cargopolicyno, :P_REPLACEMENTREGION,
:p_cargosurety, :P_BONDSURETY,
:p_replacementregion, :P_CARGOPOLICYNO,
:p_issuingregion, :P_CARGOSURETY,
:p_user_id, :P_USER_ID,
:P_NOTES, :P_NOTES,
:P_FILEIDS, :P_FILEIDS,
:p_cursor); :P_CURSOR);
END;`, END;`,
{ {
p_spid: { P_SPID: { val: finalBody.P_SPID, type: oracledb.DB_TYPE_NUMBER },
val: finalBody.p_spid, P_NAME: { val: finalBody.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
type: oracledb.DB_TYPE_NUMBER, P_LOOKUPCODE: { val: finalBody.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
}, P_ADDRESS1: { val: finalBody.P_ADDRESS1, type: oracledb.DB_TYPE_VARCHAR },
P_NAME: { P_ADDRESS2: { val: finalBody.P_ADDRESS2, type: oracledb.DB_TYPE_VARCHAR },
val: finalBody.P_NAME, P_CITY: { val: finalBody.P_CITY, type: oracledb.DB_TYPE_VARCHAR },
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_lookupcode: { P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_VARCHAR },
val: finalBody.p_lookupCode, P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
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_address1: { P_CARGOPOLICYNO: { val: finalBody.P_CARGOPOLICYNO, type: oracledb.DB_TYPE_VARCHAR },
val: finalBody.p_address1, P_CARGOSURETY: { val: finalBody.P_CARGOSURETY, type: oracledb.DB_TYPE_VARCHAR },
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_address2: { P_FILEIDS: { val: finalBody.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR },
val: finalBody.p_address2, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
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,
}, },
{ 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); this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(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) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, SpService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('updateServiceProvider failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// 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() { async getAllServiceproviders() {
let connection; let connection;
let rows: any = [];
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetAllSPs(:p_cursor); USCIB_Managed_Pkg.GetAllSPs(:P_CURSOR);
END;`, END;`,
{ {
p_cursor: { P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
if (result.outBinds && result.outBinds.p_cursor) { const outBinds = result.outBinds;
const cursor = result.outBinds.p_cursor; if (!outBinds?.P_CURSOR) {
let rowsBatch; this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
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();
} }
return await fetchCursor(outBinds.P_CURSOR, SpService.name);
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, SpService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('getAllServiceproviders failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, SpService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// 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) { async getServiceproviderByID(body: SPID_DTO) {
let connection; let connection;
let rows: any = [];
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetSPbySPID(:p_spid,:p_cursor); USCIB_Managed_Pkg.GetSPbySPID(:P_SPID,:P_CURSOR);
END;`, END;`,
{ {
p_spid: { P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
val: body.p_spid, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
type: oracledb.DB_TYPE_NUMBER,
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
if (result.outBinds && result.outBinds.p_cursor) { const outBinds = result.outBinds;
const cursor = result.outBinds.p_cursor; if (!outBinds?.P_CURSOR) {
let rowsBatch; this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
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) { return await fetchCursor(outBinds.P_CURSOR, SpService.name);
throw new BadRequestException(rows[0].ERRORMESG);
}
return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, SpService.name)
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 { } finally {
if (connection) { await closeOracleDbConnection(connection, SpService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
} }

View File

@ -2,7 +2,8 @@ import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common
import { UserMaintenanceService } from './user-maintenance.service'; import { UserMaintenanceService } from './user-maintenance.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
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 { 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') @ApiTags('User Maintenance - Oracle')
@Controller('oracle') @Controller('oracle')

View File

@ -1,11 +1,15 @@
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service'; 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 { InternalServerException } from 'src/exceptions/internalServerError.exception';
import * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception'; 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 { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO } from 'src/dto/sp/sp-property.dto';
interface RoleDetail { [key: string]: any; } interface RoleDetail { [key: string]: any; }
@ -53,7 +57,7 @@ export class UserMaintenanceService {
); );
END;`, 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_ROLECUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
P_MENUCUR: { 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 }, P_MENUPAGECUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
@ -91,24 +95,24 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.LockUserAccount( Userlogin_pkg.LockUserAccount(
:p_spid, :p_emailaddr, :p_cursor :P_SPID, :P_EMAILADDR, :P_CURSOR
); );
END;`, END;`,
{ {
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER }, P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
p_emailaddr: { val: body.p_emailaddr, type: oracledb.DB_TYPE_NVARCHAR }, P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
@ -128,22 +132,22 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.GetUSCIBLogins( Userlogin_pkg.GetUSCIBLogins(
:p_cursor :P_CURSOR
); );
END;`, END;`,
{ {
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
@ -162,28 +166,28 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.CreateUSCIBLogins( 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;`, END;`,
{ {
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
p_emailaddr: { val: body.p_emailaddr, 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_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_NVARCHAR },
p_password: { val: body.p_password, 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_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); throw new InternalServerException("Incomplete data received from the database.");
} }
return { return {
data: await fetchCursor(outBinds.p_cursor), data: await fetchCursor(outBinds.P_CURSOR),
}; };
} catch (error) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
@ -205,23 +209,23 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.GetSPLogins( Userlogin_pkg.GetSPLogins(
:p_spid , :p_cursor :P_SPID , :P_CURSOR
); );
END;`, END;`,
{ {
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER }, P_SPID: { val: body.P_SPID, 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 } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
@ -238,29 +242,29 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.CreateSPLogins( 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;`, END;`,
{ {
p_spid: { 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_NVARCHAR }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
p_domain: { val: body.p_domain, 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_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
p_lookupCode: { val: body.p_lookupCode, 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_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
P_EnablePasswordPolicy: { val: body.P_EnablePasswordPolicy, 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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
@ -280,23 +284,23 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.GetClientloginsBySPID( Userlogin_pkg.GetClientloginsBySPID(
:p_spid , :p_cursor :P_SPID , :P_CURSOR
); );
END;`, END;`,
{ {
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER }, P_SPID: { val: body.P_SPID, 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 } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
@ -315,24 +319,24 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.GetClientloginsByClientID( Userlogin_pkg.GetClientloginsByClientID(
:p_spid, :p_clientid , :p_cursor :P_SPID, :p_clientid , :P_CURSOR
); );
END;`, 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_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 } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
@ -349,34 +353,33 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
Userlogin_pkg.CreateClientLogins( 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;`, END;`,
{ {
p_spid: { 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_NVARCHAR }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
p_clientcontactid: { val: body.p_clientcontactid, type: oracledb.DB_TYPE_NUMBER }, P_CLIENTCONTACTID: { val: body.P_CLIENTCONTACTID, type: oracledb.DB_TYPE_NUMBER },
p_password: { val: body.p_password, 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_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
); );
const outBinds = result.outBinds; 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.'); this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database."); 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) { } catch (error) {
handleError(error, UserMaintenanceService.name) handleError(error, UserMaintenanceService.name)
} finally { } finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name) await closeOracleDbConnection(connection, UserMaintenanceService.name)
} }
} }
} }