moduled code

This commit is contained in:
Kallesh B S 2025-03-25 17:10:33 +05:30
parent f1edfe48d2
commit a9ed1bbdf0
34 changed files with 1990 additions and 1608 deletions

View File

@ -4,7 +4,7 @@ import { OracleModule } from './oracle/oracle.module';
import { AuthModule } from './auth/auth.module'; import { AuthModule } from './auth/auth.module';
@Module({ @Module({
imports: [DbModule, OracleModule, AuthModule], imports: [ AuthModule, DbModule, OracleModule],
controllers: [], controllers: [],
providers: [], providers: [],
}) })

View File

@ -0,0 +1,77 @@
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,
GetCarnetDetailsbyCarnetStatusDTO
} from './home-page.dto';
@Controller()
export class HomePageController {
constructor(
private readonly homePageService: HomePageService
) { }
@ApiTags('HomePage - Oracle')
@Get('/oracle/GetHomePageData/:id')
GetHomePageData(@Param('id', ParseIntPipe) id: number) {
return this.homePageService.GetHomePageData(id);
}
@ApiTags('HomePage - Oracle')
@Get('/oracle/GetCarnetSummaryData/:userid')
GetCarnetSummaryData(@Param('userid') id: string) {
return this.homePageService.GetCarnetSummaryData(id);
}
@ApiTags('HomePage - Oracle')
@Post('/oracle/SaveCarnetApplication')
SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
return this.homePageService.SaveCarnetApplication(body);
// return body;
}
@ApiTags('HomePage - Oracle')
@Post('/oracle/TransmitApplicationtoProcess')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.homePageService.TransmitApplicationtoProcess(body);
}
@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 })
}
}
}

View File

@ -0,0 +1,293 @@
import { ApiProperty } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsArray, IsDefined, IsInt, IsNumber, IsOptional, IsString, Length, Max, Min, 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;
@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 })
@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 })
@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;
}
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 })
@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;
@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 })
@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: 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 })
@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_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_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, 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, 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 })
@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, 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_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_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_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;
}
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 })
@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;
@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;
}

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { HomePageService } from './home-page.service';
import { HomePageController } from './home-page.controller';
import { DbModule } from 'src/db/db.module';
@Module({
imports:[DbModule],
providers: [ HomePageService],
controllers: [HomePageController]
})
export class HomePageModule {}

View File

@ -1,10 +1,16 @@
import { Injectable } from "@nestjs/common"; import { Injectable } from "@nestjs/common";
import { OracleDBService } from "src/db/db.service"; import { OracleDBService } from "src/db/db.service";
import * as oracledb from 'oracledb' import * as oracledb from 'oracledb'
import { GetCarnetDetailsbyCarnetStatusDTO, p_countrytableDTO, p_gltableDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO } from "./oracle.dto"; import {
p_gltableDTO,
p_countrytableDTO,
SaveCarnetApplicationDTO,
TransmitApplicationtoProcessDTO,
GetCarnetDetailsbyCarnetStatusDTO,
} from "./home-page.dto";
@Injectable() @Injectable()
export class HomePageDataService { export class HomePageService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
@ -769,5 +775,4 @@ export class HomePageDataService {
return { error: err.message } return { error: err.message }
} finally { } } finally { }
} }
} }

View File

@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('manage-fee')
export class ManageFeeController {}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageFeeController } from './manage-fee.controller';
import { ManageFeeService } from './manage-fee.service';
@Module({
controllers: [ManageFeeController],
providers: [ManageFeeService]
})
export class ManageFeeModule {}

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class ManageFeeService {}

View File

