modified oracle SP

This commit is contained in:
Kallesh B S 2025-05-09 16:47:29 +05:30
parent 9470845f37
commit d3fb3e6365
4 changed files with 99 additions and 21 deletions

View File

@ -1,6 +1,6 @@
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
import { ManageFeeService } from './manage-fee.service';
import { CreateBasicFeeDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { CreateBasicFeeDTO, CreateBondRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { ApiTags } from '@nestjs/swagger';
@Controller('mssql')
@ -25,4 +25,22 @@ export class ManageFeeController {
UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) {
return this.manageFeeService.UPDATEBASICFEE(body);
}
// @ApiTags('Manage Fee - Mssql')
// @Get('/GetBondRates')
GetBondRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBONDRATES(body);
}
// @ApiTags('Manage Fee - Mssql')
// @Post('/CreateBondRate')
CreateBondRate(@Body() body: CreateBondRateDTO) {
return this.manageFeeService.CREATEBONDRATE(body);
}
// @ApiTags('Manage Fee - Mssql')
// @Patch('/UpdateBondRate')
UpdateBondRate(@Body() body: UpdateBondRateDTO) {
return this.manageFeeService.UPDATEBONDRATE(body);
}
}

View File

@ -1,7 +1,7 @@
import { Injectable, Logger } from '@nestjs/common';
import { MssqlDBService, OracleDBService } from 'src/db/db.service';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { CreateBasicFeeDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import { CreateBasicFeeDTO, CreateBondRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO } from 'src/oracle/manage-fee/manage-fee.dto';
import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { Connection, Request } from 'mssql';
@ -14,7 +14,7 @@ export class ManageFeeService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
// get
// Basic Fee Setup
async GETBASICFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
let connection: Connection;
@ -30,8 +30,6 @@ export class ManageFeeService {
}
}
// post
async CREATEBASICFEE(body: CreateBasicFeeDTO) {
let connection: Connection;
try {
@ -50,8 +48,6 @@ export class ManageFeeService {
}
}
// update
async UPDATEBASICFEE(body: UpdateBasicFeeDTO) {
let connection: Connection;
try {
@ -67,4 +63,65 @@ export class ManageFeeService {
throw new InternalServerException();
}
}
// Bond Rate Setup
async GETBONDRATES(body: GetFeeGeneralDTO): Promise<any[]> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetBondRates');
return result.recordset;
} catch (error) {
console.log(error);
throw new InternalServerException();
}
}
async CREATEBONDRATE(body: CreateBondRateDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERTYPE', mssql.VarChar(3), body.P_HOLDERTYPE);
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(100), body.P_USCIBMEMBERFLAG);
request.input('P_SPCLCOMMODITY', mssql.VarChar(100), body.P_SPCLCOMMODITY);
request.input('P_SPCLCOUNTRY', mssql.VarChar(100), body.P_SPCLCOUNTRY);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateBondRate');
return result.recordset;
} catch (error) {
console.log(error);
throw new InternalServerException();
}
}
async UPDATEBONDRATE(body: UpdateBondRateDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_BONDRATESETUPID', mssql.Int, body.P_BONDRATESETUPID);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateBondRate');
return result.recordset;
} catch (error) {
throw new InternalServerException();
}
}
}

View File

@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { Transform } from 'class-transformer';
import { IsDefined, IsInt, IsNumber, IsString, Matches, Min } from 'class-validator';
import { IsDefined, IsInt, IsNumber, IsString, Length, Matches, Min } from 'class-validator';
export class GetFeeGeneralDTO {
@ApiProperty({ required: true })
@ -52,7 +52,9 @@ export class CreateBondRateDTO {
P_SPID: number;
@ApiProperty({ required: true })
@IsString()
@Length(0, 3, {message:"Property P_HOLDERTYPE must be between 0 to 3 characters"})
@IsString({message:"Property P_USERID must be a string"})
@IsDefined({ message: 'Property P_USERID is required' })
P_HOLDERTYPE: string;
@ApiProperty({ required: true })

View File

@ -128,7 +128,8 @@ export class SpService {
throw new BadRequestException(fres[0].ERRORMESG)
}
return fres[0];
// return fres[0];
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
@ -202,11 +203,11 @@ export class SpService {
:p_state,
:p_zip,
:p_country,
:p_issuingregion,
:p_replacementregion,
:p_bondsurety,
:p_cargopolicyno,
:p_cargosurety,
:p_replacementregion,
:p_issuingregion,
:p_user_id,
:P_NOTES,
:P_FILEIDS,
@ -249,14 +250,6 @@ export class SpService {
val: finalBody.p_country,
type: oracledb.DB_TYPE_VARCHAR,
},
p_issuingregion: {
val: finalBody.p_issuingregion,
type: oracledb.DB_TYPE_VARCHAR,
},
p_replacementregion: {
val: finalBody.p_replacementregion,
type: oracledb.DB_TYPE_VARCHAR,
},
p_bondsurety: {
val: finalBody.p_bondsurety,
type: oracledb.DB_TYPE_VARCHAR,
@ -269,6 +262,14 @@ export class SpService {
val: finalBody.p_cargosurety,
type: oracledb.DB_TYPE_VARCHAR,
},
p_replacementregion: {
val: finalBody.p_replacementregion,
type: oracledb.DB_TYPE_VARCHAR,
},
p_issuingregion: {
val: finalBody.p_issuingregion,
type: oracledb.DB_TYPE_VARCHAR,
},
p_user_id: {
val: finalBody.p_user_id,
type: oracledb.DB_TYPE_VARCHAR,
@ -299,7 +300,7 @@ export class SpService {
throw new BadRequestException(fres[0].ERRORMESG)
}
return fres[0];
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);