Compare commits
10 Commits
2c7c088adf
...
da4a75f930
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da4a75f930 | ||
|
|
a400b6842d | ||
|
|
2b8da1bafa | ||
|
|
708b731854 | ||
|
|
fd80c8213c | ||
|
|
14adadcf98 | ||
|
|
39a4ebba5f | ||
|
|
92b6401123 | ||
|
|
0f54934bb4 | ||
|
|
e0e2b540cb |
@ -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
|
||||
|
||||
###
|
||||
|
||||
|
||||
48
ormconfig.ts
48
ormconfig.ts
@ -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
31
package-lock.json
generated
@ -10,6 +10,7 @@
|
||||
"license": "UNLICENSED",
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/config": "^4.0.2",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@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": {
|
||||
"version": "11.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-11.0.10.tgz",
|
||||
@ -5947,6 +5963,21 @@
|
||||
"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": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^11.0.1",
|
||||
"@nestjs/config": "^4.0.2",
|
||||
"@nestjs/core": "^11.0.1",
|
||||
"@nestjs/platform-express": "^11.0.1",
|
||||
"@nestjs/swagger": "^11.0.6",
|
||||
|
||||
@ -4,9 +4,14 @@ import { OracleModule } from './oracle/oracle.module';
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { MssqlModule } from './mssql/mssql.module';
|
||||
import { OriginCheckMiddleware } from './middleware/OriginCheck.middleware';
|
||||
import { ReqBodyKeysToUppercaseMiddleware } from './middleware/reqBodyKeysToUppercase.middleware';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
@Module({
|
||||
imports: [MssqlModule, AuthModule, DbModule, OracleModule],
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
AuthModule, DbModule, OracleModule
|
||||
],
|
||||
controllers: [],
|
||||
providers: [],
|
||||
})
|
||||
@ -15,5 +20,18 @@ export class AppModule {
|
||||
consumer
|
||||
.apply(OriginCheckMiddleware)
|
||||
.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
20
src/db/db.config.ts
Normal 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
|
||||
},
|
||||
});
|
||||
@ -1,8 +1,10 @@
|
||||
import { MssqlConfig, OracleConfig } from 'ormconfig';
|
||||
// import { MssqlConfig, OracleConfig } from 'ormconfig';
|
||||
import { createPool, Pool, Connection as cob } from 'oracledb';
|
||||
import { Connection, ConnectionPool } from 'mssql';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { getMssqlConfig, getOracleConfig } from './db.config';
|
||||
|
||||
// @Injectable()
|
||||
// export class OracleDBService {
|
||||
@ -30,77 +32,76 @@ import { InternalServerException } from 'src/exceptions/internalServerError.exce
|
||||
@Injectable()
|
||||
export class OracleDBService {
|
||||
private pool: Pool | null = null;
|
||||
|
||||
private readonly logger = new Logger(OracleDBService.name);
|
||||
|
||||
constructor() {
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
this.initializePool().catch(err => {
|
||||
Logger.error('Error initializing Oracle DB pool', err);
|
||||
// You might want to rethrow or handle accordingly depending on app behavior
|
||||
this.logger.error('Error initializing Oracle DB pool', err);
|
||||
throw new InternalServerException();
|
||||
});
|
||||
}
|
||||
|
||||
private async initializePool(): Promise<void> {
|
||||
try {
|
||||
const config = getOracleConfig(this.configService);
|
||||
|
||||
this.pool = await createPool({
|
||||
...OracleConfig,
|
||||
...config,
|
||||
poolMin: 1,
|
||||
poolMax: 10,
|
||||
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> {
|
||||
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;
|
||||
this.logger.log('Oracle connection pool created successfully');
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Optionally add a close method to gracefully shut down the pool
|
||||
async closePool(): Promise<void> {
|
||||
if (this.pool) {
|
||||
try {
|
||||
await this.pool.close(10); // 10-second timeout
|
||||
Logger.log('Oracle DB pool closed successfully');
|
||||
await this.pool.close(10);
|
||||
this.logger.log('Oracle DB pool closed successfully');
|
||||
} catch (error) {
|
||||
Logger.error('Error closing Oracle DB pool:', error);
|
||||
throw new InternalServerException()
|
||||
this.logger.error('Error closing Oracle DB pool:', error);
|
||||
throw new InternalServerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class MssqlDBService {
|
||||
private pool: ConnectionPool;
|
||||
private poolConnected: boolean = false;
|
||||
private poolConnected = false;
|
||||
|
||||
private readonly config = {
|
||||
...MssqlConfig,
|
||||
pool: {
|
||||
max: 10,
|
||||
min: 0,
|
||||
idleTimeoutMillis: 30000,
|
||||
},
|
||||
};
|
||||
|
||||
constructor() {
|
||||
this.pool = new ConnectionPool(this.config);
|
||||
constructor(private readonly configService: ConfigService) {
|
||||
const config: any = getMssqlConfig(configService);
|
||||
this.pool = new ConnectionPool({
|
||||
...config,
|
||||
pool: {
|
||||
max: 10,
|
||||
min: 0,
|
||||
idleTimeoutMillis: 30000,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getConnection(): Promise<ConnectionPool> {
|
||||
@ -122,3 +123,4 @@ export class MssqlDBService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
294
src/dto/carnet-application/carnet-application-property.dto.ts
Normal file
294
src/dto/carnet-application/carnet-application-property.dto.ts
Normal 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;
|
||||
}
|
||||
84
src/dto/carnet-application/carnet-application.dto.ts
Normal file
84
src/dto/carnet-application/carnet-application.dto.ts
Normal 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
|
||||
) { }
|
||||
|
||||
0
src/dto/home-page/home-page-property.dto.ts
Normal file
0
src/dto/home-page/home-page-property.dto.ts
Normal file
12
src/dto/home-page/home-page.dto.ts
Normal file
12
src/dto/home-page/home-page.dto.ts
Normal 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
|
||||
) { }
|
||||
133
src/dto/manage-clients/manage-clients-property.dto.ts
Normal file
133
src/dto/manage-clients/manage-clients-property.dto.ts
Normal 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;
|
||||
}
|
||||
|
||||
109
src/dto/manage-clients/manage-clients.dto.ts
Normal file
109
src/dto/manage-clients/manage-clients.dto.ts
Normal 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
|
||||
) { }
|
||||
117
src/dto/manage-fee/manage-fee-property.dto.ts
Normal file
117
src/dto/manage-fee/manage-fee-property.dto.ts
Normal 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;
|
||||
}
|
||||
144
src/dto/manage-fee/manage-fee.dto.ts
Normal file
144
src/dto/manage-fee/manage-fee.dto.ts
Normal 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()
|
||||
// }
|
||||
121
src/dto/manage-holders/manage-holders-property.dto.ts
Normal file
121
src/dto/manage-holders/manage-holders-property.dto.ts
Normal 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;
|
||||
}
|
||||
|
||||
92
src/dto/manage-holders/manage-holders.dto.ts
Normal file
92
src/dto/manage-holders/manage-holders.dto.ts
Normal 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
|
||||
) {
|
||||
}
|
||||
80
src/dto/param-table/param-table-property.dto.ts
Normal file
80
src/dto/param-table/param-table-property.dto.ts
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
44
src/dto/param-table/param-table.dto.ts
Normal file
44
src/dto/param-table/param-table.dto.ts
Normal 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
37
src/dto/property.dto.ts
Normal 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'
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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
|
||||
) { }
|
||||
18
src/dto/uscib-managed-sp/region/region-property.dto.ts
Normal file
18
src/dto/uscib-managed-sp/region/region-property.dto.ts
Normal 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;
|
||||
}
|
||||
7
src/dto/uscib-managed-sp/region/region.dto.ts
Normal file
7
src/dto/uscib-managed-sp/region/region.dto.ts
Normal 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) { }
|
||||
@ -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;
|
||||
}
|
||||
20
src/dto/uscib-managed-sp/sp-contacts/sp-contacts.dto.ts
Normal file
20
src/dto/uscib-managed-sp/sp-contacts/sp-contacts.dto.ts
Normal 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
|
||||
) { }
|
||||
|
||||
183
src/dto/uscib-managed-sp/sp/sp-property.dto.ts
Normal file
183
src/dto/uscib-managed-sp/sp/sp-property.dto.ts
Normal 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;
|
||||
}
|
||||
21
src/dto/uscib-managed-sp/sp/sp.dto.ts
Normal file
21
src/dto/uscib-managed-sp/sp/sp.dto.ts
Normal 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
|
||||
) { }
|
||||
29
src/dto/user-maintenance/user-maintenance-property.dto.ts
Normal file
29
src/dto/user-maintenance/user-maintenance-property.dto.ts
Normal 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;
|
||||
}
|
||||
21
src/dto/user-maintenance/user-maintenance.dto.ts
Normal file
21
src/dto/user-maintenance/user-maintenance.dto.ts
Normal 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
|
||||
) { }
|
||||
17
src/main.ts
17
src/main.ts
@ -10,7 +10,7 @@ import { BadRequestException } from './exceptions/badRequest.exception';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, {
|
||||
logger:['error','warn'],
|
||||
logger: ['error', 'warn'],
|
||||
cors: {
|
||||
// origin: 'https://dev.alphaomegainfosys.com/',
|
||||
origin: '*',
|
||||
@ -20,6 +20,7 @@ async function bootstrap() {
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
function extractConstraints(validationErrors: ValidationError[]) {
|
||||
const constraints: { [key: string]: string }[] = [];
|
||||
|
||||
@ -57,7 +58,7 @@ async function bootstrap() {
|
||||
})
|
||||
.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(
|
||||
@ -82,13 +83,15 @@ async function bootstrap() {
|
||||
.addServer('http://localhost:3000', 'Development Server 1')
|
||||
.build();
|
||||
|
||||
const options: SwaggerDocumentOptions = {
|
||||
autoTagControllers: false,
|
||||
};
|
||||
const documentFactory = () =>
|
||||
SwaggerModule.createDocument(app, config, options);
|
||||
const options: SwaggerDocumentOptions = { autoTagControllers: false };
|
||||
const documentFactory = () => SwaggerModule.createDocument(app, config, options);
|
||||
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);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
30
src/middleware/reqBodyKeysToUppercase.middleware.ts
Normal file
30
src/middleware/reqBodyKeysToUppercase.middleware.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,12 @@
|
||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { ManageClientsService } from './manage-clients.service';
|
||||
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')
|
||||
export class ManageClientsController {
|
||||
@ -71,9 +76,5 @@ export class ManageClientsController {
|
||||
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
|
||||
) {
|
||||
return this.manageClientsService.GetPreparerLocByClientid(body);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
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 {
|
||||
CreateClientContactsDTO, CreateClientDataDTO,
|
||||
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
|
||||
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
|
||||
} from 'src/dto/manage-clients/manage-clients.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ManageClientsService {
|
||||
@ -10,18 +14,18 @@ export class ManageClientsService {
|
||||
|
||||
CreateClientData = async (body: CreateClientDataDTO) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_clientname: 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_revenuelocation: null,
|
||||
p_userid: null,
|
||||
P_SPID: null,
|
||||
P_CLIENTNAME: 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_REVENUELOCATION: null,
|
||||
P_USERID: null,
|
||||
p_contactstable: null,
|
||||
p_clientlocaddresstable: null,
|
||||
};
|
||||
@ -46,18 +50,18 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientname', mssql.VarChar(50), finalBody.p_clientname);
|
||||
request.input('p_lookupcode', mssql.VarChar(20), finalBody.p_lookupcode);
|
||||
request.input('p_address1', mssql.VarChar(50), finalBody.p_address1);
|
||||
request.input('p_address2', mssql.VarChar(50), finalBody.p_address2);
|
||||
request.input('p_city', mssql.VarChar(30), finalBody.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), finalBody.p_state);
|
||||
request.input('p_zip', mssql.VarChar(10), finalBody.p_zip);
|
||||
request.input('p_country', mssql.VarChar(2), finalBody.p_country);
|
||||
request.input('p_issuingregion', mssql.VarChar(2), finalBody.p_issuingregion);
|
||||
request.input('p_revenuelocation', mssql.VarChar(2), finalBody.p_revenuelocation);
|
||||
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTNAME', mssql.VarChar(50), finalBody.P_CLIENTNAME);
|
||||
request.input('P_LOOKUPCODE', mssql.VarChar(20), finalBody.P_LOOKUPCODE);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
|
||||
request.input('P_ISSUINGREGION', mssql.VarChar(2), finalBody.P_ISSUINGREGION);
|
||||
request.input('P_REVENUELOCATION', mssql.VarChar(2), finalBody.P_REVENUELOCATION);
|
||||
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
|
||||
|
||||
const contactTable = new mssql.Table('carnetsys.ContactsTable');
|
||||
contactTable.create = true;
|
||||
@ -70,19 +74,6 @@ export class ManageClientsService {
|
||||
contactTable.columns.add('MobileNo', 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);
|
||||
|
||||
const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable');
|
||||
@ -95,18 +86,6 @@ export class ManageClientsService {
|
||||
clientLocAddressTable.columns.add('Zip', mssql.VarChar(10));
|
||||
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);
|
||||
|
||||
const result = await request.execute('carnetsys.CreateClientData');
|
||||
@ -122,8 +101,8 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_clientid', mssql.Int, body.p_clientid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_CLIENTID', mssql.Int, body.P_CLIENTID);
|
||||
const result = await request.execute('carnetsys.GetPreparerbyClientID');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
@ -133,17 +112,17 @@ export class ManageClientsService {
|
||||
|
||||
UpdateClient = async (body: UpdateClientDTO) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_clientid: null,
|
||||
p_preparername: null,
|
||||
p_address1: null,
|
||||
p_address2: null,
|
||||
p_city: null,
|
||||
p_state: null,
|
||||
p_zip: null,
|
||||
p_country: null,
|
||||
p_revenuelocation: null,
|
||||
p_userid: null,
|
||||
P_SPID: null,
|
||||
P_CLIENTID: null,
|
||||
P_PREPARERNAME: null,
|
||||
P_ADDRESS1: null,
|
||||
P_ADDRESS2: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_ZIP: null,
|
||||
P_COUNTRY: null,
|
||||
P_REVENUELOCATION: null,
|
||||
P_USERID: null,
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -167,17 +146,17 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientid', mssql.Int, finalBody.p_clientid);
|
||||
request.input('p_preparername', mssql.VarChar(50), finalBody.p_preparername);
|
||||
request.input('p_address1', mssql.VarChar(50), finalBody.p_address1);
|
||||
request.input('p_address2', mssql.VarChar(50), finalBody.p_address2);
|
||||
request.input('p_city', mssql.VarChar(30), finalBody.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), finalBody.p_state);
|
||||
request.input('p_zip', mssql.VarChar(10), finalBody.p_zip);
|
||||
request.input('p_country', mssql.VarChar(2), finalBody.p_country);
|
||||
request.input('p_revenuelocation', mssql.VarChar(2), finalBody.p_revenuelocation);
|
||||
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
|
||||
request.input('P_PREPARERNAME', mssql.VarChar(50), finalBody.P_PREPARERNAME);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
|
||||
request.input('P_REVENUELOCATION', mssql.VarChar(2), finalBody.P_REVENUELOCATION);
|
||||
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
|
||||
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateClient');
|
||||
@ -190,11 +169,11 @@ export class ManageClientsService {
|
||||
|
||||
CreateClientContact = async (body: CreateClientContactsDTO) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_clientid: null,
|
||||
P_SPID: null,
|
||||
P_CLIENTID: null,
|
||||
p_contactstable: null,
|
||||
p_defcontactflag: null,
|
||||
p_userid: null,
|
||||
P_DEFCONTACTFLAG: null,
|
||||
P_USERID: null,
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -220,8 +199,8 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientid', mssql.Int, finalBody.p_clientid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
|
||||
|
||||
const contactTable = new mssql.Table('carnetsys.ContactsTable');
|
||||
contactTable.create = true;
|
||||
@ -234,23 +213,23 @@ export class ManageClientsService {
|
||||
contactTable.columns.add('MobileNo', mssql.VarChar(20));
|
||||
contactTable.columns.add('FaxNo', mssql.VarChar(20));
|
||||
|
||||
finalBody.p_contactstable.forEach((contact) => {
|
||||
finalBody.P_CONTACTSTABLE.forEach((contact) => {
|
||||
contactTable.rows.add(
|
||||
contact.FirstName,
|
||||
contact.LastName,
|
||||
contact.MiddleInitial,
|
||||
contact.Title,
|
||||
contact.EmailAddress,
|
||||
contact.PhoneNo,
|
||||
contact.MobileNo,
|
||||
contact.FaxNo,
|
||||
contact.P_FIRSTNAME,
|
||||
contact.P_LASTNAME,
|
||||
contact.P_MIDDLEINITIAL,
|
||||
contact.P_TITLE,
|
||||
contact.P_EMAILADDRESS,
|
||||
contact.P_PHONENO,
|
||||
contact.P_MOBILENO,
|
||||
contact.P_FAXNO,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
request.input('p_contactstable', contactTable);
|
||||
|
||||
request.input('p_defcontactflag', mssql.VarChar(1), finalBody.p_defcontactflag);
|
||||
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid);
|
||||
request.input('P_DEFCONTACTFLAG', mssql.VarChar(1), finalBody.P_DEFCONTACTFLAG);
|
||||
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
|
||||
|
||||
|
||||
const result = await request.execute('carnetsys.CreateClientContact');
|
||||
@ -263,17 +242,17 @@ export class ManageClientsService {
|
||||
|
||||
UpdateClientContacts = async (body: UpdateClientContactsDTO) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_clientcontactid: null,
|
||||
p_firstname: null,
|
||||
p_lastname: null,
|
||||
p_middleinitial: null,
|
||||
p_title: null,
|
||||
p_phone: null,
|
||||
p_fax: null,
|
||||
p_mobileno: null,
|
||||
p_emailaddress: null,
|
||||
p_userid: null,
|
||||
P_SPID: null,
|
||||
P_CLIENTCONTACTID: null,
|
||||
P_FIRSTNAME: null,
|
||||
P_LASTNAME: null,
|
||||
P_MIDDLEINITIAL: null,
|
||||
P_TITLE: null,
|
||||
P_PHONENO: null,
|
||||
P_FAXNO: null,
|
||||
P_MOBILENO: null,
|
||||
P_EMAILADDRESS: null,
|
||||
P_USERID: null,
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -296,17 +275,17 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientcontactid', mssql.Int, finalBody.p_clientcontactid);
|
||||
request.input('p_firstname', mssql.VarChar(50), finalBody.p_firstname);
|
||||
request.input('p_lastname', mssql.VarChar(50), finalBody.p_lastname);
|
||||
request.input('p_middleinitial', mssql.VarChar(3), finalBody.p_middleinitial);
|
||||
request.input('p_title', mssql.VarChar(50), finalBody.p_title);
|
||||
request.input('p_phone', mssql.VarChar(20), finalBody.p_phone);
|
||||
request.input('p_fax', mssql.VarChar(20), finalBody.p_fax);
|
||||
request.input('p_mobileno', mssql.VarChar(20), finalBody.p_mobileno);
|
||||
request.input('p_emailaddress', mssql.VarChar(100), finalBody.p_emailaddress);
|
||||
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTCONTACTID', mssql.Int, finalBody.P_CLIENTCONTACTID);
|
||||
request.input('P_FIRSTNAME', mssql.VarChar(50), finalBody.P_FIRSTNAME);
|
||||
request.input('P_LASTNAME', mssql.VarChar(50), finalBody.P_LASTNAME);
|
||||
request.input('P_MIDDLEINITIAL', mssql.VarChar(3), finalBody.P_MIDDLEINITIAL);
|
||||
request.input('P_TITLE', mssql.VarChar(50), finalBody.P_TITLE);
|
||||
request.input('P_PHONENO', mssql.VarChar(20), finalBody.P_PHONENO);
|
||||
request.input('P_FAXNO', mssql.VarChar(20), finalBody.P_FAXNO);
|
||||
request.input('P_MOBILENO', mssql.VarChar(20), finalBody.P_MOBILENO);
|
||||
request.input('P_EMAILADDRESS', mssql.VarChar(100), finalBody.P_EMAILADDRESS);
|
||||
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateClientContacts');
|
||||
return { data: result.recordset };
|
||||
@ -319,16 +298,16 @@ export class ManageClientsService {
|
||||
|
||||
UpdateClientLocations = async (body: UpdateClientLocationsDTO) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_clientlocationid: null,
|
||||
p_lcoationname: null,
|
||||
p_address1: null,
|
||||
p_address2: null,
|
||||
p_city: null,
|
||||
p_state: null,
|
||||
p_zip: null,
|
||||
p_country: null,
|
||||
p_userid: null,
|
||||
P_SPID: null,
|
||||
P_CLIENTLOCATIONID: null,
|
||||
P_LOCATIONNAME: null,
|
||||
P_ADDRESS1: null,
|
||||
P_ADDRESS2: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_ZIP: null,
|
||||
P_COUNTRY: null,
|
||||
P_USERID: null,
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -351,16 +330,16 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientlocationid', mssql.Int, finalBody.p_clientlocationid);
|
||||
request.input('p_lcoationname', mssql.VarChar(50), finalBody.p_lcoationname);
|
||||
request.input('p_address1', mssql.VarChar(50), finalBody.p_address1);
|
||||
request.input('p_address2', mssql.VarChar(50), finalBody.p_address2);
|
||||
request.input('p_city', mssql.VarChar(30), finalBody.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), finalBody.p_state);
|
||||
request.input('p_zip', mssql.VarChar(10), finalBody.p_zip);
|
||||
request.input('p_country', mssql.VarChar(2), finalBody.p_country);
|
||||
request.input('p_userid', mssql.VarChar(100), finalBody.p_userid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTLOCATIONID', mssql.Int, finalBody.P_CLIENTLOCATIONID);
|
||||
request.input('P_LOCATIONNAME', mssql.VarChar(50), finalBody.P_LOCATIONNAME);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
|
||||
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateClientlocations');
|
||||
return { data: result.recordset };
|
||||
@ -373,11 +352,11 @@ export class ManageClientsService {
|
||||
|
||||
CreateClientLocation = async (body: CreateClientLocationsDTO) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_clientid: null,
|
||||
P_SPID: null,
|
||||
P_CLIENTID: null,
|
||||
p_clientlocaddresstable: null,
|
||||
p_defcontactflag: null,
|
||||
p_userid: null,
|
||||
P_DEFCONTACTFLAG: null,
|
||||
P_USERID: null,
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -403,8 +382,8 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientid', mssql.Int, finalBody.p_clientid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
|
||||
|
||||
|
||||
const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable');
|
||||
@ -417,21 +396,21 @@ export class ManageClientsService {
|
||||
clientLocAddressTable.columns.add('Zip', mssql.VarChar(10));
|
||||
clientLocAddressTable.columns.add('Country', mssql.VarChar(2));
|
||||
|
||||
finalBody.p_clientlocaddresstable.forEach((contact) => {
|
||||
finalBody.P_CLIENTLOCADDRESSTABLE.forEach((contact) => {
|
||||
clientLocAddressTable.rows.add(
|
||||
contact.Nameof,
|
||||
contact.Address1,
|
||||
contact.Address2,
|
||||
contact.City,
|
||||
contact.State,
|
||||
contact.Zip,
|
||||
contact.Country,
|
||||
contact.P_NAMEOF,
|
||||
contact.P_ADDRESS1,
|
||||
contact.P_ADDRESS2,
|
||||
contact.P_CITY,
|
||||
contact.P_STATE,
|
||||
contact.P_ZIP,
|
||||
contact.P_COUNTRY,
|
||||
);
|
||||
});
|
||||
|
||||
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');
|
||||
return { data: result.recordset };
|
||||
@ -445,12 +424,12 @@ export class ManageClientsService {
|
||||
GetPreparers = async (body: GetPreparersDTO) => {
|
||||
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_name: null,
|
||||
p_lookupcode: null,
|
||||
p_city: null,
|
||||
p_state: null,
|
||||
p_status: null
|
||||
P_SPID: null,
|
||||
P_NAME: null,
|
||||
P_LOOKUPCODE: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_STATUS: null
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -476,12 +455,12 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_name', mssql.VarChar(50), finalBody.p_name);
|
||||
request.input('p_lookupcode', mssql.VarChar(30), finalBody.p_lookupcode);
|
||||
request.input('p_city', mssql.VarChar(20), finalBody.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), finalBody.p_state);
|
||||
request.input('p_status', mssql.VarChar(10), finalBody.p_status);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_NAME', mssql.VarChar(50), finalBody.P_NAME);
|
||||
request.input('P_LOOKUPCODE', mssql.VarChar(30), finalBody.P_LOOKUPCODE);
|
||||
request.input('P_CITY', mssql.VarChar(20), finalBody.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
|
||||
request.input('P_STATUS', mssql.VarChar(10), finalBody.P_STATUS);
|
||||
|
||||
const result = await request.execute('carnetsys.GetPreparers');
|
||||
return { data: result.recordset };
|
||||
@ -498,12 +477,12 @@ export class ManageClientsService {
|
||||
) => {
|
||||
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_name: null,
|
||||
p_lookupcode: null,
|
||||
p_city: null,
|
||||
p_state: null,
|
||||
p_status: null
|
||||
P_SPID: null,
|
||||
P_NAME: null,
|
||||
P_LOOKUPCODE: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_STATUS: null
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -529,8 +508,8 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientid', mssql.Int, finalBody.p_clientid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
|
||||
|
||||
const result = await request.execute('carnetsys.GetPreparerContactsbyClientID');
|
||||
return { data: result.recordset };
|
||||
@ -546,12 +525,12 @@ export class ManageClientsService {
|
||||
body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
|
||||
) => {
|
||||
const newBody = {
|
||||
p_spid: null,
|
||||
p_name: null,
|
||||
p_lookupcode: null,
|
||||
p_city: null,
|
||||
p_state: null,
|
||||
p_status: null
|
||||
P_SPID: null,
|
||||
P_NAME: null,
|
||||
P_LOOKUPCODE: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_STATUS: null
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -577,8 +556,8 @@ export class ManageClientsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientid', mssql.Int, finalBody.p_clientid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
|
||||
|
||||
const result = await request.execute('carnetsys.GetPreparerLocbyClientID');
|
||||
return { data: result.recordset };
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
|
||||
import { ManageFeeService } from './manage-fee.service';
|
||||
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/oracle/manage-fee/manage-fee.dto';
|
||||
import { 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')
|
||||
export class ManageFeeController {
|
||||
@ -17,7 +21,7 @@ export class ManageFeeController {
|
||||
@ApiTags('Manage Fee - Mssql')
|
||||
@Post('/CreateBasicFee')
|
||||
CreateBasicFee(@Body() body: CreateBasicFeeDTO) {
|
||||
return this.manageFeeService.CREATEBASICFEE(body);
|
||||
return this.manageFeeService.CREATEBASICFEE(body);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Fee - Mssql')
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/oracle/manage-fee/manage-fee.dto';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { Connection, Request } 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()
|
||||
export class ManageFeeService {
|
||||
@ -42,8 +46,8 @@ export class ManageFeeService {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_STARTCARNETVALUE', mssql.Int, body.P_STARTCARNETVALUE);
|
||||
request.input('P_ENDCARNETVALUE', mssql.Int, body.P_ENDCARNETVALUE);
|
||||
request.input('P_STARTCARNETVALUE', mssql.Int, body.P_STARTNUMBER);
|
||||
request.input('P_ENDCARNETVALUE', mssql.Int, body.P_ENDNUMBER);
|
||||
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
|
||||
request.input('P_FEES', mssql.Int, body.P_FEES);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { BadRequestException, Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/oracle/manage-holders/manage-holders.dto';
|
||||
import { ManageHoldersService } from './manage-holders.service';
|
||||
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/manage-holders/manage-holders.dto';
|
||||
|
||||
@Controller('mssql')
|
||||
export class ManageHoldersController {
|
||||
@ -29,10 +29,10 @@ export class ManageHoldersController {
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
||||
GetHolderMaster(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
) {
|
||||
const reqParams: GetHolderDTO = { p_spid, p_holderid };
|
||||
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
|
||||
|
||||
return this.manageHoldersService.GetHolderRecord(reqParams);
|
||||
}
|
||||
@ -40,81 +40,81 @@ export class ManageHoldersController {
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Get('/GetHolderContacts/:p_spid/:p_holderid')
|
||||
GetHolderContacts(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
) {
|
||||
const reqParams: GetHolderDTO = { p_spid, p_holderid };
|
||||
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
|
||||
|
||||
return this.manageHoldersService.GetHolderContacts(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Patch('/InactivateHolder/:p_spid/:p_holderid/:p_userid')
|
||||
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
|
||||
InactivateHolder(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
|
||||
if(!p_userid){
|
||||
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
|
||||
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
|
||||
|
||||
return this.manageHoldersService.InactivateHolder(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Patch('/ReactivateHolder/:p_spid/:p_holderid/:p_userid')
|
||||
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
|
||||
ReactivateHolder(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
if(!p_userid){
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
|
||||
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
|
||||
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
|
||||
|
||||
return this.manageHoldersService.ReactivateHolder(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Patch('/InactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
|
||||
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
|
||||
InactivateHolderContact(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
if(!p_userid){
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
|
||||
const reqParams: HolderContactActivateOrInactivateDTO = {
|
||||
p_spid,
|
||||
p_holderContactid,
|
||||
p_userid
|
||||
P_SPID,
|
||||
P_HOLDERCONTACTID,
|
||||
P_USERID
|
||||
};
|
||||
|
||||
return this.manageHoldersService.InactivateHolderContact(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Mssql')
|
||||
@Patch('/ReactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
|
||||
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
|
||||
ReactivateHolderContact(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
if(!p_userid){
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
|
||||
const reqParams: HolderContactActivateOrInactivateDTO = {
|
||||
p_spid,
|
||||
p_holderContactid,
|
||||
p_userid
|
||||
P_SPID,
|
||||
P_HOLDERCONTACTID,
|
||||
P_USERID
|
||||
};
|
||||
|
||||
return this.manageHoldersService.ReactivateHolderContact(reqParams);
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/oracle/manage-holders/manage-holders.dto';
|
||||
import * as mssql from 'mssql';
|
||||
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/manage-holders/manage-holders.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ManageHoldersService {
|
||||
@ -49,22 +49,23 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, finalBody.p_spid);
|
||||
request.input('p_clientlocationid', mssql.Int, finalBody.p_clientlocationid);
|
||||
request.input('p_holderno', mssql.VarChar(15), finalBody.p_holderno);
|
||||
request.input('p_holdertype', mssql.VarChar(3), finalBody.p_holdertype);
|
||||
request.input('p_uscibmemberflag', mssql.VarChar(1), finalBody.p_uscibmemberflag);
|
||||
request.input('p_govagencyflag', mssql.VarChar(1), finalBody.p_govagencyflag);
|
||||
request.input('p_holdername', mssql.VarChar(50), finalBody.p_holdername);
|
||||
request.input('p_namequalifier', mssql.VarChar(10), finalBody.p_namequalifier);
|
||||
request.input('p_addlname', mssql.VarChar(50), finalBody.p_addlname);
|
||||
request.input('p_address1', mssql.VarChar(50), finalBody.p_address1);
|
||||
request.input('p_address2', mssql.VarChar(50), finalBody.p_address2);
|
||||
request.input('p_city', mssql.VarChar(30), finalBody.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), finalBody.p_state);
|
||||
request.input('p_zip', mssql.VarChar(10), finalBody.p_zip);
|
||||
request.input('p_country', mssql.VarChar(2), finalBody.p_country);
|
||||
request.input('p_userid', mssql.VarChar(50), finalBody.p_userid);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_CLIENTLOCATIONID', mssql.Int, finalBody.P_CLIENTLOCATIONID);
|
||||
request.input('P_HOLDERNO', mssql.VarChar(15), finalBody.P_HOLDERNO);
|
||||
request.input('P_HOLDERTYPE', mssql.VarChar(3), finalBody.P_HOLDERTYPE);
|
||||
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(1), finalBody.P_USCIBMEMBERFLAG);
|
||||
request.input('P_GOVAGENCYFLAG', mssql.VarChar(1), finalBody.P_GOVAGENCYFLAG);
|
||||
request.input('P_HOLDERNAME', mssql.VarChar(50), finalBody.P_HOLDERNAME);
|
||||
request.input('P_NAMEQUALIFIER', mssql.VarChar(10), finalBody.P_NAMEQUALIFIER);
|
||||
request.input('P_ADDLNAME', mssql.VarChar(50), finalBody.P_ADDLNAME);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
|
||||
request.input('P_USERID', mssql.VarChar(50), finalBody.P_USERID);
|
||||
|
||||
|
||||
const contactTable = new mssql.Table('carnetsys.ContactsTable');
|
||||
contactTable.create = true;
|
||||
@ -77,16 +78,16 @@ export class ManageHoldersService {
|
||||
contactTable.columns.add('MobileNo', mssql.VarChar(20));
|
||||
contactTable.columns.add('FaxNo', mssql.VarChar(20));
|
||||
|
||||
finalBody.p_contactstable && finalBody.p_contactstable.forEach((contact) => {
|
||||
finalBody.P_CONTACTSTABLE && finalBody.P_CONTACTSTABLE.forEach((contact) => {
|
||||
contactTable.rows.add(
|
||||
contact.FirstName,
|
||||
contact.LastName,
|
||||
contact.MiddleInitial,
|
||||
contact.Title,
|
||||
contact.EmailAddress,
|
||||
contact.PhoneNo,
|
||||
contact.MobileNo,
|
||||
contact.FaxNo,
|
||||
contact.P_FIRSTNAME,
|
||||
contact.P_LASTNAME,
|
||||
contact.P_MIDDLEINITIAL,
|
||||
contact.P_TITLE,
|
||||
contact.P_EMAILADDRESS,
|
||||
contact.P_PHONENO,
|
||||
contact.P_MOBILENO,
|
||||
contact.P_FAXNO,
|
||||
);
|
||||
});
|
||||
|
||||
@ -97,7 +98,7 @@ export class ManageHoldersService {
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@ -106,15 +107,15 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
|
||||
|
||||
const result = await request.execute('carnetsys.GetHolderMaster');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UpdateHolder = async (body: UpdateHolderDTO) => {
|
||||
@ -123,30 +124,31 @@ export class ManageHoldersService {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new mssql.Request(connection);
|
||||
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_locationid', mssql.Int, body.p_locationid);
|
||||
request.input('p_holderno', mssql.VarChar(15), body.p_holderno);
|
||||
request.input('p_holdertype', mssql.VarChar(3), body.p_holdertype);
|
||||
request.input('p_uscibmemberflag', mssql.VarChar(1), body.p_uscibmemberflag);
|
||||
request.input('p_govagencyflag', mssql.VarChar(1), body.p_govagencyflag);
|
||||
request.input('p_holdername', mssql.VarChar(50), body.p_holdername);
|
||||
request.input('p_namequalifier', mssql.VarChar(10), body.p_namequalifier);
|
||||
request.input('p_addlname', mssql.VarChar(50), body.p_addlname);
|
||||
request.input('p_address1', mssql.VarChar(50), body.p_address1);
|
||||
request.input('p_address2', mssql.VarChar(50), body.p_address2);
|
||||
request.input('p_city', mssql.VarChar(30), body.p_city);
|
||||
request.input('p_state', mssql.VarChar(2), body.p_state);
|
||||
request.input('p_zip', mssql.VarChar(10), body.p_zip);
|
||||
request.input('p_country', mssql.VarChar(2), body.p_country);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_LOCATIONID', mssql.Int, body.P_LOCATIONID);
|
||||
request.input('P_HOLDERNO', mssql.VarChar(15), body.P_HOLDERNO);
|
||||
request.input('P_HOLDERTYPE', mssql.VarChar(3), body.P_HOLDERTYPE);
|
||||
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(1), body.P_USCIBMEMBERFLAG);
|
||||
request.input('P_GOVAGENCYFLAG', mssql.VarChar(1), body.P_GOVAGENCYFLAG);
|
||||
request.input('P_HOLDERNAME', mssql.VarChar(50), body.P_HOLDERNAME);
|
||||
request.input('P_NAMEQUALIFIER', mssql.VarChar(10), body.P_NAMEQUALIFIER);
|
||||
request.input('P_ADDLNAME', mssql.VarChar(50), body.P_ADDLNAME);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(50), body.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(50), body.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(30), body.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(2), body.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(10), body.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(2), body.P_COUNTRY);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateHolders');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
UpdateHolderContact = async (body: UpdateHolderContactDTO) => {
|
||||
@ -156,17 +158,17 @@ export class ManageHoldersService {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new mssql.Request(connection);
|
||||
|
||||
request.input('p_holdercontactid', mssql.Int, body.p_holdercontactid);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_firstname', mssql.VarChar(50), body.p_firstname);
|
||||
request.input('p_lastname', mssql.VarChar(50), body.p_lastname);
|
||||
request.input('p_middleinitial', mssql.VarChar(3), body.p_middleinitial);
|
||||
request.input('p_title', mssql.VarChar(50), body.p_title);
|
||||
request.input('p_phone', mssql.VarChar(20), body.p_phone);
|
||||
request.input('p_mobile', mssql.VarChar(20), body.p_mobile);
|
||||
request.input('p_fax', mssql.VarChar(20), body.p_fax);
|
||||
request.input('p_emailaddress', mssql.VarChar(100), body.p_emailaddress);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_FIRSTNAME', mssql.VarChar(50), body.P_FIRSTNAME);
|
||||
request.input('P_LASTNAME', mssql.VarChar(50), body.P_LASTNAME);
|
||||
request.input('P_MIDDLEINITIAL', mssql.VarChar(3), body.P_MIDDLEINITIAL);
|
||||
request.input('P_TITLE', mssql.VarChar(50), body.P_TITLE);
|
||||
request.input('P_PHONENO', mssql.VarChar(20), body.P_PHONENO);
|
||||
request.input('P_MOBILENO', mssql.VarChar(20), body.P_MOBILENO);
|
||||
request.input('P_FAXNO', mssql.VarChar(20), body.P_FAXNO);
|
||||
request.input('P_EMAILADDRESS', mssql.VarChar(100), body.P_EMAILADDRESS);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
|
||||
|
||||
const result = await request.execute('carnetsys.UpdateHolderContacts');
|
||||
@ -174,7 +176,7 @@ export class ManageHoldersService {
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
GetHolderContacts = async (body: GetHolderDTO) => {
|
||||
@ -183,15 +185,15 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
|
||||
|
||||
const result = await request.execute('carnetsys.GetHolderContacts');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
InactivateHolder = async (body: HolderActivateOrInactivateDTO) => {
|
||||
@ -202,15 +204,15 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.InactivateHolder');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ReactivateHolder = async (body: HolderActivateOrInactivateDTO) => {
|
||||
@ -218,16 +220,16 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderid', mssql.Int, body.p_holderid);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
|
||||
const result = await request.execute('carnetsys.ReactivateHolder');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
InactivateHolderContact = async (body: HolderContactActivateOrInactivateDTO) => {
|
||||
@ -235,16 +237,16 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderContactid', mssql.Int, body.p_holderContactid);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
|
||||
const result = await request.execute('carnetsys.InactivateHolderContact');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ReactivateHolderContact = async (body: HolderContactActivateOrInactivateDTO) => {
|
||||
@ -252,15 +254,15 @@ export class ManageHoldersService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request: Request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.p_spid);
|
||||
request.input('p_holderContactid', mssql.Int, body.p_holderContactid);
|
||||
request.input('p_userid', mssql.VarChar(100), body.p_userid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
|
||||
const result = await request.execute('carnetsys.ReactivateHolderContact');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,17 +1,11 @@
|
||||
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { ParamTableService } from './param-table.service';
|
||||
import {
|
||||
ActivateOrInactivateParamRecordDTO,
|
||||
CreateParamRecordDTO,
|
||||
CreateTableRecordDTO,
|
||||
getParamValuesDTO,
|
||||
UpdateParamRecordDTO,
|
||||
} from '../../oracle/param-table/param-table.dto';
|
||||
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
|
||||
|
||||
@Controller('mssql')
|
||||
export class ParamTableController {
|
||||
constructor(private readonly paramTableService: ParamTableService) {}
|
||||
constructor(private readonly paramTableService: ParamTableService) { }
|
||||
|
||||
@ApiTags('Param Table - Mssql')
|
||||
@Get('/GetParamValues')
|
||||
|
||||
@ -2,16 +2,10 @@ import { Injectable } from '@nestjs/common';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import * as mssql from 'mssql';
|
||||
import { Request } from 'mssql';
|
||||
import {
|
||||
ActivateOrInactivateParamRecordDTO,
|
||||
CreateParamRecordDTO,
|
||||
CreateTableRecordDTO,
|
||||
getParamValuesDTO,
|
||||
UpdateParamRecordDTO,
|
||||
} from '../../oracle/param-table/param-table.dto';
|
||||
import { Connection } from 'mssql';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
|
||||
|
||||
@Injectable()
|
||||
export class ParamTableService {
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||
import { CarnetSequenceService } from './carnet-sequence.service';
|
||||
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')
|
||||
export class CarnetSequenceController {
|
||||
|
||||
constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
|
||||
|
||||
@ApiTags('Carnet Sequence - Mssql')
|
||||
|
||||
@Get('/GetCarnetSequence')
|
||||
getCarnetSequence(@Query() body: GetCarnetSequenceDTO) {
|
||||
getCarnetSequence(@Query() body: SPID_DTO) {
|
||||
return this.carnetSequenceService.getCarnetSequence(body);
|
||||
}
|
||||
|
||||
@ApiTags('Carnet Sequence - Mssql')
|
||||
@Post('/CreateCarnetSequence/')
|
||||
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
|
||||
return this.carnetSequenceService.createCarnetSequence(body);
|
||||
|
||||
@ -2,20 +2,21 @@ import { Injectable } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
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()
|
||||
export class CarnetSequenceService {
|
||||
|
||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||
|
||||
async getCarnetSequence(body: GetCarnetSequenceDTO) {
|
||||
async getCarnetSequence(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
const result = await request.execute('carnetsys.GETCARNETSEQUENCE');
|
||||
return { data: result.recordset };
|
||||
|
||||
@ -29,11 +30,11 @@ export class CarnetSequenceService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||
request.input('P_REGIONID', mssql.Float, body.p_regionid);
|
||||
request.input('P_STARTNUMBER', mssql.Int, body.p_startnumber);
|
||||
request.input('P_ENDNUMBER', mssql.Int, body.p_endnumber);
|
||||
request.input('P_CARNETTYPE', mssql.VarChar(4000), body.p_carnettype);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_REGIONID', mssql.Float, body.P_REGIONID);
|
||||
request.input('P_STARTNUMBER', mssql.Int, body.P_STARTNUMBER);
|
||||
request.input('P_ENDNUMBER', mssql.Int, body.P_ENDNUMBER);
|
||||
request.input('P_CARNETTYPE', mssql.VarChar(4000), body.P_CARNETTYPE);
|
||||
const result = await request.execute('carnetsys.CREATECARNETSEQUENCE');
|
||||
return { data: result.recordset };
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Body, Controller, Get, Patch, Post } from '@nestjs/common';
|
||||
import { ApiInternalServerErrorResponse, ApiOkResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||
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')
|
||||
export class RegionController {
|
||||
@ -10,10 +10,6 @@ export class RegionController {
|
||||
|
||||
@ApiTags('Regions - Mssql')
|
||||
@ApiOperation({ summary: 'Get all regions for issuing and replacement.' })
|
||||
@ApiOkResponse({
|
||||
description: 'User retrieved successfully',
|
||||
type: RegionDto,
|
||||
})
|
||||
@ApiInternalServerErrorResponse({ description: 'Server error' })
|
||||
@Get('/GetRegions')
|
||||
getRegions() {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Injectable, InternalServerErrorException } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
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 { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
|
||||
@ -28,13 +28,13 @@ export class RegionService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
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_REGION', mssql.VarChar(mssql.MAX), body.P_REGION);
|
||||
request.input('P_NAME', mssql.VarChar(mssql.MAX), body.P_NAME);
|
||||
const result = await request.execute('carnetsys.INSERTNEWREGION');
|
||||
return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] };
|
||||
|
||||
} catch (error) {
|
||||
throw new InternalServerException();
|
||||
} catch (error) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,13 +43,13 @@ export class RegionService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_regionID', mssql.Int, body.p_regionID);
|
||||
request.input('P_NAME', mssql.VarChar(mssql.MAX), body.p_name);
|
||||
request.input('p_regionID', mssql.Int, body.P_REGIONID);
|
||||
request.input('P_NAME', mssql.VarChar(mssql.MAX), body.P_NAME);
|
||||
const result = await request.execute('carnetsys.UpdateRegion');
|
||||
return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] };
|
||||
|
||||
} catch (error) {
|
||||
throw new InternalServerException();
|
||||
throw new InternalServerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { SpContactsService } from './sp-contacts.service';
|
||||
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')
|
||||
export class SpContactsController {
|
||||
@ -11,19 +16,19 @@ export class SpContactsController {
|
||||
|
||||
@ApiTags('SPContacts - Mssql')
|
||||
@Post('/InactivateSPContact')
|
||||
inactivateSPContact(@Query() body: inactivateSPContactDTO) {
|
||||
inactivateSPContact(@Query() body: SP_CONTACTID_DTO) {
|
||||
return this.spContactsService.inactivateSPContact(body);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Mssql')
|
||||
@Get('/GetSPDefaultContact')
|
||||
getSPDefaultcontact(@Query() body: getSPDefaultcontactDTO) {
|
||||
getSPDefaultcontact(@Query() body: SPID_DTO) {
|
||||
return this.spContactsService.getSPDefaultcontacts(body);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Mssql')
|
||||
@Get('/GetSPAllContacts')
|
||||
getSPAllContacts(@Query() body: getSPAllContactsDTO) {
|
||||
getSPAllContacts(@Query() body: SPID_DTO) {
|
||||
return this.spContactsService.getSpAllContacts(body);
|
||||
}
|
||||
|
||||
@ -35,7 +40,7 @@ export class SpContactsController {
|
||||
|
||||
@ApiTags('SPContacts - Mssql')
|
||||
@Post('/SetSPDefaultContact')
|
||||
setSPDefaultcontact(@Query() body: setSPDefaultcontactDTO) {
|
||||
setSPDefaultcontact(@Query() body: SP_CONTACTID_DTO) {
|
||||
return this.spContactsService.setSPDefaultcontact(body);
|
||||
}
|
||||
|
||||
|
||||
@ -2,56 +2,60 @@ import { Injectable } from '@nestjs/common';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import * as mssql 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()
|
||||
export class SpContactsService {
|
||||
|
||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||
|
||||
async getSpAllContacts(body: getSPAllContactsDTO) {
|
||||
async getSpAllContacts(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_SPid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
const result = await request.execute('carnetsys.GETSPALLCONTACTS');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getSPDefaultcontacts(body: getSPDefaultcontactDTO) {
|
||||
async getSPDefaultcontacts(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_SPid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
const result = await request.execute('carnetsys.GETSPDEFAULTCONTACTS');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async inactivateSPContact(body: inactivateSPContactDTO) {
|
||||
async inactivateSPContact(body: SP_CONTACTID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPCONTACTID', mssql.Int, body.p_spcontactid);
|
||||
request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
|
||||
const result = await request.execute('carnetsys.INACTIVATESPCONTACTS');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async insertSPContacts(body: InsertSPContactsDTO) {
|
||||
@ -59,37 +63,37 @@ export class SpContactsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||
request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.p_defcontactflag);
|
||||
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname);
|
||||
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.P_DEFCONTACTFLAG);
|
||||
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
|
||||
request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
|
||||
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
|
||||
request.input('P_TITLE', mssql.VarChar(4000), body.p_title);
|
||||
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno);
|
||||
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno);
|
||||
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno);
|
||||
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||
request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
|
||||
request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
|
||||
request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
|
||||
request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
|
||||
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.P_EMAILADDRESS);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
|
||||
const result = await request.execute('carnetsys.INSERTSPCONTACTS');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async setSPDefaultcontact(body: setSPDefaultcontactDTO) {
|
||||
async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spContactid', mssql.Int, body.p_spcontactid);
|
||||
request.input('p_spContactid', mssql.Int, body.P_SPCONTACTID);
|
||||
const result = await request.execute('carnetsys.SETDEFAULTCONTACT');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async updateSPContacts(body: UpdateSPContactsDTO) {
|
||||
@ -97,21 +101,21 @@ export class SpContactsService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPCONTACTID', mssql.Int, body.p_spcontactid);
|
||||
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname);
|
||||
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname);
|
||||
request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
|
||||
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
|
||||
request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
|
||||
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
|
||||
request.input('P_TITLE', mssql.VarChar(4000), body.p_title);
|
||||
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno);
|
||||
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno);
|
||||
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno);
|
||||
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||
request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
|
||||
request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
|
||||
request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
|
||||
request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
|
||||
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.P_EMAILADDRESS);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
|
||||
const result = await request.execute('carnetsys.UPDATESPCONTACTS');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
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')
|
||||
export class SpController {
|
||||
@ -16,7 +17,7 @@ export class SpController {
|
||||
|
||||
@ApiTags('SP - Mssql')
|
||||
@Get('/GetSelectedServiceprovider')
|
||||
getSelectedServiceprovider(@Query() body: getSelectedServiceproviderDTO) {
|
||||
getSelectedServiceprovider(@Query() body: SPID_DTO) {
|
||||
return this.spService.getSpBySpid(body);
|
||||
}
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Connection, Request } from 'mssql';
|
||||
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 { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
|
||||
|
||||
@Injectable()
|
||||
export class SpService {
|
||||
@ -20,22 +21,22 @@ export class SpService {
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getSpBySpid(body: getSelectedServiceproviderDTO) {
|
||||
async getSpBySpid(body: SPID_DTO) {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
const result = await request.execute('carnetsys.GETSPBYSPID');
|
||||
return { data: result.recordset };
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async insertNewServiceProvider(body: InsertNewServiceProviderDTO) {
|
||||
@ -43,20 +44,20 @@ export class SpService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_NAME', mssql.VarChar(4000), body.p_name);
|
||||
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.p_lookupcode);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(4000), body.p_address1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(4000), body.p_address2);
|
||||
request.input('P_CITY', mssql.VarChar(4000), body.p_city);
|
||||
request.input('P_STATE', mssql.VarChar(4000), body.p_state);
|
||||
request.input('P_ZIP', mssql.VarChar(4000), body.p_zip);
|
||||
request.input('P_COUNTRY', mssql.VarChar(4000), body.p_country);
|
||||
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.p_issuingregion);
|
||||
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.p_replacementregion);
|
||||
request.input('P_BONDSURETY', mssql.VarChar(4000), body.p_bondsurety);
|
||||
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.p_cargopolicyno);
|
||||
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.p_cargosurety);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||
request.input('P_NAME', mssql.VarChar(4000), body.P_NAME);
|
||||
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.P_LOOKUPCODE);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(4000), body.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(4000), body.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(4000), body.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(4000), body.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(4000), body.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(4000), body.P_COUNTRY);
|
||||
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.P_ISSUINGREGION);
|
||||
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.P_REPLACEMENTREGION);
|
||||
request.input('P_BONDSURETY', mssql.VarChar(4000), body.P_BONDSURETY);
|
||||
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.P_CARGOPOLICYNO);
|
||||
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.P_CARGOSURETY);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
|
||||
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
|
||||
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
|
||||
const result = await request.execute('carnetsys.INSERTNEWSP');
|
||||
@ -64,7 +65,7 @@ export class SpService {
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async updateServiceProvider(body: UpdateServiceProviderDTO) {
|
||||
@ -72,21 +73,21 @@ export class SpService {
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||
request.input('P_NAME', mssql.VarChar(4000), body.p_name);
|
||||
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.p_lookupcode);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(4000), body.p_address1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(4000), body.p_address2);
|
||||
request.input('P_CITY', mssql.VarChar(4000), body.p_city);
|
||||
request.input('P_STATE', mssql.VarChar(4000), body.p_state);
|
||||
request.input('P_ZIP', mssql.VarChar(4000), body.p_zip);
|
||||
request.input('P_COUNTRY', mssql.VarChar(4000), body.p_country);
|
||||
request.input('P_BONDSURETY', mssql.VarChar(4000), body.p_bondsurety);
|
||||
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.p_cargopolicyno);
|
||||
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.p_cargosurety);
|
||||
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.p_replacementregion);
|
||||
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.p_issuingregion);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_NAME', mssql.VarChar(4000), body.P_NAME);
|
||||
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.P_LOOKUPCODE);
|
||||
request.input('P_ADDRESS1', mssql.VarChar(4000), body.P_ADDRESS1);
|
||||
request.input('P_ADDRESS2', mssql.VarChar(4000), body.P_ADDRESS2);
|
||||
request.input('P_CITY', mssql.VarChar(4000), body.P_CITY);
|
||||
request.input('P_STATE', mssql.VarChar(4000), body.P_STATE);
|
||||
request.input('P_ZIP', mssql.VarChar(4000), body.P_ZIP);
|
||||
request.input('P_COUNTRY', mssql.VarChar(4000), body.P_COUNTRY);
|
||||
request.input('P_BONDSURETY', mssql.VarChar(4000), body.P_BONDSURETY);
|
||||
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.P_CARGOPOLICYNO);
|
||||
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.P_CARGOSURETY);
|
||||
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.P_REPLACEMENTREGION);
|
||||
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.P_ISSUINGREGION);
|
||||
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
|
||||
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
|
||||
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
|
||||
const result = await request.execute('carnetsys.UPDATESP');
|
||||
@ -94,6 +95,6 @@ export class SpService {
|
||||
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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 {}
|
||||
705
src/oracle/carnet-application/carnet-application.service.ts
Normal file
705
src/oracle/carnet-application/carnet-application.service.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,81 +1,51 @@
|
||||
import {
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Param,
|
||||
Controller,
|
||||
ParseIntPipe,
|
||||
BadRequestException,
|
||||
} from '@nestjs/common';
|
||||
|
||||
import { HomePageService } from './home-page.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import {
|
||||
SaveCarnetApplicationDTO,
|
||||
TransmitApplicationtoProcessDTO,
|
||||
EMAIL_DTO,
|
||||
GetCarnetDetailsbyCarnetStatusDTO,
|
||||
} from './home-page.dto';
|
||||
SPID_DTO,
|
||||
USERID_DTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Controller()
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@Controller('oracle')
|
||||
export class HomePageController {
|
||||
constructor(private readonly homePageService: HomePageService) {}
|
||||
constructor(private readonly homePageService: HomePageService) { }
|
||||
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@Get('/oracle/GetHomePageData/:id')
|
||||
GetHomePageData(@Param('id', ParseIntPipe) id: number) {
|
||||
return this.homePageService.GetHomePageData(id);
|
||||
|
||||
@Get('GetHomePageData/:P_SPID')
|
||||
GetHomePageData(@Param() params: SPID_DTO) {
|
||||
return this.homePageService.GetHomePageData(params);
|
||||
}
|
||||
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@Get('/oracle/GetCarnetSummaryData/:userid')
|
||||
GetCarnetSummaryData(@Param('userid') id: string) {
|
||||
return this.homePageService.GetCarnetSummaryData(id);
|
||||
@Get('GetCarnetSummaryData/:P_USERID')
|
||||
GetCarnetSummaryData(@Param() params: USERID_DTO) {
|
||||
return this.homePageService.GetCarnetSummaryData(params);
|
||||
}
|
||||
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@Get(
|
||||
'/oracle/GetCarnetDetailsbyCarnetStatus/:p_spid/:p_userid/:p_CarnetStatus',
|
||||
)
|
||||
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,
|
||||
});
|
||||
}
|
||||
@Get('GetCarnetDetailsbyCarnetStatus/:P_SPID/:P_USERID/:P_CARNETSTATUS')
|
||||
GetCarnetDetailsbyCarnetStatus(@Param() params: GetCarnetDetailsbyCarnetStatusDTO) {
|
||||
return this.homePageService.GetCarnetDetailsbyCarnetStatus(params);
|
||||
}
|
||||
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@Post('/oracle/SaveCarnetApplication')
|
||||
SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
|
||||
return this.homePageService.SaveCarnetApplication(body);
|
||||
}
|
||||
// NOTE : this has been moved to carent-application module
|
||||
|
||||
@ApiTags('HomePage - Oracle')
|
||||
@Post('/oracle/TransmitApplicationtoProcess')
|
||||
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
|
||||
return this.homePageService.TransmitApplicationtoProcess(body);
|
||||
}
|
||||
// @Post('/oracle/SaveCarnetApplication')
|
||||
// SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
|
||||
// return this.homePageService.SaveCarnetApplication(body);
|
||||
// }
|
||||
|
||||
// NOTE : this has been moved to carent-application module
|
||||
|
||||
// @Post('/oracle/TransmitApplicationtoProcess')
|
||||
// TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
|
||||
// return this.homePageService.TransmitApplicationtoProcess(body);
|
||||
// }
|
||||
}
|
||||
|
||||
@ -13,351 +13,351 @@ import {
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
|
||||
export class p_gltableDTO {
|
||||
@ApiProperty({ required: true })
|
||||
@Max(999999999, { message: 'Property ItemNo must not exceed 999999999' })
|
||||
@Min(0, { message: 'Property ItemNo must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property ItemNo must be a number' })
|
||||
@IsDefined({ message: 'Property ItemNo is required' })
|
||||
ItemNo: number;
|
||||
// export class p_gltableDTO {
|
||||
// @ApiProperty({ required: true })
|
||||
// @Max(999999999, { message: 'Property ItemNo must not exceed 999999999' })
|
||||
// @Min(0, { message: 'Property ItemNo must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property ItemNo must be a number' })
|
||||
// @IsDefined({ message: 'Property ItemNo is required' })
|
||||
// ItemNo: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Length(0, 1000, {
|
||||
message: 'Property ItemDescription must be between 1 and 1000 characters',
|
||||
})
|
||||
@IsString({ message: 'Property ItemDescription should be string' })
|
||||
@IsDefined({ message: 'Property ItemDescription is required' })
|
||||
ItemDescription: string;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 1000, {
|
||||
// message: 'Property ItemDescription must be between 1 and 1000 characters',
|
||||
// })
|
||||
// @IsString({ message: 'Property ItemDescription should be string' })
|
||||
// @IsDefined({ message: 'Property ItemDescription is required' })
|
||||
// ItemDescription: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@IsNumber({}, { message: 'Property ItemValue should be number' })
|
||||
@IsDefined({ message: 'Property ItemValue is required' })
|
||||
ItemValue: number;
|
||||
// @ApiProperty({ required: true })
|
||||
// @IsNumber({}, { message: 'Property ItemValue should be number' })
|
||||
// @IsDefined({ message: 'Property ItemValue is required' })
|
||||
// ItemValue: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Max(99999999999, {
|
||||
message: 'Property Noofpieces must not exceed 99999999999',
|
||||
})
|
||||
@Min(0, { message: 'Property Noofpieces must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property Noofpieces must be a number' })
|
||||
@IsDefined({ message: 'Property Noofpieces is required' })
|
||||
Noofpieces: number;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Max(99999999999, {
|
||||
// message: 'Property Noofpieces must not exceed 99999999999',
|
||||
// })
|
||||
// @Min(0, { message: 'Property Noofpieces must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property Noofpieces must be a number' })
|
||||
// @IsDefined({ message: 'Property Noofpieces is required' })
|
||||
// Noofpieces: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
ItemWeight?: number;
|
||||
// @ApiProperty({ required: false })
|
||||
// @IsNumber()
|
||||
// @IsOptional()
|
||||
// ItemWeight?: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property ItemWeightUOM must be between 0 and 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
ItemWeightUOM?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property ItemWeightUOM must be between 0 and 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// ItemWeightUOM?: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Length(0, 2, {
|
||||
message: 'Property GoodsOriginCountry must be between 0 and 2 characters',
|
||||
})
|
||||
@IsString({ message: 'Property GoodsOriginCountry should be string' })
|
||||
@IsDefined({ message: 'Property name is required' })
|
||||
GoodsOriginCountry: string;
|
||||
}
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 2, {
|
||||
// message: 'Property GoodsOriginCountry must be between 0 and 2 characters',
|
||||
// })
|
||||
// @IsString({ message: 'Property GoodsOriginCountry should be string' })
|
||||
// @IsDefined({ message: 'Property name is required' })
|
||||
// GoodsOriginCountry: string;
|
||||
// }
|
||||
|
||||
export class p_countrytableDTO {
|
||||
@ApiProperty({ required: true })
|
||||
@Length(0, 1, {
|
||||
message: 'Property VisitTransitInd must be 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsDefined({ message: 'Property VisitTransitInd is required' })
|
||||
VisitTransitInd: string;
|
||||
// export class p_countrytableDTO {
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 1, {
|
||||
// message: 'Property VisitTransitInd must be 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsDefined({ message: 'Property VisitTransitInd is required' })
|
||||
// VisitTransitInd: string;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Length(0, 2, {
|
||||
message: 'Property CountryCode must be between 0 to 2 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsDefined({ message: 'Property CountryCode is required' })
|
||||
CountryCode: string;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 2, {
|
||||
// message: 'Property CountryCode must be between 0 to 2 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @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()
|
||||
@IsNumber({}, { message: 'Property NoOfTimesEntLeave must be a number' })
|
||||
@IsDefined({ message: 'Property NoOfTimesEntLeave is required' })
|
||||
NoOfTimesEntLeave: number;
|
||||
}
|
||||
// @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()
|
||||
// @IsNumber({}, { message: 'Property NoOfTimesEntLeave must be a number' })
|
||||
// @IsDefined({ message: 'Property NoOfTimesEntLeave is required' })
|
||||
// NoOfTimesEntLeave: number;
|
||||
// }
|
||||
|
||||
export class SaveCarnetApplicationDTO {
|
||||
@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()
|
||||
@IsNumber({}, { message: 'Property p_spid must be a number' })
|
||||
p_spid: number;
|
||||
// export class SaveCarnetApplicationDTO {
|
||||
// @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()
|
||||
// @IsNumber({}, { message: 'Property p_spid must be a number' })
|
||||
// p_spid: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
|
||||
@Min(0, { message: 'Property p_clientid must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property p_clientid must be a number' })
|
||||
p_clientid: number;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
|
||||
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
|
||||
// p_clientid: 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()
|
||||
@IsNumber({}, { message: 'Property p_locationid must be a number' })
|
||||
p_locationid: 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()
|
||||
// @IsNumber({}, { message: 'Property p_locationid must be a number' })
|
||||
// p_locationid: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Length(0, 50, {
|
||||
message: 'Property p_userid must be between 0 to 50 characters',
|
||||
})
|
||||
@IsString()
|
||||
p_userid: string;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 50, {
|
||||
// message: 'Property p_userid must be between 0 to 50 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// p_userid: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Max(999999999, { message: 'Property p_headerid must not exceed 999999999' })
|
||||
@Min(0, { message: 'Property p_headerid must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property p_headerid must be a number' })
|
||||
@IsOptional()
|
||||
p_headerid?: number;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Max(999999999, { message: 'Property p_headerid must not exceed 999999999' })
|
||||
// @Min(0, { message: 'Property p_headerid must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property p_headerid must be a number' })
|
||||
// @IsOptional()
|
||||
// p_headerid?: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Length(0, 50, {
|
||||
message: 'Property p_applicationname must be between 0 to 50 characters',
|
||||
})
|
||||
@IsString()
|
||||
p_applicationname: string;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 50, {
|
||||
// message: 'Property p_applicationname must be between 0 to 50 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// p_applicationname: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Max(999999999, { message: 'Property p_holderid must not exceed 999999999' })
|
||||
@Min(0, { message: 'Property p_holderid must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property p_holderid must be a number' })
|
||||
@IsOptional()
|
||||
p_holderid?: number;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Max(999999999, { message: 'Property p_holderid must not exceed 999999999' })
|
||||
// @Min(0, { message: 'Property p_holderid must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property p_holderid must be a number' })
|
||||
// @IsOptional()
|
||||
// p_holderid?: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 1, {
|
||||
message:
|
||||
'Property p_commercialsampleflag must be between 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_commercialsampleflag?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 1, {
|
||||
// message:
|
||||
// 'Property p_commercialsampleflag must be between 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_commercialsampleflag?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 1, {
|
||||
message: 'Property p_profequipmentflag must be between 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_profequipmentflag?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 1, {
|
||||
// message: 'Property p_profequipmentflag must be between 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_profequipmentflag?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 1, {
|
||||
message: 'Property p_exhibitionsfairflag must be between 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_exhibitionsfairflag?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 1, {
|
||||
// message: 'Property p_exhibitionsfairflag must be between 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_exhibitionsfairflag?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 1, {
|
||||
message: 'Property p_autoflag must be between 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_autoflag?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 1, {
|
||||
// message: 'Property p_autoflag must be between 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_autoflag?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 1, {
|
||||
message: 'Property p_horseflag must be between 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_horseflag?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 1, {
|
||||
// message: 'Property p_horseflag must be between 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_horseflag?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 200, {
|
||||
message: 'Property p_authrep must be between 0 to 200 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_authrep?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 200, {
|
||||
// message: 'Property p_authrep must be between 0 to 200 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_authrep?: string;
|
||||
|
||||
@ApiProperty({ required: false, type: () => [p_gltableDTO] })
|
||||
@Type(() => p_gltableDTO)
|
||||
@ValidateNested({ each: true })
|
||||
@IsArray()
|
||||
// @ArrayNotEmpty({message:"Property gltable should not be empty"})
|
||||
@IsOptional()
|
||||
p_gltable?: p_gltableDTO[];
|
||||
// @ApiProperty({ required: false, type: () => [p_gltableDTO] })
|
||||
// @Type(() => p_gltableDTO)
|
||||
// @ValidateNested({ each: true })
|
||||
// @IsArray()
|
||||
// // @ArrayNotEmpty({message:"Property gltable should not be empty"})
|
||||
// @IsOptional()
|
||||
// p_gltable?: p_gltableDTO[];
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Max(99999, { message: 'Property p_ussets must not exceed 99999' })
|
||||
@Min(0, { message: 'Property p_ussets must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property p_ussets must be a number' })
|
||||
@IsOptional()
|
||||
p_ussets?: number;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Max(99999, { message: 'Property p_ussets must not exceed 99999' })
|
||||
// @Min(0, { message: 'Property p_ussets must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property p_ussets must be a number' })
|
||||
// @IsOptional()
|
||||
// p_ussets?: number;
|
||||
|
||||
@ApiProperty({ required: false, type: () => [p_countrytableDTO] })
|
||||
@ValidateNested({ each: true })
|
||||
@IsArray()
|
||||
@Type(() => p_countrytableDTO)
|
||||
@IsOptional()
|
||||
p_countrytable?: p_countrytableDTO[];
|
||||
// @ApiProperty({ required: false, type: () => [p_countrytableDTO] })
|
||||
// @ValidateNested({ each: true })
|
||||
// @IsArray()
|
||||
// @Type(() => p_countrytableDTO)
|
||||
// @IsOptional()
|
||||
// p_countrytable?: p_countrytableDTO[];
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property p_shiptotype must be between 0 to 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_shiptotype?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property p_shiptotype must be between 0 to 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_shiptotype?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Max(999999999, {
|
||||
message: 'Property p_shipaddrid must not exceed 999999999',
|
||||
})
|
||||
@Min(0, { message: 'Property p_shipaddrid must be at least 0 or more' })
|
||||
@IsInt()
|
||||
@IsNumber({}, { message: 'Property p_shipaddrid must be a number' })
|
||||
@IsOptional()
|
||||
p_shipaddrid?: number;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Max(999999999, {
|
||||
// message: 'Property p_shipaddrid must not exceed 999999999',
|
||||
// })
|
||||
// @Min(0, { message: 'Property p_shipaddrid must be at least 0 or more' })
|
||||
// @IsInt()
|
||||
// @IsNumber({}, { message: 'Property p_shipaddrid must be a number' })
|
||||
// @IsOptional()
|
||||
// p_shipaddrid?: number;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 1, {
|
||||
message: 'Property p_formofsecurity must be between 0 to 1 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_formofsecurity?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 1, {
|
||||
// message: 'Property p_formofsecurity must be between 0 to 1 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_formofsecurity?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property p_insprotection must be between 0 to 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_insprotection?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property p_insprotection must be between 0 to 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_insprotection?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property p_ldiprotection must be between 0 to 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_ldiprotection?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property p_ldiprotection must be between 0 to 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_ldiprotection?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property p_deliverytype must be between 0 to 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_deliverytype?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property p_deliverytype must be between 0 to 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_deliverytype?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property p_deliverymethod must be between 0 to 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_deliverymethod?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property p_deliverymethod must be between 0 to 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_deliverymethod?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 10, {
|
||||
message: 'Property p_paymentmethod must be between 0 to 10 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_paymentmethod?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 10, {
|
||||
// message: 'Property p_paymentmethod must be between 0 to 10 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_paymentmethod?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 20, {
|
||||
message: 'Property p_custcourierno must be between 0 to 20 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_custcourierno?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 20, {
|
||||
// message: 'Property p_custcourierno must be between 0 to 20 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_custcourierno?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 20, {
|
||||
message: 'Property p_refno must be between 0 to 20 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_refno?: string;
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 20, {
|
||||
// message: 'Property p_refno must be between 0 to 20 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_refno?: string;
|
||||
|
||||
@ApiProperty({ required: false })
|
||||
@Length(0, 2000, {
|
||||
message: 'Property p_notes must be between 0 to 2000 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
p_notes?: string;
|
||||
}
|
||||
// @ApiProperty({ required: false })
|
||||
// @Length(0, 2000, {
|
||||
// message: 'Property p_notes must be between 0 to 2000 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsOptional()
|
||||
// p_notes?: string;
|
||||
// }
|
||||
|
||||
export class TransmitApplicationtoProcessDTO {
|
||||
@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()
|
||||
@IsNumber({}, { message: 'Property p_spid must be a number' })
|
||||
@IsDefined({ message: 'Property p_spid is required' })
|
||||
p_spid: number;
|
||||
// export class TransmitApplicationtoProcessDTO {
|
||||
// @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()
|
||||
// @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_userid must be between 0 to 50 characters',
|
||||
})
|
||||
@IsString()
|
||||
@IsDefined({ message: 'Property p_userid is required' })
|
||||
p_userid: string;
|
||||
// @ApiProperty({ required: true })
|
||||
// @Length(0, 50, {
|
||||
// message: 'Property p_userid must be between 0 to 50 characters',
|
||||
// })
|
||||
// @IsString()
|
||||
// @IsDefined({ message: 'Property p_userid is required' })
|
||||
// p_userid: string;
|
||||
|
||||
@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()
|
||||
@IsNumber({}, { message: 'Property p_headerid must be a number' })
|
||||
@IsDefined({ message: 'Property p_headerid is required' })
|
||||
p_headerid: 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()
|
||||
// @IsNumber({}, { message: 'Property p_headerid must be a number' })
|
||||
// @IsDefined({ message: 'Property p_headerid is required' })
|
||||
// p_headerid: number;
|
||||
// }
|
||||
|
||||
export class GetCarnetDetailsbyCarnetStatusDTO {
|
||||
@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()
|
||||
@IsNumber({}, { message: 'Property p_spid must be a number' })
|
||||
@IsDefined({ message: 'Property p_spid is required' })
|
||||
p_spid: number;
|
||||
// export class GetCarnetDetailsbyCarnetStatusDTO {
|
||||
// @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()
|
||||
// @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_userid must be between 0 to 50 characters',
|
||||
})
|
||||
@IsString({ message: 'Property p_userid must be string' })
|
||||
@IsDefined({ message: 'Property p_userid is required' })
|
||||
p_userid: 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 string' })
|
||||
// @IsDefined({ message: 'Property p_userid is required' })
|
||||
// p_userid: string;
|
||||
|
||||
@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;
|
||||
}
|
||||
// @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;
|
||||
// }
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import * as oracledb from 'oracledb';
|
||||
|
||||
|
||||
import {
|
||||
p_gltableDTO,
|
||||
SaveCarnetApplicationDTO,
|
||||
TransmitApplicationtoProcessDTO,
|
||||
EMAIL_DTO,
|
||||
GetCarnetDetailsbyCarnetStatusDTO,
|
||||
} from './home-page.dto';
|
||||
SPID_DTO,
|
||||
USERID_DTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Injectable()
|
||||
export class HomePageService {
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
async GetHomePageData(P_spid: number) {
|
||||
async GetHomePageData(params: SPID_DTO) {
|
||||
let connection;
|
||||
let p_basic_details = [];
|
||||
let p_contacts = [];
|
||||
@ -34,24 +36,24 @@ export class HomePageService {
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USERLOGIN_PKG.GetHomePageData(
|
||||
:P_spid,
|
||||
:p_basic_details_cur,
|
||||
:p_contacts_cur,
|
||||
:p_sequence_cur,
|
||||
:p_fees_comm_cur,
|
||||
:p_bf_fee_cur,
|
||||
:p_cf_Fee_cur,
|
||||
:p_cont_sheet_fee_cur,
|
||||
:p_ef_fee_cur,
|
||||
:p_security_deposit_cur,
|
||||
:p_param_cur,
|
||||
:p_region_cur
|
||||
);
|
||||
END;`,
|
||||
USERLOGIN_PKG.GetHomePageData(
|
||||
:P_SPID,
|
||||
:p_basic_details_cur,
|
||||
:p_contacts_cur,
|
||||
:p_sequence_cur,
|
||||
:p_fees_comm_cur,
|
||||
:p_bf_fee_cur,
|
||||
:p_cf_Fee_cur,
|
||||
:p_cont_sheet_fee_cur,
|
||||
:p_ef_fee_cur,
|
||||
:p_security_deposit_cur,
|
||||
:p_param_cur,
|
||||
:p_region_cur
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_spid: {
|
||||
val: P_spid,
|
||||
P_SPID: {
|
||||
val: params.P_SPID,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_basic_details_cur: {
|
||||
@ -292,7 +294,7 @@ export class HomePageService {
|
||||
}
|
||||
}
|
||||
|
||||
async GetCarnetSummaryData(p_emailaddr: string) {
|
||||
async GetCarnetSummaryData(body: USERID_DTO) {
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
@ -303,14 +305,14 @@ export class HomePageService {
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USERLOGIN_PKG.GetCarnetSummaryData(:p_emailaddr,:p_cursor);
|
||||
END;`,
|
||||
USERLOGIN_PKG.GetCarnetSummaryData(:P_USERID,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_emailaddr: {
|
||||
val: p_emailaddr,
|
||||
P_USERID: {
|
||||
val: body.P_USERID,
|
||||
type: oracledb.DB_TYPE_NVARCHAR,
|
||||
},
|
||||
p_cursor: {
|
||||
P_CURSOR: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
@ -320,8 +322,8 @@ export class HomePageService {
|
||||
},
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
const cursor = result.outBinds.P_CURSOR;
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
@ -392,430 +394,432 @@ export class HomePageService {
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
// NOTE : this has been moved to carent-application module
|
||||
|
||||
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) {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
||||
setEmptyStringsToNull(obj[key]);
|
||||
} else if (obj[key] === '') {
|
||||
obj[key] = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
// const reqBody = JSON.parse(JSON.stringify(body));
|
||||
|
||||
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;
|
||||
let rows = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
// const finalBody = { ...newBody, ...reqBody };
|
||||
|
||||
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(
|
||||
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
|
||||
}
|
||||
// // const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
|
||||
|
||||
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
|
||||
}
|
||||
// async function createGLArrayInstance(
|
||||
// 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
|
||||
// }
|
||||
|
||||
// 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');
|
||||
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
|
||||
// const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
|
||||
const CARNETCOUNTRYTABLE = await connection.getDbObjectClass(
|
||||
'CARNETSYS.CARNETCOUNTRYTABLE',
|
||||
);
|
||||
// // let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
|
||||
|
||||
// Check if GLTABLE is a constructor
|
||||
if (typeof GLTABLE !== 'function') {
|
||||
throw new Error('GLTABLE is not a constructor');
|
||||
}
|
||||
// // let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
|
||||
// const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
|
||||
// // const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
|
||||
// const CARNETCOUNTRYTABLE = await connection.getDbObjectClass(
|
||||
// 'CARNETSYS.CARNETCOUNTRYTABLE',
|
||||
// );
|
||||
|
||||
if (typeof CARNETCOUNTRYTABLE !== 'function') {
|
||||
throw new Error('CARNETCOUNTRYTABLE is not a constructor');
|
||||
}
|
||||
// // Check if GLTABLE is a constructor
|
||||
// if (typeof GLTABLE !== 'function') {
|
||||
// throw new Error('GLTABLE is not a constructor');
|
||||
// }
|
||||
|
||||
const GLTABLE_ARRAY = finalBody.p_gltable
|
||||
? await Promise.all(
|
||||
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,
|
||||
);
|
||||
}),
|
||||
)
|
||||
: [];
|
||||
// if (typeof CARNETCOUNTRYTABLE !== 'function') {
|
||||
// throw new Error('CARNETCOUNTRYTABLE is not a constructor');
|
||||
// }
|
||||
|
||||
const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable
|
||||
? await Promise.all(
|
||||
finalBody.p_countrytable.map(async (x) => {
|
||||
return await createCarnetCountryArrayInstance(
|
||||
connection,
|
||||
x.VisitTransitInd,
|
||||
x.CountryCode,
|
||||
x.NoOfTimesEntLeave,
|
||||
);
|
||||
}),
|
||||
)
|
||||
: [];
|
||||
// const GLTABLE_ARRAY = finalBody.p_gltable
|
||||
// ? await Promise.all(
|
||||
// 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 GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
|
||||
const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(
|
||||
CARNETCOUNTRYTABLE_ARRAY,
|
||||
);
|
||||
// const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable
|
||||
// ? await Promise.all(
|
||||
// finalBody.p_countrytable.map(async (x) => {
|
||||
// return await createCarnetCountryArrayInstance(
|
||||
// connection,
|
||||
// x.VisitTransitInd,
|
||||
// x.CountryCode,
|
||||
// x.NoOfTimesEntLeave,
|
||||
// );
|
||||
// }),
|
||||
// )
|
||||
// : [];
|
||||
|
||||
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: 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,
|
||||
},
|
||||
// const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
|
||||
// const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(
|
||||
// CARNETCOUNTRYTABLE_ARRAY,
|
||||
// );
|
||||
|
||||
P_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
},
|
||||
);
|
||||
await connection.commit();
|
||||
// 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: 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) {
|
||||
const cursor = result.outBinds.P_cursor;
|
||||
let rowsBatch;
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
// await connection.commit();
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
// if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
// const cursor = result.outBinds.P_CURSOR;
|
||||
// let rowsBatch;
|
||||
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new Error('No cursor returned from the stored procedure');
|
||||
}
|
||||
// do {
|
||||
// rowsBatch = await cursor.getRows(100);
|
||||
// rows = rows.concat(rowsBatch);
|
||||
// } while (rowsBatch.length > 0);
|
||||
|
||||
return rows;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// await cursor.close();
|
||||
// } else {
|
||||
// throw new Error('No cursor returned from the stored procedure');
|
||||
// }
|
||||
|
||||
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
|
||||
let connection;
|
||||
let rows = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new Error('No DB Connected');
|
||||
}
|
||||
// return rows;
|
||||
// } 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);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
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_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();
|
||||
// NOTE : this has been moved to carent-application module
|
||||
|
||||
if (result.outBinds && result.outBinds.P_cursor) {
|
||||
const cursor = result.outBinds.P_cursor;
|
||||
let rowsBatch;
|
||||
// async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
|
||||
// let connection;
|
||||
// let rows = [];
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new Error('No DB Connected');
|
||||
// }
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
// 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_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();
|
||||
} else {
|
||||
throw new Error('No cursor returned from the stored procedure');
|
||||
}
|
||||
// if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
// const cursor = result.outBinds.P_CURSOR;
|
||||
// let rowsBatch;
|
||||
|
||||
return rows;
|
||||
// do {
|
||||
// rowsBatch = await cursor.getRows(100);
|
||||
// rows = rows.concat(rowsBatch);
|
||||
// } while (rowsBatch.length > 0);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// await cursor.close();
|
||||
// } else {
|
||||
// throw new Error('No cursor returned from the stored procedure');
|
||||
// }
|
||||
|
||||
async GetCarnetDetailsbyCarnetStatus(
|
||||
body: GetCarnetDetailsbyCarnetStatusDTO,
|
||||
) {
|
||||
// return rows;
|
||||
|
||||
// // 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 rows: any = [];
|
||||
try {
|
||||
@ -826,22 +830,22 @@ export class HomePageService {
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
CARNETCONTROLCENTER_PKG.GetCarnetDetails(:p_spid,:p_userid,:p_CarnetStattus,:P_cursor);
|
||||
END;`,
|
||||
CARNETCONTROLCENTER_PKG.GetCarnetDetails(:P_SPID,:P_USERID,:P_CARNETSTATUS,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_spid: {
|
||||
val: body.p_spid,
|
||||
P_SPID: {
|
||||
val: body.P_SPID,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_userid: {
|
||||
val: body.p_userid,
|
||||
P_USERID: {
|
||||
val: body.P_USERID,
|
||||
type: oracledb.DB_TYPE_NVARCHAR,
|
||||
},
|
||||
p_CarnetStattus: {
|
||||
val: body.p_CarnetStatus,
|
||||
P_CARNETSTATUS: {
|
||||
val: body.P_CARNETSTATUS,
|
||||
type: oracledb.DB_TYPE_NVARCHAR,
|
||||
},
|
||||
P_cursor: {
|
||||
P_CURSOR: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
@ -851,8 +855,8 @@ export class HomePageService {
|
||||
},
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.P_cursor) {
|
||||
const cursor = result.outBinds.P_cursor;
|
||||
if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
const cursor = result.outBinds.P_CURSOR;
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
|
||||
@ -1,20 +1,16 @@
|
||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
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 {
|
||||
CreateClientContactsDTO, CreateClientDataDTO,
|
||||
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
|
||||
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Controller('oracle')
|
||||
export class ManageClientsController {
|
||||
constructor(private readonly manageClientsService: ManageClientsService) {}
|
||||
constructor(private readonly manageClientsService: ManageClientsService) { }
|
||||
|
||||
@ApiTags('Manage Clients - Oracle')
|
||||
@Post('CreateNewClients')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,28 +1,16 @@
|
||||
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
|
||||
import { ManageFeeService } from './manage-fee.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import {
|
||||
CreateBasicFeeDTO,
|
||||
CreateBondRateDTO,
|
||||
CreateCargoRateDTO,
|
||||
CreateCfFeeDTO,
|
||||
CreateCsFeeDTO,
|
||||
CreateEfFeeDTO,
|
||||
CreateFeeCommDTO,
|
||||
GetFeeGeneralDTO,
|
||||
UpdateBasicFeeDTO,
|
||||
UpdateBondRateDTO,
|
||||
UpdateCargoRateDTO,
|
||||
UpdateCfFeeDTO,
|
||||
UpdateCsFeeDTO,
|
||||
UpdateEfFeeDTO,
|
||||
UpdateFeeCommBodyDTO,
|
||||
UpdateFeeCommDTO,
|
||||
} from './manage-fee.dto';
|
||||
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
|
||||
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
|
||||
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Controller('oracle')
|
||||
export class ManageFeeController {
|
||||
constructor(private readonly manageFeeService: ManageFeeService) {}
|
||||
constructor(private readonly manageFeeService: ManageFeeService) { }
|
||||
|
||||
@ApiTags('Manage Fee - Oracle')
|
||||
@Get('/GetBasicFeeRates')
|
||||
|
||||
@ -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()
|
||||
}
|
||||
@ -1,27 +1,18 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import * as oracledb from 'oracledb';
|
||||
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 { 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()
|
||||
export class ManageFeeService {
|
||||
private readonly logger = new Logger(ManageFeeService.name);
|
||||
@ -30,7 +21,7 @@ export class ManageFeeService {
|
||||
|
||||
// basic fee
|
||||
|
||||
async GETBASICFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
async GETBASICFEERATES(body: GetFeeGeneralDTO) {
|
||||
let connection;
|
||||
let rows: any[] = [];
|
||||
|
||||
@ -84,24 +75,9 @@ export class ManageFeeService {
|
||||
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();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,11 +107,11 @@ export class ManageFeeService {
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
P_STARTCARNETVALUE: {
|
||||
val: body.P_STARTCARNETVALUE,
|
||||
val: body.P_STARTNUMBER,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
P_ENDCARNETVALUE: {
|
||||
val: body.P_ENDCARNETVALUE,
|
||||
val: body.P_ENDNUMBER,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
P_EFFDATE: {
|
||||
@ -171,20 +147,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATEBASICFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,26 +208,15 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATEBASICFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// bond rate
|
||||
|
||||
async GETBONDRATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
async GETBONDRATES(body: GetFeeGeneralDTO) {
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
@ -319,24 +273,9 @@ export class ManageFeeService {
|
||||
|
||||
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('GETBONDRATES failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -415,20 +354,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATEBONDRATE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,20 +415,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATEBONDRATE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,20 +570,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATECARGORATE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,26 +631,15 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATECARGORATE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// counter foil
|
||||
|
||||
async GETCFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
async GETCFFEERATES(body: GetFeeGeneralDTO) {
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
@ -798,24 +693,9 @@ export class ManageFeeService {
|
||||
|
||||
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('GETCFFEERATES failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -894,20 +774,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATECFFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -966,27 +835,16 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATECFFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// continuation sheet
|
||||
|
||||
async GETCSFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
async GETCSFEERATES(body: GetFeeGeneralDTO) {
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
@ -1040,24 +898,9 @@ export class ManageFeeService {
|
||||
|
||||
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('GETCSFEERATES failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1126,20 +969,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATECSFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1198,26 +1030,15 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATECSFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// expedited fee
|
||||
|
||||
async GETEFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
async GETEFFEERATES(body: GetFeeGeneralDTO) {
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
@ -1271,24 +1092,9 @@ export class ManageFeeService {
|
||||
|
||||
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('GETEFFEERATES failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1373,20 +1179,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATEEFFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1445,26 +1240,15 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATEEFFEE failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// fee comm
|
||||
|
||||
async GETFEECOMM(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
async GETFEECOMM(body: GetFeeGeneralDTO) {
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
@ -1518,24 +1302,9 @@ export class ManageFeeService {
|
||||
|
||||
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('GETFEECOMM failed\n', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1599,20 +1368,9 @@ export class ManageFeeService {
|
||||
|
||||
return { statusCode: 201, message: "Created Successfully" };
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('CREATEFEECOMM failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1672,20 +1430,9 @@ export class ManageFeeService {
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('UPDATEFEECOMM failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, ManageFeeService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, ManageFeeService.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,16 +10,13 @@ import {
|
||||
Put,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
CreateHoldersDTO,
|
||||
GetHolderDTO,
|
||||
HolderActivateOrInactivateDTO,
|
||||
HolderContactActivateOrInactivateDTO,
|
||||
UpdateHolderContactDTO,
|
||||
UpdateHolderDTO
|
||||
} from './manage-holders.dto';
|
||||
import { ManageHoldersService } from './manage-holders.service';
|
||||
|
||||
import {
|
||||
CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO,
|
||||
HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Controller('oracle')
|
||||
export class ManageHoldersController {
|
||||
constructor(private readonly manageHoldersService: ManageHoldersService) { }
|
||||
@ -44,94 +41,94 @@ export class ManageHoldersController {
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@Get('/GetHolderRecord/:p_spid/:p_holderid')
|
||||
@Get('/GetHolderRecord/:P_SPID/:P_HOLDERID')
|
||||
GetHolderMaster(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
) {
|
||||
const reqParams: GetHolderDTO = { p_spid, p_holderid };
|
||||
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
|
||||
|
||||
return this.manageHoldersService.GetHolderRecord(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@Get('/GetHolderContacts/:p_spid/:p_holderid')
|
||||
@Get('/GetHolderContacts/:P_SPID/:P_HOLDERID')
|
||||
GetHolderContacts(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
) {
|
||||
const reqParams: GetHolderDTO = { p_spid, p_holderid };
|
||||
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
|
||||
|
||||
return this.manageHoldersService.GetHolderContacts(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@Patch('/InactivateHolder/:p_spid/:p_holderid/:p_userid')
|
||||
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
|
||||
InactivateHolder(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
if (!p_userid) {
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
|
||||
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
|
||||
|
||||
return this.manageHoldersService.InactivateHolder(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@Patch('/ReactivateHolder/:p_spid/:p_holderid/:p_userid')
|
||||
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
|
||||
ReactivateHolder(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
if (!p_userid) {
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
|
||||
const reqParams: HolderActivateOrInactivateDTO = { p_spid, p_holderid, p_userid };
|
||||
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
|
||||
|
||||
return this.manageHoldersService.ReactivateHolder(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@Patch('/InactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
|
||||
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
|
||||
InactivateHolderContact(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderContactid', ParseIntPipe) p_holderContactid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
|
||||
if (!p_userid) {
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
|
||||
const reqParams: HolderContactActivateOrInactivateDTO = {
|
||||
p_spid,
|
||||
p_holderContactid,
|
||||
p_userid
|
||||
P_SPID,
|
||||
P_HOLDERCONTACTID,
|
||||
P_USERID
|
||||
};
|
||||
|
||||
return this.manageHoldersService.InactivateHolderContact(reqParams);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Holders - Oracle')
|
||||
@Patch('/ReactivateHolderContact/:p_spid/:p_holderContactid/:p_userid')
|
||||
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
|
||||
ReactivateHolderContact(
|
||||
@Param('p_spid', ParseIntPipe) p_spid: number,
|
||||
@Param('p_holderid', ParseIntPipe) p_holderContactid: number,
|
||||
@Param('p_userid') p_userid: string
|
||||
@Param('P_SPID', ParseIntPipe) P_SPID: number,
|
||||
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
|
||||
@Param('P_USERID') P_USERID: string
|
||||
) {
|
||||
if (!p_userid) {
|
||||
if (!P_USERID) {
|
||||
throw new BadRequestException("Bad Request");
|
||||
}
|
||||
|
||||
const reqParams: HolderContactActivateOrInactivateDTO = {
|
||||
p_spid,
|
||||
p_holderContactid,
|
||||
p_userid
|
||||
P_SPID,
|
||||
P_HOLDERCONTACTID,
|
||||
P_USERID
|
||||
};
|
||||
|
||||
return this.manageHoldersService.ReactivateHolderContact(reqParams);
|
||||
|
||||
@ -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
@ -1,4 +1,4 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { DbModule } from 'src/db/db.module';
|
||||
import { ManageHoldersModule } from './manage-holders/manage-holders.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 { ManageClientsModule } from './manage-clients/manage-clients.module';
|
||||
import { UserMaintenanceModule } from './user-maintenance/user-maintenance.module';
|
||||
import { CarnetApplicationModule } from './carnet-application/carnet-application.module';
|
||||
import { OracleService } from './oracle.service';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
UserMaintenanceModule,
|
||||
DbModule,
|
||||
CarnetApplicationModule,
|
||||
UserMaintenanceModule,
|
||||
HomePageModule,
|
||||
UscibManagedSpModule,
|
||||
ParamTableModule,
|
||||
@ -19,8 +23,8 @@ import { UserMaintenanceModule } from './user-maintenance/user-maintenance.modul
|
||||
ManageHoldersModule,
|
||||
ManageClientsModule,
|
||||
],
|
||||
providers: [],
|
||||
providers: [OracleService],
|
||||
controllers: [],
|
||||
exports: [],
|
||||
exports: [OracleService],
|
||||
})
|
||||
export class OracleModule {}
|
||||
|
||||
121
src/oracle/oracle.service.ts
Normal file
121
src/oracle/oracle.service.ts
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,16 @@
|
||||
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { ParamTableService } from './param-table.service';
|
||||
import {
|
||||
ActivateOrInactivateParamRecordDTO,
|
||||
CreateParamRecordDTO,
|
||||
CreateTableRecordDTO,
|
||||
getParamValuesDTO,
|
||||
UpdateParamRecordDTO,
|
||||
} from './param-table.dto';
|
||||
|
||||
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO,
|
||||
getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/property.dto';
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Controller('oracle')
|
||||
export class ParamTableController {
|
||||
constructor(private readonly paramTableService: ParamTableService) {}
|
||||
constructor(private readonly paramTableService: ParamTableService) { }
|
||||
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Get('/GetParamValues')
|
||||
@ApiQuery({
|
||||
name: 'P_SPID',
|
||||
@ -31,31 +28,26 @@ export class ParamTableController {
|
||||
return this.paramTableService.GETPARAMVALUES(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Post('/CreateTableRecord')
|
||||
createTableRecord(@Body() body: CreateTableRecordDTO) {
|
||||
return this.paramTableService.CREATETABLERECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Post('/CreateParamRecord')
|
||||
createParamRecord(@Body() body: CreateParamRecordDTO) {
|
||||
return this.paramTableService.CREATEPARAMRECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Patch('/UpdateParamRecord')
|
||||
UpdateParamRecord(@Body() body: UpdateParamRecordDTO) {
|
||||
return this.paramTableService.UPDATEPARAMRECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Patch('/InActivateParamRecord')
|
||||
inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
|
||||
return this.paramTableService.INACTIVATEPARAMRECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Patch('/ReActivateParamRecord')
|
||||
reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
|
||||
return this.paramTableService.REACTIVATEPARAMRECORD(body);
|
||||
|
||||
@ -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
@ -1,24 +1,21 @@
|
||||
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||
import {
|
||||
CreateCarnetSequenceDTO,
|
||||
GetCarnetSequenceDTO,
|
||||
} from './carnet-sequence.dto';
|
||||
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { CarnetSequenceService } from './carnet-sequence.service';
|
||||
|
||||
import { SPID_DTO, CreateCarnetSequenceDTO } from 'src/dto/property.dto';
|
||||
|
||||
@ApiTags('Carnet Sequence - Oracle')
|
||||
@Controller('oracle')
|
||||
export class CarnetSequenceController {
|
||||
constructor(private readonly carnetSequenceService: CarnetSequenceService) {}
|
||||
constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
|
||||
|
||||
@ApiTags('Carnet Sequence - Oracle')
|
||||
@Post('/CreateCarnetSequence/')
|
||||
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
|
||||
return this.carnetSequenceService.createCarnetSequence(body);
|
||||
}
|
||||
|
||||
@ApiTags('Carnet Sequence - Oracle')
|
||||
@Get('/GetCarnetSequence')
|
||||
getCarnetSequence(@Query() body: GetCarnetSequenceDTO) {
|
||||
return this.carnetSequenceService.getCarnetSequence(body);
|
||||
@Get('/GetCarnetSequence/:P_SPID')
|
||||
getCarnetSequence(@Param() params: SPID_DTO) {
|
||||
return this.carnetSequenceService.getCarnetSequence(params);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1,21 +1,19 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import * as oracledb from 'oracledb';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import {
|
||||
CreateCarnetSequenceDTO,
|
||||
GetCarnetSequenceDTO,
|
||||
} from './carnet-sequence.dto';
|
||||
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
|
||||
|
||||
import { SPID_DTO, CreateCarnetSequenceDTO } from 'src/dto/property.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CarnetSequenceService {
|
||||
private readonly logger = new Logger(CarnetSequenceService.name);
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) {}
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
|
||||
async createCarnetSequenceX(body: CreateCarnetSequenceDTO) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
@ -26,51 +24,51 @@ export class CarnetSequenceService {
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.CreateCarnetSequence(
|
||||
:p_spid,
|
||||
:p_regionid,
|
||||
:p_startnumber,
|
||||
:p_endnumber,
|
||||
:p_carnettype,
|
||||
:p_cursor);
|
||||
:P_SPID,
|
||||
:P_REGIONID,
|
||||
:P_STARTNUMBER,
|
||||
:P_ENDNUMBER,
|
||||
:P_CARNETTYPE,
|
||||
:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_spid: {
|
||||
val: body.p_spid,
|
||||
P_SPID: {
|
||||
val: body.P_SPID,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_regionid: {
|
||||
val: body.p_regionid,
|
||||
P_REGIONID: {
|
||||
val: body.P_REGIONID,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_startnumber: {
|
||||
val: body.p_startnumber,
|
||||
P_STARTNUMBER: {
|
||||
val: body.P_STARTNUMBER,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_endnumber: {
|
||||
val: body.p_endnumber,
|
||||
P_ENDNUMBER: {
|
||||
val: body.P_ENDNUMBER,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_carnettype: {
|
||||
val: body.p_carnettype,
|
||||
P_CARNETTYPE: {
|
||||
val: body.P_CARNETTYPE,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cursor: {
|
||||
P_CURSOR: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const fres = await result.outBinds.p_cursor.getRows();
|
||||
const fres = await result.outBinds.P_CURSOR.getRows();
|
||||
|
||||
await result.outBinds.p_cursor.close();
|
||||
await result.outBinds.P_CURSOR.close();
|
||||
|
||||
if (fres.length>0 && fres[0].ERRORMESG) {
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
@ -94,7 +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 rows = [];
|
||||
try {
|
||||
@ -106,14 +150,14 @@ export class CarnetSequenceService {
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetCarnetSequence(:p_spid,:p_cursor);
|
||||
USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_spid: {
|
||||
val: body.p_spid,
|
||||
P_SPID: {
|
||||
val: body.P_SPID,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_cursor: {
|
||||
P_CURSOR: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
@ -123,8 +167,8 @@ export class CarnetSequenceService {
|
||||
},
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
const cursor = result.outBinds.P_CURSOR;
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
@ -159,4 +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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,33 +3,27 @@ import { RegionService } from './region.service';
|
||||
import { Get, Post, Body, Controller, Patch } from '@nestjs/common';
|
||||
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { InsertRegionsDto, UpdateRegionDto } from './region.dto';
|
||||
|
||||
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto';
|
||||
|
||||
@ApiTags('Regions - Oracle')
|
||||
@Controller('oracle')
|
||||
export class RegionController {
|
||||
constructor(private readonly regionService: RegionService) {}
|
||||
constructor(private readonly regionService: RegionService) { }
|
||||
|
||||
@ApiTags('Regions - Oracle')
|
||||
@Post('/InsertRegions')
|
||||
insertRegions(@Body() body: InsertRegionsDto) {
|
||||
return this.regionService.insertRegions(body);
|
||||
}
|
||||
|
||||
@ApiTags('Regions - Oracle')
|
||||
@Patch('/UpdateRegion')
|
||||
updateRegions(@Body() body: UpdateRegionDto) {
|
||||
return this.regionService.updateRegions(body);
|
||||
}
|
||||
|
||||
@ApiTags('Regions - Oracle')
|
||||
@Get('/GetRegions')
|
||||
getRegions() {
|
||||
return this.regionService.getRegions();
|
||||
}
|
||||
|
||||
// @ApiTags('Regions - Oracle')
|
||||
// @Get('/getDetails')
|
||||
selectAll() {
|
||||
return this.regionService.selectSP();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import * as oracledb from 'oracledb';
|
||||
import { InsertRegionsDto, UpdateRegionDto } from './region.dto';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.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()
|
||||
export class RegionService {
|
||||
@ -11,266 +13,293 @@ export class RegionService {
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
async selectAll() {
|
||||
let connection: oracledb.Connection | undefined;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
// async insertRegionsX(body: InsertRegionsDto) {
|
||||
// let connection;
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException();
|
||||
// }
|
||||
|
||||
const result = await connection.execute(
|
||||
`SELECT * FROM BasicFeeSetup`,
|
||||
[],
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
}
|
||||
);
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_REGION: {
|
||||
// val: body.P_REGION,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_NAME: {
|
||||
// val: body.P_NAME,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
|
||||
return result.rows;
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// await connection.commit();
|
||||
|
||||
async selectSP() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// const fres = await result.outBinds.P_CURSOR.getRows();
|
||||
|
||||
// if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
// this.logger.warn(fres[0].ERRORMESG);
|
||||
// throw new BadRequestException(fres[0].ERRORMESG)
|
||||
// }
|
||||
|
||||
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// this.logger.warn(error.message);
|
||||
// throw error;
|
||||
// }
|
||||
// this.logger.error('insertRegions failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async insertRegions(body: InsertRegionsDto) {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor);
|
||||
USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_region: {
|
||||
val: body.p_region,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_name: {
|
||||
val: body.p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_REGION: { val: body.P_REGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_NAME: { val: body.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const fres = await result.outBinds.p_cursor.getRows();
|
||||
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);
|
||||
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();
|
||||
handleError(error, RegionService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, RegionService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// async updateRegionsX(body: UpdateRegionDto) {
|
||||
// let connection;
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException();
|
||||
// }
|
||||
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.UpdateRegion(:P_REGIONID,:P_NAME,:P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_REGIONID: {
|
||||
// val: body.P_REGIONID,
|
||||
// type: oracledb.DB_TYPE_NUMBER,
|
||||
// },
|
||||
// P_NAME: {
|
||||
// val: body.P_NAME,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
|
||||
// await connection.commit();
|
||||
|
||||
// const fres = await result.outBinds.P_CURSOR.getRows();
|
||||
|
||||
// if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
// this.logger.warn(fres[0].ERRORMESG);
|
||||
// throw new BadRequestException(fres[0].ERRORMESG)
|
||||
// }
|
||||
|
||||
// return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// this.logger.warn(error.message);
|
||||
// throw error;
|
||||
// }
|
||||
// this.logger.error('updateRegions failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async updateRegions(body: UpdateRegionDto) {
|
||||
let connection;
|
||||
try {
|
||||
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);
|
||||
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,
|
||||
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();
|
||||
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);
|
||||
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();
|
||||
handleError(error, RegionService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, RegionService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// async getRegionsX() {
|
||||
// let connection;
|
||||
// let rows = [];
|
||||
// try {
|
||||
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException()
|
||||
// }
|
||||
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
|
||||
// if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
// const cursor = result.outBinds.P_CURSOR;
|
||||
// let rowsBatch;
|
||||
|
||||
// do {
|
||||
// rowsBatch = await cursor.getRows(100);
|
||||
// rows = rows.concat(rowsBatch);
|
||||
// } while (rowsBatch.length > 0);
|
||||
|
||||
// await cursor.close();
|
||||
// } else {
|
||||
// throw new BadRequestException();
|
||||
// }
|
||||
|
||||
// return rows;
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// this.logger.warn(error.message);
|
||||
// throw error;
|
||||
// }
|
||||
// else if (error.message === "NJS-107: invalid cursor") {
|
||||
// this.logger.warn(error.message);
|
||||
// throw new BadRequestException();
|
||||
// }
|
||||
// this.logger.error('GETBASICFEERATES failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async getRegions() {
|
||||
let connection;
|
||||
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);
|
||||
USCIB_Managed_Pkg.GetRegions(:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new BadRequestException();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return rows;
|
||||
return await fetchCursor(outBinds.P_CURSOR, RegionService.name);
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
else if (error.message === "NJS-107: invalid cursor") {
|
||||
this.logger.warn(error.message);
|
||||
throw new BadRequestException();
|
||||
}
|
||||
this.logger.error('GETBASICFEERATES failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, RegionService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, RegionService.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,52 +1,45 @@
|
||||
import { SpContactsService } from './sp-contacts.service';
|
||||
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import {
|
||||
getSPAllContactsDTO,
|
||||
getSPDefaultcontactDTO,
|
||||
inactivateSPContactDTO,
|
||||
InsertSPContactsDTO,
|
||||
setSPDefaultcontactDTO,
|
||||
UpdateSPContactsDTO,
|
||||
} from './sp-contacts.dto';
|
||||
import { Body, Controller, Get, Param, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
import { SPID_DTO,
|
||||
SP_CONTACTID_DTO,
|
||||
InsertSPContactsDTO,UpdateSPContactsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Controller('oracle')
|
||||
export class SpContactsController {
|
||||
constructor(private readonly spContactsService: SpContactsService) {}
|
||||
constructor(private readonly spContactsService: SpContactsService) { }
|
||||
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Post('/InsertSPContacts')
|
||||
insertSPContacts(@Body() body: InsertSPContactsDTO) {
|
||||
return this.spContactsService.insertSPContacts(body);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Patch('/SetSPDefaultContact')
|
||||
setSPDefaultcontact(@Query() body: setSPDefaultcontactDTO) {
|
||||
return this.spContactsService.setSPDefaultcontact(body);
|
||||
@Patch('/SetSPDefaultContact/:P_SPCONTACTID')
|
||||
setSPDefaultcontact(@Param() param: SP_CONTACTID_DTO) {
|
||||
return this.spContactsService.setSPDefaultcontact(param);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Put('/UpdateSPContacts')
|
||||
updateSPContacts(@Body() body: UpdateSPContactsDTO) {
|
||||
return this.spContactsService.updateSPContacts(body);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Patch('/InactivateSPContact')
|
||||
inactivateSPContact(@Query() body: inactivateSPContactDTO) {
|
||||
return this.spContactsService.inactivateSPContact(body);
|
||||
@Patch('/InactivateSPContact/:P_SPID')
|
||||
inactivateSPContact(@Param() param: SP_CONTACTID_DTO) {
|
||||
return this.spContactsService.inactivateSPContact(param);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Get('/GetSPDefaultContact')
|
||||
getSPDefaultcontact(@Query() body: getSPDefaultcontactDTO) {
|
||||
return this.spContactsService.getSPDefaultcontacts(body);
|
||||
@Get('/GetSPDefaultContact/:P_SPID')
|
||||
getSPDefaultcontact(@Param() param: SPID_DTO) {
|
||||
return this.spContactsService.getSPDefaultcontacts(param);
|
||||
}
|
||||
|
||||
@ApiTags('SPContacts - Oracle')
|
||||
@Get('/GetSPAllContacts')
|
||||
getSPAllContacts(@Query() body: getSPAllContactsDTO) {
|
||||
return this.spContactsService.getSPAllContacts(body);
|
||||
@Get('/GetSPAllContacts/:P_SPID')
|
||||
getSPAllContacts(@Param() param: SPID_DTO) {
|
||||
return this.spContactsService.getSPAllContacts(param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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{}
|
||||
@ -1,16 +1,14 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import * as oracledb from 'oracledb';
|
||||
import {
|
||||
getSPAllContactsDTO,
|
||||
getSPDefaultcontactDTO,
|
||||
inactivateSPContactDTO,
|
||||
InsertSPContactsDTO,
|
||||
setSPDefaultcontactDTO,
|
||||
UpdateSPContactsDTO,
|
||||
} from './sp-contacts.dto';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
|
||||
|
||||
import { SPID_DTO,
|
||||
SP_CONTACTID_DTO,
|
||||
InsertSPContactsDTO,UpdateSPContactsDTO
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Injectable()
|
||||
export class SpContactsService {
|
||||
@ -18,400 +16,658 @@ export class SpContactsService {
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
// async insertSPContactsX(body: InsertSPContactsDTO) {
|
||||
// let connection;
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException();
|
||||
// }
|
||||
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.InsertSPContacts(
|
||||
// :P_SPID,
|
||||
// :P_DEFCONTACTFLAG,
|
||||
// :P_FIRSTNAME,
|
||||
// :P_LASTNAME,
|
||||
// :P_MIDDLEINITIAL,
|
||||
// :P_TITLE,
|
||||
// :P_PHONENO,
|
||||
// :P_MOBILENO,
|
||||
// :P_FAXNO,
|
||||
// :P_EMAILADDRESS,
|
||||
// :P_USER_ID,
|
||||
// :P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_SPID: {
|
||||
// val: body.P_SPID,
|
||||
// type: oracledb.DB_TYPE_NUMBER,
|
||||
// },
|
||||
// P_DEFCONTACTFLAG: {
|
||||
// val: body.P_DEFCONTACTFLAG,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_FIRSTNAME: {
|
||||
// val: body.P_FIRSTNAME,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_LASTNAME: {
|
||||
// val: body.P_LASTNAME,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_MIDDLEINITIAL: {
|
||||
// val: body.P_MIDDLEINITIAL,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_TITLE: {
|
||||
// val: body.P_TITLE,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_PHONENO: {
|
||||
// val: body.P_PHONENO,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_MOBILENO: {
|
||||
// val: body.P_MOBILENO,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_FAXNO: {
|
||||
// val: body.P_FAXNO,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_EMAILADDRESS: {
|
||||
// val: body.P_EMAILADDRESS,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_USER_ID: {
|
||||
// val: body.P_USER_ID,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
|
||||
// await connection.commit();
|
||||
|
||||
// const fres = await result.outBinds.P_CURSOR.getRows();
|
||||
|
||||
// if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
// this.logger.warn(fres[0].ERRORMESG);
|
||||
// throw new BadRequestException(fres[0].ERRORMESG)
|
||||
// }
|
||||
|
||||
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// throw error;
|
||||
// }
|
||||
// this.logger.error('insertSPContacts failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async insertSPContacts(body: InsertSPContactsDTO) {
|
||||
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InsertSPContacts(
|
||||
:p_spid,
|
||||
:p_defcontactflag,
|
||||
:p_firstname,
|
||||
:p_lastname,
|
||||
:P_MIDDLEINITIAL,
|
||||
:p_title,
|
||||
:p_phoneno,
|
||||
:p_mobileno,
|
||||
:p_faxno,
|
||||
:p_emailaddress,
|
||||
:p_user_id,
|
||||
:p_cursor);
|
||||
END;`,
|
||||
: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,
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_DEFCONTACTFLAG: { val: body.P_DEFCONTACTFLAG, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_FIRSTNAME: { val: body.P_FIRSTNAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_LASTNAME: { val: body.P_LASTNAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_MIDDLEINITIAL: { val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_TITLE: { val: body.P_TITLE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_PHONENO: { val: body.P_PHONENO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_MOBILENO: { val: body.P_MOBILENO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_FAXNO: { val: body.P_FAXNO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_EMAILADDRESS: { val: body.P_EMAILADDRESS, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_USER_ID: { val: body.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const fres = await result.outBinds.p_cursor.getRows();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
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);
|
||||
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();
|
||||
handleError(error, SpContactsService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpContactsService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async 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;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid);
|
||||
USCIB_Managed_Pkg.SetDefaultContact(:P_SPCONTACTID);
|
||||
END;`,
|
||||
{
|
||||
p_spcontactid: {
|
||||
val: body.p_spcontactid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
// const outBinds = result.outBinds;
|
||||
// if (!outBinds?.P_CURSOR) {
|
||||
// this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
// throw new InternalServerException("Incomplete data received from the database.");
|
||||
// }
|
||||
|
||||
return { statusCode: 200, message: 'Default contact was added successfully for SP' };
|
||||
|
||||
} catch (error) {
|
||||
this.logger.error('setSPDefaultcontact failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpContactsService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpContactsService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// async updateSPContactsX(body: UpdateSPContactsDTO) {
|
||||
// let connection;
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException();
|
||||
// }
|
||||
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.UpdateSPContacts(
|
||||
// :P_SPCONTACTID,
|
||||
// :P_FIRSTNAME,
|
||||
// :P_LASTNAME,
|
||||
// :P_MIDDLEINITIAL,
|
||||
// :P_TITLE,
|
||||
// :P_PHONENO,
|
||||
// :P_MOBILENO,
|
||||
// :P_FAXNO,
|
||||
// :P_EMAILADDRESS,
|
||||
// :P_USER_ID,
|
||||
// :P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_SPCONTACTID: {
|
||||
// val: body.P_SPCONTACTID,
|
||||
// type: oracledb.DB_TYPE_NUMBER,
|
||||
// },
|
||||
// P_FIRSTNAME: {
|
||||
// val: body.P_FIRSTNAME,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_LASTNAME: {
|
||||
// val: body.P_LASTNAME,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_MIDDLEINITIAL: {
|
||||
// val: body.P_MIDDLEINITIAL,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_TITLE: {
|
||||
// val: body.P_TITLE,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_PHONENO: {
|
||||
// val: body.P_PHONENO,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_MOBILENO: {
|
||||
// val: body.P_MOBILENO,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_FAXNO: {
|
||||
// val: body.P_FAXNO,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_EMAILADDRESS: {
|
||||
// val: body.P_EMAILADDRESS,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_USER_ID: {
|
||||
// val: body.P_USER_ID,
|
||||
// type: oracledb.DB_TYPE_VARCHAR,
|
||||
// },
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
|
||||
// await connection.commit();
|
||||
|
||||
// const fres = await result.outBinds.P_CURSOR.getRows();
|
||||
|
||||
// if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
// this.logger.warn(fres[0].ERRORMESG);
|
||||
// throw new BadRequestException(fres[0].ERRORMESG)
|
||||
// }
|
||||
|
||||
// return { statusCode: 200, message: "Updated Successfully" };
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// this.logger.warn(error.message);
|
||||
// throw error;
|
||||
// }
|
||||
// this.logger.error('updateSPContacts failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async updateSPContacts(body: UpdateSPContactsDTO) {
|
||||
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.UpdateSPContacts(
|
||||
:p_spcontactid,
|
||||
:p_firstname,
|
||||
:p_lastname,
|
||||
:P_MIDDLEINITIAL,
|
||||
:p_title,
|
||||
:p_phoneno,
|
||||
:p_mobileno,
|
||||
:p_faxno,
|
||||
:p_emailaddress,
|
||||
:p_user_id,
|
||||
:p_cursor);
|
||||
END;`,
|
||||
: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,
|
||||
P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_FIRSTNAME: { val: body.P_FIRSTNAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_LASTNAME: { val: body.P_LASTNAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_MIDDLEINITIAL: { val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_TITLE: { val: body.P_TITLE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_PHONENO: { val: body.P_PHONENO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_MOBILENO: { val: body.P_MOBILENO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_FAXNO: { val: body.P_FAXNO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_EMAILADDRESS: { val: body.P_EMAILADDRESS, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_USER_ID: { val: body.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
const fres = await result.outBinds.p_cursor.getRows();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
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);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('updateSPContacts failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpContactsService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpContactsService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async 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;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid);
|
||||
USCIB_Managed_Pkg.InActivateSPContacts(:P_SPCONTACTID);
|
||||
END;`,
|
||||
{
|
||||
p_spcontactid: {
|
||||
val: body.p_spcontactid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
P_SPCONTACTID: { val: body.P_SPCONTACTID, type: oracledb.DB_TYPE_NUMBER }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
|
||||
// const outBinds = result.outBinds;
|
||||
// if (!outBinds?.P_CURSOR) {
|
||||
// this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
// throw new InternalServerException("Incomplete data received from the database.");
|
||||
// }
|
||||
|
||||
return { statusCode: 200, message: 'Inactivated SP contact successfully' };
|
||||
|
||||
} catch (error) {
|
||||
this.logger.error('inactivateSPContact failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpContactsService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpContactsService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async getSPDefaultcontacts(body: 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 rows = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetSPDefaultContacts(:p_SPid,:p_cursor);
|
||||
USCIB_Managed_Pkg.GetSPDefaultContacts(:P_SPID,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_SPid: {
|
||||
val: body.p_SPid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
let rowsBatch;
|
||||
await connection.commit();
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new BadRequestException();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return rows;
|
||||
return await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
|
||||
|
||||
} catch (error) {
|
||||
this.logger.error('getSPDefaultcontacts failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpContactsService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpContactsService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async getSPAllContacts(body: 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 rows = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetSPAllContacts(:p_SPid,:p_cursor);
|
||||
USCIB_Managed_Pkg.GetSPAllContacts(:P_SPID,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_SPid: {
|
||||
val: body.p_SPid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
let rowsBatch;
|
||||
await connection.commit();
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new BadRequestException();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return rows;
|
||||
return await fetchCursor(outBinds.P_CURSOR, SpContactsService.name);
|
||||
|
||||
} catch (error) {
|
||||
this.logger.error('getSPAllContacts failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpContactsService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpContactsService.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,37 +1,35 @@
|
||||
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Param, Post, Put, Query } from '@nestjs/common';
|
||||
import { SpService } from './sp.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
getSelectedServiceproviderDTO,
|
||||
InsertNewServiceProviderDTO,
|
||||
UpdateServiceProviderDTO,
|
||||
} from './sp.dto';
|
||||
|
||||
import {
|
||||
SPID_DTO, InsertNewServiceProviderDTO,
|
||||
UpdateServiceProviderDTO,
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@ApiTags('SP - Oracle')
|
||||
@Controller('oracle')
|
||||
export class SpController {
|
||||
constructor(private readonly spService: SpService) {}
|
||||
constructor(private readonly spService: SpService) { }
|
||||
|
||||
|
||||
@ApiTags('SP - Oracle')
|
||||
@Post('/InsertNewServiceProvider')
|
||||
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
|
||||
return this.spService.insertNewServiceProvider(body);
|
||||
}
|
||||
|
||||
@ApiTags('SP - Oracle')
|
||||
@Put('/UpdateServiceProvider')
|
||||
updateServiceProider(@Body() body: UpdateServiceProviderDTO) {
|
||||
return this.spService.updateServiceProvider(body);
|
||||
}
|
||||
|
||||
@ApiTags('SP - Oracle')
|
||||
@Get('/GetAllServiceproviders')
|
||||
getAllServiceproviders() {
|
||||
return this.spService.getAllServiceproviders();
|
||||
}
|
||||
|
||||
@ApiTags('SP - Oracle')
|
||||
@Get('/GetSelectedServiceprovider')
|
||||
getSelectedServiceprovider(@Query() body: getSelectedServiceproviderDTO) {
|
||||
return this.spService.getServiceproviderByID(body);
|
||||
@Get('/GetSelectedServiceprovider/:P_SPID')
|
||||
getSelectedServiceprovider(@Param() param: SPID_DTO) {
|
||||
return this.spService.getServiceproviderByID(param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1,13 +1,14 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import * as oracledb from 'oracledb';
|
||||
import {
|
||||
getSelectedServiceproviderDTO,
|
||||
InsertNewServiceProviderDTO,
|
||||
UpdateServiceProviderDTO,
|
||||
} from './sp.dto';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
|
||||
|
||||
import {
|
||||
SPID_DTO, InsertNewServiceProviderDTO,
|
||||
UpdateServiceProviderDTO,
|
||||
} from 'src/dto/property.dto';
|
||||
|
||||
@Injectable()
|
||||
export class SpService {
|
||||
@ -15,158 +16,381 @@ export class SpService {
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
// async insertNewServiceProviderX(body: InsertNewServiceProviderDTO) {
|
||||
|
||||
// let connection;
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException();
|
||||
// }
|
||||
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.InsertNewSP(
|
||||
// :P_NAME,
|
||||
// :P_LOOKUPCODE,
|
||||
// :P_ADDRESS1,
|
||||
// :P_ADDRESS2,
|
||||
// :P_CITY,
|
||||
// :P_STATE,
|
||||
// :P_ZIP,
|
||||
// :P_COUNTRY,
|
||||
// :P_ISSUINGREGION,
|
||||
// :P_REPLACEMENTREGION,
|
||||
// :P_BONDSURETY,
|
||||
// :P_CARGOPOLICYNO,
|
||||
// :P_CARGOSURETY,
|
||||
// :P_USER_ID,
|
||||
// :P_NOTES,
|
||||
// :P_FILEIDS,
|
||||
// :P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_NAME: { val: body.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_ADDRESS1: { val: body.P_ADDRESS1, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_ADDRESS2: { val: body.P_ADDRESS2, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_CITY: { val: body.P_CITY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_STATE: { val: body.P_STATE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_ZIP: { val: body.P_ZIP, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_COUNTRY: { val: body.P_COUNTRY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_ISSUINGREGION: { val: body.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_REPLACEMENTREGION: { val: body.P_REPLACEMENTREGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_BONDSURETY: { val: body.P_BONDSURETY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_CARGOPOLICYNO: { val: body.P_CARGOPOLICYNO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_CARGOSURETY: { val: body.P_CARGOSURETY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_USER_ID: { val: body.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_FILEIDS: { val: body.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR },
|
||||
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
// await connection.commit();
|
||||
|
||||
// const fres = await result.outBinds.P_CURSOR.getRows();
|
||||
|
||||
// if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
// this.logger.warn(fres[0].ERRORMESG);
|
||||
// throw new BadRequestException(fres[0].ERRORMESG)
|
||||
// }
|
||||
|
||||
// // return fres[0];
|
||||
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// this.logger.warn(error.message);
|
||||
// throw error;
|
||||
// }
|
||||
// this.logger.error('insertNewServiceProvider failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async insertNewServiceProvider(body: InsertNewServiceProviderDTO) {
|
||||
|
||||
const newBody = {
|
||||
P_NAME: null,
|
||||
P_LOOKUPCODE: null,
|
||||
P_ADDRESS1: null,
|
||||
P_ADDRESS2: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_ZIP: null,
|
||||
P_COUNTRY: null,
|
||||
P_ISSUINGREGION: null,
|
||||
P_REPLACEMENTREGION: null,
|
||||
P_BONDSURETY: null,
|
||||
P_CARGOPOLICYNO: null,
|
||||
P_CARGOSURETY: null,
|
||||
P_USER_ID: null
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
|
||||
function setEmptyStringsToNull(obj) {
|
||||
Object.keys(obj).forEach((key) => {
|
||||
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
||||
setEmptyStringsToNull(obj[key]);
|
||||
} else if (obj[key] === '') {
|
||||
obj[key] = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setEmptyStringsToNull(reqBody);
|
||||
|
||||
const finalBody: InsertNewServiceProviderDTO = { ...newBody, ...reqBody };
|
||||
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.InsertNewSP(
|
||||
:p_name,
|
||||
:p_lookupcode,
|
||||
:p_address1,
|
||||
:p_address2,
|
||||
:p_city,
|
||||
:p_state,
|
||||
:p_zip,
|
||||
:p_country,
|
||||
:p_issuingregion,
|
||||
:p_replacementregion,
|
||||
:p_bondsurety,
|
||||
:p_cargopolicyno,
|
||||
:p_cargosurety,
|
||||
:p_user_id,
|
||||
:P_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);
|
||||
:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_name: {
|
||||
val: body.p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_lookupcode: {
|
||||
val: body.p_lookupcode,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_address1: {
|
||||
val: body.p_address1,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_address2: {
|
||||
val: body.p_address2,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_city: {
|
||||
val: body.p_city,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_state: {
|
||||
val: body.p_state,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_zip: {
|
||||
val: body.p_zip,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_country: {
|
||||
val: body.p_country,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_issuingregion: {
|
||||
val: body.p_issuingregion,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_replacementregion: {
|
||||
val: body.p_replacementregion,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_bondsurety: {
|
||||
val: body.p_bondsurety,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cargopolicyno: {
|
||||
val: body.p_cargopolicyno,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cargosurety: {
|
||||
val: body.p_cargosurety,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_user_id: {
|
||||
val: body.p_user_id,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
P_NOTES: {
|
||||
val: body.P_NOTES,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
P_FILEIDS: {
|
||||
val: body.P_FILEIDS,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_NAME: { val: finalBody.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_LOOKUPCODE: { val: finalBody.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ADDRESS1: { val: finalBody.P_ADDRESS1, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ADDRESS2: { val: finalBody.P_ADDRESS2, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CITY: { val: finalBody.P_CITY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_STATE: { val: finalBody.P_STATE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ZIP: { val: finalBody.P_ZIP, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_REPLACEMENTREGION: { val: finalBody.P_REPLACEMENTREGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_BONDSURETY: { val: finalBody.P_BONDSURETY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CARGOPOLICYNO: { val: finalBody.P_CARGOPOLICYNO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CARGOSURETY: { val: finalBody.P_CARGOSURETY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_USER_ID: { val: finalBody.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_NOTES: { val: finalBody.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_FILEIDS: { val: finalBody.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
await connection.commit();
|
||||
|
||||
const fres = await result.outBinds.p_cursor.getRows();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
if (fres.length>0 && fres[0].ERRORMESG) {
|
||||
|
||||
let fres: any = await fetchCursor(outBinds.P_CURSOR, SpService.name);
|
||||
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
// return fres[0];
|
||||
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('insertNewServiceProvider failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async 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 = {
|
||||
p_spid: null,
|
||||
p_name: null,
|
||||
p_lookupcode: null,
|
||||
p_address1: null,
|
||||
p_address2: null,
|
||||
p_city: null,
|
||||
p_state: null,
|
||||
p_zip: null,
|
||||
p_country: null,
|
||||
p_issuingregion: null,
|
||||
p_replacementregion: null,
|
||||
p_bondsurety: null,
|
||||
p_cargopolicyno: null,
|
||||
p_cargosurety: null,
|
||||
p_user_id: null
|
||||
P_SPID: null,
|
||||
P_NAME: null,
|
||||
P_LOOKUPCODE: null,
|
||||
P_ADDRESS1: null,
|
||||
P_ADDRESS2: null,
|
||||
P_CITY: null,
|
||||
P_STATE: null,
|
||||
P_ZIP: null,
|
||||
P_COUNTRY: null,
|
||||
P_ISSUINGREGION: null,
|
||||
P_REPLACEMENTREGION: null,
|
||||
P_BONDSURETY: null,
|
||||
P_CARGOPOLICYNO: null,
|
||||
P_CARGOSURETY: null,
|
||||
P_USER_ID: null
|
||||
};
|
||||
|
||||
const reqBody = JSON.parse(JSON.stringify(body));
|
||||
@ -188,266 +412,264 @@ export class SpService {
|
||||
let connection;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.UpdateSP(
|
||||
:p_spid,
|
||||
:p_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;`,
|
||||
USCIB_Managed_Pkg.UpdateSP(
|
||||
:P_SPID,
|
||||
: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_spid: {
|
||||
val: finalBody.p_spid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_name: {
|
||||
val: finalBody.p_name,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_lookupcode: {
|
||||
val: finalBody.p_lookupcode,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_address1: {
|
||||
val: finalBody.p_address1,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_address2: {
|
||||
val: finalBody.p_address2,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_city: {
|
||||
val: finalBody.p_city,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_state: {
|
||||
val: finalBody.p_state,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_zip: {
|
||||
val: finalBody.p_zip,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_country: {
|
||||
val: finalBody.p_country,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_bondsurety: {
|
||||
val: finalBody.p_bondsurety,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cargopolicyno: {
|
||||
val: finalBody.p_cargopolicyno,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cargosurety: {
|
||||
val: finalBody.p_cargosurety,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_replacementregion: {
|
||||
val: finalBody.p_replacementregion,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_issuingregion: {
|
||||
val: finalBody.p_issuingregion,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_user_id: {
|
||||
val: finalBody.p_user_id,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
P_NOTES: {
|
||||
val: finalBody.P_NOTES,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
P_FILEIDS: {
|
||||
val: finalBody.P_FILEIDS,
|
||||
type: oracledb.DB_TYPE_VARCHAR,
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_SPID: { val: finalBody.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_NAME: { val: finalBody.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_LOOKUPCODE: { val: finalBody.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ADDRESS1: { val: finalBody.P_ADDRESS1, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ADDRESS2: { val: finalBody.P_ADDRESS2, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CITY: { val: finalBody.P_CITY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_STATE: { val: finalBody.P_STATE, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ZIP: { val: finalBody.P_ZIP, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_REPLACEMENTREGION: { val: finalBody.P_REPLACEMENTREGION, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_BONDSURETY: { val: finalBody.P_BONDSURETY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CARGOPOLICYNO: { val: finalBody.P_CARGOPOLICYNO, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CARGOSURETY: { val: finalBody.P_CARGOSURETY, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_USER_ID: { val: finalBody.P_USER_ID, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_NOTES: { val: finalBody.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_FILEIDS: { val: finalBody.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
await connection.commit();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
const fres = await result.outBinds.p_cursor.getRows();
|
||||
let fres: any = await fetchCursor(outBinds.P_CURSOR, SpService.name);
|
||||
|
||||
if (fres.length>0 && fres[0].ERRORMESG) {
|
||||
if (fres.length > 0 && fres[0].ERRORMESG) {
|
||||
this.logger.warn(fres[0].ERRORMESG);
|
||||
throw new BadRequestException(fres[0].ERRORMESG)
|
||||
}
|
||||
|
||||
return { statusCode: 200, message: "Updated Successfully" };
|
||||
return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('updateServiceProvider failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpService.name)
|
||||
}
|
||||
}
|
||||
|
||||
// async getAllServiceprovidersX() {
|
||||
// let connection;
|
||||
// let rows: any = [];
|
||||
// try {
|
||||
// connection = await this.oracleDBService.getConnection();
|
||||
// if (!connection) {
|
||||
// throw new InternalServerException();
|
||||
// }
|
||||
|
||||
// const result = await connection.execute(
|
||||
// `BEGIN
|
||||
// USCIB_Managed_Pkg.GetAllSPs(:P_CURSOR);
|
||||
// END;`,
|
||||
// {
|
||||
// P_CURSOR: {
|
||||
// type: oracledb.CURSOR,
|
||||
// dir: oracledb.BIND_OUT,
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
// },
|
||||
// );
|
||||
|
||||
// if (result.outBinds && result.outBinds.P_CURSOR) {
|
||||
// const cursor = result.outBinds.P_CURSOR;
|
||||
// let rowsBatch;
|
||||
|
||||
// do {
|
||||
// rowsBatch = await cursor.getRows(100);
|
||||
// rows = rows.concat(rowsBatch);
|
||||
// } while (rowsBatch.length > 0);
|
||||
|
||||
// await cursor.close();
|
||||
|
||||
// if (rows.length > 0 && rows[0].ERRORMESG) {
|
||||
// throw new BadRequestException(rows[0].ERRORMESG);
|
||||
// }
|
||||
|
||||
// return rows;
|
||||
// } else {
|
||||
// throw new BadRequestException();
|
||||
// }
|
||||
// } catch (error) {
|
||||
// if (error instanceof BadRequestException) {
|
||||
// this.logger.warn(error.message);
|
||||
// throw error;
|
||||
// }
|
||||
// this.logger.error('getAllServiceproviders failed', error.stack || error);
|
||||
// throw new InternalServerException();
|
||||
// } finally {
|
||||
// if (connection) {
|
||||
// try {
|
||||
// await connection.close();
|
||||
// } catch (closeErr) {
|
||||
// this.logger.error('Failed to close DB connection', closeErr);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
async getAllServiceproviders() {
|
||||
|
||||
let connection;
|
||||
let rows: any = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetAllSPs(:p_cursor);
|
||||
USCIB_Managed_Pkg.GetAllSPs(:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
await cursor.close();
|
||||
|
||||
if (rows.length > 0 && rows[0].ERRORMESG) {
|
||||
throw new BadRequestException(rows[0].ERRORMESG);
|
||||
}
|
||||
|
||||
return rows;
|
||||
} else {
|
||||
throw new BadRequestException();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return await fetchCursor(outBinds.P_CURSOR, SpService.name);
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
this.logger.error('getAllServiceproviders failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpService.name)
|
||||
}
|
||||
}
|
||||
|
||||
async 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 rows: any = [];
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
USCIB_Managed_Pkg.GetSPbySPID(:p_spid,:p_cursor);
|
||||
USCIB_Managed_Pkg.GetSPbySPID(:P_SPID,:P_CURSOR);
|
||||
END;`,
|
||||
{
|
||||
p_spid: {
|
||||
val: body.p_spid,
|
||||
type: oracledb.DB_TYPE_NUMBER,
|
||||
},
|
||||
p_cursor: {
|
||||
type: oracledb.CURSOR,
|
||||
dir: oracledb.BIND_OUT,
|
||||
},
|
||||
},
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
if (result.outBinds && result.outBinds.p_cursor) {
|
||||
const cursor = result.outBinds.p_cursor;
|
||||
let rowsBatch;
|
||||
|
||||
do {
|
||||
rowsBatch = await cursor.getRows(100);
|
||||
rows = rows.concat(rowsBatch);
|
||||
} while (rowsBatch.length > 0);
|
||||
|
||||
await cursor.close();
|
||||
} else {
|
||||
throw new BadRequestException();
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
if (rows.length > 0 && rows[0].ERRORMESG) {
|
||||
throw new BadRequestException(rows[0].ERRORMESG);
|
||||
}
|
||||
return await fetchCursor(outBinds.P_CURSOR, SpService.name);
|
||||
|
||||
return rows;
|
||||
} catch (error) {
|
||||
if (error instanceof BadRequestException) {
|
||||
this.logger.warn(error.message);
|
||||
throw error;
|
||||
}
|
||||
else if (error.message === "NJS-107: invalid cursor") {
|
||||
this.logger.warn(error.message);
|
||||
throw new BadRequestException();
|
||||
}
|
||||
this.logger.error('getServiceproviderByID failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
handleError(error, SpService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, SpService.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 { 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')
|
||||
@Controller('oracle')
|
||||
export class UserMaintenanceController {
|
||||
constructor(private readonly userMaintenanceService: UserMaintenanceService) { }
|
||||
|
||||
// SP_USER_DETAILS
|
||||
|
||||
@Get('GetSPUserDetails/:p_userid')
|
||||
async GetPreparers(@Param() params: GetSPUserDetailsDTO) {
|
||||
@Get('GetUserDetails/:P_USERID')
|
||||
async GetPreparers(@Param() params: USERID_DTO) {
|
||||
return await this.userMaintenanceService.GetSPUserDetails(params);
|
||||
}
|
||||
|
||||
// @ApiTags('User Maintenance - Oracle')
|
||||
// @Get('GetSPUserDetailsv1')
|
||||
// async GetPreparersv1(@Query() query: GetSPUserDetailsDTO) {
|
||||
// return await this.userMaintenanceService.GetSPUserDetailsv1(query);
|
||||
// }
|
||||
|
||||
// @ApiTags('User Maintenance - Oracle')
|
||||
@Post('CreateUSCIBLogins')
|
||||
async CreateUSCIBLogins(@Body() body: CreateUSCIBLoginsDTO) {
|
||||
return await this.userMaintenanceService.CreateUSCIBLogins(body);
|
||||
@Patch('LockUserAccount')
|
||||
async LockUserAccount(@Body() body: SPID_EMAIL_DTO) {
|
||||
return await this.userMaintenanceService.LockUserAccount(body);
|
||||
}
|
||||
|
||||
// @ApiTags('User Maintenance - Oracle')
|
||||
// USCIB_LOGINS
|
||||
|
||||
@Get('GetUSCIBLogins')
|
||||
async GetUSCIBLogins() {
|
||||
return await this.userMaintenanceService.GetUSCIBLogins();
|
||||
}
|
||||
|
||||
@Get('GetSPLogins/:p_spid')
|
||||
async GetSPLogins(@Param() params: UseSPIDDTO) {
|
||||
@Post('CreateUSCIBLogins')
|
||||
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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -1,9 +1,14 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { OracleDBService } from 'src/db/db.service';
|
||||
import { CreateUSCIBLoginsDTO, GetSPUserDetailsDTO, UseSPIDDTO } from './user-maintenance.dto';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
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; }
|
||||
@ -25,18 +30,20 @@ export class UserMaintenanceService {
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
private async fetchCursor<T>(cursor: oracledb.ResultSet<T>): Promise<T[]> {
|
||||
try {
|
||||
const rows = await cursor.getRows(); // or getRows(1000) if needed
|
||||
await cursor.close();
|
||||
return rows;
|
||||
} catch (err) {
|
||||
this.logger.error('Failed to fetch from cursor', err.stack || err);
|
||||
throw new InternalServerException("Error reading data from database.");
|
||||
}
|
||||
}
|
||||
// private async fetchCursor<T>(cursor: oracledb.ResultSet<T>): Promise<T[]> {
|
||||
// try {
|
||||
// const rows = await cursor.getRows(); // or getRows(1000) if needed
|
||||
// await cursor.close();
|
||||
// return rows;
|
||||
// } catch (err) {
|
||||
// this.logger.error('Failed to fetch from cursor', err.stack || err);
|
||||
// throw new InternalServerException("Error reading data from database.");
|
||||
// }
|
||||
// }
|
||||
|
||||
async GetSPUserDetails(body: GetSPUserDetailsDTO): Promise<any> {
|
||||
// SP_USER_DETAILS
|
||||
|
||||
async GetSPUserDetails(body: USERID_DTO): Promise<any> {
|
||||
let connection;
|
||||
|
||||
try {
|
||||
@ -49,7 +56,7 @@ export class UserMaintenanceService {
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
P_USERID: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_ROLECUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
P_MENUCUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
P_MENUPAGECUR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
@ -63,38 +70,59 @@ export class UserMaintenanceService {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
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 {
|
||||
roleDetails: await this.fetchCursor(outBinds.P_ROLECUR),
|
||||
menuDetails: await this.fetchCursor(outBinds.P_MENUCUR),
|
||||
menuPageDetails: await this.fetchCursor(outBinds.P_MENUPAGECUR),
|
||||
roleDetails: roleDetailsTemp.map(x => x.ROLENAME),
|
||||
menuDetails: menuDetailsTemp.map(x => x.MENUNAME),
|
||||
menuPageDetails: await fetchCursor(outBinds.P_MENUPAGECUR, UserMaintenanceService.name),
|
||||
userDetails: userdetailsTemp[0]
|
||||
};
|
||||
} 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);
|
||||
handleError(error, UserMaintenanceService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, UserMaintenanceService.name)
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
try {
|
||||
@ -102,54 +130,29 @@ export class UserMaintenanceService {
|
||||
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
SPCLIENTUSER_PKG.GetSPUserDetails(
|
||||
:p_userid , :p_rolecur , :p_menucur , :p_menuPageCur , :p_userdetails
|
||||
);
|
||||
END;`,
|
||||
Userlogin_pkg.GetUSCIBLogins(
|
||||
:P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
p_rolecur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
p_menucur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
p_menuPageCur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
p_userdetails: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.p_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.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return {
|
||||
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),
|
||||
};
|
||||
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
|
||||
} 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);
|
||||
handleError(error, UserMaintenanceService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, UserMaintenanceService.name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async CreateUSCIBLogins(body: CreateUSCIBLoginsDTO) {
|
||||
@ -162,106 +165,40 @@ export class UserMaintenanceService {
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
Userlogin_pkg.CreateUSCIBLogins(
|
||||
:p_userid , :p_emailaddr , :p_lookupCode , :p_password , :P_EnablePasswordPolicy, :p_cursor
|
||||
:P_USERID , :P_EMAILADDR , :P_LOOKUPCODE , :P_PASSWORD , :P_ENABLEPASSWORDPOLICY, :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
p_userid: { val: body.p_userid, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
p_emailaddr: { val: body.p_emailaddr, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
p_lookupCode: { val: body.p_lookupCode, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
p_password: { val: body.p_password, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_EnablePasswordPolicy: { val: body.P_EnablePasswordPolicy, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_EMAILADDR: { val: body.P_EMAILADDR, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_LOOKUPCODE: { val: body.P_LOOKUPCODE, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_PASSWORD: { val: body.P_PASSWORD, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_ENABLEPASSWORDPOLICY: { val: body.P_ENABLEPASSWORDPOLICY, type: oracledb.DB_TYPE_NVARCHAR },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.p_cursor) {
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return {
|
||||
data: await this.fetchCursor(outBinds.p_cursor),
|
||||
data: await 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);
|
||||
handleError(error, UserMaintenanceService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, UserMaintenanceService.name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async GetUSCIBLogins() {
|
||||
// SP LOGINS
|
||||
|
||||
let connection;
|
||||
|
||||
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) {
|
||||
async GetSPLogins(body: SPID_DTO) {
|
||||
|
||||
let connection;
|
||||
|
||||
@ -271,46 +208,211 @@ export class UserMaintenanceService {
|
||||
const result = await connection.execute(
|
||||
`BEGIN
|
||||
Userlogin_pkg.GetSPLogins(
|
||||
:p_spid , :p_cursor
|
||||
:P_SPID , :P_CURSOR
|
||||
);
|
||||
END;`,
|
||||
{
|
||||
p_spid: { val: body.p_spid, type: oracledb.DB_TYPE_NUMBER },
|
||||
p_cursor: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
|
||||
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
|
||||
},
|
||||
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
|
||||
);
|
||||
|
||||
const outBinds = result.outBinds;
|
||||
if (!outBinds?.p_cursor) {
|
||||
if (!outBinds?.P_CURSOR) {
|
||||
this.logger.error('One or more expected cursors are missing from stored procedure output.');
|
||||
throw new InternalServerException("Incomplete data received from the database.");
|
||||
}
|
||||
|
||||
return await this.fetchCursor(outBinds.p_cursor);
|
||||
return await fetchCursor(outBinds.P_CURSOR, UserMaintenanceService.name);
|
||||
} 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);
|
||||
handleError(error, UserMaintenanceService.name)
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
await closeOracleDbConnection(connection, UserMaintenanceService.name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
49
src/utils/helper.ts
Normal 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.');
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user