@ -0,0 +1,12 @@
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
@Controller()
export class ManageHoldersController {
@ApiTags('Manage Holders - Oracle')
@Get()
GetHolderMaster(){
return {message:"Request received.."}
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageHoldersService } from './manage-holders.service';
import { ManageHoldersController } from './manage-holders.controller';
@Module({
providers: [ManageHoldersService],
controllers: [ManageHoldersController]
})
export class ManageHoldersModule {}

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class ManageHoldersService {}

View File

@ -1,10 +1,9 @@
import { BadRequestException, Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put, Query, UsePipes } from '@nestjs/common'; import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put, Query, UsePipes } from '@nestjs/common';
import { OracleService } from './oracle.service'; import { OracleService } from './oracle.service';
import { ActivateOrInactivateParamRecordDTO, CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCarnetSequenceDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, CreateParamRecordDTO, CreateTableRecordDTO, GetCarnetDetailsbyCarnetStatusDTO, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, SaveCarnetApplicationDTO, TestDTO, TransmitApplicationtoProcessDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommBodyDTO, UpdateFeeCommDTO, UpdateParamRecordDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto'; import { ActivateOrInactivateParamRecordDTO, CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCarnetSequenceDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, CreateParamRecordDTO, CreateTableRecordDTO, InsertSPContactsDTO, TestDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommBodyDTO, UpdateFeeCommDTO, UpdateParamRecordDTO, UpdateSPContactsDTO } from './oracle.dto';
import { ParamTableService } from './paramTable.service'; import { ParamTableService } from './paramTable.service';
import { ManageFeeService } from './manageFee.service'; import { ManageFeeService } from './manageFee.service';
import { ApiOperation, ApiPropertyOptional, ApiQuery, ApiTags } from '@nestjs/swagger'; import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { HomePageDataService } from './homePageData.service';
@Controller('oracle') @Controller('oracle')
export class OracleController { export class OracleController {
@ -12,62 +11,8 @@ export class OracleController {
private readonly oarcleService: OracleService, private readonly oarcleService: OracleService,
private readonly paramTableService: ParamTableService, private readonly paramTableService: ParamTableService,
private readonly manageFeeService: ManageFeeService, private readonly manageFeeService: ManageFeeService,
private readonly homePageDataService: HomePageDataService
) { } ) { }
// HomePageData
@ApiTags('HomePage - Oracle')
@Get('/GetHomePageData/:id')
GetHomePageData(@Param('id', ParseIntPipe) id: number) {
return this.homePageDataService.GetHomePageData(id);
}
@ApiTags('HomePage - Oracle')
@Get('/GetCarnetSummaryData/:userid')
GetCarnetSummaryData(@Param('userid') id: string) {
return this.homePageDataService.GetCarnetSummaryData(id);
}
@ApiTags('HomePage - Oracle')
@Post('/SaveCarnetApplication')
SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
return this.homePageDataService.SaveCarnetApplication(body);
// return body;
}
@ApiTags('HomePage - Oracle')
@Post('/TransmitApplicationtoProcess')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.homePageDataService.TransmitApplicationtoProcess(body);
}
@ApiTags('HomePage - Oracle')
@Get('/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.homePageDataService.GetCarnetDetailsbyCarnetStatus(body);
}
catch (err) {
return new BadRequestException({ message: 'Validation faileda', error: err.message })
}
}
// @ApiTags('HomePage - Oracle') // @ApiTags('HomePage - Oracle')
// @Post('/test') // @Post('/test')
// test(@Body() body:TestDTO) { // test(@Body() body:TestDTO) {
@ -75,147 +20,70 @@ export class OracleController {
// return body; // return body;
// } // }
// Regions
@ApiTags('Regions - Oracle')
@Post('/InsertRegions')
insertRegions(@Body() body: InsertRegionsDto) {
return this.oarcleService.insertRegions(body.p_region, body.p_name);
}
@ApiTags('Regions - Oracle')
@Patch('/UpdateRegion')
updateRegions(@Body() body: UpdateRegionDto) {
return this.oarcleService.updateRegions(body.p_regionID, body.p_name);
}
@ApiTags('Regions - Oracle')
@Get('/GetRegions')
getRegions() {
return this.oarcleService.getRegions();
}
// Service Provider [ SP ] // Service Provider [ SP ]
@ApiTags('SP - Oracle') // @ApiTags('SP - Oracle')
@Post('/InsertNewServiceProvider') // @Post('/InsertNewServiceProvider')
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) { // insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
return this.oarcleService.insertNewServiceProvider( // return this.oarcleService.insertNewServiceProvider(
body.p_name, // body.p_name,
body.p_lookupcode, // body.p_lookupcode,
body.p_address1, // body.p_address1,
body.p_address2, // body.p_address2,
body.p_city, // body.p_city,
body.p_state, // body.p_state,
body.p_zip, // body.p_zip,
body.p_country, // body.p_country,
body.p_issuingregion, // body.p_issuingregion,
body.p_replacementregion, // body.p_replacementregion,
body.p_bondsurety, // body.p_bondsurety,
body.p_cargopolicyno, // body.p_cargopolicyno,
body.p_cargosurety, // body.p_cargosurety,
body.p_user_id, // body.p_user_id,
body.P_NOTES, // body.P_NOTES,
body.P_FILEIDS // body.P_FILEIDS
) // )
} // }
@ApiTags('SP - Oracle') // @ApiTags('SP - Oracle')
@Put('/UpdateServiceProvider') // @Put('/UpdateServiceProvider')
updateServiceProider(@Body() body: UpdateServiceProviderDTO) { // updateServiceProider(@Body() body: UpdateServiceProviderDTO) {
return this.oarcleService.updateServiceProvider( // return this.oarcleService.updateServiceProvider(
body.p_spid, // body.p_spid,
body.p_name, // body.p_name,
body.p_lookupcode, // body.p_lookupcode,
body.p_address1, // body.p_address1,
body.p_address2, // body.p_address2,
body.p_city, // body.p_city,
body.p_state, // body.p_state,
body.p_zip, // body.p_zip,
body.p_country, // body.p_country,
body.p_issuingregion, // body.p_issuingregion,
body.p_replacementregion, // body.p_replacementregion,
body.p_bondsurety, // body.p_bondsurety,
body.p_cargopolicyno, // body.p_cargopolicyno,
body.p_cargosurety, // body.p_cargosurety,
body.p_user_id, // body.p_user_id,
body.P_NOTES, // body.P_NOTES,
body.P_FILEIDS // body.P_FILEIDS
) // )
} // }
@ApiTags('SP - Oracle') // @ApiTags('SP - Oracle')
@Get('/GetAllServiceproviders') // @Get('/GetAllServiceproviders')
getAllServiceproviders() { // getAllServiceproviders() {
return this.oarcleService.getAllServiceproviders(); // return this.oarcleService.getAllServiceproviders();
} // }
@ApiTags('SP - Oracle')
@Get('/GetSelectedServiceprovider/:id')
getSelectedServiceprovider(@Param('id', ParseIntPipe) id: number) {
return this.oarcleService.getServiceproviderByID(id);
}
// @ApiTags('SP - Oracle')
// @Get('/GetSelectedServiceprovider/:id')
// getSelectedServiceprovider(@Param('id', ParseIntPipe) id: number) {
// return this.oarcleService.getServiceproviderByID(id);
// }
// SPContacts // SPContacts
@ApiTags('SPContacts - Oracle')
@Post('/InsertSPContacts')
insertSPContacts(@Body() body: InsertSPContactsDTO) {
return this.oarcleService.insertSPContacts(
body.p_spid,
body.p_defcontactflag,
body.p_firstname,
body.p_lastname,
body.P_MIDDLEINITIAL,
body.p_title,
body.p_phoneno,
body.p_mobileno,
body.p_faxno,
body.p_emailaddress,
body.p_user_id
)
}
@ApiTags('SPContacts - Oracle')
@Post('/SetSPDefaultcontact/:id')
setSPDefaultcontact(@Param('id', ParseIntPipe) id: number) {
return this.oarcleService.setSPDefaultcontact(id)
}
@ApiTags('SPContacts - Oracle')
@Put('/UpdateSPContacts')
updateSPContacts(@Body() body: UpdateSPContactsDTO) {
return this.oarcleService.updateSPContacts(
body.p_spcontactid,
body.p_firstname,
body.p_lastname,
body.P_MIDDLEINITIAL,
body.p_title,
body.p_phoneno,
body.p_mobileno,
body.p_faxno,
body.p_emailaddress,
body.p_user_id
)
}
@ApiTags('SPContacts - Oracle')
@Post('/InactivateSPContact/:id')
inactivateSPContact(@Param('id', ParseIntPipe) id: number) {
return this.oarcleService.inactivateSPContact(id)
}
@ApiTags('SPContacts - Oracle')
@Get('/GetSPDefaultcontact/:id')
getSPDefaultcontact(@Param('id', ParseIntPipe) id: number) {
return this.oarcleService.getSPDefaultcontacts(id)
}
// @Get('/GetAllSPcontacts')
// getSPcontacts() {
// return this.oarcleService.getSPcontacts();
// }
// Carnet Sequence // Carnet Sequence

