From 5e7be5ca17cf69cbf8758869eab27f129b75d29e Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Thu, 6 Mar 2025 15:46:37 +0530 Subject: [PATCH] get api of manage fee --- manageFee.http | 52 ++++- src/oracle/manageFee.service.ts | 397 ++++++++++++++++++++++++++++++-- src/oracle/oracle.controller.ts | 35 +++ 3 files changed, 462 insertions(+), 22 deletions(-) diff --git a/manageFee.http b/manageFee.http index 89e7060..fe2014d 100644 --- a/manageFee.http +++ b/manageFee.http @@ -217,4 +217,54 @@ Content-Type: application/json "P_USERID": "user404" } -### \ No newline at end of file +### + + +// GetBasicFeeRates + +GET http://localhost:3000/oracle/GetBasicFeeRates/12 + +### + + +// GetBondRates + +GET http://localhost:3000/oracle/GetBondRates/12 + +### + + +// GetCargoRates + +GET http://localhost:3000/oracle/GetCargoRates/12 + +### + + +// GetCfFeeRates + +GET http://localhost:3000/oracle/GetCfFeeRates/12 + +### + + +// GetCsFeeRates + +GET http://localhost:3000/oracle/GetCsFeeRates/12 + +### + + +// GetEfFeeRates + +GET http://localhost:3000/oracle/GetEfFeeRates/12 + +### + + +// GetFeeComm + +GET http://localhost:3000/oracle/GetFeeComm/12 + +### + diff --git a/src/oracle/manageFee.service.ts b/src/oracle/manageFee.service.ts index f4dc87b..3fea889 100644 --- a/src/oracle/manageFee.service.ts +++ b/src/oracle/manageFee.service.ts @@ -12,7 +12,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -78,7 +78,7 @@ export class ManageFeeService { async CREATEBONDRATE(body: CreateBondRateDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -152,7 +152,7 @@ export class ManageFeeService { async CREATECARGORATE(body: CreateCargoRateDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -222,7 +222,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -297,7 +297,7 @@ export class ManageFeeService { async CREATECSFEE(body: CreateCsFeeDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -361,7 +361,7 @@ export class ManageFeeService { async CREATEEFFEE(body: CreateEfFeeDTO) { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -441,7 +441,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -498,19 +498,14 @@ export class ManageFeeService { } finally { } } - async GETBASICFEERATES() { } - async GETBONDRATES() { } - async GETCARGORATES() { } - async GETCFFEERATES() { } - async GETCSFEERATES() { } - async GETEFFEERATES() { } - async GETFEECOMM() { } + + // update 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') @@ -567,7 +562,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -624,7 +619,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -680,7 +675,7 @@ export class ManageFeeService { 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') @@ -737,7 +732,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -795,7 +790,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -851,7 +846,7 @@ export class ManageFeeService { let connection; try { - // Connect to the Oracle database using oracledb + connection = await this.oracleDBService.getConnection() if (!connection) { throw new Error('No DB Connected') @@ -904,4 +899,364 @@ export class ManageFeeService { } + + // get + + async GETBASICFEERATES(P_SPID: Number) { + 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_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; + 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); + throw new Error('Error fetching users'); + } finally { } + } + async GETBONDRATES(P_SPID: Number) { + 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_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; + 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); + throw new Error('Error fetching users'); + } finally { } + } + async GETCARGORATES(P_SPID: Number) { + 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_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; + 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); + throw new Error('Error fetching users'); + } finally { } + } + async GETCFFEERATES(P_SPID: Number) { + 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_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; + 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); + throw new Error('Error fetching users'); + } finally { } + } + async GETCSFEERATES(P_SPID: Number) { + 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_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; + 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); + throw new Error('Error fetching users'); + } finally { } + } + async GETEFFEERATES(P_SPID: Number) { + 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_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; + 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); + throw new Error('Error fetching users'); + } finally { } + } + async GETFEECOMM(P_SPID: Number) { + 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_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; + 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); + 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 c76fb09..fe05c7c 100644 --- a/src/oracle/oracle.controller.ts +++ b/src/oracle/oracle.controller.ts @@ -274,4 +274,39 @@ export class OracleController { return this.manageFeeService.UPDATEFEECOMM(body) } + @Get('/GetBasicFeeRates/:id') + GetBasicFeeRates(@Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETBASICFEERATES(id) + } + + @Get('/GetBondRates/:id') + GetBondRates( @Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETBONDRATES(id) + } + + @Get('/GetCargoRates/:id') + GetCargoRates( @Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETCARGORATES(id) + } + + @Get('/GetCfFeeRates/:id') + GetCfFeeRates( @Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETCFFEERATES(id) + } + + @Get('/GetCsFeeRates/:id') + GetCsFeeRates( @Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETCSFEERATES(id) + } + + @Get('/GetEfFeeRates/:id') + GetEfFeeRates( @Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETEFFEERATES(id) + } + + @Get('/GetFeeComm/:id') + GetFeeComm( @Param('id', ParseIntPipe) id: number) { + return this.manageFeeService.GETFEECOMM(id) + } + }