diff --git a/api.http b/api.http index 0d1122e..97ec180 100644 --- a/api.http +++ b/api.http @@ -1,7 +1,11 @@ +// GetRegions + GET http://localhost:3000/oracle/GetRegions ### +// InsertRegions + POST http://localhost:3000/oracle/InsertRegions Content-Type: application/json @@ -12,6 +16,8 @@ Content-Type: application/json ### +//UpdateRegion + PATCH http://localhost:3000/oracle/UpdateRegion Content-Type: application/json @@ -20,4 +26,38 @@ Content-Type: application/json "p_name":"p_name" } +### + +// GetAllServiceproviders + +GET http://localhost:3000/oracle/GetAllServiceproviders + +### + +//InsertNewServiceProider + +POST http://localhost:3000/oracle/InsertNewServiceProider +Content-Type: application/json + +{ + "p_name": "Service Provider Name", + "p_lookupcode": "SP001", + "p_address1": "123 Main St", + "p_address2": "Suite 100", + "p_city": "Anytown", + "p_state": "CA", + "p_zip": "90210", + "p_country": "USA", + "p_issuingregion": "Region A", + "p_replacementregion": "Region B", + "p_bondsurety": "Surety Co.", + "p_cargopolicyno": "CP123456", + "p_cargosurety": "Cargo Surety Co.", + "p_user_id": "user123" +} + +### + +// + diff --git a/src/oracle/oracle.controller.ts b/src/oracle/oracle.controller.ts index 33d337b..105c5f4 100644 --- a/src/oracle/oracle.controller.ts +++ b/src/oracle/oracle.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, Get, Patch, Post } from '@nestjs/common'; import { OracleService } from './oracle.service'; -import { InsertRegionsDto, UpdateRegionDto } from './oracle.dto'; +import { InsertNewServiceProviderDTO, InsertRegionsDto, UpdateRegionDto } from './oracle.dto'; @Controller('oracle') export class OracleController { @@ -18,6 +18,31 @@ export class OracleController { @Patch('/UpdateRegion') updateRegions(@Body() body: UpdateRegionDto) { - return this.oarcleService.updateRegions(body.p_regionID,body.p_name); + return this.oarcleService.updateRegions(body.p_regionID, body.p_name); + } + + @Get('GetAllServiceproviders') + getAllServiceproviders() { + return this.oarcleService.getAllServiceproviders(); + } + + @Post('/InsertNewServiceProvider') + insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) { + return this.oarcleService.insertNewServiceProider( + 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 + ) } } diff --git a/src/oracle/oracle.dto.ts b/src/oracle/oracle.dto.ts index 74cdc76..5f0ca5d 100644 --- a/src/oracle/oracle.dto.ts +++ b/src/oracle/oracle.dto.ts @@ -1,4 +1,4 @@ -import { IsNumber, IsString } from 'class-validator'; +import { IsNumber, IsOptional, IsString } from 'class-validator'; export class InsertRegionsDto { @IsString() @@ -16,3 +16,47 @@ export class UpdateRegionDto { p_name: string; } +export class InsertNewServiceProviderDTO { + @IsString() + p_name: string; + + @IsString() + p_lookupcode: string; + + @IsString() + p_address1: string; + + @IsString() + p_address2: string; + + @IsString() + p_city: string; + + @IsString() + p_state: string; + + @IsString() + p_zip: string; + + @IsString() + p_country: string; + + @IsString() + p_issuingregion: string; + + @IsString() + p_replacementregion: string; + + @IsString() + p_bondsurety: string; + + @IsString() + p_cargopolicyno: string; + + @IsString() + p_cargosurety: string; + + @IsString() + p_user_id: string; +} + diff --git a/src/oracle/oracle.service.ts b/src/oracle/oracle.service.ts index ac2f6c7..126a650 100644 --- a/src/oracle/oracle.service.ts +++ b/src/oracle/oracle.service.ts @@ -424,10 +424,10 @@ export class OracleService { 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(); + + return rows; } else { throw new Error('No cursor returned from the stored procedure'); }