View File

@ -1,173 +1,13 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
import { ArrayNotEmpty, IsArray, IsDefined, IsEmail, IsIn, IsInt, IsNumber, IsObject, IsOptional, IsString, Length, Max, Min, min, ValidateNested } from 'class-validator'; import { IsArray, IsDefined, IsEmail, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator';
export class InsertRegionsDto {
@ApiProperty()
@IsString()
p_region: string;
@ApiProperty()
@IsString()
p_name: string;
}
export class UpdateRegionDto {
@ApiProperty({ required: true })
@IsNumber()
p_regionID: number;
@ApiProperty({ required: true })
@IsString()
p_name: string;
}
// export class GetSelectedServiceProviderDTO { // export class GetSelectedServiceProviderDTO {
// @IsNumber() // @IsNumber()
// p_spid: number; // p_spid: number;
// } // }
export class InsertNewServiceProviderDTO {
@ApiProperty({ required: true })
@IsString()
p_name: string;
@ApiProperty({ required: true })
@IsString()
p_lookupcode: string;
@ApiProperty({ required: true })
@IsString()
p_address1: string;
@ApiProperty({ required: false })
@IsString()
p_address2: string;
@ApiProperty({ required: true })
@IsString()
p_city: string;
@ApiProperty({ required: true })
@IsString()
p_state: string;
@ApiProperty({ required: true })
@IsString()
p_zip: string;
@ApiProperty({ required: true })
@IsString()
p_country: string;
@ApiProperty({ required: true })
@IsString()
p_issuingregion: string;
@ApiProperty({ required: true })
@IsString()
p_replacementregion: string;
@ApiProperty({ required: true })
@IsString()
p_bondsurety: string;
@ApiProperty({ required: true })
@IsString()
p_cargopolicyno: string;
@ApiProperty({ required: true })
@IsString()
p_cargosurety: string;
@ApiProperty({ required: true })
@IsString()
p_user_id: string;
@ApiProperty({ required: false })
@IsString()
P_NOTES: string;
@ApiProperty({ required: false })
@IsString()
P_FILEIDS: string;
}
export class UpdateServiceProviderDTO {
@ApiProperty({ required: true })
@IsNumber()
p_spid: number;
@ApiProperty({ required: true })
@IsString()
p_name: string;
@ApiProperty({ required: true })
@IsString()
p_lookupcode: string;
@ApiProperty({ required: true })
@IsString()
p_address1: string;
@ApiProperty({ required: false })
@IsString()
p_address2: string;
@ApiProperty({ required: true })
@IsString()
p_city: string;
@ApiProperty({ required: true })
@IsString()
p_state: string;
@ApiProperty({ required: true })
@IsString()
p_zip: string;
@ApiProperty({ required: true })
@IsString()
p_country: string;
@ApiProperty({ required: true })
@IsString()
p_issuingregion: string;
@ApiProperty({ required: true })
@IsString()
p_replacementregion: string;
@ApiProperty({ required: true })
@IsString()
p_bondsurety: string;
@ApiProperty({ required: true })
@IsString()
p_cargopolicyno: string;
@ApiProperty({ required: true })
@IsString()
p_cargosurety: string;
@ApiProperty({ required: true })
@IsString()
p_user_id: string;
@ApiProperty({ required: false })
@IsString()
P_NOTES: string;
@ApiProperty({ required: false })
@IsString()
P_FILEIDS: string;
}
// export class GetSPcontactsDTO {
// @IsNumber()
// p_SPid: number;
// }
export class InsertSPContactsDTO { export class InsertSPContactsDTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsNumber() @IsNumber()
@ -744,304 +584,6 @@ export class ActivateOrInactivateParamRecordDTO {
P_USERID: string; P_USERID: string;
} }
// Homepage
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 })
@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: 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: 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;
@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;
}
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_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: 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: 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_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_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, 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 })
@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 })
@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 })
@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_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_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, 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, 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;
@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;
}
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, 20, { message: "Property p_CarnetStatus must be between 0 to 20 characters" })
@IsString()
@IsDefined({message:"Property p_CarnetStatus is required"})
p_CarnetStatus: string;
}
//-------------------------------- //--------------------------------

View File

