Compare commits

...

10 Commits

Author SHA1 Message Date
Kallesh B S
da4a75f930 new API in carnet-application and some modification 2025-06-05 16:15:01 +05:30
Kallesh B S
a400b6842d added middleware 2025-06-05 11:40:15 +05:30
Kallesh B S
2b8da1bafa optimized dto folders 2025-06-04 17:20:45 +05:30
Kallesh B S
708b731854 validate email API 2025-06-03 10:43:40 +05:30
Kallesh B S
fd80c8213c inprogress uppercase 2025-06-02 16:04:51 +05:30
Kallesh B S
14adadcf98 Merge branch 'dev-modularized' into dev-mod-merge-test 2025-05-26 17:28:59 +05:30
Kallesh B S
39a4ebba5f inprogress 2025-05-26 17:27:36 +05:30
Kallesh B S
92b6401123 added processingcenter pkg api in carnet application module 2025-05-26 14:39:32 +05:30
Kallesh B S
0f54934bb4 carnet application api added 2025-05-23 17:32:44 +05:30
Kallesh B S
e0e2b540cb 22-05-2025 added remaining user-maintenance api with oracle methed optimized with util and dto 2025-05-22 17:25:38 +05:30
84 changed files with 8143 additions and 6193 deletions

View File

@ -1,4 +1,4 @@
GET http://localhost:3000/mssql/GetParamValues?P_PARAMTYPE=000&P_SPID=asdf GET http://localhost:3000/user-maintenance/GetSPUserDetails?P_USERID=a@s.com
### ###

View File

@ -1,48 +0,0 @@
import { DataSourceOptions } from 'typeorm';
export const OracleConfig: any = {
user: 'Carnetsys',
password: 'Carnet1234',
connectString: '172.31.18.76/xe',
// user: 'C##carnetsys',
// password: 'root',
// connectString: '192.168.1.96/xe',
};
export const MssqlConfig: any = {
// type: 'mssql',
// server: 'localhost',
// user: 'mssql1433',
// password: 'root',
// database: 'CarnetDB',
server: '172.31.18.76',
port: 1433,
user: 'Carnetsys',
password: 'Carnet1234',
database: 'CarnetDB',
// entities: [__dirname + '/**/*.entity{.ts,.js}'],
// synchronize: true,
options: {
enableArithAbort: true,
trustServerCertificate: true,
encrypt:true
},
};
export const MysqlConfig: DataSourceOptions = {
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: 'root',
database: 'demo',
// entities: [__dirname + '/**/*.entity{.ts,.js}'],
synchronize: true,
};

31
package-lock.json generated
View File

@ -10,6 +10,7 @@
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"@nestjs/common": "^11.0.1", "@nestjs/common": "^11.0.1",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.0.1", "@nestjs/core": "^11.0.1",
"@nestjs/platform-express": "^11.0.1", "@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.0.6", "@nestjs/swagger": "^11.0.6",
@ -2613,6 +2614,21 @@
} }
} }
}, },
"node_modules/@nestjs/config": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/@nestjs/config/-/config-4.0.2.tgz",
"integrity": "sha512-McMW6EXtpc8+CwTUwFdg6h7dYcBUpH5iUILCclAsa+MbCEvC9ZKu4dCHRlJqALuhjLw97pbQu62l4+wRwGeZqA==",
"license": "MIT",
"dependencies": {
"dotenv": "16.4.7",
"dotenv-expand": "12.0.1",
"lodash": "4.17.21"
},
"peerDependencies": {
"@nestjs/common": "^10.0.0 || ^11.0.0",
"rxjs": "^7.1.0"
}
},
"node_modules/@nestjs/core": { "node_modules/@nestjs/core": {
"version": "11.0.10", "version": "11.0.10",
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.0.10.tgz", "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.0.10.tgz",
@ -5947,6 +5963,21 @@
"url": "https://dotenvx.com" "url": "https://dotenvx.com"
} }
}, },
"node_modules/dotenv-expand": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-12.0.1.tgz",
"integrity": "sha512-LaKRbou8gt0RNID/9RoI+J2rvXsBRPMV7p+ElHlPhcSARbCPDYcYG2s1TIzAfWv4YSgyY5taidWzzs31lNV3yQ==",
"license": "BSD-2-Clause",
"dependencies": {
"dotenv": "^16.4.5"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://dotenvx.com"
}
},
"node_modules/dunder-proto": { "node_modules/dunder-proto": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",

View File

@ -21,6 +21,7 @@
}, },
"dependencies": { "dependencies": {
"@nestjs/common": "^11.0.1", "@nestjs/common": "^11.0.1",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.0.1", "@nestjs/core": "^11.0.1",
"@nestjs/platform-express": "^11.0.1", "@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.0.6", "@nestjs/swagger": "^11.0.6",

View File

@ -4,9 +4,14 @@ import { OracleModule } from './oracle/oracle.module';
import { AuthModule } from './auth/auth.module'; import { AuthModule } from './auth/auth.module';
import { MssqlModule } from './mssql/mssql.module'; import { MssqlModule } from './mssql/mssql.module';
import { OriginCheckMiddleware } from './middleware/OriginCheck.middleware'; import { OriginCheckMiddleware } from './middleware/OriginCheck.middleware';
import { ReqBodyKeysToUppercaseMiddleware } from './middleware/reqBodyKeysToUppercase.middleware';
import { ConfigModule } from '@nestjs/config';
@Module({ @Module({
imports: [MssqlModule, AuthModule, DbModule, OracleModule], imports: [
ConfigModule.forRoot({ isGlobal: true }),
AuthModule, DbModule, OracleModule
],
controllers: [], controllers: [],
providers: [], providers: [],
}) })
@ -15,5 +20,18 @@ export class AppModule {
consumer consumer
.apply(OriginCheckMiddleware) .apply(OriginCheckMiddleware)
.forRoutes('*'); // Apply to all routes .forRoutes('*'); // Apply to all routes
consumer
.apply(ReqBodyKeysToUppercaseMiddleware)
.forRoutes('*'); // Apply to all routes
// .forRoutes('users'); // Applies to all methods on /users
// .forRoutes(UsersController); // Applies to all routes in this controller
// .forRoutes(
// { path: 'users', method: RequestMethod.GET },
// { path: 'auth/login', method: RequestMethod.POST },
// );
} }
} }

20
src/db/db.config.ts Normal file
View File

@ -0,0 +1,20 @@
import { ConfigService } from '@nestjs/config';
export const getOracleConfig = (configService: ConfigService) => ({
user: configService.get<string>('ORACLE_USER'),
password: configService.get<string>('ORACLE_PASSWORD'),
connectString: configService.get<string>('ORACLE_CONNECT_STRING'),
});
export const getMssqlConfig = (configService: ConfigService) => ({
server: configService.get<string>('MSSQL_SERVER'),
port: configService.get<string>('MSSQL_PORT'),
user: configService.get<string>('MSSQL_USER'),
password: configService.get<string>('MSSQL_PASSWORD'),
database: configService.get<string>('MSSQL_DATABASE'),
options: {
enableArithAbort: true,
trustServerCertificate: true,
encrypt: true
},
});

View File

@ -1,8 +1,10 @@
import { MssqlConfig, OracleConfig } from 'ormconfig'; // import { MssqlConfig, OracleConfig } from 'ormconfig';
import { createPool, Pool, Connection as cob } from 'oracledb'; import { createPool, Pool, Connection as cob } from 'oracledb';
import { Connection, ConnectionPool } from 'mssql'; import { Connection, ConnectionPool } from 'mssql';
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { ConfigService } from '@nestjs/config';
import { getMssqlConfig, getOracleConfig } from './db.config';
// @Injectable() // @Injectable()
// export class OracleDBService { // export class OracleDBService {
@ -30,77 +32,76 @@ import { InternalServerException } from 'src/exceptions/internalServerError.exce
@Injectable() @Injectable()
export class OracleDBService { export class OracleDBService {
private pool: Pool | null = null; private pool: Pool | null = null;
private readonly logger = new Logger(OracleDBService.name); private readonly logger = new Logger(OracleDBService.name);
constructor() { constructor(private readonly configService: ConfigService) {
this.initializePool().catch(err => { this.initializePool().catch(err => {
Logger.error('Error initializing Oracle DB pool', err); this.logger.error('Error initializing Oracle DB pool', err);
// You might want to rethrow or handle accordingly depending on app behavior
throw new InternalServerException(); throw new InternalServerException();
}); });
} }
private async initializePool(): Promise<void> { private async initializePool(): Promise<void> {
try { try {
const config = getOracleConfig(this.configService);
this.pool = await createPool({ this.pool = await createPool({
...OracleConfig, ...config,
poolMin: 1, poolMin: 1,
poolMax: 10, poolMax: 10,
poolIncrement: 1, poolIncrement: 1,
}); });
Logger.log('Oracle connection pool created successfully');
} catch (error) {
Logger.error('Failed to create Oracle DB pool:', error);
throw error; // Optional: rethrow to allow external handling
}
}
async getConnection(): Promise<cob> { this.logger.log('Oracle connection pool created successfully');
if (!this.pool) {
Logger.error('Attempted to get a connection before pool was initialized');
throw new InternalServerException('Database connection pool not initialized');
}
try {
const connection = await this.pool.getConnection();
return connection;
} catch (error) { } catch (error) {
Logger.error('Failed to get Oracle DB connection:', error); this.logger.error('Failed to create Oracle DB pool:', error);
throw error;
}
}
async getConnection(): Promise<Connection> {
if (!this.pool) {
this.logger.error('Attempted to get a connection before pool was initialized');
throw new InternalServerException('Database connection pool not initialized');
}
try {
return await this.pool.getConnection();
} catch (error) {
this.logger.error('Failed to get Oracle DB connection:', error);
throw error; throw error;
} }
} }
// Optionally add a close method to gracefully shut down the pool
async closePool(): Promise<void> { async closePool(): Promise<void> {
if (this.pool) { if (this.pool) {
try { try {
await this.pool.close(10); // 10-second timeout await this.pool.close(10);
Logger.log('Oracle DB pool closed successfully'); this.logger.log('Oracle DB pool closed successfully');
} catch (error) { } catch (error) {
Logger.error('Error closing Oracle DB pool:', error); this.logger.error('Error closing Oracle DB pool:', error);
throw new InternalServerException() throw new InternalServerException();
} }
} }
} }
} }
@Injectable() @Injectable()
export class MssqlDBService { export class MssqlDBService {
private pool: ConnectionPool; private pool: ConnectionPool;
private poolConnected: boolean = false; private poolConnected = false;
private readonly config = { constructor(private readonly configService: ConfigService) {
...MssqlConfig, const config: any = getMssqlConfig(configService);
pool: { this.pool = new ConnectionPool({
max: 10, ...config,
min: 0, pool: {
idleTimeoutMillis: 30000, max: 10,
}, min: 0,
}; idleTimeoutMillis: 30000,
},
constructor() { });
this.pool = new ConnectionPool(this.config);
} }
async getConnection(): Promise<ConnectionPool> { async getConnection(): Promise<ConnectionPool> {
@ -122,3 +123,4 @@ export class MssqlDBService {
} }
} }
} }

View File

@ -0,0 +1,294 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import {
IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString,
Length, Matches, Max, MaxLength, Min, ValidateNested
} from "class-validator";
export enum YON {
YES = "Y",
NO = "N",
}
export class CARNETSTATUS_DTO {
@ApiProperty({ required: true })
@Length(0, 20, {
message: 'Property P_CARNETSTATUS must be between 0 to 20 characters',
})
@IsString()
@IsDefined({ message: 'Property P_CARNETSTATUS is required' })
P_CARNETSTATUS: string;
}
export class HEADERID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property P_HEADERID must not exceed 999999999',
})
@Min(0, { message: 'Property P_HEADERID must be at least 0 or more' })
@IsInt({ message: 'Property P_HEADERID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_HEADERID must be a number' })
@IsDefined({ message: 'Property P_HEADERID is required' })
P_HEADERID: number;
}
export class APPLICATIONNAME_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_APPLICATIONNAME must be a string' })
@IsDefined({ message: 'Property P_APPLICATIONNAME is required' })
P_APPLICATIONNAME: string;
}
export class ORDERTYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ORDERTYPE must be a string' })
@IsDefined({ message: 'Property P_ORDERTYPE is required' })
P_ORDERTYPE: string;
}
export class COMMERCIAL_SAMPLE_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_COMMERCIALSAMPLEFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_COMMERCIALSAMPLEFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_COMMERCIALSAMPLEFLAG: YON;
}
export class PROF_EQUIPMENT_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_PROFEQUIMENTFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_PROFEQUIMENTFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_PROFEQUIPMENTFLAG: YON;
}
export class EXIBITIONS_FAIR_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_EXIBITIONSFAIRFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_EXIBITIONSFAIRFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_EXHIBITIONSFAIRFLAG: YON;
}
export class AUTO_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_AUTOFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_AUTOFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_AUTOFLAG: YON;
}
export class HORSE_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_HORSEFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_HORSEFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_HORSEFLAG: YON;
}
export class AUTHREP_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_AUTHREP must be a string' })
@IsDefined({ message: 'Property P_AUTHREP is required' })
P_AUTHREP: string;
}
export class GLTABLE_ROW_DTO {
@ApiProperty({ required: true })
@Max(99999, { message: 'Property ITEMNO must not exceed 99999' })
@Min(0, { message: 'Property ITEMNO must be at least 0 or more' })
@IsInt({ message: 'Property ITEMNO allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property ITEMNO must be a number' })
@IsDefined({ message: 'Property ITEMNO is required' })
ITEMNO: number;
@ApiProperty({ required: true })
@MaxLength(200, { message: 'Property ITEMDESCRIPTION must not exceed 200 characters' })
@IsString({ message: 'Property ITEMDESCRIPTION must be a string' })
@IsDefined({ message: 'Property ITEMDESCRIPTION is required' })
ITEMDESCRIPTION: string;
@ApiProperty({ required: true })
@Max(999999999.99, { message: 'Property ITEMVALUE must not exceed 999999999.99' })
@Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' })
@Transform(({ value }) => Number(value))
@IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' })
@IsDefined({ message: 'Property ITEMVALUE is required' })
ITEMVALUE: number;
@ApiProperty({ required: true })
@Max(99999, { message: 'Property NOOFPIECES must not exceed 99999' })
@Min(0, { message: 'Property NOOFPIECES must be at least 0 or more' })
@IsInt({ message: 'Property NOOFPIECES allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property NOOFPIECES must be a number' })
@IsDefined({ message: 'Property NOOFPIECES is required' })
NOOFPIECES: number;
@ApiProperty({ required: true })
@Max(99999.9999, { message: 'Property ITEMVALUE must not exceed 999999999.99' })
@Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' })
@Transform(({ value }) => Number(value))
@IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' })
@IsDefined({ message: 'Property ITEMVALUE is required' })
ITEMWEIGHT: number;
@ApiProperty({ required: true })
@MaxLength(10, { message: 'Property ITEMWEIGHTUOM must not exceed 10 characters' })
@IsString({ message: 'Property ITEMWEIGHTUOM must be a string' })
@IsDefined({ message: 'Property ITEMWEIGHTUOM is required' })
ITEMWEIGHTUOM: string;
@ApiProperty({ required: true })
@MaxLength(2, { message: 'Property GOODSORIGINCOUNTRY must not exceed 2 characters' })
@IsString({ message: 'Property GOODSORIGINCOUNTRY must be a string' })
@IsDefined({ message: 'Property GOODSORIGINCOUNTRY is required' })
GOODSORIGINCOUNTRY: string;
}
export class GLTABLE_DTO {
@ApiProperty({ required: true, type: () => [GLTABLE_ROW_DTO] })
@Type(() => GLTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({ message: 'Property P_GLTABLE allows only array type' })
@IsDefined({ message: 'Property P_GLTABLE is required' })
P_GLTABLE: GLTABLE_ROW_DTO[];
}
export class USSETS_DTO {
@ApiProperty({ required: true })
// @Max(99999, { message: 'Property P_USSETS must not exceed 99999' })
@Min(0, { message: 'Property P_USSETS must be at least 0 or more' })
@IsInt({ message: 'Property P_USSETS allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_USSETS must be a number' })
@IsDefined({ message: 'Property P_USSETS is required' })
P_USSETS: number;
}
export enum VOT {
V = "V",
T = "T",
}
export class COUNTRYTABLE_ROW_DTO {
@ApiProperty({ required: true, enum: VOT })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(VOT, { message: 'P_VISISTTRANSITIND must be either "V" or "T"' })
@Length(1, 1, { message: 'P_VISISTTRANSITIND must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_VISISTTRANSITIND: VOT;
@ApiProperty({ required: true })
@MaxLength(2, { message: 'Property COUNTRYCODE must not exceed 2 characters' })
@IsString({ message: 'Property COUNTRYCODE must be a string' })
@IsDefined({ message: 'Property COUNTRYCODE is required' })
COUNTRYCODE: string;
@ApiProperty({ required: true })
@Max(999, { message: 'Property NOOFTIMESENTLEAVE must not exceed 999' })
@Min(0, { message: 'Property NOOFTIMESENTLEAVE must be at least 0 or more' })
@IsInt({ message: 'Property NOOFTIMESENTLEAVE allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property NOOFTIMESENTLEAVE must be a number' })
@IsDefined({ message: 'Property NOOFTIMESENTLEAVE is required' })
NOOFTIMESENTLEAVE: number;
}
export class COUNTRYTABLE_DTO {
@ApiProperty({ required: true, type: () => [COUNTRYTABLE_ROW_DTO] })
@Type(() => COUNTRYTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({ message: 'Property P_COUNTRYTABLE allows only array type' })
@IsDefined({ message: 'Property P_COUNTRYTABLE is required' })
P_COUNTRYTABLE: COUNTRYTABLE_ROW_DTO[];
}
export class SHIPTOTYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_SHIPTOTYPE must be a string' })
@IsDefined({ message: 'Property P_SHIPTOTYPE is required' })
P_SHIPTOTYPE: string;
}
export class SHIPADDRID_DTO {
@ApiProperty({ required: true })
// @Max(99999, { message: 'Property P_USSETS must not exceed 99999' })
@Min(0, { message: 'Property P_SHIPADDRID must be at least 0 or more' })
@IsInt({ message: 'Property P_SHIPADDRID allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SHIPADDRID must be a number' })
@IsDefined({ message: 'Property P_SHIPADDRID is required' })
P_SHIPADDRID: number;
}
export class FORMOFSECURITY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_FORMOFSECURITY must be a string' })
@IsDefined({ message: 'Property P_FORMOFSECURITY is required' })
P_FORMOFSECURITY: string;
}
export class INSPROTECTION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_INSPROTECTION must be a string' })
@IsDefined({ message: 'Property P_INSPROTECTION is required' })
P_INSPROTECTION: string;
}
export class LDIPROTECTION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_LDIPROTECTION must be a string' })
@IsDefined({ message: 'Property P_LDIPROTECTION is required' })
P_LDIPROTECTION: string;
}
export class DELIVERYTYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_DELIVERYTYPE must be a string' })
@IsDefined({ message: 'Property P_DELIVERYTYPE is required' })
P_DELIVERYTYPE: string;
}
export class DELIVERYMETHOD_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_DELIVERYTYPE must be a string' })
@IsDefined({ message: 'Property P_DELIVERYTYPE is required' })
P_DELIVERYMETHOD: string;
}
export class PAYMENTMETHOD_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_PAYMENTMETHOD must be a string' })
@IsDefined({ message: 'Property P_PAYMENTMETHOD is required' })
P_PAYMENTMETHOD: string;
}
export class CUSTCOURIERNO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_CUSTCOURIERNO must be a string' })
@IsDefined({ message: 'Property P_CUSTCOURIERNO is required' })
P_CUSTCOURIERNO: string;
}
export class REFNO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_REFNO must be a string' })
@IsDefined({ message: 'Property P_REFNO is required' })
P_REFNO: string;
}

View File

