diff --git a/manageFee.http b/manageFee.http index e30babb..89e7060 100644 --- a/manageFee.http +++ b/manageFee.http @@ -119,4 +119,102 @@ Content-Type: application/json } +### + +// UpdateBasicFee + +PATCH http://localhost:3000/oracle/UpdateBasicFee +Content-Type: application/json + +{ + "P_BASICFEESETUPID": 1, + "P_FEES": 100.50, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user123" +} + +### + +// UpdateBondRate + +PATCH http://localhost:3000/oracle/UpdateBondRate +Content-Type: application/json + +{ + "P_BONDRATESETUPID": 1, + "P_RATE": 5.25, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user456" +} + +### + +// UpdateCargoRate + +PATCH http://localhost:3000/oracle/UpdateCargoRate +Content-Type: application/json + +{ + "P_CARGORATESETUPID": 1, + "P_RATE": 3.75, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user789" +} + +### + +// UpdateCfFee + +PATCH http://localhost:3000/oracle/UpdateCfFee +Content-Type: application/json + +{ + "P_CFFEESETUPID": 1, + "P_RATE": 4.50, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user101" +} + +### + +// UpdateCsFee + +PATCH http://localhost:3000/oracle/UpdateCsFee +Content-Type: application/json + +{ + "P_CSFEESETUPID": 1, + "P_RATE": 2.75, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user202" +} + +### + +// UpdateEfFee + +PATCH http://localhost:3000/oracle/UpdateEfFee +Content-Type: application/json + +{ + "P_EFFEESETUPID": 1, + "P_FEES": 150.00, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user303" +} + +### + +// UpdateFeeComm + +PATCH http://localhost:3000/oracle/UpdateFeeComm +Content-Type: application/json + +{ + "P_FEECOMMID": 1, + "P_RATE": 6.50, + "P_EFFDATE": "2023-10-01", + "P_USERID": "user404" +} + ### \ No newline at end of file diff --git a/src/oracle/manageFee.service.ts b/src/oracle/manageFee.service.ts index 3019f48..f4dc87b 100644 --- a/src/oracle/manageFee.service.ts +++ b/src/oracle/manageFee.service.ts @@ -1,6 +1,6 @@ import { Injectable } from "@nestjs/common"; import { OracleDBService } from "src/db/db.service"; -import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO } from "./oracle.dto"; +import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from "./oracle.dto"; import * as oracledb from 'oracledb'; @Injectable() @@ -437,8 +437,8 @@ export class ManageFeeService { throw new Error('Error fetching users'); } finally { } } - async CREATEFEECOMM(body: CreateFeeCommDTO) { - + async CREATEFEECOMM(body: CreateFeeCommDTO) { + let connection; try { // Connect to the Oracle database using oracledb @@ -449,7 +449,7 @@ export class ManageFeeService { const result = await connection.execute( `BEGIN - MANAGEFEE_SETUP_PKG. CREATEFEECOMM( + MANAGEFEE_SETUP_PKG.CREATEFEECOMM( :P_SPID, :P_PARAMID, :P_COMMRATE, @@ -496,7 +496,7 @@ export class ManageFeeService { console.error('Error fetching users: ', err); throw new Error('Error fetching users'); } finally { } - + } async GETBASICFEERATES() { } async GETBONDRATES() { } @@ -505,10 +505,403 @@ export class ManageFeeService { async GETCSFEERATES() { } async GETEFFEERATES() { } async GETFEECOMM() { } - async UPDATEBASICFEE() { } - async UPDATEBONDRATE() { } - async UPDATECARGORATE() { } - async UPDATECFFEE() { } - async UPDATEEFFEE() { } - async UPDATEFEECOMM() { } + + async UPDATEBASICFEE(body: UpdateBasicFeeDTO) { + + 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 + 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); + throw new Error('Error fetching users'); + } finally { } + + + } + async UPDATEBONDRATE(body: UpdateBondRateDTO) { + + 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 + 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); + throw new Error('Error fetching users'); + } finally { } + + + } + async UPDATECARGORATE(body: UpdateCargoRateDTO) { + + 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 + 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); + throw new Error('Error fetching users'); + } finally { } + + + } + async UPDATECFFEE(body: UpdateCfFeeDTO) { + 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 + 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); + throw new Error('Error fetching users'); + } finally { } + + + } + async UPDATECSFEE(body: UpdateCsFeeDTO) { + + 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 + 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); + throw new Error('Error fetching users'); + } finally { } + + + } + async UPDATEEFFEE(body: UpdateEfFeeDTO) { + + + 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 + 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); + throw new Error('Error fetching users'); + } finally { } + + } + async UPDATEFEECOMM(body: UpdateFeeCommDTO) { + + 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 + MANAGEFEE_SETUP_PKG.UPDATEFEECOMM( + :P_FEECOMMID, + :P_RATE, + :P_EFFDATE, + :P_USERID, + :P_CURSOR); + END;`, + { + P_FEECOMMID: { + val: body.P_FEECOMMID, + 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); + throw new Error('Error fetching users'); + } finally { } + + + } } \ No newline at end of file diff --git a/src/oracle/oracle.controller.ts b/src/oracle/oracle.controller.ts index 574da79..c76fb09 100644 --- a/src/oracle/oracle.controller.ts +++ b/src/oracle/oracle.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put, Query, UsePipes } from '@nestjs/common'; import { OracleService } from './oracle.service'; -import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCarnetSequenceDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, CreateParamRecordDTO, CreateTableRecordDTO, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, UpdateParamRecordDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto'; +import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCarnetSequenceDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, CreateParamRecordDTO, CreateTableRecordDTO, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO, UpdateParamRecordDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto'; import { ParamTableService } from './paramTable.service'; import { ManageFeeService } from './manageFee.service'; @@ -239,4 +239,39 @@ export class OracleController { return this.manageFeeService.CREATEFEECOMM(body) } + @Patch('/UpdateBasicFee') + UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) { + return this.manageFeeService.UPDATEBASICFEE(body) + } + + @Patch('/UpdateBondRate') + UpdateBondRate(@Body() body: UpdateBondRateDTO) { + return this.manageFeeService.UPDATEBONDRATE(body) + } + + @Patch('/UpdateCargoRate') + UpdateCargoRate(@Body() body: UpdateCargoRateDTO) { + return this.manageFeeService.UPDATECARGORATE(body) + } + + @Patch('/UpdateCfFee') + UpdateCfFee(@Body() body: UpdateCfFeeDTO) { + return this.manageFeeService.UPDATECFFEE(body) + } + + @Patch('/UpdateCsFee') + UpdateCsFee(@Body() body: UpdateCsFeeDTO) { + return this.manageFeeService.UPDATECSFEE(body) + } + + @Patch('/UpdateEfFee') + UpdateEfFee(@Body() body: UpdateEfFeeDTO) { + return this.manageFeeService.UPDATEEFFEE(body) + } + + @Patch('/UpdateFeeComm') + UpdateFeeComm(@Body() body: UpdateFeeCommDTO) { + return this.manageFeeService.UPDATEFEECOMM(body) + } + } diff --git a/src/oracle/oracle.dto.ts b/src/oracle/oracle.dto.ts index 3975c6b..6065442 100644 --- a/src/oracle/oracle.dto.ts +++ b/src/oracle/oracle.dto.ts @@ -441,3 +441,101 @@ export class CreateFeeCommDTO { @IsString() P_USERID: string; } + +export class UpdateBasicFeeDTO { + @IsNumber() + P_BASICFEESETUPID: number; + + @IsNumber() + P_FEES: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} + +export class UpdateBondRateDTO { + @IsNumber() + P_BONDRATESETUPID: number; + + @IsNumber() + P_RATE: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} + +export class UpdateCargoRateDTO { + @IsNumber() + P_CARGORATESETUPID: number; + + @IsNumber() + P_RATE: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} + +export class UpdateCfFeeDTO { + @IsNumber() + P_CFFEESETUPID: number; + + @IsNumber() + P_RATE: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} + +export class UpdateCsFeeDTO { + @IsNumber() + P_CSFEESETUPID: number; + + @IsNumber() + P_RATE: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} + +export class UpdateEfFeeDTO { + @IsNumber() + P_EFFEESETUPID: number; + + @IsNumber() + P_FEES: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} + +export class UpdateFeeCommDTO { + @IsNumber() + P_FEECOMMID: number; + + @IsNumber() + P_RATE: number; + + @IsString() + P_EFFDATE: string; + + @IsString() + P_USERID: string; +} \ No newline at end of file