@ -4,12 +4,16 @@ import { OracleController } from './oracle.controller';
import { DbModule } from 'src/db/db.module'; import { DbModule } from 'src/db/db.module';
import { ParamTableService } from './paramTable.service'; import { ParamTableService } from './paramTable.service';
import { ManageFeeService } from './manageFee.service'; import { ManageFeeService } from './manageFee.service';
import { HomePageDataService } from './homePageData.service'; import { ManageHoldersModule } from './manage-holders/manage-holders.module';
import { HomePageModule } from './home-page/home-page.module';
import { UscibManagedSpModule } from './uscib-managed-sp/uscib-managed-sp.module';
import { ParamTableModule } from './param-table/param-table.module';
import { ManageFeeModule } from './manage-fee/manage-fee.module';
@Module({ @Module({
imports:[DbModule], imports:[DbModule, HomePageModule, ManageHoldersModule, UscibManagedSpModule, ParamTableModule, ManageFeeModule],
providers: [OracleService,ParamTableService,ManageFeeService,HomePageDataService], providers: [OracleService,ParamTableService,ManageFeeService],
controllers: [OracleController], controllers: [OracleController],
exports:[OracleService,ParamTableService,ManageFeeService,HomePageDataService] exports:[OracleService,ParamTableService,ManageFeeService]
}) })
export class OracleModule {} export class OracleModule {}

View File

