modified api again

This commit is contained in:
Kallesh B S 2025-03-20 15:23:17 +05:30
parent b263dc2d09
commit 3e0b4e5b97
3 changed files with 29 additions and 15 deletions

View File

@ -1,6 +1,6 @@
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, UpdateFeeCommDTO } from "./oracle.dto";
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()
@ -842,7 +842,7 @@ export class ManageFeeService {
} finally { }
}
async UPDATEFEECOMM(body: UpdateFeeCommDTO) {
async UPDATEFEECOMM(body: UpdateFeeCommBodyDTO) {
let connection;
try {
@ -863,19 +863,19 @@ export class ManageFeeService {
END;`,
{
P_FEECOMMID: {
val: body.P_FEECOMMID,
val:body.p_fees_comm.P_FEECOMMID,
type: oracledb.DB_TYPE_NUMBER
},
P_RATE: {
val: body.P_RATE,
val:Number(body.p_fees_comm.P_RATE)|0,
type: oracledb.DB_TYPE_NUMBER
},
P_EFFDATE: {
val: body.P_EFFDATE,
val:body.p_fees_comm.P_EFFDATE,
type: oracledb.DB_TYPE_NVARCHAR
},
P_USERID: {
val: body.P_USERID,
val:body.p_fees_comm.P_USERID,
type: oracledb.DB_TYPE_NVARCHAR
},
P_CURSOR: {
@ -888,16 +888,22 @@ export class ManageFeeService {
);
await connection.commit();
let fres = await result.outBinds.p_cursor.getRows();
if (result.outBinds && result.outBinds.P_CURSOR) {
let fres = await result.outBinds.P_CURSOR.getRows();
return fres
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);
throw new Error('Error fetching users');
return{error:err.message}
// throw new Error('Error fetching users');
} finally { }
}
// get

View File

@ -1,6 +1,6 @@
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, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO, UpdateParamRecordDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto';
import { ActivateOrInactivateParamRecordDTO, CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCarnetSequenceDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, CreateParamRecordDTO, CreateTableRecordDTO, InsertNewServiceProviderDTO, InsertRegionsDto, InsertSPContactsDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommBodyDTO, UpdateFeeCommDTO, UpdateParamRecordDTO, UpdateRegionDto, UpdateServiceProviderDTO, UpdateSPContactsDTO } from './oracle.dto';
import { ParamTableService } from './paramTable.service';
import { ManageFeeService } from './manageFee.service';
import { ApiOperation, ApiPropertyOptional, ApiQuery, ApiTags } from '@nestjs/swagger';
@ -323,7 +323,7 @@ export class OracleController {
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateFeeComm')
UpdateFeeComm(@Body() body: UpdateFeeCommDTO) {
UpdateFeeComm(@Body() body: UpdateFeeCommBodyDTO) {
return this.manageFeeService.UPDATEFEECOMM(body)
}

View File

@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsNumber, IsOptional, IsString } from 'class-validator';
import { IsEmail, IsNumber, IsObject, IsOptional, IsString } from 'class-validator';
export class InsertRegionsDto {
@ApiProperty()
@ -682,7 +682,9 @@ export class UpdateEfFeeDTO {
P_USERID: string;
}
// Existing UpdateFeeCommDTO
export class UpdateFeeCommDTO {
@ApiProperty({ required: true })
@IsNumber()
P_FEECOMMID: number;
@ -700,6 +702,12 @@ export class UpdateFeeCommDTO {
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})