@ -0,0 +1,84 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import {
APPLICATIONNAME_DTO, AUTHREP_DTO, AUTO_FLAG_DTO, COMMERCIAL_SAMPLE_FLAG_DTO,
COUNTRYTABLE_DTO, CUSTCOURIERNO_DTO, DELIVERYMETHOD_DTO, DELIVERYTYPE_DTO,
EXIBITIONS_FAIR_FLAG_DTO, FORMOFSECURITY_DTO, GLTABLE_DTO, HEADERID_DTO,
HORSE_FLAG_DTO, INSPROTECTION_DTO, LDIPROTECTION_DTO, ORDERTYPE_DTO, PAYMENTMETHOD_DTO,
PROF_EQUIPMENT_FLAG_DTO, REFNO_DTO, SHIPADDRID_DTO, SHIPTOTYPE_DTO, USSETS_DTO
} from "./carnet-application-property.dto";
import { NOTES_DTO, SPID_DTO, USERID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
import { CLIENTID_DTO } from "../manage-clients/manage-clients-property.dto";
import { HOLDERID_DTO, LOCATIONID_DTO } from "../manage-holders/manage-holders-property.dto";
export class SaveCarnetApplicationDTO extends IntersectionType(
PartialType(SPID_DTO),
PartialType(CLIENTID_DTO),
PartialType(LOCATIONID_DTO),
PartialType(USERID_DTO),
PartialType(HEADERID_DTO),
(APPLICATIONNAME_DTO),
PartialType(HOLDERID_DTO),
PartialType(COMMERCIAL_SAMPLE_FLAG_DTO),
PartialType(PROF_EQUIPMENT_FLAG_DTO),
PartialType(EXIBITIONS_FAIR_FLAG_DTO),
PartialType(AUTO_FLAG_DTO),
PartialType(HORSE_FLAG_DTO),
PartialType(AUTHREP_DTO),
PartialType(GLTABLE_DTO),
PartialType(USSETS_DTO),
PartialType(COUNTRYTABLE_DTO),
PartialType(SHIPTOTYPE_DTO),
PartialType(SHIPADDRID_DTO),
PartialType(FORMOFSECURITY_DTO),
PartialType(INSPROTECTION_DTO),
PartialType(LDIPROTECTION_DTO),
PartialType(DELIVERYTYPE_DTO),
PartialType(DELIVERYMETHOD_DTO),
PartialType(PAYMENTMETHOD_DTO),
PartialType(CUSTCOURIERNO_DTO),
PartialType(REFNO_DTO),
PartialType(NOTES_DTO)
) { }
export class TransmitApplicationtoProcessDTO extends IntersectionType(
SPID_DTO, USERID_DTO, HEADERID_DTO
) { }
// processing [ PROCESSINGCENTER_PKG ]
export class CarnetProcessingCenterDTO extends (IntersectionType(USERID_DTO, HEADERID_DTO)) { }
export class CreateApplicationDTO extends IntersectionType(
SPID_DTO, CLIENTID_DTO, LOCATIONID_DTO, USERID_DTO, APPLICATIONNAME_DTO,
ORDERTYPE_DTO
) { }
export class CA_UpdateHolderDTO extends IntersectionType(
HEADERID_DTO, HOLDERID_DTO
) { }
export class UpdateExpGoodsAuthRepDTO extends IntersectionType(
HEADERID_DTO, COMMERCIAL_SAMPLE_FLAG_DTO, PROF_EQUIPMENT_FLAG_DTO,
EXIBITIONS_FAIR_FLAG_DTO, AUTO_FLAG_DTO, HORSE_FLAG_DTO,
AUTHREP_DTO
) { }
export class AddGenerallistItemsDTO extends IntersectionType(
HEADERID_DTO, GLTABLE_DTO, USERID_DTO
) { }
export class AddCountriesDTO extends IntersectionType(
HEADERID_DTO, USSETS_DTO, COUNTRYTABLE_DTO, USERID_DTO
) { }
export class UpdateShippingDetailsDTO extends IntersectionType(
HEADERID_DTO, SHIPTOTYPE_DTO, SHIPADDRID_DTO, FORMOFSECURITY_DTO,
INSPROTECTION_DTO, LDIPROTECTION_DTO, DELIVERYTYPE_DTO, DELIVERYMETHOD_DTO,
PAYMENTMETHOD_DTO, CUSTCOURIERNO_DTO, REFNO_DTO, NOTES_DTO, USERID_DTO
) { }

View File

@ -0,0 +1,12 @@
import { IntersectionType } from "@nestjs/swagger";
import { SPID_DTO, USERID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
import { CARNETSTATUS_DTO } from "../carnet-application/carnet-application-property.dto";
// homepage
export class GetCarnetDetailsbyCarnetStatusDTO extends IntersectionType(
SPID_DTO,
USERID_DTO,
CARNETSTATUS_DTO
) { }

View File

@ -0,0 +1,133 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator";
import {
ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, STATE_DTO, ZIP_DTO
} from "../uscib-managed-sp/sp/sp-property.dto";
export class CLIENTID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property p_clientid must not exceed 999999999',
})
@Min(0, { message: 'Property p_clientid must be at least 0 or more' })
@IsInt({ message: 'Property p_clientid allows only whole numbers' })
@IsNumber({}, { message: 'Property p_clientid must be a number' })
@IsDefined({ message: 'Property p_clientid is required' })
P_CLIENTID: number;
}
export class CLIENT_CONTACTID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property P_CLIENTCONTACTID must not exceed 999999999',
})
@Min(0, { message: 'Property P_CLIENTCONTACTID must be at least 0 or more' })
@IsInt({ message: 'Property P_CLIENTCONTACTID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_CLIENTCONTACTID must be a number' })
@IsDefined({ message: 'Property P_CLIENTCONTACTID is required' })
P_CLIENTCONTACTID: number;
}
export class NAMEOF_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property Nameof must be between 0 to 50 characters',
})
@IsString({ message: 'Property Nameof must be a string' })
@IsDefined({ message: 'Property Nameof is required' })
P_NAMEOF: string;
}
export class CLIENTNAME_DTO {
@ApiProperty({ required: true })
// @Max(999999999, { message: "Property P_CLIENTNAME must not exceed 999999999" })
// @Min(0, { message: "Property P_CLIENTNAME must be at least 0 or more" })
// @IsInt({ message: "Property P_CLIENTNAME allows only whole numbers" })
// @IsNumber({}, { message: "Property P_CLIENTNAME must be a number" })
// @IsDefined({ message: "Property P_CLIENTNAME is required" })
@Length(0, 50, {
message: 'Property P_CLIENTNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_CLIENTNAME must be a string' })
@IsDefined({ message: 'Property P_CLIENTNAME is required' })
P_CLIENTNAME: string;
}
export class REVENUELOCATION_DTO {
@ApiProperty({ required: true })
@Length(0, 2, {
message: 'Property P_REVENUELOCATION must be between 0 to 2 characters',
})
@IsString({ message: 'Property P_REVENUELOCATION must be a string' })
@IsDefined({ message: 'Property P_REVENUELOCATION is required' })
P_REVENUELOCATION: string;
}
export class PREPARERNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_PREPARERNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_PREPARERNAME must be a string' })
@IsDefined({ message: 'Property P_PREPARERNAME is required' })
P_PREPARERNAME: string;
}
export class STATUS_DTO {
@ApiProperty({ required: true })
@Length(0, 10, {
message: 'Property P_STATUS must be between 0 to 10 characters',
})
@IsString({ message: 'Property P_STATUS must be a string' })
@IsDefined({ message: 'Property P_STATUS is required' })
P_STATUS: string;
}
export class CLIENTLOCADDRESSTABLE_ROW_DTO extends IntersectionType(
NAMEOF_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO
) { }
export class CLIENTLOCADDRESSTABLE_DTO {
@ApiProperty({ required: true, type: () => [CLIENTLOCADDRESSTABLE_ROW_DTO] })
@Type(() => CLIENTLOCADDRESSTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({
message: 'Property P_CLIENTLOCADDRESSTABLE allows only array type',
})
@IsDefined({ message: 'Property P_CLIENTLOCADDRESSTABLE is required' })
P_CLIENTLOCADDRESSTABLE: CLIENTLOCADDRESSTABLE_ROW_DTO[];
}
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;
}
export class LOCATIONNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_LOCATIONNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_LOCATIONNAME must be a string' })
@IsDefined({ message: 'Property P_LOCATIONNAME is required' })
P_LOCATIONNAME: string;
}

View File

@ -0,0 +1,109 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import { CONTACTSTABLE_DTO } from "../manage-holders/manage-holders-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, TITLE_DTO
} from "../uscib-managed-sp/sp-contacts/sp-contacts-property.dto";
import {
CLIENT_CONTACTID_DTO, CLIENTID_DTO, CLIENTLOCADDRESSTABLE_DTO, CLIENTLOCATIONID_DTO,
CLIENTNAME_DTO, LOCATIONNAME_DTO, NAMEOF_DTO, PREPARERNAME_DTO, REVENUELOCATION_DTO, STATUS_DTO
} from "./manage-clients-property.dto";
import {
ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, ISSUING_REGION_DTO, LOOKUP_CODE_DTO,
NAME_DTO, SPID_DTO, STATE_DTO, USERID_DTO, ZIP_DTO
} from "../uscib-managed-sp/sp/sp-property.dto";
export class CreateClientDataDTO extends IntersectionType(
SPID_DTO,
CLIENTNAME_DTO,
LOOKUP_CODE_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
PartialType(ZIP_DTO),
PartialType(COUNTRY_DTO),
ISSUING_REGION_DTO,
REVENUELOCATION_DTO,
USERID_DTO
) { }
export class UpdateClientDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO,
PREPARERNAME_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
REVENUELOCATION_DTO,
USERID_DTO
) { }
export class UpdateClientContactsDTO extends IntersectionType(
SPID_DTO,
CLIENT_CONTACTID_DTO,
FIRSTNAME_DTO,
LASTNAME_DTO,
PartialType(MIDDLE_INITIAL_DTO),
PartialType(TITLE_DTO),
PHONE_NO_DTO,
FAX_NO_DTO,
PartialType(MOBILE_NO_DTO),
EMAIL_ADDRESS_DTO,
USERID_DTO
) { }
export class GetPreparersDTO extends IntersectionType(
SPID_DTO,
PartialType(NAME_DTO),
PartialType(LOOKUP_CODE_DTO),
PartialType(CITY_DTO),
PartialType(STATE_DTO),
STATUS_DTO
) { }
export class UpdateClientLocationsDTO extends IntersectionType(
SPID_DTO,
CLIENTLOCATIONID_DTO,
LOCATIONNAME_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
PartialType(CITY_DTO),
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
USERID_DTO
) { }
export class CreateClientContactsDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO,
CONTACTSTABLE_DTO,
DEFAULT_CONTACT_FLAG_DTO,
USERID_DTO
) { }
export class CreateClientLocationsDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO,
CLIENTLOCADDRESSTABLE_DTO,
USERID_DTO
) { }
export class GetPreparerByClientidContactsByClientidLocByClientidDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO
) { }

View File

@ -0,0 +1,117 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsNumber, IsString } from "class-validator";
export class EFFDATE_DTO {
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
}
export class FEES_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_FEES: number;
}
export class SPCLCOMMODITY_DTO {
@ApiProperty({ required: true })
@IsString()
P_SPCLCOMMODITY: string;
}
export class SPCLCOUNTRY_DTO {
@ApiProperty({ required: true })
@IsString()
P_SPCLCOUNTRY: string;
}
export class RATE_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
}
export class STARTSETS_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_STARTSETS: number;
}
export class ENDSETS_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_ENDSETS: number;
}
export class CUSTOMERTYPE_DTO {
@ApiProperty({ required: true })
@IsString()
P_CUSTOMERTYPE: string;
}
export class STARTTIME_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_STARTTIME: number;
}
export class ENDTIME_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_ENDTIME: number;
}
export class TIMEZONE_DTO {
@ApiProperty({ required: true })
@IsString()
P_TIMEZONE: string;
}
export class COMMRATE_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_COMMRATE: number;
}
export class BASICFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_BASICFEESETUPID: number;
}
export class BONDRATESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_BONDRATESETUPID: number;
}
export class CARGORATESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_CARGORATESETUPID: number;
}
export class CFFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_CFFEESETUPID: number;
}
export class CSFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_CSFEESETUPID: number;
}
export class EFFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_EFFEESETUPID: number;
}
export class FEECOMMID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_FEECOMMID: number;
}

View File

@ -0,0 +1,144 @@
import { IntersectionType } from "@nestjs/swagger";
import { ACTIVE_INACTIVE_STATUS_DTO, SPID_DTO, USERID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
import { HOLDERTYPE_DTO, USCIBMEMBERFLAG_DTO } from "../manage-holders/manage-holders-property.dto";
import {
BASICFEESETUPID_DTO, BONDRATESETUPID_DTO, CARGORATESETUPID_DTO, CFFEESETUPID_DTO,
COMMRATE_DTO, CSFEESETUPID_DTO, CUSTOMERTYPE_DTO, EFFDATE_DTO, EFFEESETUPID_DTO, ENDSETS_DTO,
ENDTIME_DTO, FEECOMMID_DTO, FEES_DTO, RATE_DTO, SPCLCOMMODITY_DTO, SPCLCOUNTRY_DTO,
STARTSETS_DTO, STARTTIME_DTO, TIMEZONE_DTO
} from "./manage-fee-property.dto";
import { PARAMID_DTO } from "../param-table/param-table-property.dto";
import { CARNET_TYPE_DTO, END_NUMBER_DTO, START_NUMBER_DTO } from "../uscib-managed-sp/carnet-sequence/carnet-sequence-property.dto";
import { DELIVERYTYPE_DTO } from "../carnet-application/carnet-application-property.dto";
export class GetFeeGeneralDTO extends IntersectionType(
SPID_DTO,
ACTIVE_INACTIVE_STATUS_DTO
) { }
export class CreateBasicFeeDTO extends IntersectionType(
SPID_DTO,
START_NUMBER_DTO,
END_NUMBER_DTO,
EFFDATE_DTO,
FEES_DTO,
USERID_DTO
) { }
export class CreateBondRateDTO extends IntersectionType(
SPID_DTO,
HOLDERTYPE_DTO,
USCIBMEMBERFLAG_DTO,
SPCLCOMMODITY_DTO,
SPCLCOUNTRY_DTO,
EFFDATE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateCargoRateDTO extends IntersectionType(
SPID_DTO,
CARNET_TYPE_DTO,
STARTSETS_DTO,
ENDSETS_DTO,
EFFDATE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateCfFeeDTO extends IntersectionType(
SPID_DTO,
STARTSETS_DTO,
ENDSETS_DTO,
EFFDATE_DTO,
CUSTOMERTYPE_DTO,
CARNET_TYPE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateCsFeeDTO extends IntersectionType(
SPID_DTO,
CUSTOMERTYPE_DTO,
CARNET_TYPE_DTO,
EFFDATE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateEfFeeDTO extends IntersectionType(
SPID_DTO,
CUSTOMERTYPE_DTO,
DELIVERYTYPE_DTO,
STARTTIME_DTO,
ENDTIME_DTO,
TIMEZONE_DTO,
EFFDATE_DTO,
FEES_DTO,
USERID_DTO
) { }
export class CreateFeeCommDTO extends IntersectionType(
SPID_DTO,
PARAMID_DTO,
COMMRATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateBasicFeeDTO extends IntersectionType(
BASICFEESETUPID_DTO,
FEES_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateBondRateDTO extends IntersectionType(
BONDRATESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateCargoRateDTO extends IntersectionType(
CARGORATESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateCfFeeDTO extends IntersectionType(
CFFEESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateCsFeeDTO extends IntersectionType(
CSFEESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateEfFeeDTO extends IntersectionType(
EFFEESETUPID_DTO,
FEES_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateFeeCommDTO extends IntersectionType(
FEECOMMID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
// export class UpdateFeeCommBodyDTO {
// @ApiProperty({ type: UpdateFeeCommDTO, required: true }) // Correctly reference UpdateFeeCommDTO
// p_fees_comm: UpdateFeeCommDTO; // No need for @IsObject()
// }

View File

@ -0,0 +1,121 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator";
import { Transform, Type } from "class-transformer";
import {
EMAIL_ADDRESS_DTO, FAX_NO_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO,
MOBILE_NO_DTO, PHONE_NO_DTO, TITLE_DTO
} from "../uscib-managed-sp/sp-contacts/sp-contacts-property.dto";
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;
}
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 LOCATIONID_DTO {
@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' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_locationid must be a number' })
@IsDefined({ message: 'Property p_locationid is required' })
P_LOCATIONID: number;
}
export class HOLDERID_DTO {
@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 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_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 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 "src/dto/property.dto";
import { CLIENTLOCATIONID_DTO } from "src/dto/property.dto";
import {
ADDLNAME_DTO, CONTACTSTABLE_DTO, HOLDERCONTACTID_DTO, HOLDERNAME_DTO, HOLDERNO_DTO,
HOLDERTYPE_DTO, NAMEQUALIFIER_DTO
} from "src/dto/property.dto";
import { GOVAGENCYFLAG_DTO, USCIBMEMBERFLAG_DTO } from "src/dto/property.dto";
import {
ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, EMAIL_DTO, HOLDERID_DTO,
LOCATIONID_DTO, STATE_DTO, USERID_DTO, ZIP_DTO
} from "src/dto/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 "src/dto/property.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,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 "../uscib-managed-sp/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
) { }

37
src/dto/property.dto.ts Normal file
View File

@ -0,0 +1,37 @@
export * from './carnet-application/carnet-application-property.dto' // ind
export * from './uscib-managed-sp/sp/sp-property.dto' // ind
export * from './manage-holders/manage-holders-property.dto' // dep c-a-p (YON)
export * from './user-maintenance/user-maintenance-property.dto' // dep c-a-p (YON)
export * from './uscib-managed-sp/sp-contacts/sp-contacts-property.dto' // ind
export * from './manage-clients/manage-clients-property.dto' // ind
export * from './param-table/param-table-property.dto' // ind
export * from './manage-fee/manage-fee-property.dto' // ind
export * from './uscib-managed-sp/carnet-sequence/carnet-sequence-property.dto' // ind
export * from './uscib-managed-sp/region/region-property.dto' // ind
export * from './manage-clients/manage-clients.dto'
export * from './carnet-application/carnet-application.dto'
// export * from './home-page/home-page-property.dto' // NA
export * from './home-page/home-page.dto'
export * from './manage-fee/manage-fee.dto'
export * from './param-table/param-table.dto'
export * from './uscib-managed-sp/carnet-sequence/carnet-sequence.dto'
export * from './uscib-managed-sp/region/region.dto'
export * from './uscib-managed-sp/sp/sp.dto'
export * from './uscib-managed-sp/sp-contacts/sp-contacts.dto'
export * from './user-maintenance/user-maintenance.dto'
export * from './manage-holders/manage-holders.dto'

View File

@ -0,0 +1,23 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsString, Length, 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,8 @@
import { IntersectionType } from '@nestjs/swagger';
import { CARNET_TYPE_DTO, END_NUMBER_DTO, START_NUMBER_DTO } from './carnet-sequence-property.dto';
import { SPID_DTO } from '../sp/sp-property.dto';
import { REGIONID_DTO } from '../region/region-property.dto';
export class CreateCarnetSequenceDTO extends IntersectionType(
SPID_DTO, REGIONID_DTO, START_NUMBER_DTO, END_NUMBER_DTO, CARNET_TYPE_DTO
) { }

View File

@ -0,0 +1,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

@ -0,0 +1,7 @@
import { IntersectionType } from '@nestjs/swagger';
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 UpdateRegionDto extends IntersectionType(REGIONID_DTO, NAME_DTO) { }

View File

@ -0,0 +1,85 @@
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 "src/dto/carnet-application/carnet-application-property.dto";
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,20 @@
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, TITLE_DTO
} from 'src/dto/property.dto';
import { USER_ID_DTO } from '../../property.dto';
import { SPID_DTO } from '../sp/sp-property.dto';
export class InsertSPContactsDTO extends IntersectionType(
SPID_DTO, DEFAULT_CONTACT_FLAG_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, TITLE_DTO,
PHONE_NO_DTO, MOBILE_NO_DTO, FAX_NO_DTO, EMAIL_ADDRESS_DTO, USER_ID_DTO
) { }
export class UpdateSPContactsDTO extends IntersectionType(
SP_CONTACTID_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, TITLE_DTO, PHONE_NO_DTO,
MOBILE_NO_DTO, FAX_NO_DTO, EMAIL_ADDRESS_DTO, USER_ID_DTO
) { }

View File

@ -0,0 +1,183 @@
// SP
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString,
Length, Matches, Max, MaxLength, Min, ValidateNested } 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;
}
export class USERID_DTO {
@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;
}
export class USER_ID_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_USER_ID must be a string' })
@IsDefined({ message: 'Property P_USER_ID is required' })
P_USER_ID: string;
}
export class EMAIL_DTO {
@ApiProperty({ required: true })
@IsEmail({}, { message: "Invalid P_EMAILADDR property" })
@Length(0, 50, {
message: 'Property P_EMAILADDR must be between 0 to 50 characters',
})
@IsString({ message: 'P_EMAILADDR p_userid must be string' })
@IsDefined({ message: 'P_EMAILADDR p_userid is required' })
P_EMAILADDR: string;
}
export class LOOKUP_CODE_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_LOOKUPCODE: string;
}
export class PASSWORD_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_PASSWORD: string;
}
export class NAME_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_NAME must be a string' })
@IsDefined({ message: 'Property P_NAME is required' })
P_NAME: string;
}
export class ADDRESS1_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ADDRESS1 must be a string' })
@IsDefined({ message: 'Property P_ADDRESS1 is required' })
P_ADDRESS1: string;
}
export class ADDRESS2_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ADDRESS2 must be a string' })
@IsDefined({ message: 'Property P_ADDRESS2 is required' })
P_ADDRESS2: string;
}
export class CITY_DTO {
@ApiProperty({ required: true })
@Length(0, 30, {
message: 'Property P_CITY must be between 0 to 30 characters',
})
@IsString({ message: 'Property P_CITY must be a string' })
@IsDefined({ message: 'Property P_CITY is required' })
P_CITY: string;
}
export class STATE_DTO {
@ApiProperty({ required: true })
@Length(0, 2, {
message: 'Property P_STATE must be between 0 to 2 characters',
})
@IsString({ message: 'Property P_STATE must be a string' })
@IsDefined({ message: 'Property P_STATE is required' })
P_STATE: string;
}
export class COUNTRY_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_COUNTRY must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_COUNTRY must be a string' })
@IsDefined({ message: 'Property P_COUNTRY is required' })
P_COUNTRY: string;
}
export class ZIP_DTO {
@ApiProperty({ required: true })
@Length(0, 10, {
message: 'Property P_ZIP must be between 0 to 10 characters',
})
@IsString({ message: 'Property P_ZIP must be a string' })
@IsDefined({ message: 'Property P_ZIP is required' })
P_ZIP: string;
}
export class ISSUING_REGION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ISSUINGREGION must be a string' })
@IsDefined({ message: 'Property P_ISSUINGREGION is required' })
P_ISSUINGREGION: string;
}
export class REPLACEMENT_REGION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_REPLACEMENTREGION must be a string' })
@IsDefined({ message: 'Property P_REPLACEMENTREGION is required' })
P_REPLACEMENTREGION: string;
}
export class BOND_SURETY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_BONDSURETY must be a string' })
@IsDefined({ message: 'Property P_BONDSURETY is required' })
P_BONDSURETY: string;
}
export class CARGO_POLICY_NO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_CARGOPOLICYNO must be a string' })
@IsDefined({ message: 'Property P_CARGOPOLICYNO is required' })
P_CARGOPOLICYNO: string;
}
export class CARGO_SURETY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_CARGOSURETY must be a string' })
@IsDefined({ message: 'Property P_CARGOSURETY is required' })
P_CARGOSURETY: string;
}
export class NOTES_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_NOTES must be a string' })
P_NOTES: string;
}
export class FILE_ID_DTO {
@ApiProperty({ required: false })
@IsString({ message: 'Property P_FILEIDS must be a string' })
@IsOptional()
P_FILEIDS?: string;
}
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;
}