@ -6,898 +6,9 @@ import * as oracledb from 'oracledb'
export class OracleService { export class OracleService {
constructor(private readonly oracleDBService: OracleDBService) { } constructor(private readonly oracleDBService: OracleDBService) { }
// Regions API
async insertRegions(p_region: String, p_name: String) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor);
END;`, {
p_region: {
val: p_region,
type: oracledb.DB_TYPE_VARCHAR
},
p_name: {
val: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async updateRegions(p_regionID: Number, p_name: String) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:p_name,:p_cursor);
END;`, {
p_regionID: {
val: p_regionID,
type: oracledb.DB_TYPE_NUMBER
},
p_name: {
val: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getRegions() {
let connection;
let rows = [];
try {
try {
connection = await this.oracleDBService.getConnection()
}
catch (err) {
console.log("DB ERROR: ", err);
return { error: "Error while connecting to DB" }
}
// if (!connection) {
// throw new Error('No DB Connected')
// }
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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
console.log('Rows fetched:', rows);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
// Servipe provider [ SP ]
async insertNewServiceProvider(
p_name: String,
p_lookupcode: String,
p_address1: String,
p_address2: String,
p_city: String,
p_state: String,
p_zip: String,
p_country: String,
p_issuingregion: String,
p_replacementregion: String,
p_bondsurety: String,
p_cargopolicyno: String,
p_cargosurety: String,
p_user_id: String,
P_NOTES: string,
P_FILEIDS: string
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_lookupcode: {
val: p_lookupcode,
type: oracledb.DB_TYPE_VARCHAR
},
p_address1: {
val: p_address1,
type: oracledb.DB_TYPE_VARCHAR
},
p_address2: {
val: p_address2,
type: oracledb.DB_TYPE_VARCHAR
},
p_city: {
val: p_city,
type: oracledb.DB_TYPE_VARCHAR
},
p_state: {
val: p_state,
type: oracledb.DB_TYPE_VARCHAR
},
p_zip: {
val: p_zip,
type: oracledb.DB_TYPE_VARCHAR
},
p_country: {
val: p_country,
type: oracledb.DB_TYPE_VARCHAR
},
p_issuingregion: {
val: p_issuingregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_replacementregion: {
val: p_replacementregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_bondsurety: {
val: p_bondsurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargopolicyno: {
val: p_cargopolicyno,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargosurety: {
val: p_cargosurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: p_user_id,
type: oracledb.DB_TYPE_VARCHAR
},
P_NOTES: {
val: P_NOTES,
type: oracledb.DB_TYPE_VARCHAR
},
P_FILEIDS: {
val: P_FILEIDS,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async updateServiceProvider(
p_spid: Number,
p_name: String,
p_lookupcode: String,
p_address1: String,
p_address2: String,
p_city: String,
p_state: String,
p_zip: String,
p_country: String,
p_issuingregion: String,
p_replacementregion: String,
p_bondsurety: String,
p_cargopolicyno: String,
p_cargosurety: String,
p_user_id: String,
P_NOTES: string,
P_FILEIDS: string
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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_issuingregion,
:p_replacementregion,
:p_bondsurety,
:p_cargopolicyno,
:p_cargosurety,
:p_user_id,
:P_NOTES,
:P_FILEIDS,
:p_cursor);
END;`, {
p_spid: {
val: p_spid,
type: oracledb.DB_TYPE_NUMBER
},
p_name: {
val: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_lookupcode: {
val: p_lookupcode,
type: oracledb.DB_TYPE_VARCHAR
},
p_address1: {
val: p_address1,
type: oracledb.DB_TYPE_VARCHAR
},
p_address2: {
val: p_address2,
type: oracledb.DB_TYPE_VARCHAR
},
p_city: {
val: p_city,
type: oracledb.DB_TYPE_VARCHAR
},
p_state: {
val: p_state,
type: oracledb.DB_TYPE_VARCHAR
},
p_zip: {
val: p_zip,
type: oracledb.DB_TYPE_VARCHAR
},
p_country: {
val: p_country,
type: oracledb.DB_TYPE_VARCHAR
},
p_issuingregion: {
val: p_issuingregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_replacementregion: {
val: p_replacementregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_bondsurety: {
val: p_bondsurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargopolicyno: {
val: p_cargopolicyno,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargosurety: {
val: p_cargosurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: p_user_id,
type: oracledb.DB_TYPE_VARCHAR
},
P_NOTES: {
val: P_NOTES,
type: oracledb.DB_TYPE_VARCHAR
},
P_FILEIDS: {
val: P_FILEIDS,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getAllServiceproviders() {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
// Close the cursor after you're done
await cursor.close();
return rows;
} else {
throw new Error('No cursor returned from the stored procedure');
}
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getServiceproviderByID(p_spid: Number) {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetSPbySPID(:p_spid,:p_cursor);
END;`,
{
p_spid: {
val: 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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
console.log('Rows fetched:', rows);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
// Service provider contacts [ SPContacts ] // Service provider contacts [ SPContacts ]
async insertSPContacts(
p_spid: number,
p_defcontactflag: string,
p_firstname: string,
p_lastname: string,
P_MIDDLEINITIAL: string,
p_title: string,
p_phoneno: string,
p_mobileno: string,
p_faxno: string,
p_emailaddress: string,
p_user_id: string
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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: p_spid,
type: oracledb.DB_TYPE_NUMBER
},
p_defcontactflag: {
val: p_defcontactflag,
type: oracledb.DB_TYPE_VARCHAR
},
p_firstname: {
val: p_firstname,
type: oracledb.DB_TYPE_VARCHAR
},
p_lastname: {
val: p_lastname,
type: oracledb.DB_TYPE_VARCHAR
},
P_MIDDLEINITIAL: {
val: P_MIDDLEINITIAL,
type: oracledb.DB_TYPE_VARCHAR
},
p_title: {
val: p_title,
type: oracledb.DB_TYPE_VARCHAR
},
p_phoneno: {
val: p_phoneno,
type: oracledb.DB_TYPE_VARCHAR
},
p_mobileno: {
val: p_mobileno,
type: oracledb.DB_TYPE_VARCHAR
},
p_faxno: {
val: p_faxno,
type: oracledb.DB_TYPE_VARCHAR
},
p_emailaddress: {
val: p_emailaddress,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: 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();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async setSPDefaultcontact(p_spcontactid: number) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid);
END;`,
{
p_spcontactid: {
val: p_spcontactid,
type: oracledb.DB_TYPE_NUMBER
},
}
);
await connection.commit();
return "SP executed successfully"
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async updateSPContacts(
p_spcontactid: number,
p_firstname: string,
p_lastname: string,
P_MIDDLEINITIAL: string,
p_title: string,
p_phoneno: string,
p_mobileno: string,
p_faxno: string,
p_emailaddress: string,
p_user_id: string,
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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: p_spcontactid,
type: oracledb.DB_TYPE_NUMBER
},
p_firstname: {
val: p_firstname,
type: oracledb.DB_TYPE_VARCHAR
},
p_lastname: {
val: p_lastname,
type: oracledb.DB_TYPE_VARCHAR
},
P_MIDDLEINITIAL: {
val: P_MIDDLEINITIAL,
type: oracledb.DB_TYPE_VARCHAR
},
p_title: {
val: p_title,
type: oracledb.DB_TYPE_VARCHAR
},
p_phoneno: {
val: p_phoneno,
type: oracledb.DB_TYPE_VARCHAR
},
p_mobileno: {
val: p_mobileno,
type: oracledb.DB_TYPE_VARCHAR
},
p_faxno: {
val: p_faxno,
type: oracledb.DB_TYPE_VARCHAR
},
p_emailaddress: {
val: p_emailaddress,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: 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();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async inactivateSPContact(p_spcontactid: number) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid);
END;`, {
p_spcontactid: {
val: p_spcontactid,
type: oracledb.DB_TYPE_NUMBER
}
}
);
await connection.commit();
return "SP executed successfully"
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getSPDefaultcontacts(p_SPid: number) {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetSPDefaultContacts(:p_SPid,:p_cursor);
END;`,
{
p_SPid: {
val: 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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getSPcontacts() {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetSPAllContacts(: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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
console.log('Rows fetched:', rows);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
// CarnetSequence // CarnetSequence

View File

@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('param-table')
export class ParamTableController {}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ParamTableController } from './param-table.controller';
import { ParamTableService } from './param-table.service';
@Module({
controllers: [ParamTableController],
providers: [ParamTableService]
})
export class ParamTableModule {}

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class ParamTableService {}

View File

@ -0,0 +1,4 @@
import { Controller } from '@nestjs/common';
@Controller('carnet-sequence')
export class CarnetSequenceController {}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { CarnetSequenceController } from './carnet-sequence.controller';
import { CarnetSequenceService } from './carnet-sequence.service';
@Module({
controllers: [CarnetSequenceController],
providers: [CarnetSequenceService]
})
export class CarnetSequenceModule {}

View File

@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';
@Injectable()
export class CarnetSequenceService {}

View File

@ -0,0 +1,38 @@
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';
@Controller('oracle')
export class RegionController {
constructor(
private readonly regionService: RegionService
) { }
@ApiTags('Regions - Oracle')
@Post('/InsertRegions')
insertRegions(@Body() body: InsertRegionsDto) {
return this.regionService.insertRegions(body.p_region, body.p_name);
}
@ApiTags('Regions - Oracle')
@Patch('/UpdateRegion')
updateRegions(@Body() body: UpdateRegionDto) {
return this.regionService.updateRegions(body.p_regionID, body.p_name);
}
@ApiTags('Regions - Oracle')
@Get('/GetRegions')
getRegions() {
return this.regionService.getRegions();
}
}

View File

@ -0,0 +1,22 @@
import { IsNumber,IsString } from "class-validator";
import { ApiProperty } from "@nestjs/swagger";
export class InsertRegionsDto {
@ApiProperty()
@IsString()
p_region: string;
@ApiProperty()
@IsString()
p_name: string;
}
export class UpdateRegionDto {
@ApiProperty({ required: true })
@IsNumber()
p_regionID: number;
@ApiProperty({ required: true })
@IsString()
p_name: string;
}

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { RegionController } from './region.controller';
import { RegionService } from './region.service';
import { DbModule } from 'src/db/db.module';
@Module({
imports:[DbModule],
controllers: [RegionController],
providers: [RegionService]
})
export class RegionModule {}

View File

@ -0,0 +1,149 @@
import { Injectable } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'
@Injectable()
export class RegionService {
constructor(private readonly oracleDBService: OracleDBService) { }
async insertRegions(p_region: String, p_name: String) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor);
END;`, {
p_region: {
val: p_region,
type: oracledb.DB_TYPE_VARCHAR
},
p_name: {
val: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async updateRegions(p_regionID: Number, p_name: String) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:p_name,:p_cursor);
END;`, {
p_regionID: {
val: p_regionID,
type: oracledb.DB_TYPE_NUMBER
},
p_name: {
val: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getRegions() {
let connection;
let rows = [];
try {
try {
connection = await this.oracleDBService.getConnection()
}
catch (err) {
console.log("DB ERROR: ", err);
return { error: "Error while connecting to DB" }
}
// if (!connection) {
// throw new Error('No DB Connected')
// }
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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
console.log('Rows fetched:', rows);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
}

View File

@ -0,0 +1,70 @@
import { SpContactsService } from './sp-contacts.service';
import { Body, Controller, Get, Param, ParseIntPipe, Post, Put } from '@nestjs/common';
import { InsertSPContactsDTO, UpdateSPContactsDTO } from './sp-contacts.dto';
import { ApiTags } from '@nestjs/swagger';
@Controller('oracle')
export class SpContactsController {
constructor(
private readonly spContactsService: SpContactsService,
) { }
@ApiTags('SPContacts - Oracle')
@Post('/InsertSPContacts')
insertSPContacts(@Body() body: InsertSPContactsDTO) {
return this.spContactsService.insertSPContacts(
body.p_spid,
body.p_defcontactflag,
body.p_firstname,
body.p_lastname,
body.P_MIDDLEINITIAL,
body.p_title,
body.p_phoneno,
body.p_mobileno,
body.p_faxno,
body.p_emailaddress,
body.p_user_id
)
}
@ApiTags('SPContacts - Oracle')
@Post('/SetSPDefaultcontact/:id')
setSPDefaultcontact(@Param('id', ParseIntPipe) id: number) {
return this.spContactsService.setSPDefaultcontact(id)
}
@ApiTags('SPContacts - Oracle')
@Put('/UpdateSPContacts')
updateSPContacts(@Body() body: UpdateSPContactsDTO) {
return this.spContactsService.updateSPContacts(
body.p_spcontactid,
body.p_firstname,
body.p_lastname,
body.P_MIDDLEINITIAL,
body.p_title,
body.p_phoneno,
body.p_mobileno,
body.p_faxno,
body.p_emailaddress,
body.p_user_id
)
}
@ApiTags('SPContacts - Oracle')
@Post('/InactivateSPContact/:id')
inactivateSPContact(@Param('id', ParseIntPipe) id: number) {
return this.spContactsService.inactivateSPContact(id)
}
@ApiTags('SPContacts - Oracle')
@Get('/GetSPDefaultcontact/:id')
getSPDefaultcontact(@Param('id', ParseIntPipe) id: number) {
return this.spContactsService.getSPDefaultcontacts(id)
}
// @Get('/GetAllSPcontacts')
// getSPcontacts() {
// return this.oarcleService.getSPcontacts();
// }
}

View File

@ -0,0 +1,90 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsNumber, IsString } 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;
}

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { SpContactsService } from './sp-contacts.service';
import { SpContactsController } from './sp-contacts.controller';
import { DbModule } from 'src/db/db.module';
@Module({
imports:[DbModule],
providers: [SpContactsService],
controllers: [SpContactsController]
})
export class SpContactsModule {}

View File

@ -0,0 +1,377 @@
import { Injectable } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'
@Injectable()
export class SpContactsService {
constructor(private readonly oracleDBService: OracleDBService) { }
async insertSPContacts(
p_spid: number,
p_defcontactflag: string,
p_firstname: string,
p_lastname: string,
P_MIDDLEINITIAL: string,
p_title: string,
p_phoneno: string,
p_mobileno: string,
p_faxno: string,
p_emailaddress: string,
p_user_id: string
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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: p_spid,
type: oracledb.DB_TYPE_NUMBER
},
p_defcontactflag: {
val: p_defcontactflag,
type: oracledb.DB_TYPE_VARCHAR
},
p_firstname: {
val: p_firstname,
type: oracledb.DB_TYPE_VARCHAR
},
p_lastname: {
val: p_lastname,
type: oracledb.DB_TYPE_VARCHAR
},
P_MIDDLEINITIAL: {
val: P_MIDDLEINITIAL,
type: oracledb.DB_TYPE_VARCHAR
},
p_title: {
val: p_title,
type: oracledb.DB_TYPE_VARCHAR
},
p_phoneno: {
val: p_phoneno,
type: oracledb.DB_TYPE_VARCHAR
},
p_mobileno: {
val: p_mobileno,
type: oracledb.DB_TYPE_VARCHAR
},
p_faxno: {
val: p_faxno,
type: oracledb.DB_TYPE_VARCHAR
},
p_emailaddress: {
val: p_emailaddress,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: 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();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async setSPDefaultcontact(p_spcontactid: number) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.SetDefaultContact(:p_spcontactid);
END;`,
{
p_spcontactid: {
val: p_spcontactid,
type: oracledb.DB_TYPE_NUMBER
},
}
);
await connection.commit();
return "SP executed successfully"
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async updateSPContacts(
p_spcontactid: number,
p_firstname: string,
p_lastname: string,
P_MIDDLEINITIAL: string,
p_title: string,
p_phoneno: string,
p_mobileno: string,
p_faxno: string,
p_emailaddress: string,
p_user_id: string,
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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: p_spcontactid,
type: oracledb.DB_TYPE_NUMBER
},
p_firstname: {
val: p_firstname,
type: oracledb.DB_TYPE_VARCHAR
},
p_lastname: {
val: p_lastname,
type: oracledb.DB_TYPE_VARCHAR
},
P_MIDDLEINITIAL: {
val: P_MIDDLEINITIAL,
type: oracledb.DB_TYPE_VARCHAR
},
p_title: {
val: p_title,
type: oracledb.DB_TYPE_VARCHAR
},
p_phoneno: {
val: p_phoneno,
type: oracledb.DB_TYPE_VARCHAR
},
p_mobileno: {
val: p_mobileno,
type: oracledb.DB_TYPE_VARCHAR
},
p_faxno: {
val: p_faxno,
type: oracledb.DB_TYPE_VARCHAR
},
p_emailaddress: {
val: p_emailaddress,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: 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();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async inactivateSPContact(p_spcontactid: number) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid);
END;`, {
p_spcontactid: {
val: p_spcontactid,
type: oracledb.DB_TYPE_NUMBER
}
}
);
await connection.commit();
return "SP executed successfully"
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getSPDefaultcontacts(p_SPid: number) {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetSPDefaultContacts(:p_SPid,:p_cursor);
END;`,
{
p_SPid: {
val: 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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getSPcontacts() {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetSPAllContacts(: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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
console.log('Rows fetched:', rows);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
}

View File

@ -0,0 +1,71 @@
import { Body, Controller, Get, Param, ParseIntPipe, Post, Put } from '@nestjs/common';
import { SpService } from './sp.service';
import { ApiTags } from '@nestjs/swagger';
import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from './sp.dto';
@Controller('oracle')
export class SpController {
constructor(
private readonly spService: SpService
) { }
@ApiTags('SP - Oracle')
@Post('/InsertNewServiceProvider')
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
return this.spService.insertNewServiceProvider(
body.p_name,
body.p_lookupcode,
body.p_address1,
body.p_address2,
body.p_city,
body.p_state,
body.p_zip,
body.p_country,
body.p_issuingregion,
body.p_replacementregion,
body.p_bondsurety,
body.p_cargopolicyno,
body.p_cargosurety,
body.p_user_id,
body.P_NOTES,
body.P_FILEIDS
)
}
@ApiTags('SP - Oracle')
@Put('/UpdateServiceProvider')
updateServiceProider(@Body() body: UpdateServiceProviderDTO) {
return this.spService.updateServiceProvider(
body.p_spid,
body.p_name,
body.p_lookupcode,
body.p_address1,
body.p_address2,
body.p_city,
body.p_state,
body.p_zip,
body.p_country,
body.p_issuingregion,
body.p_replacementregion,
body.p_bondsurety,
body.p_cargopolicyno,
body.p_cargosurety,
body.p_user_id,
body.P_NOTES,
body.P_FILEIDS
)
}
@ApiTags('SP - Oracle')
@Get('/GetAllServiceproviders')
getAllServiceproviders() {
return this.spService.getAllServiceproviders();
}
@ApiTags('SP - Oracle')
@Get('/GetSelectedServiceprovider/:id')
getSelectedServiceprovider(@Param('id', ParseIntPipe) id: number) {
return this.spService.getServiceproviderByID(id);
}
}

View File

@ -0,0 +1,144 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNumber, IsString } from 'class-validator';
export class InsertNewServiceProviderDTO {
@ApiProperty({ required: true })
@IsString()
p_name: string;
@ApiProperty({ required: true })
@IsString()
p_lookupcode: string;
@ApiProperty({ required: true })
@IsString()
p_address1: string;
@ApiProperty({ required: false })
@IsString()
p_address2: string;
@ApiProperty({ required: true })
@IsString()
p_city: string;
@ApiProperty({ required: true })
@IsString()
p_state: string;
@ApiProperty({ required: true })
@IsString()
p_zip: string;
@ApiProperty({ required: true })
@IsString()
p_country: string;
@ApiProperty({ required: true })
@IsString()
p_issuingregion: string;
@ApiProperty({ required: true })
@IsString()
p_replacementregion: string;
@ApiProperty({ required: true })
@IsString()
p_bondsurety: string;
@ApiProperty({ required: true })
@IsString()
p_cargopolicyno: string;
@ApiProperty({ required: true })
@IsString()
p_cargosurety: string;
@ApiProperty({ required: true })
@IsString()
p_user_id: string;
@ApiProperty({ required: false })
@IsString()
P_NOTES: string;
@ApiProperty({ required: false })
@IsString()
P_FILEIDS: string;
}
export class UpdateServiceProviderDTO {
@ApiProperty({ required: true })
@IsNumber()
p_spid: number;
@ApiProperty({ required: true })
@IsString()
p_name: string;
@ApiProperty({ required: true })
@IsString()
p_lookupcode: string;
@ApiProperty({ required: true })
@IsString()
p_address1: string;
@ApiProperty({ required: false })
@IsString()
p_address2: string;
@ApiProperty({ required: true })
@IsString()
p_city: string;
@ApiProperty({ required: true })
@IsString()
p_state: string;
@ApiProperty({ required: true })
@IsString()
p_zip: string;
@ApiProperty({ required: true })
@IsString()
p_country: string;
@ApiProperty({ required: true })
@IsString()
p_issuingregion: string;
@ApiProperty({ required: true })
@IsString()
p_replacementregion: string;
@ApiProperty({ required: true })
@IsString()
p_bondsurety: string;
@ApiProperty({ required: true })
@IsString()
p_cargopolicyno: string;
@ApiProperty({ required: true })
@IsString()
p_cargosurety: string;
@ApiProperty({ required: true })
@IsString()
p_user_id: string;
@ApiProperty({ required: false })
@IsString()
P_NOTES: string;
@ApiProperty({ required: false })
@IsString()
P_FILEIDS: string;
}
// export class GetSPcontactsDTO {
// @IsNumber()
// p_SPid: number;
// }

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { SpController } from './sp.controller';
import { SpService } from './sp.service';
import { DbModule } from 'src/db/db.module';
@Module({
imports:[DbModule],
controllers: [SpController],
providers: [SpService]
})
export class SpModule {}

View File

@ -0,0 +1,389 @@
import { Injectable } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'
@Injectable()
export class SpService {
constructor(private readonly oracleDBService: OracleDBService) { }
async insertNewServiceProvider(
p_name: String,
p_lookupcode: String,
p_address1: String,
p_address2: String,
p_city: String,
p_state: String,
p_zip: String,
p_country: String,
p_issuingregion: String,
p_replacementregion: String,
p_bondsurety: String,
p_cargopolicyno: String,
p_cargosurety: String,
p_user_id: String,
P_NOTES: string,
P_FILEIDS: string
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_lookupcode: {
val: p_lookupcode,
type: oracledb.DB_TYPE_VARCHAR
},
p_address1: {
val: p_address1,
type: oracledb.DB_TYPE_VARCHAR
},
p_address2: {
val: p_address2,
type: oracledb.DB_TYPE_VARCHAR
},
p_city: {
val: p_city,
type: oracledb.DB_TYPE_VARCHAR
},
p_state: {
val: p_state,
type: oracledb.DB_TYPE_VARCHAR
},
p_zip: {
val: p_zip,
type: oracledb.DB_TYPE_VARCHAR
},
p_country: {
val: p_country,
type: oracledb.DB_TYPE_VARCHAR
},
p_issuingregion: {
val: p_issuingregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_replacementregion: {
val: p_replacementregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_bondsurety: {
val: p_bondsurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargopolicyno: {
val: p_cargopolicyno,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargosurety: {
val: p_cargosurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: p_user_id,
type: oracledb.DB_TYPE_VARCHAR
},
P_NOTES: {
val: P_NOTES,
type: oracledb.DB_TYPE_VARCHAR
},
P_FILEIDS: {
val: P_FILEIDS,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async updateServiceProvider(
p_spid: Number,
p_name: String,
p_lookupcode: String,
p_address1: String,
p_address2: String,
p_city: String,
p_state: String,
p_zip: String,
p_country: String,
p_issuingregion: String,
p_replacementregion: String,
p_bondsurety: String,
p_cargopolicyno: String,
p_cargosurety: String,
p_user_id: String,
P_NOTES: string,
P_FILEIDS: string
) {
let connection;
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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_issuingregion,
:p_replacementregion,
:p_bondsurety,
:p_cargopolicyno,
:p_cargosurety,
:p_user_id,
:P_NOTES,
:P_FILEIDS,
:p_cursor);
END;`, {
p_spid: {
val: p_spid,
type: oracledb.DB_TYPE_NUMBER
},
p_name: {
val: p_name,
type: oracledb.DB_TYPE_VARCHAR
},
p_lookupcode: {
val: p_lookupcode,
type: oracledb.DB_TYPE_VARCHAR
},
p_address1: {
val: p_address1,
type: oracledb.DB_TYPE_VARCHAR
},
p_address2: {
val: p_address2,
type: oracledb.DB_TYPE_VARCHAR
},
p_city: {
val: p_city,
type: oracledb.DB_TYPE_VARCHAR
},
p_state: {
val: p_state,
type: oracledb.DB_TYPE_VARCHAR
},
p_zip: {
val: p_zip,
type: oracledb.DB_TYPE_VARCHAR
},
p_country: {
val: p_country,
type: oracledb.DB_TYPE_VARCHAR
},
p_issuingregion: {
val: p_issuingregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_replacementregion: {
val: p_replacementregion,
type: oracledb.DB_TYPE_VARCHAR
},
p_bondsurety: {
val: p_bondsurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargopolicyno: {
val: p_cargopolicyno,
type: oracledb.DB_TYPE_VARCHAR
},
p_cargosurety: {
val: p_cargosurety,
type: oracledb.DB_TYPE_VARCHAR
},
p_user_id: {
val: p_user_id,
type: oracledb.DB_TYPE_VARCHAR
},
P_NOTES: {
val: P_NOTES,
type: oracledb.DB_TYPE_VARCHAR
},
P_FILEIDS: {
val: P_FILEIDS,
type: oracledb.DB_TYPE_VARCHAR
},
p_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT
}
}, {
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
return fres
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getAllServiceproviders() {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
// Close the cursor after you're done
await cursor.close();
return rows;
} else {
throw new Error('No cursor returned from the stored procedure');
}
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
async getServiceproviderByID(p_spid: Number) {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection()
if (!connection) {
throw new Error('No DB Connected')
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetSPbySPID(:p_spid,:p_cursor);
END;`,
{
p_spid: {
val: 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; // The OUT cursor
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time
rows = rows.concat(rowsBatch); // Append fetched rows to the main array
} while (rowsBatch.length > 0);
console.log('Rows fetched:', rows);
// Close the cursor after you're done
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
console.error('Error fetching users: ', err);
return { error: err.message }
} finally { }
}
}

View File

@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { RegionModule } from './region/region.module';
import { SpModule } from './sp/sp.module';
import { SpContactsModule } from './sp-contacts/sp-contacts.module';
import { CarnetSequenceModule } from './carnet-sequence/carnet-sequence.module';
@Module({
controllers: [],
providers: [],
imports: [RegionModule, SpModule, SpContactsModule, CarnetSequenceModule]
})
export class UscibManagedSpModule {}