diff --git a/src/app.module.ts b/src/app.module.ts index 4f162a1..46adb9a 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -2,7 +2,6 @@ import { Module } from '@nestjs/common'; import { DbModule } from './db/db.module'; import { OracleModule } from './oracle/oracle.module'; import { AuthModule } from './auth/auth.module'; -import { CustomPipeModule } from './custom-pipe/custom-pipe.module'; @Module({ imports: [ AuthModule, DbModule, OracleModule], diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 63a6cca..b867eeb 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -3,7 +3,7 @@ import { AuthService } from './auth.service'; import { ApiTags } from '@nestjs/swagger'; import { AuthLoginDTO } from './auth.dto'; -@Controller('auth') +@Controller() export class AuthController { constructor(private readonly authService:AuthService){} diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index ff5fadd..c45c953 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@nestjs/common'; +import { BadRequestException, Injectable } from '@nestjs/common'; import { OracleDBService } from 'src/db/db.service'; import { AuthLoginDTO } from './auth.dto'; import * as oracledb from 'oracledb' @@ -42,80 +42,19 @@ export class AuthService { ); if (result.outBinds && result.outBinds.p_login_cursor) { - const cursor = result.outBinds.p_login_cursor; // The OUT cursor + const cursor = result.outBinds.p_login_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 + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); } 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 new BadRequestException({Error:"Error executing request try after some time!"}); } - // if (result.outBinds && result.outBinds.p_carnet_count_cur) { - // const cursor = result.outBinds.p_carnet_count_cur; // The OUT cursor - // let rowsBatch; - - // do { - // rowsBatch = await cursor.getRows(100); // Fetch 100 rows at a time - // crows = crows.concat(rowsBatch); // Append fetched rows to the main array - // } while (rowsBatch.length > 0); - - // console.log('Rows fetched:', crows); - - // // Close the cursor after you're done - // await cursor.close(); - // } else { - // throw new Error('No cursor returned from the stored procedure'); - // } - - // crows = crows.map(obj => { - // // Create a new object to hold the modified keys - // let newObj = {}; - - // // Iterate over the keys of the current object - // for (let key in obj) { - // // Replace spaces with underscores in the key - // let newKey = key.replace(/ /g, "_"); - // newObj[newKey] = obj[key]; - // } - - // return newObj; - // }); - - // crows = crows.reduce((acc, curr) => { - // // Find if the current item already exists in the accumulator - // let existing = acc.find(item => item["Service_Provider_Name"] === curr["Service_Provider_Name"] && item.SPID === curr.SPID); - - // if (existing) { - // // If it exists, push the current "cs" and "c c" values into the arrays - // existing.CARNETSTATUS.push(curr.CARNETSTATUS); - // existing["Carnet_Count"].push(curr["Carnet_Count"]); - // } else { - // // If it doesn't exist, create a new entry - // acc.push({ - // "Service_Provider_Name": curr["Service_Provider_Name"], - // SPID: curr.SPID, - // CARNETSTATUS: [curr.CARNETSTATUS], - // "Carnet_Count": [curr["Carnet_Count"]] - // }); - // } - - // return acc; - // }, []); - - // if(!crows[0].SPID){ - // return {error:"Invalid username or password"} - // } - - // return {rows,chartResult:crows}; - if(rows[0]["ERRORMESG"]){ return {error:"Invalid username or password!"} } @@ -123,7 +62,6 @@ export class AuthService { } catch (err) { console.error('Error fetching users: ', err.message); - // throw new Error('Error fetching users'); return {error:"Invalid username or password"} } finally { } diff --git a/src/custom-pipe/custom-parseInt-pipe.service.ts b/src/custom-pipe/custom-parseInt-pipe.service.ts deleted file mode 100644 index b3a8b5b..0000000 --- a/src/custom-pipe/custom-parseInt-pipe.service.ts +++ /dev/null @@ -1,11 +0,0 @@ - -import { ArgumentMetadata, Injectable, PipeTransform, BadRequestException } from '@nestjs/common'; - -@Injectable() -export class CustomParseIntPipe implements PipeTransform { - transform(value: any, metadata: ArgumentMetadata) { - const parsedValue = parseInt(value, 10); - - return parsedValue; - } -} \ No newline at end of file diff --git a/src/custom-pipe/custom-pipe.module.ts b/src/custom-pipe/custom-pipe.module.ts deleted file mode 100644 index c998832..0000000 --- a/src/custom-pipe/custom-pipe.module.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { Module } from '@nestjs/common'; -import { CustomParseIntPipe } from './custom-parseInt-pipe.service'; - -@Module({ - imports:[], - providers: [CustomParseIntPipe], - exports:[CustomParseIntPipe] -}) -export class CustomPipeModule {} diff --git a/src/oracle/home-page/home-page.controller.ts b/src/oracle/home-page/home-page.controller.ts index 20a42a5..9341bff 100644 --- a/src/oracle/home-page/home-page.controller.ts +++ b/src/oracle/home-page/home-page.controller.ts @@ -35,19 +35,6 @@ export class HomePageController { 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( @@ -74,4 +61,18 @@ export class HomePageController { return new BadRequestException({ message: 'Validation faileda', error: err.message }) } } + + @ApiTags('HomePage - Oracle') + @Post('/oracle/SaveCarnetApplication') + SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) { + return this.homePageService.SaveCarnetApplication(body); + } + + @ApiTags('HomePage - Oracle') + @Post('/oracle/TransmitApplicationtoProcess') + TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) { + return this.homePageService.TransmitApplicationtoProcess(body); + } + + } diff --git a/src/oracle/home-page/home-page.service.ts b/src/oracle/home-page/home-page.service.ts index 0d187e8..e4a5128 100644 --- a/src/oracle/home-page/home-page.service.ts +++ b/src/oracle/home-page/home-page.service.ts @@ -290,7 +290,7 @@ export class HomePageService { return output; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -378,7 +378,7 @@ export class HomePageService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -667,7 +667,7 @@ export class HomePageService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -735,7 +735,7 @@ export class HomePageService { // return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -797,7 +797,7 @@ export class HomePageService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } diff --git a/src/oracle/manage-clients/manage-clients.controller.ts b/src/oracle/manage-clients/manage-clients.controller.ts index fdb2b87..d1d3c7b 100644 --- a/src/oracle/manage-clients/manage-clients.controller.ts +++ b/src/oracle/manage-clients/manage-clients.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common'; import { ManageClientsService } from './manage-clients.service'; -import { CreateAdditionalClientContactsDTO, CreateAdditionalClientLocationsDTO, CreateClientDataDTO, GetPreparerByClientidDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from './manage-clients.dto'; +import { CreateAdditionalClientContactsDTO, CreateAdditionalClientLocationsDTO, CreateClientDataDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from './manage-clients.dto'; import { ApiTags } from '@nestjs/swagger'; @Controller('oracle') @@ -52,15 +52,19 @@ export class ManageClientsController { @ApiTags('Manage Clients - Oracle') @Get('GetPreparerByClientid') - GetPreparerByClientid(@Query() body:GetPreparerByClientidDTO){ + GetPreparerByClientid(@Query() body:GetPreparerByClientidContactsByClientidLocByClientidDTO){ return this.manageClientsService.GetPreparerByClientid(body); } - GetPreparerContactsByClientid(){ - + @ApiTags('Manage Clients - Oracle') + @Get('GetPreparerContactsByClientid') + GetPreparerContactsByClientid(@Query() body:GetPreparerByClientidContactsByClientidLocByClientidDTO){ + return body; } - GetPreparerLocByClientid(){ - + @ApiTags('Manage Clients - Oracle') + @Get('GetPreparerLocByClientid') + GetPreparerLocByClientid(@Query() body:GetPreparerByClientidContactsByClientidLocByClientidDTO){ + return body; } } diff --git a/src/oracle/manage-clients/manage-clients.dto.ts b/src/oracle/manage-clients/manage-clients.dto.ts index 797bee4..27d3279 100644 --- a/src/oracle/manage-clients/manage-clients.dto.ts +++ b/src/oracle/manage-clients/manage-clients.dto.ts @@ -468,7 +468,7 @@ export class CreateAdditionalClientLocationsDTO { p_userid: string; } -export class GetPreparerByClientidDTO { +export class GetPreparerByClientidContactsByClientidLocByClientidDTO { @ApiProperty({ required: true }) @Transform(({ value }) => Number(value)) @Max(999999999, { message: "Property p_spid must not exceed 999999999" }) diff --git a/src/oracle/manage-clients/manage-clients.service.ts b/src/oracle/manage-clients/manage-clients.service.ts index af54f5e..db9bc5e 100644 --- a/src/oracle/manage-clients/manage-clients.service.ts +++ b/src/oracle/manage-clients/manage-clients.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@nestjs/common'; import { OracleDBService } from 'src/db/db.service'; -import { CreateAdditionalClientContactsDTO, CreateAdditionalClientLocationsDTO, CreateClientDataDTO, GetPreparerByClientidDTO, GetPreparersDTO, p_clientlocaddresstableDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from './manage-clients.dto'; +import { CreateAdditionalClientContactsDTO, CreateAdditionalClientLocationsDTO, CreateClientDataDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO, GetPreparersDTO, p_clientlocaddresstableDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from './manage-clients.dto'; import { p_contactstableDTO } from '../manage-holders/manage-holders.dto'; import * as oracledb from 'oracledb' @@ -268,7 +268,7 @@ export class ManageClientsService { } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -405,7 +405,7 @@ export class ManageClientsService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -541,7 +541,7 @@ export class ManageClientsService { return { P_cursor: P_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -672,7 +672,7 @@ export class ManageClientsService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -806,7 +806,7 @@ export class ManageClientsService { } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -935,7 +935,7 @@ export class ManageClientsService { } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -1051,12 +1051,12 @@ export class ManageClientsService { return { p_maincursor: p_maincursor_rows, p_contactscursor: p_contactscursor_rows, p_locationcursor: p_locationcursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - GetPreparerByClientid = async (body: GetPreparerByClientidDTO) => { + GetPreparerByClientid = async (body: GetPreparerByClientidContactsByClientidLocByClientidDTO) => { let connection; let p_cursor_rows = []; @@ -1110,17 +1110,125 @@ export class ManageClientsService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - GetPreparerContactsByClientid = async () => { + GetPreparerContactsByClientid = async (body: GetPreparerByClientidContactsByClientidLocByClientidDTO) => { + let connection; + let p_cursor_rows = []; + try { + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPREPARER_PKG.GetPreparerContactsByClientid( + :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 + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + p_cursor_rows = p_cursor_rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } + + return { p_cursor: p_cursor_rows }; + + } catch (err) { + + return { error: err.message } + } finally { } } - GetPreparerLocByClientid = async () => { + GetPreparerLocByClientid = async (body: GetPreparerByClientidContactsByClientidLocByClientidDTO) => { + let connection; + let p_cursor_rows = []; + try { + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPREPARER_PKG.GetPreparerLocByClientid( + :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 + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + p_cursor_rows = p_cursor_rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } + + return { p_cursor: p_cursor_rows }; + + } catch (err) { + + return { error: err.message } + } finally { } } } diff --git a/src/oracle/manage-fee/manage-fee.controller.ts b/src/oracle/manage-fee/manage-fee.controller.ts index 97d697f..0286ffa 100644 --- a/src/oracle/manage-fee/manage-fee.controller.ts +++ b/src/oracle/manage-fee/manage-fee.controller.ts @@ -1,4 +1,152 @@ -import { Controller } from '@nestjs/common'; +import { Body, Controller, Get, Param, ParseIntPipe, 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 +} from './manage-fee.dto'; @Controller('manage-fee') -export class ManageFeeController {} +export class ManageFeeController { + constructor(private readonly manageFeeService: ManageFeeService) { } + + + @ApiTags('Manage Fee - Oracle') + @Get('/GetBasicFeeRates') + GetBasicFeeRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETBASICFEERATES(body) + } + + @ApiTags('Manage Fee - Oracle') + @Get('/GetBondRates') + GetBondRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETBONDRATES(body) + } + + @ApiTags('Manage Fee - Oracle') + @Get('/GetCargoRates') + GetCargoRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETCARGORATES(body) + } + + @ApiTags('Manage Fee - Oracle') + @Get('/GetCfFeeRates') + GetCfFeeRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETCFFEERATES(body) + } + + @ApiTags('Manage Fee - Oracle') + @Get('/GetCsFeeRates') + GetCsFeeRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETCSFEERATES(body) + } + + @ApiTags('Manage Fee - Oracle') + @Get('/GetEfFeeRates') + GetEfFeeRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETEFFEERATES(body) + } + + @ApiTags('Manage Fee - Oracle') + @Get('/GetFeeComm') + GetFeeComm(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETFEECOMM(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateBasicFee') + CreateBasicFee(@Body() body: CreateBasicFeeDTO) { + return this.manageFeeService.CREATEBASICFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateBondRate') + CreateBondRate(@Body() body: CreateBondRateDTO) { + return this.manageFeeService.CREATEBONDRATE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateCargoRate') + CreateCargoRate(@Body() body: CreateCargoRateDTO) { + return this.manageFeeService.CREATECARGORATE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateCfFee') + CreateCfFee(@Body() body: CreateCfFeeDTO) { + return this.manageFeeService.CREATECFFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateCsFee') + CreateCsFee(@Body() body: CreateCsFeeDTO) { + return this.manageFeeService.CREATECSFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateEfFee') + CreateEeFee(@Body() body: CreateEfFeeDTO) { + return this.manageFeeService.CREATEEFFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Post('/CreateFeeComm') + CreateFeeComm(@Body() body: CreateFeeCommDTO) { + return this.manageFeeService.CREATEFEECOMM(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateBasicFee') + UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) { + return this.manageFeeService.UPDATEBASICFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateBondRate') + UpdateBondRate(@Body() body: UpdateBondRateDTO) { + return this.manageFeeService.UPDATEBONDRATE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateCargoRate') + UpdateCargoRate(@Body() body: UpdateCargoRateDTO) { + return this.manageFeeService.UPDATECARGORATE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateCfFee') + UpdateCfFee(@Body() body: UpdateCfFeeDTO) { + return this.manageFeeService.UPDATECFFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateCsFee') + UpdateCsFee(@Body() body: UpdateCsFeeDTO) { + return this.manageFeeService.UPDATECSFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateEfFee') + UpdateEfFee(@Body() body: UpdateEfFeeDTO) { + return this.manageFeeService.UPDATEEFFEE(body) + } + + @ApiTags('Manage Fee - Oracle') + @Patch('/UpdateFeeComm') + UpdateFeeComm(@Body() body: UpdateFeeCommBodyDTO) { + return this.manageFeeService.UPDATEFEECOMM(body) + } +} diff --git a/src/oracle/manage-fee/manage-fee.dto.ts b/src/oracle/manage-fee/manage-fee.dto.ts new file mode 100644 index 0000000..cb721d3 --- /dev/null +++ b/src/oracle/manage-fee/manage-fee.dto.ts @@ -0,0 +1,360 @@ +import { ApiProperty } from "@nestjs/swagger"; +import { Transform } from "class-transformer"; +import { IsDefined, IsInt, IsNumber, IsString, 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 }) + @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 }) + @IsString() + 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() +} \ No newline at end of file diff --git a/src/oracle/manage-fee/manage-fee.service.ts b/src/oracle/manage-fee/manage-fee.service.ts index cecae46..d29df9c 100644 --- a/src/oracle/manage-fee/manage-fee.service.ts +++ b/src/oracle/manage-fee/manage-fee.service.ts @@ -1,4 +1,1316 @@ import { Injectable } 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 +} from './manage-fee.dto'; @Injectable() -export class ManageFeeService {} +export class ManageFeeService { + constructor(private readonly oracleDBService: OracleDBService) { } + + // get + + async GETBASICFEERATES(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETBASICFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + async GETBONDRATES(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETBONDRATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + async GETCARGORATES(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETCARGORATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + async GETCFFEERATES(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETCFFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + async GETCSFEERATES(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETCSFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + async GETEFFEERATES(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETEFFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + async GETFEECOMM(body: GetFeeGeneralDTO) { + let connection; + let rows = []; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.GETFEECOMM(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER, + }, + P_ACTIVE_INACTIVE: { + val: body.P_ACTIVE_INACTIVE, + type: oracledb.DB_TYPE_NVARCHAR, + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } + + // post + + async CREATEBASICFEE(body: CreateBasicFeeDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATEBASICFEE( + :P_SPID, + :P_STARTCARNETVALUE, + :P_ENDCARNETVALUE, + :P_EFFDATE, + :P_FEES, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_STARTCARNETVALUE: { + val: body.P_STARTCARNETVALUE, + type: oracledb.DB_TYPE_NUMBER + }, + P_ENDCARNETVALUE: { + val: body.P_ENDCARNETVALUE, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_FEES: { + val: body.P_FEES, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + + } + async CREATEBONDRATE(body: CreateBondRateDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATEBONDRATE( + :P_SPID, + :P_HOLDERTYPE, + :P_USCIBMEMBERFLAG, + :P_SPCLCOMMODITY, + :P_SPCLCOUNTRY, + :P_EFFDATE, + :P_RATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_HOLDERTYPE: { + val: body.P_HOLDERTYPE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_USCIBMEMBERFLAG: { + val: body.P_USCIBMEMBERFLAG, + type: oracledb.DB_TYPE_VARCHAR + }, + P_SPCLCOMMODITY: { + val: body.P_SPCLCOMMODITY, + type: oracledb.DB_TYPE_VARCHAR + }, + P_SPCLCOUNTRY: { + val: body.P_SPCLCOUNTRY, + type: oracledb.DB_TYPE_VARCHAR + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + } + async CREATECARGORATE(body: CreateCargoRateDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATECARGORATE( + :P_SPID, + :P_CARNETTYPE, + :P_STARTSETS, + :P_ENDSETS, + :P_EFFDATE, + :P_RATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_CARNETTYPE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_STARTSETS: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_ENDSETS: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + } + async CREATECFFEE(body: CreateCfFeeDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATECFFEE( + :P_SPID, + :P_STARTSETS, + :P_ENDSETS, + :P_EFFDATE, + :P_CUSTOMERTYPE, + :P_CARNETTYPE, + :P_RATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_STARTSETS: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_ENDSETS: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CUSTOMERTYPE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CARNETTYPE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + + } + async CREATECSFEE(body: CreateCsFeeDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATECSFEE( + :P_SPID, + :P_CUSTOMERTYPE, + :P_CARNETTYPE, + :P_EFFDATE, + :P_RATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_CUSTOMERTYPE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CARNETTYPE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + } + async CREATEEFFEE(body: CreateEfFeeDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATEEFFEE( + :P_SPID, + :P_CUSTOMERTYPE, + :P_DELIVERYTYPE, + :P_STARTTIME, + :P_ENDTIME, + :P_TIMEZONE, + :P_EFFDATE, + :P_FEES, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_CUSTOMERTYPE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_DELIVERYTYPE: { + val: body.P_DELIVERYTYPE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_STARTTIME: { + val: body.P_STARTTIME, + type: oracledb.DB_TYPE_NUMBER + }, + P_ENDTIME: { + val: body.P_ENDTIME, + type: oracledb.DB_TYPE_NUMBER + }, + P_TIMEZONE: { + val: body.P_TIMEZONE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_FEES: { + val: body.P_FEES, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + } + async CREATEFEECOMM(body: CreateFeeCommDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.CREATEFEECOMM( + :P_SPID, + :P_PARAMID, + :P_COMMRATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_PARAMID: { + val: body.P_PARAMID, + type: oracledb.DB_TYPE_NUMBER + }, + P_COMMRATE: { + val: body.P_COMMRATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + } + + // update + + async UPDATEBASICFEE(body: UpdateBasicFeeDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATEBASICFEE( + :P_BASICFEESETUPID, + :P_FEES, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_BASICFEESETUPID: { + val: body.P_BASICFEESETUPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_FEES: { + val: body.P_FEES, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + + } + async UPDATEBONDRATE(body: UpdateBondRateDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATEBONDRATE( + :P_BONDRATESETUPID, + :P_RATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_BONDRATESETUPID: { + val: body.P_BONDRATESETUPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + + } + async UPDATECARGORATE(body: UpdateCargoRateDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATECARGORATE( + :P_CARGORATESETUPID, + :P_RATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_CARGORATESETUPID: { + val: body.P_CARGORATESETUPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + + } + async UPDATECFFEE(body: UpdateCfFeeDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATECFFEE( + :P_CFFEESETUPID, + :P_RATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_CFFEESETUPID: { + val: body.P_CFFEESETUPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + + } + async UPDATECSFEE(body: UpdateCsFeeDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATECSFEE( + :P_CSFEESETUPID, + :P_RATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_CSFEESETUPID: { + val: body.P_CSFEESETUPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_RATE: { + val: body.P_RATE, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + + } + async UPDATEEFFEE(body: UpdateEfFeeDTO) { + + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATEEFFEE( + :P_EFFEESETUPID, + :P_FEES, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_EFFEESETUPID: { + val: body.P_EFFEESETUPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_FEES: { + val: body.P_FEES, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + 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) { + + return { error: err.message } + } finally { } + + } + async UPDATEFEECOMM(body: UpdateFeeCommBodyDTO) { + + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEFEE_SETUP_PKG.UPDATEFEECOMM( + :P_FEECOMMID, + :P_RATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_FEECOMMID: { + val: body.p_fees_comm.P_FEECOMMID, + type: oracledb.DB_TYPE_NUMBER + }, + P_RATE: { + val: Number(body.p_fees_comm.P_RATE) | 0, + type: oracledb.DB_TYPE_NUMBER + }, + P_EFFDATE: { + val: body.p_fees_comm.P_EFFDATE, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_USERID: { + val: body.p_fees_comm.P_USERID, + type: oracledb.DB_TYPE_NVARCHAR + }, + P_CURSOR: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + if (result.outBinds && result.outBinds.P_CURSOR) { + let fres = await result.outBinds.P_CURSOR.getRows(); + + console.log("pcursor: ", fres); + + return fres + } + else { + console.log("No cursor returned...."); + return { error: "No cursor found" } + } + } catch (err) { + + return { error: err.message } + // return {error: err.message} + } finally { } + } + + +} diff --git a/src/oracle/manage-holders/manage-holders.controller.ts b/src/oracle/manage-holders/manage-holders.controller.ts index 30cd51d..89e47df 100644 --- a/src/oracle/manage-holders/manage-holders.controller.ts +++ b/src/oracle/manage-holders/manage-holders.controller.ts @@ -2,7 +2,6 @@ import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put, UsePipes, import { ApiTags } from '@nestjs/swagger'; import { CreateHoldersDTO, GetHolderContactActivateOrInactivateDTO, GetHolderOrContactDTO, UpdateHolderContactDTO, UpdateHolderDTO } from './manage-holders.dto'; import { ManageHoldersService } from './manage-holders.service'; -import { CustomParseIntPipe } from 'src/custom-pipe/custom-parseInt-pipe.service'; @Controller('oracle') export class ManageHoldersController { diff --git a/src/oracle/manage-holders/manage-holders.module.ts b/src/oracle/manage-holders/manage-holders.module.ts index 295437d..730e36f 100644 --- a/src/oracle/manage-holders/manage-holders.module.ts +++ b/src/oracle/manage-holders/manage-holders.module.ts @@ -2,7 +2,6 @@ import { Module } from '@nestjs/common'; import { ManageHoldersService } from './manage-holders.service'; import { ManageHoldersController } from './manage-holders.controller'; import { DbModule } from 'src/db/db.module'; -import { CustomPipeModule } from 'src/custom-pipe/custom-pipe.module'; @Module({ imports:[DbModule], diff --git a/src/oracle/manage-holders/manage-holders.service.ts b/src/oracle/manage-holders/manage-holders.service.ts index 927a132..34a0dfd 100644 --- a/src/oracle/manage-holders/manage-holders.service.ts +++ b/src/oracle/manage-holders/manage-holders.service.ts @@ -238,7 +238,7 @@ export class ManageHoldersService { // return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -413,7 +413,7 @@ export class ManageHoldersService { // return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -472,7 +472,7 @@ export class ManageHoldersService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -611,7 +611,7 @@ export class ManageHoldersService { // return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -668,7 +668,7 @@ export class ManageHoldersService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -725,7 +725,7 @@ export class ManageHoldersService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -782,7 +782,7 @@ export class ManageHoldersService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -839,7 +839,7 @@ export class ManageHoldersService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -896,7 +896,7 @@ export class ManageHoldersService { return { p_cursor: p_cursor_rows }; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } diff --git a/src/oracle/manageFee.service.ts b/src/oracle/manageFee.service.ts deleted file mode 100644 index 7cea275..0000000 --- a/src/oracle/manageFee.service.ts +++ /dev/null @@ -1,1297 +0,0 @@ -import { Injectable } from "@nestjs/common"; -import { OracleDBService } from "src/db/db.service"; -import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommBodyDTO, UpdateFeeCommDTO } from "./oracle.dto"; -import * as oracledb from 'oracledb'; - -@Injectable() -export class ManageFeeService { - - constructor(private readonly oracleDBService: OracleDBService) { } - - async CREATEBASICFEE(body: CreateBasicFeeDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATEBASICFEE( - :P_SPID, - :P_STARTCARNETVALUE, - :P_ENDCARNETVALUE, - :P_EFFDATE, - :P_FEES, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_STARTCARNETVALUE: { - val: body.P_STARTCARNETVALUE, - type: oracledb.DB_TYPE_NUMBER - }, - P_ENDCARNETVALUE: { - val: body.P_ENDCARNETVALUE, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_FEES: { - val: body.P_FEES, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - - } - async CREATEBONDRATE(body: CreateBondRateDTO) { - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATEBONDRATE( - :P_SPID, - :P_HOLDERTYPE, - :P_USCIBMEMBERFLAG, - :P_SPCLCOMMODITY, - :P_SPCLCOUNTRY, - :P_EFFDATE, - :P_RATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_HOLDERTYPE: { - val: body.P_HOLDERTYPE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_USCIBMEMBERFLAG: { - val: body.P_USCIBMEMBERFLAG, - type: oracledb.DB_TYPE_VARCHAR - }, - P_SPCLCOMMODITY: { - val: body.P_SPCLCOMMODITY, - type: oracledb.DB_TYPE_VARCHAR - }, - P_SPCLCOUNTRY: { - val: body.P_SPCLCOUNTRY, - type: oracledb.DB_TYPE_VARCHAR - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async CREATECARGORATE(body: CreateCargoRateDTO) { - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATECARGORATE( - :P_SPID, - :P_CARNETTYPE, - :P_STARTSETS, - :P_ENDSETS, - :P_EFFDATE, - :P_RATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_CARNETTYPE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_STARTSETS: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_ENDSETS: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async CREATECFFEE(body: CreateCfFeeDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATECFFEE( - :P_SPID, - :P_STARTSETS, - :P_ENDSETS, - :P_EFFDATE, - :P_CUSTOMERTYPE, - :P_CARNETTYPE, - :P_RATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_STARTSETS: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_ENDSETS: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CUSTOMERTYPE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CARNETTYPE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - - } - async CREATECSFEE(body: CreateCsFeeDTO) { - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATECSFEE( - :P_SPID, - :P_CUSTOMERTYPE, - :P_CARNETTYPE, - :P_EFFDATE, - :P_RATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_CUSTOMERTYPE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CARNETTYPE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async CREATEEFFEE(body: CreateEfFeeDTO) { - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATEEFFEE( - :P_SPID, - :P_CUSTOMERTYPE, - :P_DELIVERYTYPE, - :P_STARTTIME, - :P_ENDTIME, - :P_TIMEZONE, - :P_EFFDATE, - :P_FEES, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_CUSTOMERTYPE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_DELIVERYTYPE: { - val: body.P_DELIVERYTYPE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_STARTTIME: { - val: body.P_STARTTIME, - type: oracledb.DB_TYPE_NUMBER - }, - P_ENDTIME: { - val: body.P_ENDTIME, - type: oracledb.DB_TYPE_NUMBER - }, - P_TIMEZONE: { - val: body.P_TIMEZONE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_FEES: { - val: body.P_FEES, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async CREATEFEECOMM(body: CreateFeeCommDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.CREATEFEECOMM( - :P_SPID, - :P_PARAMID, - :P_COMMRATE, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_PARAMID: { - val: body.P_PARAMID, - type: oracledb.DB_TYPE_NUMBER - }, - P_COMMRATE: { - val: body.P_COMMRATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 { } - - } - - // update - - async UPDATEBASICFEE(body: UpdateBasicFeeDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATEBASICFEE( - :P_BASICFEESETUPID, - :P_FEES, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_BASICFEESETUPID: { - val: body.P_BASICFEESETUPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_FEES: { - val: body.P_FEES, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 UPDATEBONDRATE(body: UpdateBondRateDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATEBONDRATE( - :P_BONDRATESETUPID, - :P_RATE, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_BONDRATESETUPID: { - val: body.P_BONDRATESETUPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 UPDATECARGORATE(body: UpdateCargoRateDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATECARGORATE( - :P_CARGORATESETUPID, - :P_RATE, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_CARGORATESETUPID: { - val: body.P_CARGORATESETUPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 UPDATECFFEE(body: UpdateCfFeeDTO) { - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATECFFEE( - :P_CFFEESETUPID, - :P_RATE, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_CFFEESETUPID: { - val: body.P_CFFEESETUPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 UPDATECSFEE(body: UpdateCsFeeDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATECSFEE( - :P_CSFEESETUPID, - :P_RATE, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_CSFEESETUPID: { - val: body.P_CSFEESETUPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_RATE: { - val: body.P_RATE, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 UPDATEEFFEE(body: UpdateEfFeeDTO) { - - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATEEFFEE( - :P_EFFEESETUPID, - :P_FEES, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_EFFEESETUPID: { - val: body.P_EFFEESETUPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_FEES: { - val: body.P_FEES, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - 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 UPDATEFEECOMM(body: UpdateFeeCommBodyDTO) { - - let connection; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.UPDATEFEECOMM( - :P_FEECOMMID, - :P_RATE, - :P_EFFDATE, - :P_USERID, - :P_CURSOR); - END;`, - { - P_FEECOMMID: { - val: body.p_fees_comm.P_FEECOMMID, - type: oracledb.DB_TYPE_NUMBER - }, - P_RATE: { - val: Number(body.p_fees_comm.P_RATE) | 0, - type: oracledb.DB_TYPE_NUMBER - }, - P_EFFDATE: { - val: body.p_fees_comm.P_EFFDATE, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_USERID: { - val: body.p_fees_comm.P_USERID, - type: oracledb.DB_TYPE_NVARCHAR - }, - P_CURSOR: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - if (result.outBinds && result.outBinds.P_CURSOR) { - let fres = await result.outBinds.P_CURSOR.getRows(); - - console.log("pcursor: ", fres); - - return fres - } - else { - console.log("No cursor returned...."); - return { error: "No cursor found" } - } - } catch (err) { - console.error('Error fetching users: ', err); - return { error: err.message } - // return {error: err.message} - } finally { } - } - - // get - - async GETBASICFEERATES(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETBASICFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async GETBONDRATES(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETBONDRATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async GETCARGORATES(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETCARGORATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async GETCFFEERATES(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETCFFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async GETCSFEERATES(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETCSFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async GETEFFEERATES(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETEFFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - async GETFEECOMM(P_SPID: Number, P_ACTIVE_INACTIVE: string) { - let connection; - let rows = []; - try { - - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEFEE_SETUP_PKG.GETFEECOMM(:P_SPID,:P_ACTIVE_INACTIVE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER, - }, - P_ACTIVE_INACTIVE: { - val: P_ACTIVE_INACTIVE, - type: oracledb.DB_TYPE_NVARCHAR, - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; - let rowsBatch; - - do { - rowsBatch = await cursor.getRows(100); - rows = rows.concat(rowsBatch); - } while (rowsBatch.length > 0); - - - await cursor.close(); - } else { - throw new Error('No cursor returned from the stored procedure'); - } - - return rows; - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } -} \ No newline at end of file diff --git a/src/oracle/oracle.controller.ts b/src/oracle/oracle.controller.ts deleted file mode 100644 index 5739ccf..0000000 --- a/src/oracle/oracle.controller.ts +++ /dev/null @@ -1,314 +0,0 @@ -import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put, Query, UsePipes } from '@nestjs/common'; -import { OracleService } from './oracle.service'; -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 { ManageFeeService } from './manageFee.service'; -import { ApiQuery, ApiTags } from '@nestjs/swagger'; - -@Controller('oracle') -export class OracleController { - constructor( - private readonly oarcleService: OracleService, - private readonly paramTableService: ParamTableService, - private readonly manageFeeService: ManageFeeService, - ) { } - - // @ApiTags('HomePage - Oracle') - // @Post('/test') - // test(@Body() body:TestDTO) { - - // return body; - // } - - // Service Provider [ SP ] - - // @ApiTags('SP - Oracle') - // @Post('/InsertNewServiceProvider') - // insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) { - // return this.oarcleService.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.oarcleService.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.oarcleService.getAllServiceproviders(); - // } - - // @ApiTags('SP - Oracle') - // @Get('/GetSelectedServiceprovider/:id') - // getSelectedServiceprovider(@Param('id', ParseIntPipe) id: number) { - // return this.oarcleService.getServiceproviderByID(id); - // } - - // SPContacts - - - - // Carnet Sequence - - @ApiTags('Carnet Sequence - Oracle') - @Post('/CreateCarnetSequence/') - createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) { - return this.oarcleService.createCarnetSequence( - body.p_spid, - body.p_regionid, - body.p_startnumber, - body.p_endnumber, - body.p_carnettype - ) - } - - @ApiTags('Carnet Sequence - Oracle') - @Get('/GetCarnetSequence/:id') - getCarnetSequence(@Param('id', ParseIntPipe) id: number) { - return this.oarcleService.getCarnetSequence(id) - } - - // param table - - @ApiTags('Param Table - Oracle') - @Get('/GetParamValues') - @UsePipes() - @ApiQuery({ name: 'id', required: false, type: Number, description: 'The ID of the parameter' }) - @ApiQuery({ name: 'type', required: false, type: String, description: 'The type of the parameter' }) - getParamValues( - @Query('id') id: string, - @Query('type') type: string - ) { - return this.paramTableService.GETPARAMVALUES(id ? Number(id) : undefined, type); - } - - @ApiTags('Param Table - Oracle') - @Post('/CreateTableRecord') - createTableRecord(@Body() body: CreateTableRecordDTO) { - return this.paramTableService.CREATETABLERECORD(body.P_USERID, body.P_TABLEFULLDESC) - } - - @ApiTags('Param Table - Oracle') - @Post('/CreateParamRecord') - createParamRecord(@Body() body: CreateParamRecordDTO) { - return this.paramTableService.CREATEPARAMRECORD( - body.P_PARAMTYPE, - body.P_PARAMDESC, - body.P_PARAMVALUE, - body.P_SORTSEQ, - body.P_USERID, - body.P_SPID, - body.P_ADDLPARAMVALUE1, - body.P_ADDLPARAMVALUE2, - body.P_ADDLPARAMVALUE3, - body.P_ADDLPARAMVALUE4, - body.P_ADDLPARAMVALUE5, - ) - } - - @ApiTags('Param Table - Oracle') - @Patch('/UpdateParamRecord') - UpdateParamRecord(@Body() body: UpdateParamRecordDTO) { - return this.paramTableService.UPDATEPARAMRECORD(body) - } - - @ApiTags('Param Table - Oracle') - @Put('/InActivateParamRecord') - inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) { - return this.paramTableService.INACTIVATEPARAMRECORD(body) - } - - @ApiTags('Param Table - Oracle') - @Put('/ReActivateParamRecord') - reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) { - return this.paramTableService.REACTIVATEPARAMRECORD(body) - } - - - // ManageFee - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateBasicFee') - CreateBasicFee(@Body() body: CreateBasicFeeDTO) { - return this.manageFeeService.CREATEBASICFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateBondRate') - CreateBondRate(@Body() body: CreateBondRateDTO) { - return this.manageFeeService.CREATEBONDRATE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateCargoRate') - CreateCargoRate(@Body() body: CreateCargoRateDTO) { - return this.manageFeeService.CREATECARGORATE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateCfFee') - CreateCfFee(@Body() body: CreateCfFeeDTO) { - return this.manageFeeService.CREATECFFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateCsFee') - CreateCsFee(@Body() body: CreateCsFeeDTO) { - return this.manageFeeService.CREATECSFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateEfFee') - CreateEeFee(@Body() body: CreateEfFeeDTO) { - return this.manageFeeService.CREATEEFFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Post('/CreateFeeComm') - CreateFeeComm(@Body() body: CreateFeeCommDTO) { - return this.manageFeeService.CREATEFEECOMM(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateBasicFee') - UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) { - return this.manageFeeService.UPDATEBASICFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateBondRate') - UpdateBondRate(@Body() body: UpdateBondRateDTO) { - return this.manageFeeService.UPDATEBONDRATE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateCargoRate') - UpdateCargoRate(@Body() body: UpdateCargoRateDTO) { - return this.manageFeeService.UPDATECARGORATE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateCfFee') - UpdateCfFee(@Body() body: UpdateCfFeeDTO) { - return this.manageFeeService.UPDATECFFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateCsFee') - UpdateCsFee(@Body() body: UpdateCsFeeDTO) { - return this.manageFeeService.UPDATECSFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateEfFee') - UpdateEfFee(@Body() body: UpdateEfFeeDTO) { - return this.manageFeeService.UPDATEEFFEE(body) - } - - @ApiTags('Manage Fee - Oracle') - @Patch('/UpdateFeeComm') - UpdateFeeComm(@Body() body: UpdateFeeCommBodyDTO) { - return this.manageFeeService.UPDATEFEECOMM(body) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetBasicFeeRates/:P_SPID/:P_ACTIVE_INACTIVE') - GetBasicFeeRates( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE',) P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETBASICFEERATES(P_SPID, P_ACTIVE_INACTIVE) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetBondRates/:P_SPID/:P_ACTIVE_INACTIVE') - GetBondRates( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE',) P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETBONDRATES(P_SPID, P_ACTIVE_INACTIVE) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetCargoRates/:P_SPID/:P_ACTIVE_INACTIVE') - GetCargoRates( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE',) P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETCARGORATES(P_SPID, P_ACTIVE_INACTIVE) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetCfFeeRates/:P_SPID/:P_ACTIVE_INACTIVE') - GetCfFeeRates( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE',) P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETCFFEERATES(P_SPID, P_ACTIVE_INACTIVE) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetCsFeeRates/:P_SPID/:P_ACTIVE_INACTIVE') - GetCsFeeRates( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE',) P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETCSFEERATES(P_SPID, P_ACTIVE_INACTIVE) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetEfFeeRates/:P_SPID/:P_ACTIVE_INACTIVE') - GetEfFeeRates( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE',) P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETEFFEERATES(P_SPID, P_ACTIVE_INACTIVE) - } - - @ApiTags('Manage Fee - Oracle') - @Get('/GetFeeComm/:P_SPID/:P_ACTIVE_INACTIVE') - GetFeeComm( - @Param('P_SPID', ParseIntPipe) P_SPID: number, - @Param('P_ACTIVE_INACTIVE') P_ACTIVE_INACTIVE: string - ) { - return this.manageFeeService.GETFEECOMM(P_SPID, P_ACTIVE_INACTIVE) - } - -} diff --git a/src/oracle/oracle.dto.ts b/src/oracle/oracle.dto.ts index 174c2f2..a45d910 100644 --- a/src/oracle/oracle.dto.ts +++ b/src/oracle/oracle.dto.ts @@ -3,586 +3,11 @@ import { Type } from 'class-transformer'; import { IsArray, IsDefined, IsEmail, IsNumber, IsOptional, IsString, ValidateNested } from 'class-validator'; -// export class GetSelectedServiceProviderDTO { -// @IsNumber() -// p_spid: number; -// } -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 CreateCarnetSequenceDTO { - @ApiProperty({ required: true }) - @IsNumber() - p_spid: number; - - @ApiProperty({ required: true }) - @IsNumber() - p_regionid: number; - - @ApiProperty({ required: true }) - @IsNumber() - p_startnumber: number; - - @ApiProperty({ required: true }) - @IsNumber() - p_endnumber: number; - - @ApiProperty({ required: true }) - @IsString() - p_carnettype: string; -} - -export class CreateTableRecordDTO { - @ApiProperty({ required: true }) - @IsString() - P_USERID: string; - - @ApiProperty({ required: true }) - @IsString() - 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 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 }) - @IsString() - 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; -} - -// Existing UpdateFeeCommDTO -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; -} - -// New UpdateFeeCommBodyDTO -export class UpdateFeeCommBodyDTO { - @ApiProperty({ type: UpdateFeeCommDTO, required: true }) // Correctly reference UpdateFeeCommDTO - p_fees_comm: UpdateFeeCommDTO; // No need for @IsObject() -} - -export class ActivateOrInactivateParamRecordDTO { - - @ApiProperty({ required: true }) - @IsNumber() - P_PARAMID: number; - - @ApiProperty({ required: true }) - @IsString() - P_USERID: string; -} diff --git a/src/oracle/oracle.module.ts b/src/oracle/oracle.module.ts index edc3d6b..16f35a4 100644 --- a/src/oracle/oracle.module.ts +++ b/src/oracle/oracle.module.ts @@ -1,9 +1,5 @@ import { Module } from '@nestjs/common'; -import { OracleService } from './oracle.service'; -import { OracleController } from './oracle.controller'; import { DbModule } from 'src/db/db.module'; -import { ParamTableService } from './paramTable.service'; -import { ManageFeeService } from './manageFee.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'; @@ -12,9 +8,9 @@ import { ManageFeeModule } from './manage-fee/manage-fee.module'; import { ManageClientsModule } from './manage-clients/manage-clients.module'; @Module({ - imports:[DbModule, HomePageModule, ManageHoldersModule, UscibManagedSpModule, ParamTableModule, ManageFeeModule, ManageClientsModule], - providers: [OracleService,ParamTableService,ManageFeeService], - controllers: [OracleController], - exports:[OracleService,ParamTableService,ManageFeeService] + imports:[DbModule, HomePageModule, UscibManagedSpModule, ParamTableModule, ManageFeeModule, ManageHoldersModule, ManageClientsModule], + providers: [], + controllers: [], + exports:[] }) export class OracleModule {} diff --git a/src/oracle/oracle.service.ts b/src/oracle/oracle.service.ts deleted file mode 100644 index 9c241e6..0000000 --- a/src/oracle/oracle.service.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { OracleDBService } from 'src/db/db.service'; -import * as oracledb from 'oracledb' - -@Injectable() -export class OracleService { - constructor(private readonly oracleDBService: OracleDBService) { } - - // Service provider contacts [ SPContacts ] - - - - // CarnetSequence - - async createCarnetSequence( - p_spid: number, - p_regionid: number, - p_startnumber: number, - p_endnumber: number, - p_carnettype: 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.CreateCarnetSequence( - :p_spid, - :p_regionid, - :p_startnumber, - :p_endnumber, - :p_carnettype, - :p_cursor); - END;`, { - p_spid: { - val: p_spid, - type: oracledb.DB_TYPE_NUMBER - }, - p_regionid: { - val: p_regionid, - type: oracledb.DB_TYPE_NUMBER - }, - p_startnumber: { - val: p_startnumber, - type: oracledb.DB_TYPE_NUMBER - }, - p_endnumber: { - val: p_endnumber, - type: oracledb.DB_TYPE_NUMBER - }, - p_carnettype: { - val: p_carnettype, - 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(); - - await result.outBinds.p_cursor.close() - - return fres - - } catch (err) { - console.error('Error fetching users: ', err); - return { error: err.message } - } finally { } - } - - async getCarnetSequence(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.GetCarnetSequence(: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 { } - } -} diff --git a/src/oracle/param-table/param-table.controller.ts b/src/oracle/param-table/param-table.controller.ts index b7d26e8..0f774fc 100644 --- a/src/oracle/param-table/param-table.controller.ts +++ b/src/oracle/param-table/param-table.controller.ts @@ -1,4 +1,48 @@ -import { Controller } from '@nestjs/common'; +import { Body, Controller, Get, Patch, Post, Put, Query, UsePipes } 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'; @Controller('param-table') -export class ParamTableController {} +export class ParamTableController { + + constructor(private readonly paramTableService: ParamTableService) { } + + @ApiTags('Param Table - Oracle') + @Get('/GetParamValues') + @ApiQuery({ name: 'P_SPID', required: false, type: Number, description: 'The ID of the parameter' }) + @ApiQuery({ name: 'P_PARAMTYPE', required: false, type: String, description: 'The type of the parameter' }) + getParamValues(@Query() body: getParamValuesDTO) { + 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') + @Put('/InActivateParamRecord') + inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) { + return this.paramTableService.INACTIVATEPARAMRECORD(body) + } + + @ApiTags('Param Table - Oracle') + @Put('/ReActivateParamRecord') + reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) { + return this.paramTableService.REACTIVATEPARAMRECORD(body) + } +} diff --git a/src/oracle/param-table/param-table.dto.ts b/src/oracle/param-table/param-table.dto.ts new file mode 100644 index 0000000..7dae1bb --- /dev/null +++ b/src/oracle/param-table/param-table.dto.ts @@ -0,0 +1,140 @@ +import { ApiProperty } from "@nestjs/swagger"; +import { Transform } from "class-transformer"; +import { IsDefined, IsInt, IsNumber, IsOptional, IsString, Min, ValidateIf } 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 { + @IsInt({ message: "Property P_SPID must be a whole number" }) + @IsNumber({}, { message: "Property P_SPID must be a number" }) + @Min(0, { message: "Property P_SPID must be at least 0" }) + @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; +} \ No newline at end of file diff --git a/src/oracle/param-table/param-table.service.ts b/src/oracle/param-table/param-table.service.ts index 8325272..ee1d838 100644 --- a/src/oracle/param-table/param-table.service.ts +++ b/src/oracle/param-table/param-table.service.ts @@ -1,4 +1,367 @@ import { Injectable } from '@nestjs/common'; +import { OracleDBService } from 'src/db/db.service'; +import * as oracledb from 'oracledb' +import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from './param-table.dto'; @Injectable() -export class ParamTableService {} +export class ParamTableService { + constructor(private readonly oracleDBService: OracleDBService) { } + + async GETPARAMVALUES(body:getParamValuesDTO) { + + let finalBody = { + P_SPID: body.P_SPID ? body.P_SPID : null, + P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null + } + + let connection; + let rows = []; + try { + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.GETPARAMVALUES(:P_SPID,:P_PARAMTYPE,:p_cursor); + END;`, + { + P_SPID: { + val: finalBody.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_PARAMTYPE: { + val: finalBody.P_PARAMTYPE, + type: oracledb.DB_TYPE_NVARCHAR + }, + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + if (result.outBinds && result.outBinds.p_cursor) { + const cursor = result.outBinds.p_cursor; + let rowsBatch; + + do { + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + + } + + async CREATETABLERECORD(body: CreateTableRecordDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.CREATETABLERECORD(:P_USERID,:P_TABLEFULLDESC,:p_cursor); + END;`, + { + P_TABLEFULLDESC: { + val: body.P_TABLEFULLDESC, + type: oracledb.DB_TYPE_VARCHAR + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + } + + async CREATEPARAMRECORD(body: CreateParamRecordDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD( + :P_SPID, + :P_PARAMTYPE, + :P_PARAMDESC, + :P_PARAMVALUE, + :P_ADDLPARAMVALUE1, + :P_ADDLPARAMVALUE2, + :P_ADDLPARAMVALUE3, + :P_ADDLPARAMVALUE4, + :P_ADDLPARAMVALUE5, + :P_SORTSEQ, + :P_USERID, + :p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_PARAMTYPE: { + val: body.P_PARAMTYPE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_PARAMDESC: { + val: body.P_PARAMDESC, + type: oracledb.DB_TYPE_VARCHAR + }, + P_PARAMVALUE: { + val: body.P_PARAMVALUE, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE1: { + val: body.P_ADDLPARAMVALUE1, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE2: { + val: body.P_ADDLPARAMVALUE2, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE3: { + val: body.P_ADDLPARAMVALUE3, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE4: { + val: body.P_ADDLPARAMVALUE4, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE5: { + val: body.P_ADDLPARAMVALUE5, + type: oracledb.DB_TYPE_VARCHAR + }, + P_SORTSEQ: { + val: body.P_SORTSEQ, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + + } catch (err) { + + return { error: err.message } + } finally { } + } + + async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD( + :P_SPID, + :P_PARAMID, + :P_PARAMDESC, + :P_ADDLPARAMVALUE1, + :P_ADDLPARAMVALUE2, + :P_ADDLPARAMVALUE3, + :P_ADDLPARAMVALUE4, + :P_ADDLPARAMVALUE5, + :P_SORTSEQ, + :P_USERID, + :p_cursor); + END;`, + { + P_SPID: { + val: body.P_SPID, + type: oracledb.DB_TYPE_NUMBER + }, + P_PARAMID: { + val: body.P_PARAMID, + type: oracledb.DB_TYPE_NUMBER + }, + P_PARAMDESC: { + val: body.P_PARAMDESC, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE1: { + val: body.P_ADDLPARAMVALUE1, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE2: { + val: body.P_ADDLPARAMVALUE2, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE3: { + val: body.P_ADDLPARAMVALUE3, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE4: { + val: body.P_ADDLPARAMVALUE4, + type: oracledb.DB_TYPE_VARCHAR + }, + P_ADDLPARAMVALUE5: { + val: body.P_ADDLPARAMVALUE5, + type: oracledb.DB_TYPE_VARCHAR + }, + P_SORTSEQ: { + val: body.P_SORTSEQ, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + + p_cursor: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + return fres + + + } catch (err) { + + return { error: err.message } + } finally { } + } + + async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.INACTIVATEPARAMRECORD( + :P_PARAMID, + :P_USERID); + END;`, + { + P_PARAMID: { + val: body.P_PARAMID, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + } + ); + await connection.commit(); + + return "SP Executed Successfully" + + + } catch (err) { + + return { error: err.message } + } finally { } + } + + async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) { + let connection; + try { + + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD( + :P_PARAMID, + :P_USERID); + END;`, + { + P_PARAMID: { + val: body.P_PARAMID, + type: oracledb.DB_TYPE_NUMBER + }, + P_USERID: { + val: body.P_USERID, + type: oracledb.DB_TYPE_VARCHAR + }, + }, + ); + await connection.commit(); + + return "SP Executed Successfully" + + + } catch (err) { + + return { error: err.message } + } finally { } + } +} diff --git a/src/oracle/paramTable.service.ts b/src/oracle/paramTable.service.ts deleted file mode 100644 index 0135628..0000000 --- a/src/oracle/paramTable.service.ts +++ /dev/null @@ -1,377 +0,0 @@ -import { Injectable } from '@nestjs/common'; -import { OracleDBService } from 'src/db/db.service'; -import * as oracledb from 'oracledb' -import { ActivateOrInactivateParamRecordDTO, UpdateParamRecordDTO } from './oracle.dto'; - -@Injectable() -export class ParamTableService { - constructor(private readonly oracleDBService: OracleDBService) { } - - async GETPARAMVALUES(P_SPID?: number | null, P_PARAMTYPE?: string | null) { - P_SPID = P_SPID ? P_SPID : null; - P_PARAMTYPE = P_PARAMTYPE ? P_PARAMTYPE : null; - let connection; - let rows = []; - try { - connection = await this.oracleDBService.getConnection() - if (!connection) { - throw new Error('No DB Connected') - } - - const result = await connection.execute( - `BEGIN - MANAGEPARAMTABLE_PKG.GETPARAMVALUES(:P_SPID,:P_PARAMTYPE,:p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_PARAMTYPE: { - val: P_PARAMTYPE, - type: oracledb.DB_TYPE_NVARCHAR - }, - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, - { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - - if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; // 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 { } - - } - - async CREATETABLERECORD(P_USERID: string, P_TABLEFULLDESC: 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 - MANAGEPARAMTABLE_PKG.CREATETABLERECORD(:P_USERID,:P_TABLEFULLDESC,:p_cursor); - END;`, - { - P_TABLEFULLDESC: { - val: P_TABLEFULLDESC, - type: oracledb.DB_TYPE_VARCHAR - }, - P_USERID: { - val: P_USERID, - 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 CREATEPARAMRECORD( - P_PARAMTYPE: string, - P_PARAMDESC: string, - P_PARAMVALUE: string, - P_SORTSEQ: number, - P_USERID: string, - P_SPID?: number, - P_ADDLPARAMVALUE1?: string, - P_ADDLPARAMVALUE2?: string, - P_ADDLPARAMVALUE3?: string, - P_ADDLPARAMVALUE4?: string, - P_ADDLPARAMVALUE5?: 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 - MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD( - :P_SPID, - :P_PARAMTYPE, - :P_PARAMDESC, - :P_PARAMVALUE, - :P_ADDLPARAMVALUE1, - :P_ADDLPARAMVALUE2, - :P_ADDLPARAMVALUE3, - :P_ADDLPARAMVALUE4, - :P_ADDLPARAMVALUE5, - :P_SORTSEQ, - :P_USERID, - :p_cursor); - END;`, - { - P_SPID: { - val: P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_PARAMTYPE: { - val: P_PARAMTYPE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_PARAMDESC: { - val: P_PARAMDESC, - type: oracledb.DB_TYPE_VARCHAR - }, - P_PARAMVALUE: { - val: P_PARAMVALUE, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE1: { - val: P_ADDLPARAMVALUE1, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE2: { - val: P_ADDLPARAMVALUE2, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE3: { - val: P_ADDLPARAMVALUE3, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE4: { - val: P_ADDLPARAMVALUE4, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE5: { - val: P_ADDLPARAMVALUE5, - type: oracledb.DB_TYPE_VARCHAR - }, - P_SORTSEQ: { - val: P_SORTSEQ, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: P_USERID, - 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 UPDATEPARAMRECORD(body: UpdateParamRecordDTO) { - 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 - MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD( - :P_SPID, - :P_PARAMID, - :P_PARAMDESC, - :P_ADDLPARAMVALUE1, - :P_ADDLPARAMVALUE2, - :P_ADDLPARAMVALUE3, - :P_ADDLPARAMVALUE4, - :P_ADDLPARAMVALUE5, - :P_SORTSEQ, - :P_USERID, - :p_cursor); - END;`, - { - P_SPID: { - val: body.P_SPID, - type: oracledb.DB_TYPE_NUMBER - }, - P_PARAMID: { - val: body.P_PARAMID, - type: oracledb.DB_TYPE_NUMBER - }, - P_PARAMDESC: { - val: body.P_PARAMDESC, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE1: { - val: body.P_ADDLPARAMVALUE1, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE2: { - val: body.P_ADDLPARAMVALUE2, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE3: { - val: body.P_ADDLPARAMVALUE3, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE4: { - val: body.P_ADDLPARAMVALUE4, - type: oracledb.DB_TYPE_VARCHAR - }, - P_ADDLPARAMVALUE5: { - val: body.P_ADDLPARAMVALUE5, - type: oracledb.DB_TYPE_VARCHAR - }, - P_SORTSEQ: { - val: body.P_SORTSEQ, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - - p_cursor: { - type: oracledb.CURSOR, - dir: oracledb.BIND_OUT - } - }, { - outFormat: oracledb.OUT_FORMAT_OBJECT - } - ); - await connection.commit(); - - let fres = await result.outBinds.p_cursor.getRows(); - - return fres - - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - - async INACTIVATEPARAMRECORD(body:ActivateOrInactivateParamRecordDTO) { - 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 - MANAGEPARAMTABLE_PKG.INACTIVATEPARAMRECORD( - :P_PARAMID, - :P_USERID); - END;`, - { - P_PARAMID: { - val: body.P_PARAMID, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - } - ); - await connection.commit(); - - return "SP Executed Successfully" - - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } - - async REACTIVATEPARAMRECORD(body:ActivateOrInactivateParamRecordDTO) { - 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 - MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD( - :P_PARAMID, - :P_USERID); - END;`, - { - P_PARAMID: { - val: body.P_PARAMID, - type: oracledb.DB_TYPE_NUMBER - }, - P_USERID: { - val: body.P_USERID, - type: oracledb.DB_TYPE_VARCHAR - }, - }, - ); - await connection.commit(); - - return "SP Executed Successfully" - - - } catch (err) { - console.error('Error fetching users: ', err); - return {error: err.message} - } finally { } - } -} \ No newline at end of file diff --git a/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.controller.ts b/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.controller.ts index b199b14..b7f676a 100644 --- a/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.controller.ts +++ b/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.controller.ts @@ -1,4 +1,22 @@ -import { Controller } from '@nestjs/common'; +import { Body, Controller, Get, Param, ParseIntPipe, Post, Query } from '@nestjs/common'; +import { CreateCarnetSequenceDTO, GetCarnetSequenceDTO } from './carnet-sequence.dto'; +import { ApiTags } from '@nestjs/swagger'; +import { CarnetSequenceService } from './carnet-sequence.service'; @Controller('carnet-sequence') -export class CarnetSequenceController {} +export class CarnetSequenceController { + + 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) + } +} diff --git a/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto.ts b/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto.ts new file mode 100644 index 0000000..b84c7c0 --- /dev/null +++ b/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto.ts @@ -0,0 +1,42 @@ +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; +} \ No newline at end of file diff --git a/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.service.ts b/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.service.ts index 333ffb2..3be18cf 100644 --- a/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.service.ts +++ b/src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.service.ts @@ -1,4 +1,123 @@ import { Injectable } from '@nestjs/common'; +import * as oracledb from 'oracledb'; +import { OracleDBService } from 'src/db/db.service'; +import { CreateCarnetSequenceDTO, GetCarnetSequenceDTO } from './carnet-sequence.dto'; @Injectable() -export class CarnetSequenceService {} +export class CarnetSequenceService { + + constructor(private readonly oracleDBService:OracleDBService){} + + async createCarnetSequence(body:CreateCarnetSequenceDTO) { + let connection; + try { + connection = await this.oracleDBService.getConnection() + if (!connection) { + throw new Error('No DB Connected') + } + + const result = await connection.execute( + `BEGIN + USCIB_Managed_Pkg.CreateCarnetSequence( + :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: { + type: oracledb.CURSOR, + dir: oracledb.BIND_OUT + } + }, { + outFormat: oracledb.OUT_FORMAT_OBJECT + } + ); + + await connection.commit(); + + let fres = await result.outBinds.p_cursor.getRows(); + + await result.outBinds.p_cursor.close() + + return fres + + } catch (err) { + + return { error: err.message } + } finally { } + } + + async getCarnetSequence(body: GetCarnetSequenceDTO) { + 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.GetCarnetSequence(: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); // Fetch 100 rows at a time + rows = rows.concat(rowsBatch); + } while (rowsBatch.length > 0); + + + await cursor.close(); + } else { + throw new Error('No cursor returned from the stored procedure'); + } + + return rows; + + } catch (err) { + + return { error: err.message } + } finally { } + } +} diff --git a/src/oracle/uscib-managed-sp/region/region.controller.ts b/src/oracle/uscib-managed-sp/region/region.controller.ts index 4100025..b2b7ddd 100644 --- a/src/oracle/uscib-managed-sp/region/region.controller.ts +++ b/src/oracle/uscib-managed-sp/region/region.controller.ts @@ -21,13 +21,13 @@ export class RegionController { @ApiTags('Regions - Oracle') @Post('/InsertRegions') insertRegions(@Body() body: InsertRegionsDto) { - return this.regionService.insertRegions(body.p_region, body.p_name); + return this.regionService.insertRegions(body); } @ApiTags('Regions - Oracle') @Patch('/UpdateRegion') updateRegions(@Body() body: UpdateRegionDto) { - return this.regionService.updateRegions(body.p_regionID, body.p_name); + return this.regionService.updateRegions(body); } @ApiTags('Regions - Oracle') diff --git a/src/oracle/uscib-managed-sp/region/region.dto.ts b/src/oracle/uscib-managed-sp/region/region.dto.ts index 17192b3..89290d4 100644 --- a/src/oracle/uscib-managed-sp/region/region.dto.ts +++ b/src/oracle/uscib-managed-sp/region/region.dto.ts @@ -1,22 +1,26 @@ -import { IsNumber,IsString } from "class-validator"; +import { IsDefined, IsNumber,IsString } from "class-validator"; import { ApiProperty } from "@nestjs/swagger"; export class InsertRegionsDto { - @ApiProperty() - @IsString() + @ApiProperty({ required: true }) + @IsString({ message: "Property p_region must be a string" }) + @IsDefined({ message: "Property p_region is required" }) p_region: string; - @ApiProperty() - @IsString() + @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() + @IsNumber({}, { message: "Property p_regionID must be a number" }) + @IsDefined({ message: "Property p_regionID is required" }) p_regionID: number; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_name must be a string" }) + @IsDefined({ message: "Property p_name is required" }) p_name: string; } \ No newline at end of file diff --git a/src/oracle/uscib-managed-sp/region/region.module.ts b/src/oracle/uscib-managed-sp/region/region.module.ts index 4e6842e..12ff331 100644 --- a/src/oracle/uscib-managed-sp/region/region.module.ts +++ b/src/oracle/uscib-managed-sp/region/region.module.ts @@ -1,10 +1,8 @@ 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] }) diff --git a/src/oracle/uscib-managed-sp/region/region.service.ts b/src/oracle/uscib-managed-sp/region/region.service.ts index 0cfb04a..cd6aaf4 100644 --- a/src/oracle/uscib-managed-sp/region/region.service.ts +++ b/src/oracle/uscib-managed-sp/region/region.service.ts @@ -1,16 +1,17 @@ import { Injectable } from '@nestjs/common'; import { OracleDBService } from 'src/db/db.service'; import * as oracledb from 'oracledb' +import { InsertRegionsDto, UpdateRegionDto } from './region.dto'; @Injectable() export class RegionService { constructor(private readonly oracleDBService: OracleDBService) { } - async insertRegions(p_region: String, p_name: String) { + async insertRegions(body: InsertRegionsDto) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -18,14 +19,14 @@ export class RegionService { const result = await connection.execute( `BEGIN - USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor); - END;`, { + USCIB_Managed_Pkg.InsertNewRegion(:p_region,:p_name,:p_cursor); + END;`, { p_region: { - val: p_region, + val: body.p_region, type: oracledb.DB_TYPE_VARCHAR }, p_name: { - val: p_name, + val: body.p_name, type: oracledb.DB_TYPE_VARCHAR }, p_cursor: { @@ -44,15 +45,15 @@ export class RegionService { return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - async updateRegions(p_regionID: Number, p_name: String) { + async updateRegions(body: UpdateRegionDto) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -60,14 +61,14 @@ export class RegionService { const result = await connection.execute( `BEGIN - USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:p_name,:p_cursor); - END;`, { + USCIB_Managed_Pkg.UpdateRegion(:p_regionID,:p_name,:p_cursor); + END;`, { p_regionID: { - val: p_regionID, + val: body.p_regionID, type: oracledb.DB_TYPE_NUMBER }, p_name: { - val: p_name, + val: body.p_name, type: oracledb.DB_TYPE_VARCHAR }, p_cursor: { @@ -86,7 +87,7 @@ export class RegionService { return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } @@ -102,11 +103,6 @@ export class RegionService { 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); @@ -123,17 +119,14 @@ export class RegionService { ); if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; // The OUT cursor + const cursor = result.outBinds.p_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 + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); } 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'); @@ -142,7 +135,7 @@ export class RegionService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } diff --git a/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.controller.ts b/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.controller.ts index a7e34be..1c09432 100644 --- a/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.controller.ts +++ b/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.controller.ts @@ -1,6 +1,6 @@ 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 { Body, Controller, Get, Param, ParseIntPipe, Post, Put, Query } from '@nestjs/common'; +import { getSPDefaultcontactDTO, inactivateSPContactDTO, InsertSPContactsDTO, setSPDefaultcontactDTO, UpdateSPContactsDTO } from './sp-contacts.dto'; import { ApiTags } from '@nestjs/swagger'; @Controller('oracle') @@ -13,54 +13,31 @@ export class SpContactsController { @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 - ) + return this.spContactsService.insertSPContacts(body) } @ApiTags('SPContacts - Oracle') - @Post('/SetSPDefaultcontact/:id') - setSPDefaultcontact(@Param('id', ParseIntPipe) id: number) { - return this.spContactsService.setSPDefaultcontact(id) + @Post('/SetSPDefaultcontact') + setSPDefaultcontact(@Query() body:setSPDefaultcontactDTO) { + return this.spContactsService.setSPDefaultcontact(body) } @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 - ) + return this.spContactsService.updateSPContacts(body) } @ApiTags('SPContacts - Oracle') - @Post('/InactivateSPContact/:id') - inactivateSPContact(@Param('id', ParseIntPipe) id: number) { - return this.spContactsService.inactivateSPContact(id) + @Post('/InactivateSPContact') + inactivateSPContact(@Query() body:inactivateSPContactDTO) { + return this.spContactsService.inactivateSPContact(body) } @ApiTags('SPContacts - Oracle') - @Get('/GetSPDefaultcontact/:id') - getSPDefaultcontact(@Param('id', ParseIntPipe) id: number) { - return this.spContactsService.getSPDefaultcontacts(id) + @Get('/GetSPDefaultcontact') + getSPDefaultcontact(@Query() body:getSPDefaultcontactDTO) { + return this.spContactsService.getSPDefaultcontacts(body) } // @Get('/GetAllSPcontacts') diff --git a/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto.ts b/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto.ts index 0b3e86f..b335e73 100644 --- a/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto.ts +++ b/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto.ts @@ -1,5 +1,6 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsEmail, IsNumber, IsString } from 'class-validator'; +import { Transform } from 'class-transformer'; +import { IsDefined, IsEmail, IsInt, IsNumber, IsString, Min } from 'class-validator'; export class InsertSPContactsDTO { @ApiProperty({ required: true }) @@ -87,4 +88,25 @@ export class UpdateSPContactsDTO { @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; } \ No newline at end of file diff --git a/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.service.ts b/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.service.ts index 4559f99..06c3425 100644 --- a/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.service.ts +++ b/src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.service.ts @@ -1,29 +1,23 @@ import { Injectable } from '@nestjs/common'; import { OracleDBService } from 'src/db/db.service'; import * as oracledb from 'oracledb' +import { + getSPDefaultcontactDTO, + inactivateSPContactDTO, + InsertSPContactsDTO, + setSPDefaultcontactDTO, + UpdateSPContactsDTO +} from './sp-contacts.dto'; @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 - ) { + async insertSPContacts(body: InsertSPContactsDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -46,47 +40,47 @@ export class SpContactsService { :p_cursor); END;`, { p_spid: { - val: p_spid, + val: body.p_spid, type: oracledb.DB_TYPE_NUMBER }, p_defcontactflag: { - val: p_defcontactflag, + val: body.p_defcontactflag, type: oracledb.DB_TYPE_VARCHAR }, p_firstname: { - val: p_firstname, + val: body.p_firstname, type: oracledb.DB_TYPE_VARCHAR }, p_lastname: { - val: p_lastname, + val: body.p_lastname, type: oracledb.DB_TYPE_VARCHAR }, P_MIDDLEINITIAL: { - val: P_MIDDLEINITIAL, + val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_VARCHAR }, p_title: { - val: p_title, + val: body.p_title, type: oracledb.DB_TYPE_VARCHAR }, p_phoneno: { - val: p_phoneno, + val: body.p_phoneno, type: oracledb.DB_TYPE_VARCHAR }, p_mobileno: { - val: p_mobileno, + val: body.p_mobileno, type: oracledb.DB_TYPE_VARCHAR }, p_faxno: { - val: p_faxno, + val: body.p_faxno, type: oracledb.DB_TYPE_VARCHAR }, p_emailaddress: { - val: p_emailaddress, + val: body.p_emailaddress, type: oracledb.DB_TYPE_VARCHAR }, p_user_id: { - val: p_user_id, + val: body.p_user_id, type: oracledb.DB_TYPE_VARCHAR }, p_cursor: { @@ -105,16 +99,16 @@ export class SpContactsService { return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - async setSPDefaultcontact(p_spcontactid: number) { + async setSPDefaultcontact(body: setSPDefaultcontactDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -126,7 +120,7 @@ export class SpContactsService { END;`, { p_spcontactid: { - val: p_spcontactid, + val: body.p_spcontactid, type: oracledb.DB_TYPE_NUMBER }, } @@ -137,27 +131,16 @@ export class SpContactsService { 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, - ) { + async updateSPContacts(body: UpdateSPContactsDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -179,43 +162,43 @@ export class SpContactsService { :p_cursor); END;`, { p_spcontactid: { - val: p_spcontactid, + val: body.p_spcontactid, type: oracledb.DB_TYPE_NUMBER }, p_firstname: { - val: p_firstname, + val: body.p_firstname, type: oracledb.DB_TYPE_VARCHAR }, p_lastname: { - val: p_lastname, + val: body.p_lastname, type: oracledb.DB_TYPE_VARCHAR }, P_MIDDLEINITIAL: { - val: P_MIDDLEINITIAL, + val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_VARCHAR }, p_title: { - val: p_title, + val: body.p_title, type: oracledb.DB_TYPE_VARCHAR }, p_phoneno: { - val: p_phoneno, + val: body.p_phoneno, type: oracledb.DB_TYPE_VARCHAR }, p_mobileno: { - val: p_mobileno, + val: body.p_mobileno, type: oracledb.DB_TYPE_VARCHAR }, p_faxno: { - val: p_faxno, + val: body.p_faxno, type: oracledb.DB_TYPE_VARCHAR }, p_emailaddress: { - val: p_emailaddress, + val: body.p_emailaddress, type: oracledb.DB_TYPE_VARCHAR }, p_user_id: { - val: p_user_id, + val: body.p_user_id, type: oracledb.DB_TYPE_VARCHAR }, p_cursor: { @@ -234,16 +217,16 @@ export class SpContactsService { return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - async inactivateSPContact(p_spcontactid: number) { + async inactivateSPContact(body: inactivateSPContactDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -254,7 +237,7 @@ export class SpContactsService { USCIB_Managed_Pkg.InActivateSPContacts(:p_spcontactid); END;`, { p_spcontactid: { - val: p_spcontactid, + val: body.p_spcontactid, type: oracledb.DB_TYPE_NUMBER } } @@ -265,18 +248,18 @@ export class SpContactsService { return "SP executed successfully" } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - async getSPDefaultcontacts(p_SPid: number) { + async getSPDefaultcontacts(body: getSPDefaultcontactDTO) { 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') @@ -288,7 +271,7 @@ export class SpContactsService { END;`, { p_SPid: { - val: p_SPid, + val: body.p_SPid, type: oracledb.DB_TYPE_NUMBER, }, p_cursor: { @@ -302,15 +285,15 @@ export class SpContactsService { ); if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; // The OUT cursor + const cursor = result.outBinds.p_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 + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); } 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'); @@ -319,7 +302,7 @@ export class SpContactsService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -329,7 +312,7 @@ export class SpContactsService { 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') @@ -351,17 +334,17 @@ export class SpContactsService { ); if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; // The OUT cursor + const cursor = result.outBinds.p_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 + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); } 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'); @@ -370,7 +353,7 @@ export class SpContactsService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } diff --git a/src/oracle/uscib-managed-sp/sp/sp.controller.ts b/src/oracle/uscib-managed-sp/sp/sp.controller.ts index ca09a83..1c35fd7 100644 --- a/src/oracle/uscib-managed-sp/sp/sp.controller.ts +++ b/src/oracle/uscib-managed-sp/sp/sp.controller.ts @@ -1,7 +1,7 @@ -import { Body, Controller, Get, Param, ParseIntPipe, Post, Put } from '@nestjs/common'; +import { Body, Controller, Get, Param, ParseIntPipe, Post, Put, Query } from '@nestjs/common'; import { SpService } from './sp.service'; import { ApiTags } from '@nestjs/swagger'; -import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from './sp.dto'; +import { getSelectedServiceproviderDTO, InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from './sp.dto'; @Controller('oracle') export class SpController { @@ -13,48 +13,13 @@ export class SpController { @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 - ) + return this.spService.insertNewServiceProvider(body) } @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 - ) + return this.spService.updateServiceProvider(body) } @ApiTags('SP - Oracle') @@ -64,8 +29,8 @@ export class SpController { } @ApiTags('SP - Oracle') - @Get('/GetSelectedServiceprovider/:id') - getSelectedServiceprovider(@Param('id', ParseIntPipe) id: number) { - return this.spService.getServiceproviderByID(id); + @Get('/GetSelectedServiceprovider') + getSelectedServiceprovider(@Query() body:getSelectedServiceproviderDTO) { + return this.spService.getServiceproviderByID(body); } } diff --git a/src/oracle/uscib-managed-sp/sp/sp.dto.ts b/src/oracle/uscib-managed-sp/sp/sp.dto.ts index 152a3ff..56815c7 100644 --- a/src/oracle/uscib-managed-sp/sp/sp.dto.ts +++ b/src/oracle/uscib-managed-sp/sp/sp.dto.ts @@ -1,144 +1,183 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsNumber, IsString } from 'class-validator'; +import { Transform } from 'class-transformer'; +import { IsDefined, IsInt, IsNumber, IsOptional, IsString, Min } from 'class-validator'; export class InsertNewServiceProviderDTO { @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_name must be a string" }) + @IsDefined({ message: "Property p_name is required" }) p_name: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_lookupcode must be a string" }) + @IsDefined({ message: "Property p_lookupcode is required" }) p_lookupcode: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_address1 must be a string" }) + @IsDefined({ message: "Property p_address1 is required" }) p_address1: string; @ApiProperty({ required: false }) - @IsString() - p_address2: string; + @IsString({ message: "Property p_address2 must be a string" }) + @IsOptional() + p_address2?: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_city must be a string" }) + @IsDefined({ message: "Property p_city is required" }) p_city: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_state must be a string" }) + @IsDefined({ message: "Property p_state is required" }) p_state: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_zip must be a string" }) + @IsDefined({ message: "Property p_zip is required" }) p_zip: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_country must be a string" }) + @IsDefined({ message: "Property p_country is required" }) p_country: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_issuingregion must be a string" }) + @IsDefined({ message: "Property p_issuingregion is required" }) p_issuingregion: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_replacementregion must be a string" }) + @IsDefined({ message: "Property p_replacementregion is required" }) p_replacementregion: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_bondsurety must be a string" }) + @IsDefined({ message: "Property p_bondsurety is required" }) p_bondsurety: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_cargopolicyno must be a string" }) + @IsDefined({ message: "Property p_cargopolicyno is required" }) p_cargopolicyno: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_cargosurety must be a string" }) + @IsDefined({ message: "Property p_cargosurety is required" }) p_cargosurety: string; @ApiProperty({ required: true }) - @IsString() + @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() - P_NOTES: string; + @IsString({ message: "Property P_NOTES must be a string" }) + @IsOptional() + P_NOTES?: string; @ApiProperty({ required: false }) - @IsString() - P_FILEIDS: string; + @IsString({ message: "Property P_FILEIDS must be a string" }) + @IsOptional() + P_FILEIDS?: string; } export class UpdateServiceProviderDTO { @ApiProperty({ required: true }) - @IsNumber() + @IsNumber({}, { message: "Property p_spid must be a number" }) + @IsDefined({ message: "Property p_spid is required" }) p_spid: number; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_name must be a string" }) + @IsDefined({ message: "Property p_name is required" }) p_name: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_lookupcode must be a string" }) + @IsDefined({ message: "Property p_lookupcode is required" }) p_lookupcode: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_address1 must be a string" }) + @IsDefined({ message: "Property p_address1 is required" }) p_address1: string; @ApiProperty({ required: false }) - @IsString() - p_address2: string; + @IsString({ message: "Property p_address2 must be a string" }) + @IsOptional() + p_address2?: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_city must be a string" }) + @IsDefined({ message: "Property p_city is required" }) p_city: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_state must be a string" }) + @IsDefined({ message: "Property p_state is required" }) p_state: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_zip must be a string" }) + @IsDefined({ message: "Property p_zip is required" }) p_zip: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_country must be a string" }) + @IsDefined({ message: "Property p_country is required" }) p_country: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_issuingregion must be a string" }) + @IsDefined({ message: "Property p_issuingregion is required" }) p_issuingregion: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_replacementregion must be a string" }) + @IsDefined({ message: "Property p_replacementregion is required" }) p_replacementregion: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_bondsurety must be a string" }) + @IsDefined({ message: "Property p_bondsurety is required" }) p_bondsurety: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_cargopolicyno must be a string" }) + @IsDefined({ message: "Property p_cargopolicyno is required" }) p_cargopolicyno: string; @ApiProperty({ required: true }) - @IsString() + @IsString({ message: "Property p_cargosurety must be a string" }) + @IsDefined({ message: "Property p_cargosurety is required" }) p_cargosurety: string; @ApiProperty({ required: true }) - @IsString() + @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() - P_NOTES: string; + @IsString({ message: "Property P_NOTES must be a string" }) + @IsOptional() + P_NOTES?: string; @ApiProperty({ required: false }) - @IsString() - P_FILEIDS: string; + @IsString({ message: "Property P_FILEIDS must be a string" }) + @IsOptional() + P_FILEIDS?: string; } -// export class GetSPcontactsDTO { -// @IsNumber() -// p_SPid: number; -// } +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; +} diff --git a/src/oracle/uscib-managed-sp/sp/sp.module.ts b/src/oracle/uscib-managed-sp/sp/sp.module.ts index 151c7aa..774e3e0 100644 --- a/src/oracle/uscib-managed-sp/sp/sp.module.ts +++ b/src/oracle/uscib-managed-sp/sp/sp.module.ts @@ -1,10 +1,8 @@ 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] }) diff --git a/src/oracle/uscib-managed-sp/sp/sp.service.ts b/src/oracle/uscib-managed-sp/sp/sp.service.ts index 108972a..d5b7781 100644 --- a/src/oracle/uscib-managed-sp/sp/sp.service.ts +++ b/src/oracle/uscib-managed-sp/sp/sp.service.ts @@ -1,34 +1,18 @@ import { Injectable } from '@nestjs/common'; import { OracleDBService } from 'src/db/db.service'; import * as oracledb from 'oracledb' +import { getSelectedServiceproviderDTO, InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from './sp.dto'; @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 - ) { + async insertNewServiceProvider(body: InsertNewServiceProviderDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -56,67 +40,67 @@ export class SpService { :p_cursor); END;`, { p_name: { - val: p_name, + val: body.p_name, type: oracledb.DB_TYPE_VARCHAR }, p_lookupcode: { - val: p_lookupcode, + val: body.p_lookupcode, type: oracledb.DB_TYPE_VARCHAR }, p_address1: { - val: p_address1, + val: body.p_address1, type: oracledb.DB_TYPE_VARCHAR }, p_address2: { - val: p_address2, + val: body.p_address2, type: oracledb.DB_TYPE_VARCHAR }, p_city: { - val: p_city, + val: body.p_city, type: oracledb.DB_TYPE_VARCHAR }, p_state: { - val: p_state, + val: body.p_state, type: oracledb.DB_TYPE_VARCHAR }, p_zip: { - val: p_zip, + val: body.p_zip, type: oracledb.DB_TYPE_VARCHAR }, p_country: { - val: p_country, + val: body.p_country, type: oracledb.DB_TYPE_VARCHAR }, p_issuingregion: { - val: p_issuingregion, + val: body.p_issuingregion, type: oracledb.DB_TYPE_VARCHAR }, p_replacementregion: { - val: p_replacementregion, + val: body.p_replacementregion, type: oracledb.DB_TYPE_VARCHAR }, p_bondsurety: { - val: p_bondsurety, + val: body.p_bondsurety, type: oracledb.DB_TYPE_VARCHAR }, p_cargopolicyno: { - val: p_cargopolicyno, + val: body.p_cargopolicyno, type: oracledb.DB_TYPE_VARCHAR }, p_cargosurety: { - val: p_cargosurety, + val: body.p_cargosurety, type: oracledb.DB_TYPE_VARCHAR }, p_user_id: { - val: p_user_id, + val: body.p_user_id, type: oracledb.DB_TYPE_VARCHAR }, P_NOTES: { - val: P_NOTES, + val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR }, P_FILEIDS: { - val: P_FILEIDS, + val: body.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR }, @@ -135,35 +119,17 @@ export class SpService { 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 - ) { + async updateServiceProvider(body: UpdateServiceProviderDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -192,71 +158,71 @@ export class SpService { :p_cursor); END;`, { p_spid: { - val: p_spid, + val: body.p_spid, type: oracledb.DB_TYPE_NUMBER }, p_name: { - val: p_name, + val: body.p_name, type: oracledb.DB_TYPE_VARCHAR }, p_lookupcode: { - val: p_lookupcode, + val: body.p_lookupcode, type: oracledb.DB_TYPE_VARCHAR }, p_address1: { - val: p_address1, + val: body.p_address1, type: oracledb.DB_TYPE_VARCHAR }, p_address2: { - val: p_address2, + val: body.p_address2, type: oracledb.DB_TYPE_VARCHAR }, p_city: { - val: p_city, + val: body.p_city, type: oracledb.DB_TYPE_VARCHAR }, p_state: { - val: p_state, + val: body.p_state, type: oracledb.DB_TYPE_VARCHAR }, p_zip: { - val: p_zip, + val: body.p_zip, type: oracledb.DB_TYPE_VARCHAR }, p_country: { - val: p_country, + val: body.p_country, type: oracledb.DB_TYPE_VARCHAR }, p_issuingregion: { - val: p_issuingregion, + val: body.p_issuingregion, type: oracledb.DB_TYPE_VARCHAR }, p_replacementregion: { - val: p_replacementregion, + val: body.p_replacementregion, type: oracledb.DB_TYPE_VARCHAR }, p_bondsurety: { - val: p_bondsurety, + val: body.p_bondsurety, type: oracledb.DB_TYPE_VARCHAR }, p_cargopolicyno: { - val: p_cargopolicyno, + val: body.p_cargopolicyno, type: oracledb.DB_TYPE_VARCHAR }, p_cargosurety: { - val: p_cargosurety, + val: body.p_cargosurety, type: oracledb.DB_TYPE_VARCHAR }, p_user_id: { - val: p_user_id, + val: body.p_user_id, type: oracledb.DB_TYPE_VARCHAR }, P_NOTES: { - val: P_NOTES, + val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR }, P_FILEIDS: { - val: P_FILEIDS, + val: body.P_FILEIDS, type: oracledb.DB_TYPE_VARCHAR }, p_cursor: { @@ -275,7 +241,7 @@ export class SpService { return fres } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } @@ -286,7 +252,7 @@ export class SpService { 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') @@ -308,15 +274,15 @@ export class SpService { ); if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; // The OUT cursor + const cursor = result.outBinds.p_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 + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); } while (rowsBatch.length > 0); - // Close the cursor after you're done + await cursor.close(); return rows; @@ -325,18 +291,18 @@ export class SpService { } } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { } } - async getServiceproviderByID(p_spid: Number) { + async getServiceproviderByID(body:getSelectedServiceproviderDTO) { 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') @@ -344,11 +310,11 @@ export class SpService { const result = await connection.execute( `BEGIN - USCIB_Managed_Pkg.GetSPbySPID(:p_spid,:p_cursor); - END;`, + USCIB_Managed_Pkg.GetSPbySPID(:p_spid,:p_cursor); + END;`, { p_spid: { - val: p_spid, + val: body.p_spid, type: oracledb.DB_TYPE_NUMBER, }, p_cursor: { @@ -362,17 +328,14 @@ export class SpService { ); if (result.outBinds && result.outBinds.p_cursor) { - const cursor = result.outBinds.p_cursor; // The OUT cursor + const cursor = result.outBinds.p_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 + rowsBatch = await cursor.getRows(100); + rows = rows.concat(rowsBatch); } 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'); @@ -381,7 +344,7 @@ export class SpService { return rows; } catch (err) { - console.error('Error fetching users: ', err); + return { error: err.message } } finally { }