View File

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

View File

@ -0,0 +1,29 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString,
Length, Matches, Max, MaxLength, Min, ValidateNested } from "class-validator";
import { YON } from "../carnet-application/carnet-application-property.dto";
// user maintenance
export class ENABLE_PASSWORD_POLICY_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_ENABLEPASSWORDPOLICY must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_ENABLEPASSWORDPOLICY must be between 5 and 6 characters' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_ENABLEPASSWORDPOLICY: YON;
}
export class DOMAIN_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_DOMAIN must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_DOMAIN must be a string' })
@IsDefined({ message: 'Property P_DOMAIN is required' })
P_DOMAIN: string;
}

View File

@ -0,0 +1,21 @@
import { IntersectionType } from "@nestjs/swagger";
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 "../uscib-managed-sp/sp/sp-property.dto";
export class SPID_CLIENTID_DTO extends IntersectionType(SPID_DTO, CLIENTID_DTO) { }
export class SPID_EMAIL_DTO extends IntersectionType(SPID_DTO, EMAIL_DTO) { }
export class CreateUSCIBLoginsDTO extends IntersectionType(
USERID_DTO, EMAIL_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO, ENABLE_PASSWORD_POLICY_DTO
) { }
export class CreateClientLoginsDTO extends IntersectionType(
SPID_DTO, USERID_DTO, CLIENT_CONTACTID_DTO, PASSWORD_DTO, ENABLE_PASSWORD_POLICY_DTO
) { }
export class CreateSPLoginsDTO extends IntersectionType(
SPID_DTO, USERID_DTO, DOMAIN_DTO, EMAIL_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO, ENABLE_PASSWORD_POLICY_DTO
) { }

View File

@ -10,7 +10,7 @@ import { BadRequestException } from './exceptions/badRequest.exception';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule, { const app = await NestFactory.create(AppModule, {
logger:['error','warn'], logger: ['error', 'warn'],
cors: { cors: {
// origin: 'https://dev.alphaomegainfosys.com/', // origin: 'https://dev.alphaomegainfosys.com/',
origin: '*', origin: '*',
@ -20,6 +20,7 @@ async function bootstrap() {
}, },
}); });
function extractConstraints(validationErrors: ValidationError[]) { function extractConstraints(validationErrors: ValidationError[]) {
const constraints: { [key: string]: string }[] = []; const constraints: { [key: string]: string }[] = [];
@ -57,7 +58,7 @@ async function bootstrap() {
}) })
.filter(Boolean); .filter(Boolean);
throw new BadRequestException(`Bad Request${newResult[0].message !== 'Bad Request' ? " : "+newResult[0].message : ""}`); throw new BadRequestException(`Bad Request${newResult[0].message !== 'Bad Request' ? " : " + newResult[0].message : ""}`);
}; };
app.useGlobalPipes( app.useGlobalPipes(
@ -82,13 +83,15 @@ async function bootstrap() {
.addServer('http://localhost:3000', 'Development Server 1') .addServer('http://localhost:3000', 'Development Server 1')
.build(); .build();
const options: SwaggerDocumentOptions = { const options: SwaggerDocumentOptions = { autoTagControllers: false };
autoTagControllers: false, const documentFactory = () => SwaggerModule.createDocument(app, config, options);
};
const documentFactory = () =>
SwaggerModule.createDocument(app, config, options);
SwaggerModule.setup('api', app, documentFactory); SwaggerModule.setup('api', app, documentFactory);
app.use('/api-json', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.send(document);
});
await app.listen(process.env.PORT ?? 3000); await app.listen(process.env.PORT ?? 3000);
} }
bootstrap(); bootstrap();

View File

@ -0,0 +1,30 @@
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
@Injectable()
export class ReqBodyKeysToUppercaseMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
if (req.body && typeof req.body === 'object' && !Array.isArray(req.body)) {
console.log('I am here will start operation shortly...');
req.body = this.uppercaseKeys(req.body);
}
next();
}
private uppercaseKeys(obj: Record<string, any>): Record<string, any> {
const newObj: Record<string, any> = {};
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
const upperKey = key.toUpperCase();
const value = obj[key];
newObj[upperKey] =
value !== null && typeof value === 'object' && !Array.isArray(value)
? this.uppercaseKeys(value)
: value;
}
}
return newObj;
}
}

View File

@ -1,7 +1,12 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ManageClientsService } from './manage-clients.service'; import { ManageClientsService } from './manage-clients.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/oracle/manage-clients/manage-clients.dto';
import {
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/manage-clients/manage-clients.dto';
@Controller('mssql') @Controller('mssql')
export class ManageClientsController { export class ManageClientsController {
@ -72,8 +77,4 @@ export class ManageClientsController {
) { ) {
return this.manageClientsService.GetPreparerLocByClientid(body); return this.manageClientsService.GetPreparerLocByClientid(body);
} }
} }

View File

@ -1,8 +1,12 @@
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 { CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/oracle/manage-clients/manage-clients.dto';
import * as mssql from 'mssql'; import * as mssql from 'mssql';
import {
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/manage-clients/manage-clients.dto';
@Injectable() @Injectable()
export class ManageClientsService { export class ManageClientsService {
@ -10,18 +14,18 @@ export class ManageClientsService {
CreateClientData = async (body: CreateClientDataDTO) => { CreateClientData = async (body: CreateClientDataDTO) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_clientname: null, P_CLIENTNAME: 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_revenuelocation: null, P_REVENUELOCATION: null,
p_userid: null, P_USERID: null,
p_contactstable: null, p_contactstable: null,
p_clientlocaddresstable: null, p_clientlocaddresstable: null,
}; };
@ -46,18 +50,18 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientname', mssql.VarChar(50), finalBody.p_clientname); request.input('P_CLIENTNAME', mssql.VarChar(50), finalBody.P_CLIENTNAME);
request.input('p_lookupcode', mssql.VarChar(20), finalBody.p_lookupcode); request.input('P_LOOKUPCODE', mssql.VarChar(20), finalBody.P_LOOKUPCODE);
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_issuingregion', mssql.VarChar(2), finalBody.p_issuingregion); request.input('P_ISSUINGREGION', mssql.VarChar(2), finalBody.P_ISSUINGREGION);
request.input('p_revenuelocation', mssql.VarChar(2), finalBody.p_revenuelocation); request.input('P_REVENUELOCATION', mssql.VarChar(2), finalBody.P_REVENUELOCATION);
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid); request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const contactTable = new mssql.Table('carnetsys.ContactsTable'); const contactTable = new mssql.Table('carnetsys.ContactsTable');
contactTable.create = true; contactTable.create = true;
@ -70,19 +74,6 @@ export class ManageClientsService {
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.forEach((contact) => {
// contactTable.rows.add(
// contact.FirstName,
// contact.LastName,
// contact.MiddleInitial,
// contact.Title,
// contact.EmailAddress,
// contact.PhoneNo,
// contact.MobileNo,
// contact.FaxNo,
// );
// });
request.input('p_contactstable', contactTable); request.input('p_contactstable', contactTable);
const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable'); const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable');
@ -95,18 +86,6 @@ export class ManageClientsService {
clientLocAddressTable.columns.add('Zip', mssql.VarChar(10)); clientLocAddressTable.columns.add('Zip', mssql.VarChar(10));
clientLocAddressTable.columns.add('Country', mssql.VarChar(2)); clientLocAddressTable.columns.add('Country', mssql.VarChar(2));
// finalBody.p_clientlocaddresstable.forEach((contact) => {
// clientLocAddressTable.rows.add(
// contact.Nameof,
// contact.Address1,
// contact.Address2,
// contact.City,
// contact.State,
// contact.Zip,
// contact.Country,
// );
// });
request.input('p_clientlocaddresstable', clientLocAddressTable); request.input('p_clientlocaddresstable', clientLocAddressTable);
const result = await request.execute('carnetsys.CreateClientData'); const result = await request.execute('carnetsys.CreateClientData');
@ -122,8 +101,8 @@ export class ManageClientsService {
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_clientid', mssql.Int, body.p_clientid); request.input('P_CLIENTID', mssql.Int, body.P_CLIENTID);
const result = await request.execute('carnetsys.GetPreparerbyClientID'); const result = await request.execute('carnetsys.GetPreparerbyClientID');
return { data: result.recordset }; return { data: result.recordset };
} catch (error) { } catch (error) {
@ -133,17 +112,17 @@ export class ManageClientsService {
UpdateClient = async (body: UpdateClientDTO) => { UpdateClient = async (body: UpdateClientDTO) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_clientid: null, P_CLIENTID: null,
p_preparername: null, P_PREPARERNAME: 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_revenuelocation: null, P_REVENUELOCATION: null,
p_userid: null, P_USERID: null,
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -167,17 +146,17 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientid', mssql.Int, finalBody.p_clientid); request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
request.input('p_preparername', mssql.VarChar(50), finalBody.p_preparername); request.input('P_PREPARERNAME', mssql.VarChar(50), finalBody.P_PREPARERNAME);
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_revenuelocation', mssql.VarChar(2), finalBody.p_revenuelocation); request.input('P_REVENUELOCATION', mssql.VarChar(2), finalBody.P_REVENUELOCATION);
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid); request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.UpdateClient'); const result = await request.execute('carnetsys.UpdateClient');
@ -190,11 +169,11 @@ export class ManageClientsService {
CreateClientContact = async (body: CreateClientContactsDTO) => { CreateClientContact = async (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));
@ -220,8 +199,8 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientid', mssql.Int, finalBody.p_clientid); request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const contactTable = new mssql.Table('carnetsys.ContactsTable'); const contactTable = new mssql.Table('carnetsys.ContactsTable');
contactTable.create = true; contactTable.create = true;
@ -234,23 +213,23 @@ export class ManageClientsService {
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.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);
request.input('p_defcontactflag', mssql.VarChar(1), finalBody.p_defcontactflag); request.input('P_DEFCONTACTFLAG', mssql.VarChar(1), finalBody.P_DEFCONTACTFLAG);
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid); request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.CreateClientContact'); const result = await request.execute('carnetsys.CreateClientContact');
@ -263,17 +242,17 @@ export class ManageClientsService {
UpdateClientContacts = async (body: UpdateClientContactsDTO) => { UpdateClientContacts = async (body: UpdateClientContactsDTO) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_clientcontactid: null, P_CLIENTCONTACTID: null,
p_firstname: null, P_FIRSTNAME: null,
p_lastname: null, P_LASTNAME: null,
p_middleinitial: null, P_MIDDLEINITIAL: null,
p_title: null, P_TITLE: null,
p_phone: null, P_PHONENO: null,
p_fax: null, P_FAXNO: null,
p_mobileno: null, P_MOBILENO: null,
p_emailaddress: null, P_EMAILADDRESS: null,
p_userid: null, P_USERID: null,
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -296,17 +275,17 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientcontactid', mssql.Int, finalBody.p_clientcontactid); request.input('P_CLIENTCONTACTID', mssql.Int, finalBody.P_CLIENTCONTACTID);
request.input('p_firstname', mssql.VarChar(50), finalBody.p_firstname); request.input('P_FIRSTNAME', mssql.VarChar(50), finalBody.P_FIRSTNAME);
request.input('p_lastname', mssql.VarChar(50), finalBody.p_lastname); request.input('P_LASTNAME', mssql.VarChar(50), finalBody.P_LASTNAME);
request.input('p_middleinitial', mssql.VarChar(3), finalBody.p_middleinitial); request.input('P_MIDDLEINITIAL', mssql.VarChar(3), finalBody.P_MIDDLEINITIAL);
request.input('p_title', mssql.VarChar(50), finalBody.p_title); request.input('P_TITLE', mssql.VarChar(50), finalBody.P_TITLE);
request.input('p_phone', mssql.VarChar(20), finalBody.p_phone); request.input('P_PHONENO', mssql.VarChar(20), finalBody.P_PHONENO);
request.input('p_fax', mssql.VarChar(20), finalBody.p_fax); request.input('P_FAXNO', mssql.VarChar(20), finalBody.P_FAXNO);
request.input('p_mobileno', mssql.VarChar(20), finalBody.p_mobileno); request.input('P_MOBILENO', mssql.VarChar(20), finalBody.P_MOBILENO);
request.input('p_emailaddress', mssql.VarChar(100), finalBody.p_emailaddress); request.input('P_EMAILADDRESS', mssql.VarChar(100), finalBody.P_EMAILADDRESS);
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid); request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.UpdateClientContacts'); const result = await request.execute('carnetsys.UpdateClientContacts');
return { data: result.recordset }; return { data: result.recordset };
@ -319,16 +298,16 @@ export class ManageClientsService {
UpdateClientLocations = async (body: UpdateClientLocationsDTO) => { UpdateClientLocations = async (body: UpdateClientLocationsDTO) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_clientlocationid: null, P_CLIENTLOCATIONID: null,
p_lcoationname: null, P_LOCATIONNAME: 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_userid: null, P_USERID: null,
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -351,16 +330,16 @@ export class ManageClientsService {
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, 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_lcoationname', mssql.VarChar(50), finalBody.p_lcoationname); request.input('P_LOCATIONNAME', mssql.VarChar(50), finalBody.P_LOCATIONNAME);
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(100), finalBody.p_userid); request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.UpdateClientlocations'); const result = await request.execute('carnetsys.UpdateClientlocations');
return { data: result.recordset }; return { data: result.recordset };
@ -373,11 +352,11 @@ export class ManageClientsService {
CreateClientLocation = async (body: CreateClientLocationsDTO) => { CreateClientLocation = async (body: CreateClientLocationsDTO) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_clientid: null, P_CLIENTID: null,
p_clientlocaddresstable: null, p_clientlocaddresstable: 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));
@ -403,8 +382,8 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientid', mssql.Int, finalBody.p_clientid); request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable'); const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable');
@ -417,21 +396,21 @@ export class ManageClientsService {
clientLocAddressTable.columns.add('Zip', mssql.VarChar(10)); clientLocAddressTable.columns.add('Zip', mssql.VarChar(10));
clientLocAddressTable.columns.add('Country', mssql.VarChar(2)); clientLocAddressTable.columns.add('Country', mssql.VarChar(2));
finalBody.p_clientlocaddresstable.forEach((contact) => { finalBody.P_CLIENTLOCADDRESSTABLE.forEach((contact) => {
clientLocAddressTable.rows.add( clientLocAddressTable.rows.add(
contact.Nameof, contact.P_NAMEOF,
contact.Address1, contact.P_ADDRESS1,
contact.Address2, contact.P_ADDRESS2,
contact.City, contact.P_CITY,
contact.State, contact.P_STATE,
contact.Zip, contact.P_ZIP,
contact.Country, contact.P_COUNTRY,
); );
}); });
request.input('p_clientlocaddresstable', clientLocAddressTable); request.input('p_clientlocaddresstable', clientLocAddressTable);
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid); request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.CreateClientLocation'); const result = await request.execute('carnetsys.CreateClientLocation');
return { data: result.recordset }; return { data: result.recordset };
@ -445,12 +424,12 @@ export class ManageClientsService {
GetPreparers = async (body: GetPreparersDTO) => { GetPreparers = async (body: GetPreparersDTO) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_name: null, P_NAME: null,
p_lookupcode: null, P_LOOKUPCODE: null,
p_city: null, P_CITY: null,
p_state: null, P_STATE: null,
p_status: null P_STATUS: null
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -476,12 +455,12 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_name', mssql.VarChar(50), finalBody.p_name); request.input('P_NAME', mssql.VarChar(50), finalBody.P_NAME);
request.input('p_lookupcode', mssql.VarChar(30), finalBody.p_lookupcode); request.input('P_LOOKUPCODE', mssql.VarChar(30), finalBody.P_LOOKUPCODE);
request.input('p_city', mssql.VarChar(20), finalBody.p_city); request.input('P_CITY', mssql.VarChar(20), 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_status', mssql.VarChar(10), finalBody.p_status); request.input('P_STATUS', mssql.VarChar(10), finalBody.P_STATUS);
const result = await request.execute('carnetsys.GetPreparers'); const result = await request.execute('carnetsys.GetPreparers');
return { data: result.recordset }; return { data: result.recordset };
@ -498,12 +477,12 @@ export class ManageClientsService {
) => { ) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_name: null, P_NAME: null,
p_lookupcode: null, P_LOOKUPCODE: null,
p_city: null, P_CITY: null,
p_state: null, P_STATE: null,
p_status: null P_STATUS: null
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -529,8 +508,8 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientid', mssql.Int, finalBody.p_clientid); request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const result = await request.execute('carnetsys.GetPreparerContactsbyClientID'); const result = await request.execute('carnetsys.GetPreparerContactsbyClientID');
return { data: result.recordset }; return { data: result.recordset };
@ -546,12 +525,12 @@ export class ManageClientsService {
body: GetPreparerByClientidContactsByClientidLocByClientidDTO, body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) => { ) => {
const newBody = { const newBody = {
p_spid: null, P_SPID: null,
p_name: null, P_NAME: null,
p_lookupcode: null, P_LOOKUPCODE: null,
p_city: null, P_CITY: null,
p_state: null, P_STATE: null,
p_status: null P_STATUS: null
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -577,8 +556,8 @@ export class ManageClientsService {
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, finalBody.p_spid); request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('p_clientid', mssql.Int, finalBody.p_clientid); request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const result = await request.execute('carnetsys.GetPreparerLocbyClientID'); const result = await request.execute('carnetsys.GetPreparerLocbyClientID');
return { data: result.recordset }; return { data: result.recordset };

View File

@ -1,7 +1,11 @@
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 { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/manage-fee/manage-fee.dto';
@Controller('mssql') @Controller('mssql')
export class ManageFeeController { export class ManageFeeController {

View File

@ -1,10 +1,14 @@
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 { 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 {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/manage-fee/manage-fee.dto';
@Injectable() @Injectable()
export class ManageFeeService { export class ManageFeeService {
@ -42,8 +46,8 @@ export class ManageFeeService {
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_STARTCARNETVALUE', mssql.Int, body.P_STARTCARNETVALUE); request.input('P_STARTCARNETVALUE', mssql.Int, body.P_STARTNUMBER);
request.input('P_ENDCARNETVALUE', mssql.Int, body.P_ENDCARNETVALUE); request.input('P_ENDCARNETVALUE', mssql.Int, body.P_ENDNUMBER);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE); request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_FEES', mssql.Int, body.P_FEES); request.input('P_FEES', mssql.Int, body.P_FEES);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID); request.input('P_USERID', mssql.VarChar(100), body.P_USERID);

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/manage-holders/manage-holders.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/manage-holders/manage-holders.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,
); );
}); });
@ -106,8 +107,8 @@ 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 };
@ -123,23 +124,24 @@ 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 };
@ -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');
@ -183,8 +185,8 @@ 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 };
@ -202,9 +204,9 @@ 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) {
@ -218,9 +220,9 @@ 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 };
@ -235,9 +237,9 @@ 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 };
@ -252,9 +254,9 @@ 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 };

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

@ -1,20 +1,21 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common'; 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, GetCarnetSequenceDTO } from 'src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto'; import { CreateCarnetSequenceDTO } from 'src/dto/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
import { SPID_DTO } from 'src/dto/uscib-managed-sp/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: GetCarnetSequenceDTO) { 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

@ -2,20 +2,21 @@ 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 * as mssql from 'mssql' import * as mssql from 'mssql'
import { CreateCarnetSequenceDTO, GetCarnetSequenceDTO } from 'src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto'; import { CreateCarnetSequenceDTO } from 'src/dto/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@Injectable() @Injectable()
export class CarnetSequenceService { export class CarnetSequenceService {
constructor(private readonly mssqlDBService: MssqlDBService) { } constructor(private readonly mssqlDBService: MssqlDBService) { }
async getCarnetSequence(body: GetCarnetSequenceDTO) { async getCarnetSequence(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.GETCARNETSEQUENCE'); const result = await request.execute('carnetsys.GETCARNETSEQUENCE');
return { data: result.recordset }; return { data: result.recordset };
@ -29,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

@ -1,7 +1,7 @@
import { Body, Controller, Get, Patch, Post } from '@nestjs/common'; import { Body, Controller, Get, Patch, Post } from '@nestjs/common';
import { ApiInternalServerErrorResponse, ApiOkResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiInternalServerErrorResponse, ApiOkResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { RegionService } from './region.service'; import { RegionService } from './region.service';
import { InsertRegionsDto, RegionDto, UpdateRegionDto } from 'src/oracle/uscib-managed-sp/region/region.dto'; import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/uscib-managed-sp/region/region.dto';
@Controller('mssql') @Controller('mssql')
export class RegionController { export class RegionController {
@ -10,10 +10,6 @@ export class RegionController {
@ApiTags('Regions - Mssql') @ApiTags('Regions - Mssql')
@ApiOperation({ summary: 'Get all regions for issuing and replacement.' }) @ApiOperation({ summary: 'Get all regions for issuing and replacement.' })
@ApiOkResponse({
description: 'User retrieved successfully',
type: RegionDto,
})
@ApiInternalServerErrorResponse({ description: 'Server error' }) @ApiInternalServerErrorResponse({ description: 'Server error' })
@Get('/GetRegions') @Get('/GetRegions')
getRegions() { getRegions() {

View File

@ -1,7 +1,7 @@
import { Injectable, InternalServerErrorException } from '@nestjs/common'; import { Injectable, InternalServerErrorException } 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 { InsertRegionsDto, UpdateRegionDto } from 'src/oracle/uscib-managed-sp/region/region.dto'; import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/uscib-managed-sp/region/region.dto';
import * as mssql from 'mssql'; import * as mssql from 'mssql';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
@ -28,8 +28,8 @@ export class RegionService {
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_REGION', mssql.VarChar(mssql.MAX), body.p_region); request.input('P_REGION', mssql.VarChar(mssql.MAX), body.P_REGION);
request.input('P_NAME', mssql.VarChar(mssql.MAX), body.p_name); request.input('P_NAME', mssql.VarChar(mssql.MAX), body.P_NAME);
const result = await request.execute('carnetsys.INSERTNEWREGION'); const result = await request.execute('carnetsys.INSERTNEWREGION');
return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] };
@ -43,8 +43,8 @@ export class RegionService {
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_regionID', mssql.Int, body.p_regionID); request.input('p_regionID', mssql.Int, body.P_REGIONID);
request.input('P_NAME', mssql.VarChar(mssql.MAX), body.p_name); request.input('P_NAME', mssql.VarChar(mssql.MAX), body.P_NAME);
const result = await request.execute('carnetsys.UpdateRegion'); const result = await request.execute('carnetsys.UpdateRegion');
return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] };

View File

@ -1,7 +1,12 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common'; 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 { getSPAllContactsDTO, getSPDefaultcontactDTO, inactivateSPContactDTO, InsertSPContactsDTO, setSPDefaultcontactDTO, UpdateSPContactsDTO } from 'src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto';
import {
SPID_DTO,
SP_CONTACTID_DTO,
InsertSPContactsDTO, UpdateSPContactsDTO
} from 'src/dto/property.dto';
@Controller('mssql') @Controller('mssql')
export class SpContactsController { export class SpContactsController {
@ -11,19 +16,19 @@ export class SpContactsController {
@ApiTags('SPContacts - Mssql') @ApiTags('SPContacts - Mssql')
@Post('/InactivateSPContact') @Post('/InactivateSPContact')
inactivateSPContact(@Query() body: inactivateSPContactDTO) { inactivateSPContact(@Query() body: SP_CONTACTID_DTO) {
return this.spContactsService.inactivateSPContact(body); return this.spContactsService.inactivateSPContact(body);
} }
@ApiTags('SPContacts - Mssql') @ApiTags('SPContacts - Mssql')
@Get('/GetSPDefaultContact') @Get('/GetSPDefaultContact')
getSPDefaultcontact(@Query() body: getSPDefaultcontactDTO) { 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: getSPAllContactsDTO) { getSPAllContacts(@Query() body: SPID_DTO) {
return this.spContactsService.getSpAllContacts(body); return this.spContactsService.getSpAllContacts(body);
} }
@ -35,7 +40,7 @@ export class SpContactsController {
@ApiTags('SPContacts - Mssql') @ApiTags('SPContacts - Mssql')
@Post('/SetSPDefaultContact') @Post('/SetSPDefaultContact')
setSPDefaultcontact(@Query() body: setSPDefaultcontactDTO) { setSPDefaultcontact(@Query() body: SP_CONTACTID_DTO) {
return this.spContactsService.setSPDefaultcontact(body); return this.spContactsService.setSPDefaultcontact(body);
} }

View File

@ -2,20 +2,24 @@ 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 { Connection, Request } from 'mssql'; import { Connection, Request } from 'mssql';
import { getSPAllContactsDTO, getSPDefaultcontactDTO, inactivateSPContactDTO, InsertSPContactsDTO, setSPDefaultcontactDTO, UpdateSPContactsDTO } from 'src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto';
import { SP_CONTACTID_DTO,
SPID_DTO,
InsertSPContactsDTO, UpdateSPContactsDTO
} from 'src/dto/property.dto';
@Injectable() @Injectable()
export class SpContactsService { export class SpContactsService {
constructor(private readonly mssqlDBService: MssqlDBService) { } constructor(private readonly mssqlDBService: MssqlDBService) { }
async getSpAllContacts(body: getSPAllContactsDTO) { 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 };
@ -24,13 +28,13 @@ export class SpContactsService {
} }
} }
async getSPDefaultcontacts(body: getSPDefaultcontactDTO) { 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 };
@ -39,13 +43,13 @@ export class SpContactsService {
} }
} }
async inactivateSPContact(body: inactivateSPContactDTO) { async inactivateSPContact(body: SP_CONTACTID_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_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 };
@ -59,17 +63,17 @@ 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 };
@ -78,12 +82,12 @@ export class SpContactsService {
} }
} }
async setSPDefaultcontact(body: setSPDefaultcontactDTO) { async setSPDefaultcontact(body: SP_CONTACTID_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_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 };
@ -97,16 +101,16 @@ 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 };

View File

@ -1,7 +1,8 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common'; 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 { getSelectedServiceproviderDTO, InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/oracle/uscib-managed-sp/sp/sp.dto'; import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/dto/uscib-managed-sp/sp/sp.dto';
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@Controller('mssql') @Controller('mssql')
export class SpController { export class SpController {
@ -16,7 +17,7 @@ export class SpController {
@ApiTags('SP - Mssql') @ApiTags('SP - Mssql')
@Get('/GetSelectedServiceprovider') @Get('/GetSelectedServiceprovider')
getSelectedServiceprovider(@Query() body: getSelectedServiceproviderDTO) { getSelectedServiceprovider(@Query() body: SPID_DTO) {
return this.spService.getSpBySpid(body); return this.spService.getSpBySpid(body);
} }

View File

@ -1,8 +1,9 @@
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 { getSelectedServiceproviderDTO, InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/oracle/uscib-managed-sp/sp/sp.dto'; import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/dto/uscib-managed-sp/sp/sp.dto';
import * as mssql from 'mssql' import * as mssql from 'mssql'
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@Injectable() @Injectable()
export class SpService { export class SpService {
@ -23,13 +24,13 @@ export class SpService {
} }
} }
async getSpBySpid(body: getSelectedServiceproviderDTO) { async getSpBySpid(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.GETSPBYSPID'); const result = await request.execute('carnetsys.GETSPBYSPID');
return { data: result.recordset }; return { data: result.recordset };
@ -43,20 +44,20 @@ 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_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');
@ -72,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');

View File

@ -0,0 +1,86 @@
import { Body, Controller, Patch, Post, Put } from '@nestjs/common';
import { CarnetApplicationService } from './carnet-application.service';
import { ApiTags } from '@nestjs/swagger';
import {
AddCountriesDTO,
AddGenerallistItemsDTO,
CA_UpdateHolderDTO,
CarnetProcessingCenterDTO, CreateApplicationDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
UpdateExpGoodsAuthRepDTO,
UpdateShippingDetailsDTO
} from 'src/dto/property.dto';
@ApiTags('Carnet Application - Oracle')
@Controller('oracle')
export class CarnetApplicationController {
constructor(private readonly carnetApplicationService: CarnetApplicationService) { }
// [ CARNETAPPLICATION_PKG ]
@Post('SaveCarnetApplication')
async CreateClientData(@Body() body: SaveCarnetApplicationDTO) {
return this.carnetApplicationService.SaveCarnetApplication(body);
}
@Post('TransmitApplicationtoProcess')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.carnetApplicationService.TransmitApplicationtoProcess(body);
}
@Post('CreateApplication')
CreateApplication(@Body() body: CreateApplicationDTO) {
return this.carnetApplicationService.CreateApplication(body);
}
@Patch('update-holder')
UpdateHolder(@Body() body: CA_UpdateHolderDTO) {
return this.carnetApplicationService.UpdateHolder(body);
}
@Patch('UpdateExpGoodsAuthRep')
UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) {
return this.carnetApplicationService.UpdateExpGoodsAuthRep(body);
}
@Post('AddGenerallistItems')
AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
return this.carnetApplicationService.AddGenerallistItems(body);
}
@Post('AddCountries')
AddCountries(@Body() body: AddCountriesDTO) {
return this.carnetApplicationService.AddCountries(body);
}
@Patch('UpdateShippingDetails')
UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
return this.carnetApplicationService.UpdateShippingDetails(body);
}
// processing [ PROCESSINGCENTER_PKG ]
@Patch('ProcessOriginalCarnet')
ProcessOriginalCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.ProcessOriginalCarnet(body);
}
@Patch('UpdatePrintCarnet')
UpdatePrintCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.UpdatePrintCarnet(body);
}
@Patch('VoidCarnet')
VoidCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.VoidCarnet(body);
}
@Patch('DuplicateCarnet')
DuplicateCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.DuplicateCarnet(body);
}
@Patch('CloseCarnet')
CloseCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.CloseCarnet(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { CarnetApplicationController } from './carnet-application.controller';
import { CarnetApplicationService } from './carnet-application.service';
@Module({
controllers: [CarnetApplicationController],
providers: [CarnetApplicationService]
})
export class CarnetApplicationModule {}

View File

@ -0,0 +1,705 @@
import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import {
COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO,
CarnetProcessingCenterDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
CreateApplicationDTO,
UpdateExpGoodsAuthRepDTO,
AddGenerallistItemsDTO,
AddCountriesDTO,
UpdateShippingDetailsDTO,
CA_UpdateHolderDTO
} from 'src/dto/property.dto';
import { OracleService } from '../oracle.service';
@Injectable()
export class CarnetApplicationService {
private readonly logger = new Logger(CarnetApplicationService.name);
constructor(
private readonly oracleDBService: OracleDBService,
private readonly oracleService: OracleService
) { }
// [ CARNETAPPLICATION_PKG ]
async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
const newBody = {
P_SPID: null, //
P_CLIENTID: null,
P_LOCATIONID: null,
P_USERID: null, //
P_HEADERID: null,
P_APPLICATIONNAME: null,
P_HOLDERID: null,
P_COMMERCIALSAMPLEFLAG: null,
P_PROFEQUIPMENTFLAG: null,
P_EXHIBITIONSFAIRFLAG: null,
P_AUTOFLAG: null,
P_HORSEFLAG: null,
P_AUTHREP: null,
P_GLTABLE: null,
P_USSETS: null,
P_COUNTRYTABLE: null,
P_SHIPTOTYPE: null,
P_SHIPADDRID: null,
P_FORMOFSECURITY: null,
P_INSPROTECTION: null,
P_LDIPROTECTION: null,
P_DELIVERYTYPE: null,
P_DELIVERYMETHOD: null,
P_PAYMENTMETHOD: null,
P_CUSTCOURIERNO: null,
P_REFNO: null,
P_NOTES: 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 = { ...newBody, ...reqBody };
let connection;
try {
connection = await this.oracleDBService.getConnection();
// const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
// return res;
// const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
// if (typeof GLTABLE !== 'function') {
// throw new InternalServerException('GLTABLE is not a constructor');
// }
// async function createGLArrayInstance(
// ITEMNO,
// ITEMDESCRIPTION,
// ITEMVALUE,
// NOOFPIECES,
// ITEMWEIGHT,
// ITEMWEIGHTUOM,
// GOODSORIGINCOUNTRY,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.GLARRAY(:ITEMNO, :ITEMDESCRIPTION, :ITEMVALUE, :NOOFPIECES, :ITEMWEIGHT, :ITEMWEIGHTUOM, :GOODSORIGINCOUNTRY) FROM dual`,
// {
// ITEMNO,
// ITEMDESCRIPTION,
// ITEMVALUE,
// NOOFPIECES,
// ITEMWEIGHT,
// ITEMWEIGHTUOM,
// GOODSORIGINCOUNTRY,
// },
// );
// console.log(result.rows);
// return result.rows[0][0];
// }
// const GLTABLE_ARRAY: GLTABLE_DTO = {
// P_GLTABLE: await Promise.all(
// (finalBody.P_GLTABLE ?? []).map(async (x: GLTABLE_ROW_DTO) => {
// return await createGLArrayInstance(
// x.ITEMNO,
// x.ITEMDESCRIPTION,
// x.ITEMVALUE,
// x.NOOFPIECES,
// x.ITEMWEIGHT,
// x.ITEMWEIGHTUOM,
// x.GOODSORIGINCOUNTRY,
// );
// })
// )
// };
// const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY.P_GLTABLE ?? []);
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(finalBody);
// const COUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
// if (typeof COUNTRYTABLE !== 'function') {
// throw new Error('COUNTRYTABLE is not a constructor');
// }
// async function createCarnetCountryArrayInstance(
// P_VISISTTRANSITIND,
// COUNTRYCODE,
// NOOFTIMESENTLEAVE,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.CARNETCOUNTRYARRAY(:P_VISISTTRANSITIND, :COUNTRYCODE, :NOOFTIMESENTLEAVE) FROM dual`,
// {
// P_VISISTTRANSITIND,
// COUNTRYCODE,
// NOOFTIMESENTLEAVE,
// },
// );
// console.log(result.rows);
// return result.rows[0][0];
// }
// const COUNTRYTABLE_ARRAY: COUNTRYTABLE_DTO = {
// P_COUNTRYTABLE: await Promise.all(
// (finalBody.P_COUNTRYTABLE ?? []).map(async (x: COUNTRYTABLE_ROW_DTO) => {
// return await createCarnetCountryArrayInstance(
// x.P_VISISTTRANSITIND,
// x.COUNTRYCODE,
// x.NOOFTIMESENTLEAVE,
// );
// })
// )
// };
// const COUNTRYTABLE_INSTANCE = new COUNTRYTABLE(COUNTRYTABLE_ARRAY.P_COUNTRYTABLE ?? []);
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(finalBody);
// return { aa:GLTABLE_ARRAY, ab:COUNTRYTABLE_ARRAY, a: GLTABLE_INSTANCE, b: COUNTRYTABLE_INSTANCE }
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.SaveCarnetApplication(
:P_SPID, :P_CLIENTID, :P_LOCATIONID, :P_USERID, :P_HEADERID, :P_APPLICATIONNAME, :P_HOLDERID, :P_COMMERCIALSAMPLEFLAG, :P_PROFEQUIPMENTFLAG, :P_EXHIBITIONSFAIRFLAG, :P_AUTOFLAG, :P_HORSEFLAG, :P_AUTHREP, :P_GLTABLE, :P_USSETS, :P_COUNTRYTABLE, :P_SHIPTOTYPE, :P_SHIPADDRID, :P_FORMOFSECURITY, :P_INSPROTECTION, :P_LDIPROTECTION, :P_DELIVERYTYPE, :P_DELIVERYMETHOD, :P_PAYMENTMETHOD, :P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_VARCHAR },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
P_COMMERCIALSAMPLEFLAG: { val: body.P_COMMERCIALSAMPLEFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_PROFEQUIPMENTFLAG: { val: body.P_PROFEQUIPMENTFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_EXHIBITIONSFAIRFLAG: { val: body.P_EXHIBITIONSFAIRFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_AUTOFLAG: { val: body.P_AUTOFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_HORSEFLAG: { val: body.P_HORSEFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_VARCHAR },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER },
P_FORMOFSECURITY: { val: body.P_FORMOFSECURITY, type: oracledb.DB_TYPE_VARCHAR },
P_INSPROTECTION: { val: body.P_INSPROTECTION, type: oracledb.DB_TYPE_VARCHAR },
P_LDIPROTECTION: { val: body.P_LDIPROTECTION, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYMETHOD: { val: body.P_DELIVERYMETHOD, type: oracledb.DB_TYPE_VARCHAR },
P_PAYMENTMETHOD: { val: body.P_PAYMENTMETHOD, type: oracledb.DB_TYPE_VARCHAR },
P_CUSTCOURIERNO: { val: body.P_CUSTCOURIERNO, type: oracledb.DB_TYPE_VARCHAR },
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_VARCHAR },
P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
:P_SPID, :P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ 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, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async CreateApplication(body: CreateApplicationDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.CreateApplication(
:P_SPID, :P_CLIENTID, :P_LOCATIONID, :P_USERID,
:P_APPLICATIONNAME, :P_ORDERTYPE, :P_ERRORMESG
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_ORDERTYPE: { val: body.P_ORDERTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateHolder(body: CA_UpdateHolderDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateHolder(
:P_HEADERID, :P_HOLDERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateExpGoodsAuthRep(
:P_HEADERID, :P_COMMERCIALSAMPLEFLAG, :P_PROFEQUIPMENTFLAG,
:P_EXHIBITIONSFAIRFLAG, :P_AUTOFLAG, :P_HORSEFLAG, :P_AUTHREP,
:P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_COMMERCIALSAMPLEFLAG: { val: body.P_COMMERCIALSAMPLEFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_PROFEQUIPMENTFLAG: { val: body.P_PROFEQUIPMENTFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_EXHIBITIONSFAIRFLAG: { val: body.P_EXHIBITIONSFAIRFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_AUTOFLAG: { val: body.P_AUTOFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_HORSEFLAG: { val: body.P_HORSEFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddGenerallistItems(body: AddGenerallistItemsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddGenerallistItems(
:P_HEADERID, :P_GLTABLE, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddCountries(body: AddCountriesDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddCountries(
:P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT, typeName: 'CARNETCOUNTRYTABLE' },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateHolder(
:P_HEADERID, :P_SHIPTOTYPE, :P_SHIPADDRID, :P_FORMOFSECURITY, :P_INSPROTECTION,
:P_LDIPROTECTION, :P_DELIVERYTYPE, :P_DELIVERYMETHOD, :P_PAYMENTMETHOD,
:P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER },
P_FORMOFSECURITY: { val: body.P_FORMOFSECURITY, type: oracledb.DB_TYPE_NVARCHAR },
P_INSPROTECTION: { val: body.P_INSPROTECTION, type: oracledb.DB_TYPE_NVARCHAR },
P_LDIPROTECTION: { val: body.P_LDIPROTECTION, type: oracledb.DB_TYPE_NVARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_DELIVERYMETHOD: { val: body.P_DELIVERYMETHOD, type: oracledb.DB_TYPE_NVARCHAR },
P_PAYMENTMETHOD: { val: body.P_PAYMENTMETHOD, type: oracledb.DB_TYPE_NVARCHAR },
P_CUSTCOURIERNO: { val: body.P_CUSTCOURIERNO, type: oracledb.DB_TYPE_NVARCHAR },
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_NVARCHAR },
P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_NVARCHAR },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
// processing [ PROCESSINGCENTER_PKG ]
async ProcessOriginalCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.ProcessOriginalCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ 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, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdatePrintCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.UpdatePrintCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ 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, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async VoidCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.VoidCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ 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, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async DuplicateCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.DuplicateCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ 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, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async CloseCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.CloseCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ 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, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
}

View File

@ -1,81 +1,51 @@
import { import {
Get, Get,
Post,
Body,
Param, Param,
Controller, Controller,
ParseIntPipe,
BadRequestException,
} from '@nestjs/common'; } from '@nestjs/common';
import { HomePageService } from './home-page.service'; import { HomePageService } from './home-page.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { import {
SaveCarnetApplicationDTO, EMAIL_DTO,
TransmitApplicationtoProcessDTO,
GetCarnetDetailsbyCarnetStatusDTO, GetCarnetDetailsbyCarnetStatusDTO,
} from './home-page.dto'; SPID_DTO,
USERID_DTO
} from 'src/dto/property.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/:P_SPID')
GetHomePageData(@Param('id', ParseIntPipe) id: number) { GetHomePageData(@Param() params: SPID_DTO) {
return this.homePageService.GetHomePageData(id); return this.homePageService.GetHomePageData(params);
} }
@ApiTags('HomePage - Oracle') @Get('GetCarnetSummaryData/:P_USERID')
@Get('/oracle/GetCarnetSummaryData/:userid') GetCarnetSummaryData(@Param() params: USERID_DTO) {
GetCarnetSummaryData(@Param('userid') id: string) { return this.homePageService.GetCarnetSummaryData(params);
return this.homePageService.GetCarnetSummaryData(id);
} }
@ApiTags('HomePage - Oracle') @Get('GetCarnetDetailsbyCarnetStatus/:P_SPID/:P_USERID/:P_CARNETSTATUS')
@Get( GetCarnetDetailsbyCarnetStatus(@Param() params: GetCarnetDetailsbyCarnetStatusDTO) {
'/oracle/GetCarnetDetailsbyCarnetStatus/:p_spid/:p_userid/:p_CarnetStatus', return this.homePageService.GetCarnetDetailsbyCarnetStatus(params);
)
GetCarnetDetailsbyCarnetStatus(
@Param('p_spid', ParseIntPipe) p_spid: number,
@Param('p_userid') p_userid: string,
@Param('p_CarnetStatus') p_CarnetStatus: string,
) {
if (!p_spid || !p_userid || !p_CarnetStatus) {
throw new BadRequestException(
'spid, userid and Carnet Status are required',
);
} else if (Number(p_userid) || Number(p_CarnetStatus)) {
throw new BadRequestException(
'Param p_userid and p_CarnetStatus should be string',
);
}
try {
const body: GetCarnetDetailsbyCarnetStatusDTO = {
p_spid: p_spid,
p_userid: p_userid,
p_CarnetStatus: p_CarnetStatus,
};
return this.homePageService.GetCarnetDetailsbyCarnetStatus(body);
} catch (err) {
return new BadRequestException({
message: 'Validation faileda',
error: err.message,
});
}
} }
@ApiTags('HomePage - Oracle') // NOTE : this has been moved to carent-application module
@Post('/oracle/SaveCarnetApplication')
SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
return this.homePageService.SaveCarnetApplication(body);
}
@ApiTags('HomePage - Oracle') // @Post('/oracle/SaveCarnetApplication')
@Post('/oracle/TransmitApplicationtoProcess') // SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) { // return this.homePageService.SaveCarnetApplication(body);
return this.homePageService.TransmitApplicationtoProcess(body); // }
}
// NOTE : this has been moved to carent-application module
// @Post('/oracle/TransmitApplicationtoProcess')
// TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
// return this.homePageService.TransmitApplicationtoProcess(body);
// }
} }

View File

@ -13,351 +13,351 @@ import {
ValidateNested, ValidateNested,
} from 'class-validator'; } from 'class-validator';
export class p_gltableDTO { // export class p_gltableDTO {
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999999999, { message: 'Property ItemNo must not exceed 999999999' }) // @Max(999999999, { message: 'Property ItemNo must not exceed 999999999' })
@Min(0, { message: 'Property ItemNo must be at least 0 or more' }) // @Min(0, { message: 'Property ItemNo must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property ItemNo must be a number' }) // @IsNumber({}, { message: 'Property ItemNo must be a number' })
@IsDefined({ message: 'Property ItemNo is required' }) // @IsDefined({ message: 'Property ItemNo is required' })
ItemNo: number; // ItemNo: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 1000, { // @Length(0, 1000, {
message: 'Property ItemDescription must be between 1 and 1000 characters', // message: 'Property ItemDescription must be between 1 and 1000 characters',
}) // })
@IsString({ message: 'Property ItemDescription should be string' }) // @IsString({ message: 'Property ItemDescription should be string' })
@IsDefined({ message: 'Property ItemDescription is required' }) // @IsDefined({ message: 'Property ItemDescription is required' })
ItemDescription: string; // ItemDescription: string;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@IsNumber({}, { message: 'Property ItemValue should be number' }) // @IsNumber({}, { message: 'Property ItemValue should be number' })
@IsDefined({ message: 'Property ItemValue is required' }) // @IsDefined({ message: 'Property ItemValue is required' })
ItemValue: number; // ItemValue: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(99999999999, { // @Max(99999999999, {
message: 'Property Noofpieces must not exceed 99999999999', // message: 'Property Noofpieces must not exceed 99999999999',
}) // })
@Min(0, { message: 'Property Noofpieces must be at least 0 or more' }) // @Min(0, { message: 'Property Noofpieces must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property Noofpieces must be a number' }) // @IsNumber({}, { message: 'Property Noofpieces must be a number' })
@IsDefined({ message: 'Property Noofpieces is required' }) // @IsDefined({ message: 'Property Noofpieces is required' })
Noofpieces: number; // Noofpieces: number;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@IsNumber() // @IsNumber()
@IsOptional() // @IsOptional()
ItemWeight?: number; // ItemWeight?: number;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property ItemWeightUOM must be between 0 and 10 characters', // message: 'Property ItemWeightUOM must be between 0 and 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
ItemWeightUOM?: string; // ItemWeightUOM?: string;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 2, { // @Length(0, 2, {
message: 'Property GoodsOriginCountry must be between 0 and 2 characters', // message: 'Property GoodsOriginCountry must be between 0 and 2 characters',
}) // })
@IsString({ message: 'Property GoodsOriginCountry should be string' }) // @IsString({ message: 'Property GoodsOriginCountry should be string' })
@IsDefined({ message: 'Property name is required' }) // @IsDefined({ message: 'Property name is required' })
GoodsOriginCountry: string; // GoodsOriginCountry: string;
} // }
export class p_countrytableDTO { // export class p_countrytableDTO {
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 1, { // @Length(0, 1, {
message: 'Property VisitTransitInd must be 0 to 1 characters', // message: 'Property VisitTransitInd must be 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsDefined({ message: 'Property VisitTransitInd is required' }) // @IsDefined({ message: 'Property VisitTransitInd is required' })
VisitTransitInd: string; // VisitTransitInd: string;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 2, { // @Length(0, 2, {
message: 'Property CountryCode must be between 0 to 2 characters', // message: 'Property CountryCode must be between 0 to 2 characters',
}) // })
@IsString() // @IsString()
@IsDefined({ message: 'Property CountryCode is required' }) // @IsDefined({ message: 'Property CountryCode is required' })
CountryCode: string; // CountryCode: string;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999, { message: 'Property NoOfTimesEntLeave must not exceed 999' }) // @Max(999, { message: 'Property NoOfTimesEntLeave must not exceed 999' })
@Min(0, { message: 'Property NoOfTimesEntLeave must be at least 0 or more' }) // @Min(0, { message: 'Property NoOfTimesEntLeave must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property NoOfTimesEntLeave must be a number' }) // @IsNumber({}, { message: 'Property NoOfTimesEntLeave must be a number' })
@IsDefined({ message: 'Property NoOfTimesEntLeave is required' }) // @IsDefined({ message: 'Property NoOfTimesEntLeave is required' })
NoOfTimesEntLeave: number; // NoOfTimesEntLeave: number;
} // }
export class SaveCarnetApplicationDTO { // export class SaveCarnetApplicationDTO {
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_spid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
@Min(0, { message: 'Property p_spid must be at least 0 or more' }) // @Min(0, { message: 'Property p_spid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_spid must be a number' }) // @IsNumber({}, { message: 'Property p_spid must be a number' })
p_spid: number; // p_spid: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_clientid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
@Min(0, { message: 'Property p_clientid must be at least 0 or more' }) // @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_clientid must be a number' }) // @IsNumber({}, { message: 'Property p_clientid must be a number' })
p_clientid: number; // p_clientid: number;
@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() // @IsInt()
@IsNumber({}, { message: 'Property p_locationid must be a number' }) // @IsNumber({}, { message: 'Property p_locationid must be a number' })
p_locationid: number; // p_locationid: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 50, { // @Length(0, 50, {
message: 'Property p_userid must be between 0 to 50 characters', // message: 'Property p_userid must be between 0 to 50 characters',
}) // })
@IsString() // @IsString()
p_userid: string; // p_userid: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Max(999999999, { message: 'Property p_headerid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_headerid must not exceed 999999999' })
@Min(0, { message: 'Property p_headerid must be at least 0 or more' }) // @Min(0, { message: 'Property p_headerid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_headerid must be a number' }) // @IsNumber({}, { message: 'Property p_headerid must be a number' })
@IsOptional() // @IsOptional()
p_headerid?: number; // p_headerid?: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 50, { // @Length(0, 50, {
message: 'Property p_applicationname must be between 0 to 50 characters', // message: 'Property p_applicationname must be between 0 to 50 characters',
}) // })
@IsString() // @IsString()
p_applicationname: string; // p_applicationname: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Max(999999999, { message: 'Property p_holderid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_holderid must not exceed 999999999' })
@Min(0, { message: 'Property p_holderid must be at least 0 or more' }) // @Min(0, { message: 'Property p_holderid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_holderid must be a number' }) // @IsNumber({}, { message: 'Property p_holderid must be a number' })
@IsOptional() // @IsOptional()
p_holderid?: number; // p_holderid?: number;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 1, { // @Length(0, 1, {
message: // message:
'Property p_commercialsampleflag must be between 0 to 1 characters', // 'Property p_commercialsampleflag must be between 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_commercialsampleflag?: string; // p_commercialsampleflag?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 1, { // @Length(0, 1, {
message: 'Property p_profequipmentflag must be between 0 to 1 characters', // message: 'Property p_profequipmentflag must be between 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_profequipmentflag?: string; // p_profequipmentflag?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 1, { // @Length(0, 1, {
message: 'Property p_exhibitionsfairflag must be between 0 to 1 characters', // message: 'Property p_exhibitionsfairflag must be between 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_exhibitionsfairflag?: string; // p_exhibitionsfairflag?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 1, { // @Length(0, 1, {
message: 'Property p_autoflag must be between 0 to 1 characters', // message: 'Property p_autoflag must be between 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_autoflag?: string; // p_autoflag?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 1, { // @Length(0, 1, {
message: 'Property p_horseflag must be between 0 to 1 characters', // message: 'Property p_horseflag must be between 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_horseflag?: string; // p_horseflag?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 200, { // @Length(0, 200, {
message: 'Property p_authrep must be between 0 to 200 characters', // message: 'Property p_authrep must be between 0 to 200 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_authrep?: string; // p_authrep?: string;
@ApiProperty({ required: false, type: () => [p_gltableDTO] }) // @ApiProperty({ required: false, type: () => [p_gltableDTO] })
@Type(() => p_gltableDTO) // @Type(() => p_gltableDTO)
@ValidateNested({ each: true }) // @ValidateNested({ each: true })
@IsArray() // @IsArray()
// @ArrayNotEmpty({message:"Property gltable should not be empty"}) // // @ArrayNotEmpty({message:"Property gltable should not be empty"})
@IsOptional() // @IsOptional()
p_gltable?: p_gltableDTO[]; // p_gltable?: p_gltableDTO[];
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Max(99999, { message: 'Property p_ussets must not exceed 99999' }) // @Max(99999, { message: 'Property p_ussets must not exceed 99999' })
@Min(0, { message: 'Property p_ussets must be at least 0 or more' }) // @Min(0, { message: 'Property p_ussets must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_ussets must be a number' }) // @IsNumber({}, { message: 'Property p_ussets must be a number' })
@IsOptional() // @IsOptional()
p_ussets?: number; // p_ussets?: number;
@ApiProperty({ required: false, type: () => [p_countrytableDTO] }) // @ApiProperty({ required: false, type: () => [p_countrytableDTO] })
@ValidateNested({ each: true }) // @ValidateNested({ each: true })
@IsArray() // @IsArray()
@Type(() => p_countrytableDTO) // @Type(() => p_countrytableDTO)
@IsOptional() // @IsOptional()
p_countrytable?: p_countrytableDTO[]; // p_countrytable?: p_countrytableDTO[];
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property p_shiptotype must be between 0 to 10 characters', // message: 'Property p_shiptotype must be between 0 to 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_shiptotype?: string; // p_shiptotype?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Max(999999999, { // @Max(999999999, {
message: 'Property p_shipaddrid must not exceed 999999999', // message: 'Property p_shipaddrid must not exceed 999999999',
}) // })
@Min(0, { message: 'Property p_shipaddrid must be at least 0 or more' }) // @Min(0, { message: 'Property p_shipaddrid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_shipaddrid must be a number' }) // @IsNumber({}, { message: 'Property p_shipaddrid must be a number' })
@IsOptional() // @IsOptional()
p_shipaddrid?: number; // p_shipaddrid?: number;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 1, { // @Length(0, 1, {
message: 'Property p_formofsecurity must be between 0 to 1 characters', // message: 'Property p_formofsecurity must be between 0 to 1 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_formofsecurity?: string; // p_formofsecurity?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property p_insprotection must be between 0 to 10 characters', // message: 'Property p_insprotection must be between 0 to 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_insprotection?: string; // p_insprotection?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property p_ldiprotection must be between 0 to 10 characters', // message: 'Property p_ldiprotection must be between 0 to 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_ldiprotection?: string; // p_ldiprotection?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property p_deliverytype must be between 0 to 10 characters', // message: 'Property p_deliverytype must be between 0 to 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_deliverytype?: string; // p_deliverytype?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property p_deliverymethod must be between 0 to 10 characters', // message: 'Property p_deliverymethod must be between 0 to 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_deliverymethod?: string; // p_deliverymethod?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 10, { // @Length(0, 10, {
message: 'Property p_paymentmethod must be between 0 to 10 characters', // message: 'Property p_paymentmethod must be between 0 to 10 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_paymentmethod?: string; // p_paymentmethod?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 20, { // @Length(0, 20, {
message: 'Property p_custcourierno must be between 0 to 20 characters', // message: 'Property p_custcourierno must be between 0 to 20 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_custcourierno?: string; // p_custcourierno?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 20, { // @Length(0, 20, {
message: 'Property p_refno must be between 0 to 20 characters', // message: 'Property p_refno must be between 0 to 20 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_refno?: string; // p_refno?: string;
@ApiProperty({ required: false }) // @ApiProperty({ required: false })
@Length(0, 2000, { // @Length(0, 2000, {
message: 'Property p_notes must be between 0 to 2000 characters', // message: 'Property p_notes must be between 0 to 2000 characters',
}) // })
@IsString() // @IsString()
@IsOptional() // @IsOptional()
p_notes?: string; // p_notes?: string;
} // }
export class TransmitApplicationtoProcessDTO { // export class TransmitApplicationtoProcessDTO {
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_spid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
@Min(0, { message: 'Property p_spid must be at least 0 or more' }) // @Min(0, { message: 'Property p_spid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_spid must be a number' }) // @IsNumber({}, { message: 'Property p_spid must be a number' })
@IsDefined({ message: 'Property p_spid is required' }) // @IsDefined({ message: 'Property p_spid is required' })
p_spid: number; // p_spid: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 50, { // @Length(0, 50, {
message: 'Property p_userid must be between 0 to 50 characters', // message: 'Property p_userid must be between 0 to 50 characters',
}) // })
@IsString() // @IsString()
@IsDefined({ message: 'Property p_userid is required' }) // @IsDefined({ message: 'Property p_userid is required' })
p_userid: string; // p_userid: string;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_spid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
@Min(0, { message: 'Property p_spid must be at least 0 or more' }) // @Min(0, { message: 'Property p_spid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_headerid must be a number' }) // @IsNumber({}, { message: 'Property p_headerid must be a number' })
@IsDefined({ message: 'Property p_headerid is required' }) // @IsDefined({ message: 'Property p_headerid is required' })
p_headerid: number; // p_headerid: number;
} // }
export class GetCarnetDetailsbyCarnetStatusDTO { // export class GetCarnetDetailsbyCarnetStatusDTO {
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_spid must not exceed 999999999' }) // @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
@Min(0, { message: 'Property p_spid must be at least 0 or more' }) // @Min(0, { message: 'Property p_spid must be at least 0 or more' })
@IsInt() // @IsInt()
@IsNumber({}, { message: 'Property p_spid must be a number' }) // @IsNumber({}, { message: 'Property p_spid must be a number' })
@IsDefined({ message: 'Property p_spid is required' }) // @IsDefined({ message: 'Property p_spid is required' })
p_spid: number; // p_spid: number;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 50, { // @Length(0, 50, {
message: 'Property p_userid must be between 0 to 50 characters', // message: 'Property p_userid must be between 0 to 50 characters',
}) // })
@IsString({ message: 'Property p_userid must be string' }) // @IsString({ message: 'Property p_userid must be string' })
@IsDefined({ message: 'Property p_userid is required' }) // @IsDefined({ message: 'Property p_userid is required' })
p_userid: string; // p_userid: string;
@ApiProperty({ required: true }) // @ApiProperty({ required: true })
@Length(0, 20, { // @Length(0, 20, {
message: 'Property p_CarnetStatus must be between 0 to 20 characters', // message: 'Property p_CarnetStatus must be between 0 to 20 characters',
}) // })
@IsString() // @IsString()
@IsDefined({ message: 'Property p_CarnetStatus is required' }) // @IsDefined({ message: 'Property p_CarnetStatus is required' })
p_CarnetStatus: string; // p_CarnetStatus: string;
} // }

View File

@ -1,18 +1,20 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service'; import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import { import {
p_gltableDTO, EMAIL_DTO,
SaveCarnetApplicationDTO,
TransmitApplicationtoProcessDTO,
GetCarnetDetailsbyCarnetStatusDTO, GetCarnetDetailsbyCarnetStatusDTO,
} from './home-page.dto'; SPID_DTO,
USERID_DTO
} from 'src/dto/property.dto';
@Injectable() @Injectable()
export class HomePageService { export class HomePageService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
async GetHomePageData(P_spid: number) { async GetHomePageData(params: SPID_DTO) {
let connection; let connection;
let p_basic_details = []; let p_basic_details = [];
let p_contacts = []; let p_contacts = [];
@ -34,24 +36,24 @@ export class HomePageService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USERLOGIN_PKG.GetHomePageData( USERLOGIN_PKG.GetHomePageData(
:P_spid, :P_SPID,
:p_basic_details_cur, :p_basic_details_cur,
:p_contacts_cur, :p_contacts_cur,
:p_sequence_cur, :p_sequence_cur,
:p_fees_comm_cur, :p_fees_comm_cur,
:p_bf_fee_cur, :p_bf_fee_cur,
:p_cf_Fee_cur, :p_cf_Fee_cur,
:p_cont_sheet_fee_cur, :p_cont_sheet_fee_cur,
:p_ef_fee_cur, :p_ef_fee_cur,
:p_security_deposit_cur, :p_security_deposit_cur,
:p_param_cur, :p_param_cur,
:p_region_cur :p_region_cur
); );
END;`, END;`,
{ {
P_spid: { P_SPID: {
val: P_spid, val: params.P_SPID,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
p_basic_details_cur: { p_basic_details_cur: {
@ -292,7 +294,7 @@ export class HomePageService {
} }
} }
async GetCarnetSummaryData(p_emailaddr: string) { async GetCarnetSummaryData(body: USERID_DTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -303,14 +305,14 @@ export class HomePageService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USERLOGIN_PKG.GetCarnetSummaryData(:p_emailaddr,:p_cursor); USERLOGIN_PKG.GetCarnetSummaryData(:P_USERID,:P_CURSOR);
END;`, END;`,
{ {
p_emailaddr: { P_USERID: {
val: p_emailaddr, val: body.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,
}, },
@ -320,8 +322,8 @@ export class HomePageService {
}, },
); );
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 {
@ -392,430 +394,432 @@ export class HomePageService {
} }
} }
async SaveCarnetApplication(body: SaveCarnetApplicationDTO) { // NOTE : this has been moved to carent-application module
const newBody = {
p_headerid: null,
p_holderid: null,
p_commercialsampleflag: null,
p_profequipmentflag: null,
p_exhibitionsfairflag: null,
p_autoflag: null,
p_horseflag: null,
p_authrep: null,
p_gltable: null,
p_ussets: null,
p_countrytable: null,
p_shiptotype: null,
p_shipaddrid: null,
p_formofsecurity: null,
p_insprotection: null,
p_ldiprotection: null,
p_deliverytype: null,
p_deliverymethod: null,
p_paymentmethod: null,
p_custcourierno: null,
p_refno: null,
p_notes: null,
};
const reqBody = JSON.parse(JSON.stringify(body)); // async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
// const newBody = {
// p_headerid: null,
// p_holderid: null,
// p_commercialsampleflag: null,
// p_profequipmentflag: null,
// p_exhibitionsfairflag: null,
// p_autoflag: null,
// p_horseflag: null,
// p_authrep: null,
// p_gltable: null,
// p_ussets: null,
// p_countrytable: null,
// p_shiptotype: null,
// p_shipaddrid: null,
// p_formofsecurity: null,
// p_insprotection: null,
// p_ldiprotection: null,
// p_deliverytype: null,
// p_deliverymethod: null,
// p_paymentmethod: null,
// p_custcourierno: null,
// p_refno: null,
// p_notes: null,
// };
function setEmptyStringsToNull(obj) { // const reqBody = JSON.parse(JSON.stringify(body));
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); // 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;
// }
// });
// }
const finalBody = { ...newBody, ...reqBody }; // setEmptyStringsToNull(reqBody);
let connection; // const finalBody = { ...newBody, ...reqBody };
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
console.log('here ------------ 1'); // let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new Error('No DB Connected');
// }
// const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`); // console.log('here ------------ 1');
async function createGLArrayInstance( // // const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
connection,
itemNo,
itemDescription,
itemValue,
noOfPieces,
itemWeight,
itemWeightUOM,
goodsOriginCountry,
) {
const result = await connection.execute(
`SELECT CARNETSYS.GLARRAY(:itemNo, :itemDescription, :itemValue, :noOfPieces, :itemWeight, :itemWeightUOM, :goodsOriginCountry) FROM dual`,
{
itemNo,
itemDescription,
itemValue,
noOfPieces,
itemWeight,
itemWeightUOM,
goodsOriginCountry,
},
);
return result.rows[0][0]; // Access the first row and first column to get the GLARRAY instance
}
async function createCarnetCountryArrayInstance( // async function createGLArrayInstance(
connection, // connection,
visitTransitInd, // itemNo,
countryCode, // itemDescription,
noOfTimesEntLeave, // itemValue,
) { // noOfPieces,
const result = await connection.execute( // itemWeight,
`SELECT CARNETSYS.CARNETCOUNTRYARRAY(:visitTransitInd, :countryCode, :noOfTimesEntLeave) FROM dual`, // itemWeightUOM,
{ // goodsOriginCountry,
visitTransitInd, // ) {
countryCode, // const result = await connection.execute(
noOfTimesEntLeave, // `SELECT CARNETSYS.GLARRAY(:itemNo, :itemDescription, :itemValue, :noOfPieces, :itemWeight, :itemWeightUOM, :goodsOriginCountry) FROM dual`,
}, // {
); // itemNo,
return result.rows[0][0]; // Access the first row and first column to get the CARNETCOUNTRYARRAY instance // itemDescription,
} // itemValue,
// noOfPieces,
// itemWeight,
// itemWeightUOM,
// goodsOriginCountry,
// },
// );
// return result.rows[0][0]; // Access the first row and first column to get the GLARRAY instance
// }
// let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`) // async function createCarnetCountryArrayInstance(
// connection,
// visitTransitInd,
// countryCode,
// noOfTimesEntLeave,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.CARNETCOUNTRYARRAY(:visitTransitInd, :countryCode, :noOfTimesEntLeave) FROM dual`,
// {
// visitTransitInd,
// countryCode,
// noOfTimesEntLeave,
// },
// );
// return result.rows[0][0]; // Access the first row and first column to get the CARNETCOUNTRYARRAY instance
// }
// let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY'); // // let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
// const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
const CARNETCOUNTRYTABLE = await connection.getDbObjectClass(
'CARNETSYS.CARNETCOUNTRYTABLE',
);
// Check if GLTABLE is a constructor // // let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
if (typeof GLTABLE !== 'function') { // const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
throw new Error('GLTABLE is not a constructor'); // // const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
} // const CARNETCOUNTRYTABLE = await connection.getDbObjectClass(
// 'CARNETSYS.CARNETCOUNTRYTABLE',
// );
if (typeof CARNETCOUNTRYTABLE !== 'function') { // // Check if GLTABLE is a constructor
throw new Error('CARNETCOUNTRYTABLE is not a constructor'); // if (typeof GLTABLE !== 'function') {
} // throw new Error('GLTABLE is not a constructor');
// }
const GLTABLE_ARRAY = finalBody.p_gltable // if (typeof CARNETCOUNTRYTABLE !== 'function') {
? await Promise.all( // throw new Error('CARNETCOUNTRYTABLE is not a constructor');
finalBody.p_gltable.map(async (x: p_gltableDTO) => { // }
return await createGLArrayInstance(
connection,
x.ItemNo,
x.ItemDescription,
x.ItemValue,
x.Noofpieces,
x.ItemWeight,
x.ItemWeightUOM,
x.GoodsOriginCountry,
);
}),
)
: [];
const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable // const GLTABLE_ARRAY = finalBody.p_gltable
? await Promise.all( // ? await Promise.all(
finalBody.p_countrytable.map(async (x) => { // finalBody.p_gltable.map(async (x: p_gltableDTO) => {
return await createCarnetCountryArrayInstance( // return await createGLArrayInstance(
connection, // connection,
x.VisitTransitInd, // x.ItemNo,
x.CountryCode, // x.ItemDescription,
x.NoOfTimesEntLeave, // x.ItemValue,
); // x.Noofpieces,
}), // x.ItemWeight,
) // x.ItemWeightUOM,
: []; // x.GoodsOriginCountry,
// );
// }),
// )
// : [];
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY); // const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable
const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE( // ? await Promise.all(
CARNETCOUNTRYTABLE_ARRAY, // finalBody.p_countrytable.map(async (x) => {
); // return await createCarnetCountryArrayInstance(
// connection,
// x.VisitTransitInd,
// x.CountryCode,
// x.NoOfTimesEntLeave,
// );
// }),
// )
// : [];
const result = await connection.execute( // const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
`BEGIN // const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(
CARNETAPPLICATION_PKG.SaveCarnetApplication( // CARNETCOUNTRYTABLE_ARRAY,
:p_spid, // );
:p_clientid,
:p_locationid,
:p_userid,
:p_headerid,
:p_applicationname,
:p_holderid,
:p_commercialsampleflag,
:p_profequipmentflag,
:p_exhibitionsfairflag,
:p_autoflag,
:p_horseflag,
:p_authrep,
:p_gltable,
:p_ussets,
:p_countrytable,
:p_shiptotype,
:p_shipaddrid,
:p_formofsecurity,
:p_insprotection,
:p_ldiprotection,
:p_deliverytype,
:p_deliverymethod,
:p_paymentmethod,
:p_custcourierno,
:p_refno,
:p_notes,
:P_cursor
);
END;`,
{
p_spid: {
val: finalBody.p_spid ? finalBody.p_spid : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_clientid: {
val: finalBody.p_clientid ? finalBody.p_clientid : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_locationid: {
val: finalBody.p_locationid ? finalBody.p_locationid : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_userid: {
val: finalBody.p_userid ? finalBody.p_userid : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_headerid: {
val: finalBody.p_headerid ? finalBody.p_headerid : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_applicationname: {
val: finalBody.p_applicationname
? finalBody.p_applicationname
: null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_holderid: {
val: finalBody.p_holderid ? finalBody.p_holderid : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_commercialsampleflag: {
val: finalBody.p_commercialsampleflag
? finalBody.p_commercialsampleflag
: null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_profequipmentflag: {
val: finalBody.p_profequipmentflag
? finalBody.p_profequipmentflag
: null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_exhibitionsfairflag: {
val: finalBody.p_exhibitionsfairflag
? finalBody.p_exhibitionsfairflag
: null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_autoflag: {
val: finalBody.p_autoflag ? finalBody.p_autoflag : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_horseflag: {
val: finalBody.p_horseflag ? finalBody.p_horseflag : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_authrep: {
val: finalBody.p_authrep ? finalBody.p_authrep : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_gltable: {
val: GLTABLE_INSTANCE,
type: oracledb.DB_TYPE_OBJECT,
},
p_ussets: {
val: finalBody.p_ussets ? finalBody.p_ussets : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_countrytable: {
val: CARNETCOUNTRYTABLE_INSTANCE,
type: oracledb.DB_TYPE_OBJECT,
},
p_shiptotype: {
val: finalBody.p_shiptotype ? finalBody.p_shiptotype : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_shipaddrid: {
val: finalBody.p_shipaddrid ? finalBody.p_shipaddrid : null,
type: oracledb.DB_TYPE_NUMBER,
},
p_formofsecurity: {
val: finalBody.p_formofsecurity ? finalBody.p_formofsecurity : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_insprotection: {
val: finalBody.p_insprotection ? finalBody.p_insprotection : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_ldiprotection: {
val: finalBody.p_ldiprotection ? finalBody.p_ldiprotection : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_deliverytype: {
val: finalBody.p_deliverytype ? finalBody.p_deliverytype : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_deliverymethod: {
val: finalBody.p_deliverymethod ? finalBody.p_deliverymethod : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_paymentmethod: {
val: finalBody.p_paymentmethod ? finalBody.p_paymentmethod : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_custcourierno: {
val: finalBody.p_custcourierno ? finalBody.p_custcourierno : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_refno: {
val: finalBody.p_refno ? finalBody.p_refno : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_notes: {
val: finalBody.p_notes ? finalBody.p_notes : null,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_cursor: { // const result = await connection.execute(
type: oracledb.CURSOR, // `BEGIN
dir: oracledb.BIND_OUT, // CARNETAPPLICATION_PKG.SaveCarnetApplication(
}, // :P_SPID,
}, // :p_clientid,
{ // :p_locationid,
outFormat: oracledb.OUT_FORMAT_OBJECT, // :P_USERID,
}, // :p_headerid,
); // :p_applicationname,
await connection.commit(); // :p_holderid,
// :p_commercialsampleflag,
// :p_profequipmentflag,
// :p_exhibitionsfairflag,
// :p_autoflag,
// :p_horseflag,
// :p_authrep,
// :p_gltable,
// :p_ussets,
// :p_countrytable,
// :p_shiptotype,
// :p_shipaddrid,
// :p_formofsecurity,
// :p_insprotection,
// :p_ldiprotection,
// :p_deliverytype,
// :p_deliverymethod,
// :p_paymentmethod,
// :p_custcourierno,
// :p_refno,
// :p_notes,
// :P_CURSOR
// );
// END;`,
// {
// P_SPID: {
// val: finalBody.P_SPID ? finalBody.P_SPID : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_clientid: {
// val: finalBody.p_clientid ? finalBody.p_clientid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_locationid: {
// val: finalBody.p_locationid ? finalBody.p_locationid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: finalBody.P_USERID ? finalBody.P_USERID : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_headerid: {
// val: finalBody.p_headerid ? finalBody.p_headerid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_applicationname: {
// val: finalBody.p_applicationname
// ? finalBody.p_applicationname
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_holderid: {
// val: finalBody.p_holderid ? finalBody.p_holderid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_commercialsampleflag: {
// val: finalBody.p_commercialsampleflag
// ? finalBody.p_commercialsampleflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_profequipmentflag: {
// val: finalBody.p_profequipmentflag
// ? finalBody.p_profequipmentflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_exhibitionsfairflag: {
// val: finalBody.p_exhibitionsfairflag
// ? finalBody.p_exhibitionsfairflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_autoflag: {
// val: finalBody.p_autoflag ? finalBody.p_autoflag : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_horseflag: {
// val: finalBody.p_horseflag ? finalBody.p_horseflag : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_authrep: {
// val: finalBody.p_authrep ? finalBody.p_authrep : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_gltable: {
// val: GLTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_ussets: {
// val: finalBody.p_ussets ? finalBody.p_ussets : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_countrytable: {
// val: CARNETCOUNTRYTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_shiptotype: {
// val: finalBody.p_shiptotype ? finalBody.p_shiptotype : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_shipaddrid: {
// val: finalBody.p_shipaddrid ? finalBody.p_shipaddrid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_formofsecurity: {
// val: finalBody.p_formofsecurity ? finalBody.p_formofsecurity : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_insprotection: {
// val: finalBody.p_insprotection ? finalBody.p_insprotection : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_ldiprotection: {
// val: finalBody.p_ldiprotection ? finalBody.p_ldiprotection : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_deliverytype: {
// val: finalBody.p_deliverytype ? finalBody.p_deliverytype : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_deliverymethod: {
// val: finalBody.p_deliverymethod ? finalBody.p_deliverymethod : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_paymentmethod: {
// val: finalBody.p_paymentmethod ? finalBody.p_paymentmethod : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_custcourierno: {
// val: finalBody.p_custcourierno ? finalBody.p_custcourierno : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_refno: {
// val: finalBody.p_refno ? finalBody.p_refno : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_notes: {
// val: finalBody.p_notes ? finalBody.p_notes : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
if (result.outBinds && result.outBinds.P_cursor) { // P_CURSOR: {
const cursor = result.outBinds.P_cursor; // type: oracledb.CURSOR,
let rowsBatch; // dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
do { // if (result.outBinds && result.outBinds.P_CURSOR) {
rowsBatch = await cursor.getRows(100); // const cursor = result.outBinds.P_CURSOR;
rows = rows.concat(rowsBatch); // let rowsBatch;
} while (rowsBatch.length > 0);
await cursor.close(); // do {
} else { // rowsBatch = await cursor.getRows(100);
throw new Error('No cursor returned from the stored procedure'); // rows = rows.concat(rowsBatch);
} // } while (rowsBatch.length > 0);
return rows; // await cursor.close();
} catch (err) { // } else {
if (err instanceof Error) { // throw new Error('No cursor returned from the stored procedure');
return { error: err.message }; // }
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
}
}
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) { // return rows;
let connection; // } catch (err) {
let rows = []; // if (err instanceof Error) {
try { // return { error: err.message };
connection = await this.oracleDBService.getConnection(); // } else {
if (!connection) { // return { error: 'An unknown error occurred' };
throw new Error('No DB Connected'); // }
} // }
// finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// console.error('Failed to close connection:', closeErr);
// }
// }
// }
// }
const result = await connection.execute( // NOTE : this has been moved to carent-application module
`BEGIN
CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
:p_spid,
:p_userid,
:p_headerid,
:P_cursor
);
END;`,
{
p_spid: {
val: body.p_spid,
type: oracledb.DB_TYPE_NUMBER,
},
p_userid: {
val: body.p_userid,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_headerid: {
val: body.p_headerid,
type: oracledb.DB_TYPE_NUMBER,
},
P_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
await connection.commit();
if (result.outBinds && result.outBinds.P_cursor) { // async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
const cursor = result.outBinds.P_cursor; // let connection;
let rowsBatch; // let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new Error('No DB Connected');
// }
do { // const result = await connection.execute(
rowsBatch = await cursor.getRows(100); // `BEGIN
rows = rows.concat(rowsBatch); // CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
} while (rowsBatch.length > 0); // :P_SPID,
// :P_USERID,
// :p_headerid,
// :P_CURSOR
// );
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_headerid: {
// val: body.p_headerid,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
await cursor.close(); // if (result.outBinds && result.outBinds.P_CURSOR) {
} else { // const cursor = result.outBinds.P_CURSOR;
throw new Error('No cursor returned from the stored procedure'); // let rowsBatch;
}
return rows; // do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// return fres // await cursor.close();
} catch (err) { // } else {
if (err instanceof Error) { // throw new Error('No cursor returned from the stored procedure');
return { error: err.message }; // }
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
}
}
async GetCarnetDetailsbyCarnetStatus( // return rows;
body: GetCarnetDetailsbyCarnetStatusDTO,
) { // // return fres
// } catch (err) {
// if (err instanceof Error) {
// return { error: err.message };
// } else {
// return { error: 'An unknown error occurred' };
// }
// }
// finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// console.error('Failed to close connection:', closeErr);
// }
// }
// }
// }
async GetCarnetDetailsbyCarnetStatus(body: GetCarnetDetailsbyCarnetStatusDTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -826,22 +830,22 @@ export class HomePageService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
CARNETCONTROLCENTER_PKG.GetCarnetDetails(:p_spid,:p_userid,:p_CarnetStattus,:P_cursor); CARNETCONTROLCENTER_PKG.GetCarnetDetails(:P_SPID,:P_USERID,:P_CARNETSTATUS,: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_userid: { P_USERID: {
val: body.p_userid, val: body.P_USERID,
type: oracledb.DB_TYPE_NVARCHAR, type: oracledb.DB_TYPE_NVARCHAR,
}, },
p_CarnetStattus: { P_CARNETSTATUS: {
val: body.p_CarnetStatus, val: body.P_CARNETSTATUS,
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,
}, },
@ -851,8 +855,8 @@ export class HomePageService {
}, },
); );
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 {

View File

@ -1,20 +1,16 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common'; import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ManageClientsService } from './manage-clients.service'; import { ManageClientsService } from './manage-clients.service';
import {
CreateClientContactsDTO,
CreateClientDataDTO,
CreateClientLocationsDTO,
GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO,
UpdateClientContactsDTO,
UpdateClientDTO,
UpdateClientLocationsDTO,
} from './manage-clients.dto';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import {
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/property.dto';
@Controller('oracle') @Controller('oracle')
export class ManageClientsController { export class ManageClientsController {
constructor(private readonly manageClientsService: ManageClientsService) {} constructor(private readonly manageClientsService: ManageClientsService) { }
@ApiTags('Manage Clients - Oracle') @ApiTags('Manage Clients - Oracle')
@Post('CreateNewClients') @Post('CreateNewClients')

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,16 @@
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 { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { import {
CreateBasicFeeDTO, CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateBondRateDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
CreateCargoRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
CreateCfFeeDTO, } from 'src/dto/property.dto';
CreateCsFeeDTO,
CreateEfFeeDTO,
CreateFeeCommDTO,
GetFeeGeneralDTO,
UpdateBasicFeeDTO,
UpdateBondRateDTO,
UpdateCargoRateDTO,
UpdateCfFeeDTO,
UpdateCsFeeDTO,
UpdateEfFeeDTO,
UpdateFeeCommBodyDTO,
UpdateFeeCommDTO,
} from './manage-fee.dto';
@Controller('oracle') @Controller('oracle')
export class ManageFeeController { export class ManageFeeController {
constructor(private readonly manageFeeService: ManageFeeService) {} constructor(private readonly manageFeeService: ManageFeeService) { }
@ApiTags('Manage Fee - Oracle') @ApiTags('Manage Fee - Oracle')
@Get('/GetBasicFeeRates') @Get('/GetBasicFeeRates')

View File

@ -1,364 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsDefined, IsInt, IsNumber, IsString, Length, Matches, Min } from 'class-validator';
export class GetFeeGeneralDTO {
@ApiProperty({ required: true })
@Transform(({ value }) => Number(value))
@Min(0, { message: 'Property P_SPID must be at least 0' })
@IsInt({ message: 'Property P_SPID must be a whole number' })
@IsNumber({}, { message: 'Property P_SPID must be a number' })
@IsDefined({ message: 'Property P_SPID is required' })
P_SPID: number;
@ApiProperty({ required: true })
@Matches(/^.{6}$|^.{8}$/, {
message: 'Property P_ACTIVE_INACTIVE is invalid',
})
@IsString({ message: 'Property P_ACTIVE_INACTIVE must be a string' })
@IsDefined({ message: 'Property P_ACTIVE_INACTIVE is required' })
P_ACTIVE_INACTIVE: string;
}
export class CreateBasicFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_STARTCARNETVALUE: number;
@ApiProperty({ required: true })
@IsNumber()
P_ENDCARNETVALUE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsNumber()
P_FEES: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class CreateBondRateDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@Length(0, 3, {message:"Property P_HOLDERTYPE must be between 0 to 3 characters"})
@IsString({message:"Property P_USERID must be a string"})
@IsDefined({ message: 'Property P_USERID is required' })
P_HOLDERTYPE: string;
@ApiProperty({ required: true })
@IsString()
P_USCIBMEMBERFLAG: string;
@ApiProperty({ required: true })
@IsString()
P_SPCLCOMMODITY: string;
@ApiProperty({ required: true })
@IsString()
P_SPCLCOUNTRY: string;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class CreateCargoRateDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@IsString()
P_CARNETTYPE: string;
@ApiProperty({ required: true })
@IsNumber()
P_STARTSETS: number;
@ApiProperty({ required: true })
@IsNumber()
P_ENDSETS: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class CreateCfFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_STARTSETS: number;
@ApiProperty({ required: true })
@IsNumber()
P_ENDSETS: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_CUSTOMERTYPE: string;
@ApiProperty({ required: true })
@IsString()
P_CARNETTYPE: string;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class CreateCsFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@IsString()
P_CUSTOMERTYPE: string;
@ApiProperty({ required: true })
@IsString()
P_CARNETTYPE: string;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class CreateEfFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@IsString()
P_CUSTOMERTYPE: string;
@ApiProperty({ required: true })
@IsString()
P_DELIVERYTYPE: string;
@ApiProperty({ required: true })
@IsNumber()
P_STARTTIME: number;
@ApiProperty({ required: true })
@IsNumber()
P_ENDTIME: number;
@ApiProperty({ required: true })
@IsString()
P_TIMEZONE: string;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsNumber()
P_FEES: number;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class CreateFeeCommDTO {
@ApiProperty({ required: true })
@IsNumber()
P_SPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_PARAMID: number;
@ApiProperty({ required: true })
@IsNumber()
P_COMMRATE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateBasicFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_BASICFEESETUPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_FEES: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateBondRateDTO {
@ApiProperty({ required: true })
@IsNumber()
P_BONDRATESETUPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateCargoRateDTO {
@ApiProperty({ required: true })
@IsNumber()
P_CARGORATESETUPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateCfFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_CFFEESETUPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateCsFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_CSFEESETUPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateEfFeeDTO {
@ApiProperty({ required: true })
@IsNumber()
P_EFFEESETUPID: number;
@ApiProperty({ required: true })
@IsNumber()
P_FEES: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateFeeCommDTO {
@ApiProperty({ required: true })
@IsNumber()
P_FEECOMMID: number;
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
@ApiProperty({ required: true })
@IsString()
P_USERID: string;
}
export class UpdateFeeCommBodyDTO {
@ApiProperty({ type: UpdateFeeCommDTO, required: true }) // Correctly reference UpdateFeeCommDTO
p_fees_comm: UpdateFeeCommDTO; // No need for @IsObject()
}

View File

@ -1,27 +1,18 @@
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import { OracleDBService } from 'src/db/db.service'; import { OracleDBService } from 'src/db/db.service';
import {
CreateBasicFeeDTO,
CreateBondRateDTO,
CreateCargoRateDTO,
CreateCfFeeDTO,
CreateCsFeeDTO,
CreateEfFeeDTO,
CreateFeeCommDTO,
GetFeeGeneralDTO,
UpdateBasicFeeDTO,
UpdateBondRateDTO,
UpdateCargoRateDTO,
UpdateCfFeeDTO,
UpdateCsFeeDTO,
UpdateEfFeeDTO,
UpdateFeeCommBodyDTO,
UpdateFeeCommDTO,
} 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 { closeOracleDbConnection, handleError } from 'src/utils/helper';
import {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/property.dto';
@Injectable() @Injectable()
export class ManageFeeService { export class ManageFeeService {
private readonly logger = new Logger(ManageFeeService.name); private readonly logger = new Logger(ManageFeeService.name);
@ -30,7 +21,7 @@ export class ManageFeeService {
// basic fee // basic fee
async GETBASICFEERATES(body: GetFeeGeneralDTO): Promise<any[]> { async GETBASICFEERATES(body: GetFeeGeneralDTO) {
let connection; let connection;
let rows: any[] = []; let rows: any[] = [];
@ -84,24 +75,9 @@ export class ManageFeeService {
return rows; return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.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('GETBASICFEERATES failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -131,11 +107,11 @@ export class ManageFeeService {
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
P_STARTCARNETVALUE: { P_STARTCARNETVALUE: {
val: body.P_STARTCARNETVALUE, val: body.P_STARTNUMBER,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
P_ENDCARNETVALUE: { P_ENDCARNETVALUE: {
val: body.P_ENDCARNETVALUE, val: body.P_ENDNUMBER,
type: oracledb.DB_TYPE_NUMBER, type: oracledb.DB_TYPE_NUMBER,
}, },
P_EFFDATE: { P_EFFDATE: {
@ -171,20 +147,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATEBASICFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -243,26 +208,15 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATEBASICFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// bond rate // bond rate
async GETBONDRATES(body: GetFeeGeneralDTO): Promise<any[]> { async GETBONDRATES(body: GetFeeGeneralDTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -319,24 +273,9 @@ export class ManageFeeService {
return rows; return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.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('GETBONDRATES failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -415,20 +354,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATEBONDRATE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -487,20 +415,9 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATEBONDRATE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -653,20 +570,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATECARGORATE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -725,26 +631,15 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATECARGORATE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// counter foil // counter foil
async GETCFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> { async GETCFFEERATES(body: GetFeeGeneralDTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -798,24 +693,9 @@ export class ManageFeeService {
return rows; return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.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('GETCFFEERATES failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -894,20 +774,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATECFFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -966,27 +835,16 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATECFFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// continuation sheet // continuation sheet
async GETCSFEERATES(body: GetFeeGeneralDTO): Promise<any[]> { async GETCSFEERATES(body: GetFeeGeneralDTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -1040,24 +898,9 @@ export class ManageFeeService {
return rows; return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.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('GETCSFEERATES failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -1126,20 +969,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATECSFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -1198,26 +1030,15 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATECSFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// expedited fee // expedited fee
async GETEFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> { async GETEFFEERATES(body: GetFeeGeneralDTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -1271,24 +1092,9 @@ export class ManageFeeService {
return rows; return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.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('GETEFFEERATES failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -1373,20 +1179,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATEEFFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -1445,26 +1240,15 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATEEFFEE failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// fee comm // fee comm
async GETFEECOMM(body: GetFeeGeneralDTO): Promise<any[]> { async GETFEECOMM(body: GetFeeGeneralDTO) {
let connection; let connection;
let rows: any = []; let rows: any = [];
try { try {
@ -1518,24 +1302,9 @@ export class ManageFeeService {
return rows; return rows;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.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('GETFEECOMM failed\n', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -1599,20 +1368,9 @@ export class ManageFeeService {
return { statusCode: 201, message: "Created Successfully" }; return { statusCode: 201, message: "Created Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('CREATEFEECOMM failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
@ -1672,20 +1430,9 @@ export class ManageFeeService {
return { statusCode: 200, message: "Updated Successfully" }; return { statusCode: 200, message: "Updated Successfully" };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, ManageFeeService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('UPDATEFEECOMM failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, ManageFeeService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
} }

View File

@ -10,16 +10,13 @@ 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/property.dto';
@Controller('oracle') @Controller('oracle')
export class ManageHoldersController { export class ManageHoldersController {
constructor(private readonly manageHoldersService: ManageHoldersService) { } constructor(private readonly manageHoldersService: ManageHoldersService) { }
@ -44,94 +41,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,4 +1,4 @@
import { Module } from '@nestjs/common'; import { Global, Module } from '@nestjs/common';
import { DbModule } from 'src/db/db.module'; import { DbModule } from 'src/db/db.module';
import { ManageHoldersModule } from './manage-holders/manage-holders.module'; import { ManageHoldersModule } from './manage-holders/manage-holders.module';
import { HomePageModule } from './home-page/home-page.module'; import { HomePageModule } from './home-page/home-page.module';
@ -7,11 +7,15 @@ import { ParamTableModule } from './param-table/param-table.module';
import { ManageFeeModule } from './manage-fee/manage-fee.module'; import { ManageFeeModule } from './manage-fee/manage-fee.module';
import { ManageClientsModule } from './manage-clients/manage-clients.module'; import { ManageClientsModule } from './manage-clients/manage-clients.module';
import { UserMaintenanceModule } from './user-maintenance/user-maintenance.module'; import { UserMaintenanceModule } from './user-maintenance/user-maintenance.module';
import { CarnetApplicationModule } from './carnet-application/carnet-application.module';
import { OracleService } from './oracle.service';
@Global()
@Module({ @Module({
imports: [ imports: [
UserMaintenanceModule,
DbModule, DbModule,
CarnetApplicationModule,
UserMaintenanceModule,
HomePageModule, HomePageModule,
UscibManagedSpModule, UscibManagedSpModule,
ParamTableModule, ParamTableModule,
@ -19,8 +23,8 @@ import { UserMaintenanceModule } from './user-maintenance/user-maintenance.modul
ManageHoldersModule, ManageHoldersModule,
ManageClientsModule, ManageClientsModule,
], ],
providers: [], providers: [OracleService],
controllers: [], controllers: [],
exports: [], exports: [OracleService],
}) })
export class OracleModule {} export class OracleModule {}

View File

@ -0,0 +1,121 @@
import { Injectable, Logger } from "@nestjs/common";
import { OracleDBService } from "src/db/db.service";
import { COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO } from "src/dto/property.dto";
import { InternalServerException } from "src/exceptions/internalServerError.exception";
import { closeOracleDbConnection, handleError } from "src/utils/helper";
@Injectable()
export class OracleService {
private readonly logger = new Logger(OracleService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
async get_GL_TABLE_INSTANCE(finalBody: any) {
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
if (typeof GLTABLE !== 'function') {
throw new InternalServerException('GLTABLE is not a constructor');
}
async function createGLArrayInstance(
ITEMNO, ITEMDESCRIPTION, ITEMVALUE, NOOFPIECES,
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
) {
const result = await connection.execute(
`SELECT CARNETSYS.GLARRAY(
:ITEMNO, :ITEMDESCRIPTION, :ITEMVALUE, :NOOFPIECES,
:ITEMWEIGHT, :ITEMWEIGHTUOM, :GOODSORIGINCOUNTRY
) FROM dual`,
{
ITEMNO, ITEMDESCRIPTION, ITEMVALUE, NOOFPIECES,
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
}
);
console.log(result.rows);
return result.rows[0][0];
}
const GLTABLE_ARRAY: GLTABLE_DTO = {
P_GLTABLE: await Promise.all(
(finalBody.P_GLTABLE ?? []).map(async (x: GLTABLE_ROW_DTO) => {
return await createGLArrayInstance(
x.ITEMNO, x.ITEMDESCRIPTION, x.ITEMVALUE, x.NOOFPIECES,
x.ITEMWEIGHT, x.ITEMWEIGHTUOM, x.GOODSORIGINCOUNTRY,
);
})
)
};
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY.P_GLTABLE ?? []);
return GLTABLE_INSTANCE;
} catch (error) {
throw new Error("Error occured completing this process")
} finally {
await closeOracleDbConnection(connection, OracleService.name)
}
}
async get_COUNTRY_TABLE_INSTANCE(finalBody: any) {
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' }
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }
let connection;
try {
connection = await this.oracleDBService.getConnection();
const COUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
if (typeof COUNTRYTABLE !== 'function') {
throw new Error('COUNTRYTABLE is not a constructor');
}
async function createCarnetCountryArrayInstance(
P_VISISTTRANSITIND, COUNTRYCODE, NOOFTIMESENTLEAVE,
) {
const result = await connection.execute(
`SELECT CARNETSYS.CARNETCOUNTRYARRAY(
:P_VISISTTRANSITIND, :COUNTRYCODE, :NOOFTIMESENTLEAVE
) FROM dual`,
{
P_VISISTTRANSITIND, COUNTRYCODE, NOOFTIMESENTLEAVE,
},
);
console.log(result.rows);
return result.rows[0][0];
}
const COUNTRYTABLE_ARRAY: COUNTRYTABLE_DTO = {
P_COUNTRYTABLE: await Promise.all(
(finalBody.P_COUNTRYTABLE ?? []).map(async (x: COUNTRYTABLE_ROW_DTO) => {
return await createCarnetCountryArrayInstance(
x.P_VISISTTRANSITIND, x.COUNTRYCODE, x.NOOFTIMESENTLEAVE,
);
})
)
};
const COUNTRYTABLE_INSTANCE = new COUNTRYTABLE(COUNTRYTABLE_ARRAY.P_COUNTRYTABLE ?? []);
return COUNTRYTABLE_INSTANCE;
} catch (error) {
throw new Error("Error occured completing this process")
} finally {
await closeOracleDbConnection(connection, OracleService.name)
}
}
}

View File

@ -1,19 +1,16 @@
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 {
ActivateOrInactivateParamRecordDTO,
CreateParamRecordDTO,
CreateTableRecordDTO,
getParamValuesDTO,
UpdateParamRecordDTO,
} from './param-table.dto';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO,
getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/property.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 +28,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,21 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common'; import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import {
CreateCarnetSequenceDTO,
GetCarnetSequenceDTO,
} from './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, CreateCarnetSequenceDTO } from 'src/dto/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: GetCarnetSequenceDTO) { return this.carnetSequenceService.getCarnetSequence(params);
return this.carnetSequenceService.getCarnetSequence(body);
} }
} }

View File

@ -1,42 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsDefined, IsInt, IsNumber, IsString, Min } from 'class-validator';
export class CreateCarnetSequenceDTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_spid must be a number' })
@IsDefined({ message: 'Property p_spid is required' })
p_spid: number;
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_regionid must be a number' })
@IsDefined({ message: 'Property p_regionid is required' })
p_regionid: number;
@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;
@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;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_carnettype must be a string' })
@IsDefined({ message: 'Property p_carnettype is required' })
p_carnettype: string;
}
export class GetCarnetSequenceDTO {
@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;
}

View File

@ -1,21 +1,19 @@
import { Injectable, Logger } from '@nestjs/common'; import { Injectable, Logger } from '@nestjs/common';
import * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import { OracleDBService } from 'src/db/db.service'; import { OracleDBService } from 'src/db/db.service';
import {
CreateCarnetSequenceDTO,
GetCarnetSequenceDTO,
} from './carnet-sequence.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 { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO, CreateCarnetSequenceDTO } from 'src/dto/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 +24,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 +92,53 @@ export class CarnetSequenceService {
} }
} }
async getCarnetSequence(body: GetCarnetSequenceDTO) { 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 +150,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 +167,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 +203,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

@ -3,33 +3,27 @@ import { RegionService } from './region.service';
import { Get, Post, Body, Controller, Patch } from '@nestjs/common'; import { Get, Post, Body, Controller, Patch } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { InsertRegionsDto, UpdateRegionDto } from './region.dto';
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto';
@ApiTags('Regions - Oracle')
@Controller('oracle') @Controller('oracle')
export class RegionController { export class RegionController {
constructor(private readonly regionService: RegionService) {} constructor(private readonly regionService: RegionService) { }
@ApiTags('Regions - Oracle')
@Post('/InsertRegions') @Post('/InsertRegions')
insertRegions(@Body() body: InsertRegionsDto) { insertRegions(@Body() body: InsertRegionsDto) {
return this.regionService.insertRegions(body); return this.regionService.insertRegions(body);
} }
@ApiTags('Regions - Oracle')
@Patch('/UpdateRegion') @Patch('/UpdateRegion')
updateRegions(@Body() body: UpdateRegionDto) { updateRegions(@Body() body: UpdateRegionDto) {
return this.regionService.updateRegions(body); return this.regionService.updateRegions(body);
} }
@ApiTags('Regions - Oracle')
@Get('/GetRegions') @Get('/GetRegions')
getRegions() { getRegions() {
return this.regionService.getRegions(); return this.regionService.getRegions();
} }
// @ApiTags('Regions - Oracle')
// @Get('/getDetails')
selectAll() {
return this.regionService.selectSP();
}
} }

View File

@ -1,45 +0,0 @@
import { IsDefined, IsInt, IsNumber, IsOptional, IsString } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
export class InsertRegionsDto {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_region must be a string' })
@IsDefined({ message: 'Property p_region is required' })
p_region: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_name must be a string' })
@IsDefined({ message: 'Property p_name is required' })
p_name: string;
}
export class UpdateRegionDto {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_regionID must be a number' })
@IsDefined({ message: 'Property p_regionID is required' })
p_regionID: number;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_name must be a string' })
@IsDefined({ message: 'Property p_name is required' })
p_name: string;
}
export class RegionDto {
@ApiProperty({ example: 1, description: 'Unique identifier for the region' })
@IsInt()
REGIONID: number;
@ApiProperty({ example: '01', description: 'Region code' })
@IsString()
REGION: string;
@ApiProperty({ example: 'uk', description: 'Human-readable region name' })
@IsString()
REGIONNAME: string;
@ApiPropertyOptional({ example: null, description: 'Error message if applicable' })
@IsOptional()
@IsString()
ERRORMESG?: string | null;
}

View File

@ -1,9 +1,11 @@
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 * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import { InsertRegionsDto, UpdateRegionDto } from './region.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 { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto';
@Injectable() @Injectable()
export class RegionService { export class RegionService {
@ -11,266 +13,293 @@ export class RegionService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
async selectAll() { // async insertRegionsX(body: InsertRegionsDto) {
let connection: oracledb.Connection | undefined; // 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(
`SELECT * FROM BasicFeeSetup`, // `BEGIN
[], // USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
{ // END;`,
outFormat: oracledb.OUT_FORMAT_OBJECT, // {
} // P_REGION: {
); // val: body.P_REGION,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_NAME: {
// val: body.P_NAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
return result.rows; // await connection.commit();
} catch (error) {
this.logger.error('selectAll 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 selectSP() { // const fres = await result.outBinds.P_CURSOR.getRows();
let connection: oracledb.Connection | undefined;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
// const result = await connection.execute(
// `
// SELECT text
// FROM all_source
// WHERE name = 'MANAGEPREPARER_PKG' AND type = 'PACKAGE BODY'
// ORDER BY line
// `,
// [],
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// }
// );
const result: any = await connection.execute(
`SELECT text
FROM all_source
WHERE name = :pkgName AND type = 'PACKAGE BODY'
ORDER BY line`,
{ pkgName: 'USCIB_MANAGED_PKG' }, // bind variable
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
console.log(result);
const sourceCode = result.rows.map(row => row.TEXT).join('');
console.log(sourceCode);
return sourceCode;
} catch (error) {
this.logger.error('selectAll 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);
}
}
}
}
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('insertRegions failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async insertRegions(body: InsertRegionsDto) { async insertRegions(body: InsertRegionsDto) {
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.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, type: oracledb.DB_TYPE_VARCHAR },
val: body.p_region, P_NAME: { val: body.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
type: oracledb.DB_TYPE_VARCHAR, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
},
p_name: {
val: body.p_name,
type: oracledb.DB_TYPE_VARCHAR,
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}, },
{ 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.");
}
if (fres.length>0 && fres[0].ERRORMESG) { const fres: any = await fetchCursor(outBinds.P_CURSOR, RegionService.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 { 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, RegionService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('insertRegions failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, RegionService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// async updateRegionsX(body: UpdateRegionDto) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.UpdateRegion(:P_REGIONID,:P_NAME,:P_CURSOR);
// END;`,
// {
// P_REGIONID: {
// val: body.P_REGIONID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_NAME: {
// val: body.P_NAME,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('updateRegions failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async updateRegions(body: UpdateRegionDto) { async updateRegions(body: UpdateRegionDto) {
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.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, type: oracledb.DB_TYPE_NUMBER },
val: body.p_regionID, P_NAME: { val: body.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
type: oracledb.DB_TYPE_NUMBER, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
p_name: {
val: body.p_name,
type: oracledb.DB_TYPE_VARCHAR,
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}, },
{ 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.");
}
if (fres.length>0 && fres[0].ERRORMESG) { const fres: any = await fetchCursor(outBinds.P_CURSOR, RegionService.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 { statusCode: 200, message: "Updated Successfully", ...fres[0] }; return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, RegionService.name)
this.logger.warn(error.message);
throw error;
}
this.logger.error('updateRegions failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, RegionService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
// async getRegionsX() {
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException()
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
// END;`,
// {
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// return rows;
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// this.logger.warn(error.message);
// throw new BadRequestException();
// }
// this.logger.error('GETBASICFEERATES failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getRegions() { async getRegions() {
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.GetRegions(:p_cursor); USCIB_Managed_Pkg.GetRegions(: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();
} else {
throw new BadRequestException();
} }
return rows; return await fetchCursor(outBinds.P_CURSOR, RegionService.name);
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, RegionService.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('GETBASICFEERATES failed', error.stack || error);
throw new InternalServerException();
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, RegionService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
} }

View File

@ -1,52 +1,45 @@
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 {
getSPAllContactsDTO,
getSPDefaultcontactDTO,
inactivateSPContactDTO,
InsertSPContactsDTO,
setSPDefaultcontactDTO,
UpdateSPContactsDTO,
} from './sp-contacts.dto';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { SPID_DTO,
SP_CONTACTID_DTO,
InsertSPContactsDTO,UpdateSPContactsDTO
} from 'src/dto/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: setSPDefaultcontactDTO) { 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: inactivateSPContactDTO) { 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: getSPDefaultcontactDTO) { 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: getSPAllContactsDTO) { return this.spContactsService.getSPAllContacts(param);
return this.spContactsService.getSPAllContacts(body);
} }
} }

View File

@ -1,121 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import {
IsDefined,
IsEmail,
IsInt,
IsNumber,
IsString,
Min,
} from 'class-validator';
export class InsertSPContactsDTO {
@ApiProperty({ required: true })
@IsNumber()
p_spid: number;
@ApiProperty({ required: true })
@IsString()
p_defcontactflag: string;
@ApiProperty({ required: true })
@IsString()
p_firstname: string;
@ApiProperty({ required: true })
@IsString()
p_lastname: string;
@ApiProperty({ required: false })
@IsString()
P_MIDDLEINITIAL: string;
@ApiProperty({ required: true })
@IsString()
p_title: string;
@ApiProperty({ required: true })
@IsString()
p_phoneno: string;
@ApiProperty({ required: true })
@IsString()
p_mobileno: string;
@ApiProperty({ required: true })
@IsString()
p_faxno: string;
@ApiProperty({ required: true })
@IsEmail()
p_emailaddress: string;
@ApiProperty({ required: true })
@IsString()
p_user_id: string;
}
export class UpdateSPContactsDTO {
@ApiProperty({ required: true })
@IsNumber()
p_spcontactid: number;
@ApiProperty({ required: true })
@IsString()
p_firstname: string;
@ApiProperty({ required: true })
@IsString()
p_lastname: string;
@ApiProperty({ required: false })
@IsString()
P_MIDDLEINITIAL: string;
@ApiProperty({ required: true })
@IsString()
p_title: string;
@ApiProperty({ required: true })
@IsString()
p_phoneno: string;
@ApiProperty({ required: true })
@IsString()
p_mobileno: string;
@ApiProperty({ required: true })
@IsString()
p_faxno: string;
@ApiProperty({ required: true })
@IsEmail()
p_emailaddress: string;
@ApiProperty({ required: true })
@IsString()
p_user_id: string;
}
export class setSPDefaultcontactDTO {
@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 inactivateSPContactDTO extends setSPDefaultcontactDTO {}
export class getSPDefaultcontactDTO {
@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 getSPAllContactsDTO extends getSPDefaultcontactDTO{}

View File

@ -1,16 +1,14 @@
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 * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import {
getSPAllContactsDTO,
getSPDefaultcontactDTO,
inactivateSPContactDTO,
InsertSPContactsDTO,
setSPDefaultcontactDTO,
UpdateSPContactsDTO,
} from './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 { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO,
SP_CONTACTID_DTO,
InsertSPContactsDTO,UpdateSPContactsDTO
} from 'src/dto/property.dto';
@Injectable() @Injectable()
export class SpContactsService { export class SpContactsService {
@ -18,400 +16,658 @@ 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.");
}
if (fres.length>0 && fres[0].ERRORMESG) { const fres: any = await fetchCursor(outBinds.P_CURSOR, SpContactsService.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 { 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 setSPDefaultcontact(body: setSPDefaultcontactDTO) { // async setSPDefaultcontactX(body: SP_CONTACTID_DTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.SetDefaultContact(:P_SPCONTACTID);
// END;`,
// {
// P_SPCONTACTID: {
// val: body.P_SPCONTACTID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Default contact was added successfully for SP' };
// } catch (error) {
// this.logger.error('setSPDefaultcontact failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
let connection; 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.");
}
if (fres.length>0 && fres[0].ERRORMESG) { const fres: any = await fetchCursor(outBinds.P_CURSOR, SpContactsService.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 { 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 inactivateSPContact(body: inactivateSPContactDTO) { // async inactivateSPContactX(body: SP_CONTACTID_DTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.InActivateSPContacts(:P_SPCONTACTID);
// END;`,
// {
// P_SPCONTACTID: {
// val: body.P_SPCONTACTID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Inactivated SP contact successfully' };
// } catch (error) {
// this.logger.error('inactivateSPContact failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async inactivateSPContact(body: SP_CONTACTID_DTO) {
let connection; 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: getSPDefaultcontactDTO) { // 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: getSPAllContactsDTO) { // 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 {
getSelectedServiceproviderDTO,
InsertNewServiceProviderDTO,
UpdateServiceProviderDTO,
} from './sp.dto';
import {
SPID_DTO, InsertNewServiceProviderDTO,
UpdateServiceProviderDTO,
} from 'src/dto/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: getSelectedServiceproviderDTO) { return this.spService.getServiceproviderByID(param);
return this.spService.getServiceproviderByID(body);
} }
} }

View File

@ -1,190 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import {
IsDefined,
IsInt,
IsNumber,
IsOptional,
IsString,
Min,
} from 'class-validator';
export class InsertNewServiceProviderDTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_name must be a string' })
@IsDefined({ message: 'Property p_name is required' })
p_name: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_lookupcode must be a string' })
@IsDefined({ message: 'Property p_lookupcode is required' })
p_lookupcode: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_address1 must be a string' })
@IsDefined({ message: 'Property p_address1 is required' })
p_address1: string;
@ApiProperty({ required: false })
@IsString({ message: 'Property p_address2 must be a string' })
@IsOptional()
p_address2?: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_city must be a string' })
@IsDefined({ message: 'Property p_city is required' })
p_city: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_state must be a string' })
@IsDefined({ message: 'Property p_state is required' })
p_state: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_country must be a string' })
@IsDefined({ message: 'Property p_country is required' })
p_country: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_zip must be a string' })
@IsDefined({ message: 'Property p_zip is required' })
p_zip: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_issuingregion must be a string' })
@IsDefined({ message: 'Property p_issuingregion is required' })
p_issuingregion: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_replacementregion must be a string' })
@IsDefined({ message: 'Property p_replacementregion is required' })
p_replacementregion: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_bondsurety must be a string' })
@IsDefined({ message: 'Property p_bondsurety is required' })
p_bondsurety: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_cargopolicyno must be a string' })
@IsDefined({ message: 'Property p_cargopolicyno is required' })
p_cargopolicyno: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_cargosurety must be a string' })
@IsDefined({ message: 'Property p_cargosurety is required' })
p_cargosurety: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_user_id must be a string' })
@IsDefined({ message: 'Property p_user_id is required' })
p_user_id: string;
@ApiProperty({ required: false })
@IsString({ message: 'Property P_NOTES must be a string' })
@IsOptional()
P_NOTES?: string;
@ApiProperty({ required: false })
@IsString({ message: 'Property P_FILEIDS must be a string' })
@IsOptional()
P_FILEIDS?: string;
}
export class UpdateServiceProviderDTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_spid must be a number' })
@IsDefined({ message: 'Property p_spid is required' })
p_spid: number;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_name must be a string' })
@IsDefined({ message: 'Property p_name is required' })
p_name: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_lookupcode must be a string' })
@IsDefined({ message: 'Property p_lookupcode is required' })
p_lookupcode: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_address1 must be a string' })
@IsDefined({ message: 'Property p_address1 is required' })
p_address1: string;
@ApiProperty({ required: false })
@IsString({ message: 'Property p_address2 must be a string' })
@IsOptional()
p_address2?: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_city must be a string' })
@IsDefined({ message: 'Property p_city is required' })
p_city: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_state must be a string' })
@IsDefined({ message: 'Property p_state is required' })
p_state: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_country must be a string' })
@IsDefined({ message: 'Property p_country is required' })
p_country: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_issuingregion must be a string' })
@IsDefined({ message: 'Property p_issuingregion is required' })
p_issuingregion: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_replacementregion must be a string' })
@IsDefined({ message: 'Property p_replacementregion is required' })
p_replacementregion: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_bondsurety must be a string' })
@IsDefined({ message: 'Property p_bondsurety is required' })
p_bondsurety: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_cargopolicyno must be a string' })
@IsDefined({ message: 'Property p_cargopolicyno is required' })
p_cargopolicyno: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_cargosurety must be a string' })
@IsDefined({ message: 'Property p_cargosurety is required' })
p_cargosurety: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_zip must be a string' })
@IsDefined({ message: 'Property p_zip is required' })
p_zip: string;
@ApiProperty({ required: true })
@IsString({ message: 'Property p_user_id must be a string' })
@IsDefined({ message: 'Property p_user_id is required' })
p_user_id: string;
@ApiProperty({ required: false })
@IsString({ message: 'Property P_NOTES must be a string' })
@IsOptional()
P_NOTES?: string;
@ApiProperty({ required: false })
@IsString({ message: 'Property P_FILEIDS must be a string' })
@IsOptional()
P_FILEIDS?: string;
}
export class getSelectedServiceproviderDTO {
@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;
}

View File

@ -1,13 +1,14 @@
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 * as oracledb from 'oracledb'; import * as oracledb from 'oracledb';
import {
getSelectedServiceproviderDTO,
InsertNewServiceProviderDTO,
UpdateServiceProviderDTO,
} from './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 { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import {
SPID_DTO, InsertNewServiceProviderDTO,
UpdateServiceProviderDTO,
} from 'src/dto/property.dto';
@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 getServiceproviderByID(body: getSelectedServiceproviderDTO) { // async getServiceproviderByIDX(body: SPID_DTO) {
// let connection;
// let rows: any = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// USCIB_Managed_Pkg.GetSPbySPID(:P_SPID,:P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// if (rows.length > 0 && rows[0].ERRORMESG) {
// throw new BadRequestException(rows[0].ERRORMESG);
// }
// return rows;
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// this.logger.warn(error.message);
// throw new BadRequestException();
// }
// this.logger.error('getServiceproviderByID failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async getServiceproviderByID(body: SPID_DTO) {
let connection; let 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

@ -1,41 +1,75 @@
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common'; 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 { CreateUSCIBLoginsDTO, GetSPUserDetailsDTO, UseSPIDDTO } from './user-maintenance.dto';
import {
SPID_DTO,
EMAIL_DTO, USERID_DTO,
CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO, SPID_EMAIL_DTO
} from 'src/dto/property.dto';
@ApiTags('User Maintenance - Oracle') @ApiTags('User Maintenance - Oracle')
@Controller('oracle') @Controller('oracle')
export class UserMaintenanceController { export class UserMaintenanceController {
constructor(private readonly userMaintenanceService: UserMaintenanceService) { } constructor(private readonly userMaintenanceService: UserMaintenanceService) { }
// SP_USER_DETAILS
@Get('GetSPUserDetails/:p_userid') @Get('GetUserDetails/:P_USERID')
async GetPreparers(@Param() params: GetSPUserDetailsDTO) { async GetPreparers(@Param() params: USERID_DTO) {
return await this.userMaintenanceService.GetSPUserDetails(params); return await this.userMaintenanceService.GetSPUserDetails(params);
} }
// @ApiTags('User Maintenance - Oracle') @Patch('LockUserAccount')
// @Get('GetSPUserDetailsv1') async LockUserAccount(@Body() body: SPID_EMAIL_DTO) {
// async GetPreparersv1(@Query() query: GetSPUserDetailsDTO) { return await this.userMaintenanceService.LockUserAccount(body);
// return await this.userMaintenanceService.GetSPUserDetailsv1(query);
// }
// @ApiTags('User Maintenance - Oracle')
@Post('CreateUSCIBLogins')
async CreateUSCIBLogins(@Body() body: CreateUSCIBLoginsDTO) {
return await this.userMaintenanceService.CreateUSCIBLogins(body);
} }
// @ApiTags('User Maintenance - Oracle') // USCIB_LOGINS
@Get('GetUSCIBLogins') @Get('GetUSCIBLogins')
async GetUSCIBLogins() { async GetUSCIBLogins() {
return await this.userMaintenanceService.GetUSCIBLogins(); return await this.userMaintenanceService.GetUSCIBLogins();
} }
@Get('GetSPLogins/:p_spid') @Post('CreateUSCIBLogins')
async GetSPLogins(@Param() params: UseSPIDDTO) { async CreateUSCIBLogins(@Body() body: CreateUSCIBLoginsDTO) {
return await this.userMaintenanceService.CreateUSCIBLogins(body);
}
// SP LOGINS
@Get('GetSPLogins/:P_SPID')
async GetSPLogins(@Param() params: SPID_DTO) {
return await this.userMaintenanceService.GetSPLogins(params); return await this.userMaintenanceService.GetSPLogins(params);
} }
@Post('CreateSPLogins')
async CreateSPLogins(@Body() body: CreateSPLoginsDTO) {
return await this.userMaintenanceService.CreateSPLogins(body);
}
// CLIENT LOGINS
@Get('GetClientloginsBySPID/:P_SPID')
async GetClientloginsBySPID(@Param() params: SPID_DTO) {
return await this.userMaintenanceService.GetSPLogins(params);
}
@Get('GetClientloginsByClientID/:P_SPID/:P_CLIENTID')
async GetClientloginsByClientID(@Param() params: SPID_CLIENTID_DTO) {
return await this.userMaintenanceService.GetSPLogins(params);
}
@Post('CreateClientLogins')
async CreateClientLogins(@Body() body: CreateClientLoginsDTO) {
return await this.userMaintenanceService.CreateClientLogins(body);
}
// validate email
@Get('ValidateEmail/:P_EMAILADDR')
async ValidateEmail(@Param() params: EMAIL_DTO) {
return await this.userMaintenanceService.ValidateEmail(params);
}
} }

View File

@ -1,57 +0,0 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import { IsDefined, IsEmail, IsEnum, IsInt, IsPositive, IsString, Length, Min } from "class-validator";
export enum YON {
YES = "Y",
NO = "N",
}
export class GetSPUserDetailsDTO {
@ApiProperty({ required: true })
// @IsEmail({},{message:"Invalid P_USERID property"})
@IsString()
@IsDefined({ message: "Invalid Request" })
p_userid: string;
}
export class CreateUSCIBLoginsDTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_userid: string;
@ApiProperty({ required: true })
@IsEmail({}, { message: "Invalid p_emailaddr property" })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_emailaddr: string;
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_lookupCode: string;
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
p_password: string;
@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_EnablePasswordPolicy: YON;
}
export class UseSPIDDTO {
@ApiProperty({ required: true })
@Min(0, { message: 'p_spid must be greater than or equal to 0' })
@IsInt({ message: "p_spid must be whole number" })
@IsDefined({ message: 'Invalid Request' })
@Type(() => Number)
p_spid: number;
}

View File

@ -1,9 +1,14 @@
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 { CreateUSCIBLoginsDTO, GetSPUserDetailsDTO, UseSPIDDTO } from './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 { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import {
SPID_DTO,
EMAIL_DTO, USERID_DTO,
CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, SPID_CLIENTID_DTO, SPID_EMAIL_DTO
} from 'src/dto/property.dto';
interface RoleDetail { [key: string]: any; } interface RoleDetail { [key: string]: any; }
@ -25,18 +30,20 @@ export class UserMaintenanceService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
private async fetchCursor<T>(cursor: oracledb.ResultSet<T>): Promise<T[]> { // private async fetchCursor<T>(cursor: oracledb.ResultSet<T>): Promise<T[]> {
try { // try {
const rows = await cursor.getRows(); // or getRows(1000) if needed // const rows = await cursor.getRows(); // or getRows(1000) if needed
await cursor.close(); // await cursor.close();
return rows; // return rows;
} catch (err) { // } catch (err) {
this.logger.error('Failed to fetch from cursor', err.stack || err); // this.logger.error('Failed to fetch from cursor', err.stack || err);
throw new InternalServerException("Error reading data from database."); // throw new InternalServerException("Error reading data from database.");
} // }
} // }
async GetSPUserDetails(body: GetSPUserDetailsDTO): Promise<any> { // SP_USER_DETAILS
async GetSPUserDetails(body: USERID_DTO): Promise<any> {
let connection; let connection;
try { try {
@ -49,7 +56,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 },
@ -63,38 +70,59 @@ export class UserMaintenanceService {
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.");
} }
let userdetailsTemp: any = await this.fetchCursor(outBinds.P_USERDETAILS); let roleDetailsTemp: { "ROLENAME": "" }[] = await fetchCursor(outBinds.P_ROLECUR, UserMaintenanceService.name);
let menuDetailsTemp: { "MENUNAME": "" }[] = await fetchCursor(outBinds.P_MENUCUR, UserMaintenanceService.name);
let userdetailsTemp: any = await fetchCursor(outBinds.P_USERDETAILS, UserMaintenanceService.name);
return { return {
roleDetails: await this.fetchCursor(outBinds.P_ROLECUR), roleDetails: roleDetailsTemp.map(x => x.ROLENAME),
menuDetails: await this.fetchCursor(outBinds.P_MENUCUR), menuDetails: menuDetailsTemp.map(x => x.MENUNAME),
menuPageDetails: await this.fetchCursor(outBinds.P_MENUPAGECUR), menuPageDetails: await fetchCursor(outBinds.P_MENUPAGECUR, UserMaintenanceService.name),
userDetails: userdetailsTemp[0] userDetails: userdetailsTemp[0]
}; };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, UserMaintenanceService.name)
this.logger.warn(error.message);
throw error;
} else if (error.message.includes("NJS-107")) {
this.logger.warn("Invalid cursor encountered: " + error.message);
throw new BadRequestException("Invalid database response.");
} else if (error.message.includes("ORA-")) {
this.logger.error("Oracle error occurred: " + error.message);
throw new InternalServerException(error.message);
}
this.logger.error('GetSPUserDetails failed', error.stack || error);
throw new InternalServerException(error.message);
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, UserMaintenanceService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
async GetSPUserDetailsv1(body: GetSPUserDetailsDTO): Promise<GetUserDetailsResult> { async LockUserAccount(body: SPID_EMAIL_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
Userlogin_pkg.LockUserAccount(
:P_SPID, :P_EMAILADDR, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
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, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
// USCIB_LOGINS
async GetUSCIBLogins() {
let connection; let connection;
try { try {
@ -102,54 +130,29 @@ export class UserMaintenanceService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
SPCLIENTUSER_PKG.GetSPUserDetails( Userlogin_pkg.GetUSCIBLogins(
:p_userid , :p_rolecur , :p_menucur , :p_menuPageCur , :p_userdetails :P_CURSOR
); );
END;`, END;`,
{ {
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR }, P_CURSOR: { 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_menuPageCur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_userdetails: { 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_rolecur || !outBinds?.p_menucur || !outBinds?.p_menuPageCur || !outBinds?.p_userdetails) { 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 await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
roleDetails: await this.fetchCursor(outBinds.p_rolecur),
menuDetails: await this.fetchCursor(outBinds.p_menucur),
menuPageDetails: await this.fetchCursor(outBinds.p_menuPageCur),
userDetails: await this.fetchCursor(outBinds.p_userdetails),
};
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, UserMaintenanceService.name)
this.logger.warn(error.message);
throw error;
} else if (error.message.includes("NJS-107")) {
this.logger.warn("Invalid cursor encountered: " + error.message);
throw new BadRequestException("Invalid database response.");
} else if (error.message.includes("ORA-")) {
this.logger.error("Oracle error occurred: " + error.message);
throw new InternalServerException(error.message);
}
this.logger.error('GetSPUserDetails failed', error.stack || error);
throw new InternalServerException(error.message);
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, UserMaintenanceService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
async CreateUSCIBLogins(body: CreateUSCIBLoginsDTO) { async CreateUSCIBLogins(body: CreateUSCIBLoginsDTO) {
@ -162,106 +165,40 @@ 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 this.fetchCursor(outBinds.p_cursor), data: await fetchCursor(outBinds.P_CURSOR),
}; };
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, UserMaintenanceService.name)
this.logger.warn(error.message);
throw error;
} else if (error.message.includes("NJS-107")) {
this.logger.warn("Invalid cursor encountered: " + error.message);
throw new BadRequestException("Invalid database response.");
} else if (error.message.includes("ORA-")) {
this.logger.error("Oracle error occurred: " + error.message);
throw new InternalServerException(error.message);
}
this.logger.error('GetSPUserDetails failed', error.stack || error);
throw new InternalServerException(error.message);
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, UserMaintenanceService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
async GetUSCIBLogins() { // SP LOGINS
let connection; async GetSPLogins(body: SPID_DTO) {
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetUSCIBLogins(
:p_cursor
);
END;`,
{
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
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 this.fetchCursor(outBinds.p_cursor);
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
} else if (error.message.includes("NJS-107")) {
this.logger.warn("Invalid cursor encountered: " + error.message);
throw new BadRequestException("Invalid database response.");
} else if (error.message.includes("ORA-")) {
this.logger.error("Oracle error occurred: " + error.message);
throw new InternalServerException(error.message);
}
this.logger.error('GetSPUserDetails failed', error.stack || error);
throw new InternalServerException(error.message);
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
}
}
async GetSPLogins(body: UseSPIDDTO) {
let connection; let connection;
@ -271,46 +208,211 @@ 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 this.fetchCursor(outBinds.p_cursor); return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) { } catch (error) {
if (error instanceof BadRequestException) { handleError(error, UserMaintenanceService.name)
this.logger.warn(error.message);
throw error;
} else if (error.message.includes("NJS-107")) {
this.logger.warn("Invalid cursor encountered: " + error.message);
throw new BadRequestException("Invalid database response.");
} else if (error.message.includes("ORA-")) {
this.logger.error("Oracle error occurred: " + error.message);
throw new InternalServerException(error.message);
}
this.logger.error('GetSPUserDetails failed', error.stack || error);
throw new InternalServerException(error.message);
} finally { } finally {
if (connection) { await closeOracleDbConnection(connection, UserMaintenanceService.name)
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
} }
} }
async CreateSPLogins(body: CreateSPLoginsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
Userlogin_pkg.CreateSPLogins(
:P_SPID, :P_USERID, :P_DOMAIN, :P_EMAILADDR, :P_LOOKUPCODE, :P_PASSWORD, :P_ENABLEPASSWORDPOLICY, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_DOMAIN: { val: body.P_DOMAIN, type: oracledb.DB_TYPE_NVARCHAR },
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_NVARCHAR },
P_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
P_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
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, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
// CLIENT LOGINS
async GetClientloginsBySPID(body: SPID_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetClientloginsBySPID(
: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 }
);
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, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
async GetClientloginsByClientID(body: SPID_CLIENTID_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
Userlogin_pkg.GetClientloginsByClientID(
:P_SPID, :p_clientid , :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
p_clientid: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
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, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
async CreateClientLogins(body: CreateClientLoginsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
Userlogin_pkg.CreateClientLogins(
:P_SPID, :P_USERID, :P_CLIENTCONTACTID, :P_PASSWORD, :P_ENABLEPASSWORDPOLICY, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CLIENTCONTACTID: { val: body.P_CLIENTCONTACTID, type: oracledb.DB_TYPE_NUMBER },
P_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
P_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
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, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
// validate email
async ValidateEmail(body: EMAIL_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
userlogin_pkg.ValidateEmail(
:P_EMAILADDR, :P_CURSOR
);
END;`,
{
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
} catch (error) {
handleError(error, UserMaintenanceService.name)
} finally {
await closeOracleDbConnection(connection, UserMaintenanceService.name)
}
}
} }

49
src/utils/helper.ts Normal file
View File

@ -0,0 +1,49 @@
import {
BadRequestException,
InternalServerErrorException,
Logger,
} from '@nestjs/common';
import * as oracledb from 'oracledb';
const logger = new Logger('Helper');
export const handleError = (error: any, context: string = 'UnknownService'): never => {
if (error instanceof BadRequestException) {
logger.warn(`[${context}] ${error.message}`);
throw error;
}
if (error.message?.includes('NJS-107')) {
logger.warn(`[${context}] Invalid cursor encountered: ${error.message}`);
throw new BadRequestException('Invalid database response.');
}
if (error.message?.includes('ORA-')) {
logger.error(`[${context}] Oracle error occurred: ${error.message}`);
throw new InternalServerErrorException(error.message);
}
logger.error(`[${context}] Unexpected error:`, error.stack || error);
throw new InternalServerErrorException(error.message || 'Internal error');
};
export const closeOracleDbConnection = async (connection: any, context: string = 'UnknownService'): Promise<void> => {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
logger.error(`[${context}] Failed to close DB connection`, closeErr.stack || closeErr);
}
}
};
export const fetchCursor = async <T>(cursor: oracledb.ResultSet<T>, context: string = 'UnknownService'): Promise<T[]> => {
try {
const rows = await cursor.getRows();
await cursor.close();
return rows;
} catch (err) {
logger.error(`[${context}] Failed to fetch from cursor`, err.stack || err);
throw new InternalServerErrorException('Error reading data from database.');
}
};