uppercase all response keys

This commit is contained in:
Kallesh B S 2025-09-22 17:13:48 +05:30
parent a1fd355171
commit 8e94cdd97a
28 changed files with 864 additions and 274 deletions

View File

@ -23,8 +23,8 @@ import { RolesGuard } from 'src/guards/roles.guard';
import { ApiExcludeController, ApiTags } from '@nestjs/swagger'; import { ApiExcludeController, ApiTags } from '@nestjs/swagger';
@ApiTags('Carnet Application - PG') @ApiTags('Carnet Application - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('ca', 'sa') @Roles('pca', 'psa')
@Controller('2') @Controller('2')
export class CarnetApplicationController { export class CarnetApplicationController {
constructor(private readonly carnetApplicationService: CarnetApplicationService) { } constructor(private readonly carnetApplicationService: CarnetApplicationService) { }
@ -37,13 +37,13 @@ export class CarnetApplicationController {
// } // }
@Post('TransmitApplicationtoProcess') @Post('TransmitApplicationtoProcess')
@Roles('ca') @Roles('pca')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) { TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.carnetApplicationService.TransmitApplicationtoProcess(body); return this.carnetApplicationService.TransmitApplicationtoProcess(body);
} }
@Post('CreateApplication') @Post('CreateApplication')
@Roles('ca') @Roles('pca')
CreateApplication(@Body() body: CreateApplicationDTO) { CreateApplication(@Body() body: CreateApplicationDTO) {
return this.carnetApplicationService.CreateApplication(body); return this.carnetApplicationService.CreateApplication(body);
} }
@ -53,107 +53,107 @@ export class CarnetApplicationController {
return this.carnetApplicationService.UpdateHolder(body); return this.carnetApplicationService.UpdateHolder(body);
} }
// @Patch('UpdateExpGoodsAuthRep') @Patch('UpdateExpGoodsAuthRep')
// UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) { UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) {
// return this.carnetApplicationService.UpdateExpGoodsAuthRep(body); return this.carnetApplicationService.UpdateExpGoodsAuthRep(body);
// } }
// @Post('AddGenerallistItems') @Post('AddGenerallistItems')
// AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) { AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
// return this.carnetApplicationService.AddGenerallistItems(body); return this.carnetApplicationService.AddGenerallistItems(body);
// } }
// @Post('AddCountries') @Post('AddCountries')
// AddCountries(@Body() body: AddCountriesDTO) { AddCountries(@Body() body: AddCountriesDTO) {
// return this.carnetApplicationService.AddCountries(body); return this.carnetApplicationService.AddCountries(body);
// } }
// @Put('EditGenerallistItems') @Put('EditGenerallistItems')
// EditGenerallistItems(@Body() body: EditGenerallistItemsDTO) { EditGenerallistItems(@Body() body: EditGenerallistItemsDTO) {
// return this.carnetApplicationService.EditGenerallistItems(body); return this.carnetApplicationService.EditGenerallistItems(body);
// } }
// @Delete('DeleteGenerallistItems') @Delete('DeleteGenerallistItems')
// DeleteGenerallistItems(@Body() body: DeleteGenerallistItemsDTO) { DeleteGenerallistItems(@Body() body: DeleteGenerallistItemsDTO) {
// return this.carnetApplicationService.DeleteGenerallistItems(body); return this.carnetApplicationService.DeleteGenerallistItems(body);
// } }
// @Patch('UpdateShippingDetails') @Patch('UpdateShippingDetails')
// UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) { UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
// return this.carnetApplicationService.UpdateShippingDetails(body); return this.carnetApplicationService.UpdateShippingDetails(body);
// } }
// @Get('EstimatedFees/:P_SPID/:P_USERID/:P_HEADERID') @Get('EstimatedFees/:P_SPID/:P_USERID/:P_HEADERID')
// EstimatedFees(@Param() body: GetCarnetControlCenterDTO) { EstimatedFees(@Param() body: GetCarnetControlCenterDTO) {
// return this.carnetApplicationService.EstimatedFees(body); return this.carnetApplicationService.EstimatedFees(body);
// } }
// // processing [ PROCESSINGCENTER_PKG ] // // processing [ PROCESSINGCENTER_PKG ]
// @Patch('ProcessCarnet') @Patch('ProcessCarnet')
// ProcessOriginalCarnet(@Body() body: CarnetProcessingCenterDTO) { ProcessOriginalCarnet(@Body() body: CarnetProcessingCenterDTO) {
// return this.carnetApplicationService.ProcessCarnet(body); return this.carnetApplicationService.ProcessCarnet(body);
// } }
// @Patch('UpdatePrintCarnet') @Patch('UpdatePrintCarnet')
// UpdatePrintCarnet(@Body() body: CarnetProcessingCenterDTO) { UpdatePrintCarnet(@Body() body: CarnetProcessingCenterDTO) {
// return this.carnetApplicationService.UpdatePrintCarnet(body); return this.carnetApplicationService.UpdatePrintCarnet(body);
// } }
// @Patch('VoidCarnet') @Patch('VoidCarnet')
// @Roles('sa') @Roles('psa')
// VoidCarnet(@Body() body: CarnetProcessingCenterDTO) { VoidCarnet(@Body() body: CarnetProcessingCenterDTO) {
// return this.carnetApplicationService.VoidCarnet(body); return this.carnetApplicationService.VoidCarnet(body);
// } }
// @Patch('CopyCarnet') @Patch('CopyCarnet')
// CopyCarnet(@Body() body: CopyCarnetDTO) { CopyCarnet(@Body() body: CopyCarnetDTO) {
// return this.carnetApplicationService.CopyCarnet(body); return this.carnetApplicationService.CopyCarnet(body);
// } }
// @Patch('DuplicateCarnet') @Patch('DuplicateCarnet')
// DuplicateCarnet(@Body() body: CarnetProcessingCenterDTO2) { DuplicateCarnet(@Body() body: CarnetProcessingCenterDTO2) {
// return this.carnetApplicationService.DuplicateCarnet(body); return this.carnetApplicationService.DuplicateCarnet(body);
// } }
// @Patch('AddlSets') @Patch('AddlSets')
// AddlSets(@Body() body: CarnetProcessingCenterDTO2) { AddlSets(@Body() body: CarnetProcessingCenterDTO2) {
// return this.carnetApplicationService.AddlSets(body); return this.carnetApplicationService.AddlSets(body);
// } }
// @Patch('ExtendCarnet') @Patch('ExtendCarnet')
// ExtendCarnet(@Body() body: CarnetProcessingCenterDTO2) { ExtendCarnet(@Body() body: CarnetProcessingCenterDTO2) {
// return this.carnetApplicationService.ExtendCarnet(body); return this.carnetApplicationService.ExtendCarnet(body);
// } }
// @Get('GetExtendedSection/:P_SPID/:P_HEADERID') @Get('GetExtendedSection/:P_SPID/:P_HEADERID')
// GetExtendedSection(@Param() body: GetExtendedSectionDTO) { GetExtendedSection(@Param() body: GetExtendedSectionDTO) {
// return this.carnetApplicationService.GetExtendedSection(body); return this.carnetApplicationService.GetExtendedSection(body);
// } }
// @Post('SaveExtensionApplication') @Post('SaveExtensionApplication')
// @HttpCode(200) @HttpCode(200)
// SaveExtensionApplication(@Body() body: SaveExtensionApplicationDTO) { SaveExtensionApplication(@Body() body: SaveExtensionApplicationDTO) {
// return this.carnetApplicationService.SaveExtensionApplication(body); return this.carnetApplicationService.SaveExtensionApplication(body);
// } }
// @Patch('CloseCarnet') @Patch('CloseCarnet')
// @Roles('sa') @Roles('psa')
// CloseCarnet(@Body() body: CarnetProcessingCenterDTO) { CloseCarnet(@Body() body: CarnetProcessingCenterDTO) {
// return this.carnetApplicationService.CloseCarnet(body); return this.carnetApplicationService.CloseCarnet(body);
// } }
// @Patch('ResetCarnet') @Patch('ResetCarnet')
// @Roles('sa') @Roles('psa')
// ResetCarnet(@Body() body: CarnetProcessingCenterDTO) { ResetCarnet(@Body() body: CarnetProcessingCenterDTO) {
// return this.carnetApplicationService.ResetCarnet(body); return this.carnetApplicationService.ResetCarnet(body);
// } }
// @Delete('DeleteCarnet') @Delete('DeleteCarnet')
// DeleteCarnet(@Body() body: CarnetProcessingCenterDTO) { DeleteCarnet(@Body() body: CarnetProcessingCenterDTO) {
// return this.carnetApplicationService.DeleteCarnet(body); return this.carnetApplicationService.DeleteCarnet(body);
// } }
// [ CARNETCONTROLCENTER_PKG ] // [ CARNETCONTROLCENTER_PKG ]

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { CarnetApplicationController } from './carnet-application.controller'; import { CarnetApplicationController } from './carnet-application.controller';
import { CarnetApplicationService } from './carnet-application.service'; import { CarnetApplicationService } from './carnet-application.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [CarnetApplicationController], controllers: [CarnetApplicationController],
providers: [CarnetApplicationService] providers: [CarnetApplicationService]
}) })

View File

@ -26,7 +26,7 @@ import {
import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class CarnetApplicationService { export class CarnetApplicationService {
@ -63,7 +63,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.transmitted, message: ResponseStatus.transmitted,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -101,7 +101,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -139,7 +139,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -177,7 +177,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -242,7 +242,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.added, message: ResponseStatus.added,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -307,7 +307,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -345,7 +345,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.deleted, message: ResponseStatus.deleted,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -406,7 +406,7 @@ export class CarnetApplicationService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.added, message: ResponseStatus.added,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -417,26 +417,557 @@ export class CarnetApplicationService {
} }
} }
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) { } async UpdateShippingDetails(body: UpdateShippingDetailsDTO) {
let client: PoolClient | null = null;
async EstimatedFees(body: GetCarnetControlCenterDTO) { } const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".carnetapplication_pkg_updateshippingdetails($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29)
`;
await client.query(callProcQuery,
[
body.P_HEADERID,
body.P_SHIPTOTYPE,
body.P_SHIPCONTACTID,
body.P_SHIPNAME,
body.P_ADDRESS1,
body.P_ADDRESS2,
body.P_CITY,
body.P_STATE,
body.P_ZIP,
body.P_COUNTRY,
body.P_FIRSTNAME,
body.P_LASTNAME,
body.P_TITLE,
body.P_PHONENO,
body.P_MOBILENO,
body.P_FAXNO,
body.P_EMAILADDRESS,
body.P_MIDDLEINITIAL,
body.P_FORMOFSECURITY,
body.P_INSPROTECTION,
body.P_LDIPROTECTION,
body.P_DELIVERYTYPE,
body.P_DELIVERYMETHOD,
body.P_PAYMENTMETHOD,
body.P_CUSTCOURIERNO,
body.P_REFNO,
body.P_NOTES,
body.P_USERID,
cursorName
]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.updated,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async EstimatedFees(body: GetCarnetControlCenterDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".carnetapplication_pkg_estimatedfees($1, $2, $3, $4)
`;
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
return toUpperCaseKeys(fetchResult.rows);
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
// processing [ PROCESSINGCENTER_PKG ] // processing [ PROCESSINGCENTER_PKG ]
async ProcessCarnet(body: CarnetProcessingCenterDTO) { } async ProcessCarnet(body: CarnetProcessingCenterDTO) {
async UpdatePrintCarnet(body: CarnetProcessingCenterDTO) { } let client: PoolClient | null = null;
async VoidCarnet(body: CarnetProcessingCenterDTO) { }
async CopyCarnet(body: CopyCarnetDTO) { } const cursorName = 'p_cursor';
async DuplicateCarnet(body: CarnetProcessingCenterDTO2) { }
async AddlSets(body: CarnetProcessingCenterDTO2) { }
async ExtendCarnet(body: CarnetProcessingCenterDTO2) { }
async GetExtendedSection(body: GetExtendedSectionDTO) { }
async SaveExtensionApplication(body: SaveExtensionApplicationDTO) { }
async CloseCarnet(body: CarnetProcessingCenterDTO) { } try {
async ResetCarnet(body: CarnetProcessingCenterDTO) { } client = await this.pgDBService.getConnection();
async DeleteCarnet(body: CarnetProcessingCenterDTO) { }
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_processcarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.processed,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async UpdatePrintCarnet(body: CarnetProcessingCenterDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_updateprintcarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.updated,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async VoidCarnet(body: CarnetProcessingCenterDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_voidcarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.voided,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async CopyCarnet(body: CopyCarnetDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_copycarnet($1, $2, $3, $4)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, body.P_APPLICATIONNAME, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.copied,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async DuplicateCarnet(body: CarnetProcessingCenterDTO2) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_duplicatecarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_CARNETNO, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.duplicated,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async AddlSets(body: CarnetProcessingCenterDTO2) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_addlsets($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_CARNETNO, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.addl_completed,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async ExtendCarnet(body: CarnetProcessingCenterDTO2) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_extendcarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_CARNETNO, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.extended,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async GetExtendedSection(body: GetExtendedSectionDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_getextendedsection($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_SPID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
return toUpperCaseKeys(fetchResult.rows);
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async SaveExtensionApplication(body: SaveExtensionApplicationDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_saveextensionapplication($1, $2, $3, $4, $5, $6, $7, $8)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_SPID, body.P_HEADERID, body.P_GOODSPORT, body.P_GOODSCOUNTRY, body.P_REASONCODE, body.P_EXTENSIONPERIOD, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.saved,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async CloseCarnet(body: CarnetProcessingCenterDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_closecarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.closed,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async ResetCarnet(body: CarnetProcessingCenterDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_resetcarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.reset_successfull,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
async DeleteCarnet(body: CarnetProcessingCenterDTO) {
let client: PoolClient | null = null;
const cursorName = 'p_cursor';
try {
client = await this.pgDBService.getConnection();
await client.query('BEGIN');
const callProcQuery = `
CALL "CARNETSYS".processingcenter_pkg_deletecarnet($1, $2, $3)
`;
await client.query(callProcQuery, [body.P_USERID, body.P_HEADERID, cursorName]);
// 🚫 DON'T quote the cursor name in FETCH
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult);
return {
statusCode: 200,
message: ResponseStatus.deleted,
...toUpperCaseKeys(fetchResult?.rows)[0]
};
} catch (error) {
if (client) await client.query('ROLLBACK');
handlePgError(error, CarnetApplicationService.name)
} finally {
releasePgClient(client)
}
}
// [ CARNETCONTROLCENTER_PKG ] // [ CARNETCONTROLCENTER_PKG ]
@ -462,7 +993,7 @@ export class CarnetApplicationService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -494,7 +1025,7 @@ export class CarnetApplicationService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -526,7 +1057,7 @@ export class CarnetApplicationService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -558,7 +1089,7 @@ export class CarnetApplicationService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -590,7 +1121,7 @@ export class CarnetApplicationService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -7,8 +7,8 @@ import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
import { RolesGuard } from 'src/guards/roles.guard'; import { RolesGuard } from 'src/guards/roles.guard';
@ApiTags('Manage Clients - PG') @ApiTags('Manage Clients - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('sa') @Roles('psa')
@Controller('2') @Controller('2')
export class ManageClientsController { export class ManageClientsController {
constructor(private readonly manageClientsService: ManageClientsService) { } constructor(private readonly manageClientsService: ManageClientsService) { }
@ -24,19 +24,19 @@ export class ManageClientsController {
} }
@Put('UpdateClientContacts') @Put('UpdateClientContacts')
@Roles('ca', 'sa') @Roles('pca', 'psa')
UpdateClientContacts(@Body() body: UpdateClientContactsDTO) { UpdateClientContacts(@Body() body: UpdateClientContactsDTO) {
return this.manageClientsService.UpdateClientContacts(body); return this.manageClientsService.UpdateClientContacts(body);
} }
@Put('UpdateClientLocations') @Put('UpdateClientLocations')
@Roles('ca', 'sa') @Roles('pca', 'psa')
UpdateClientLocations(@Body() body: UpdateClientLocationsDTO) { UpdateClientLocations(@Body() body: UpdateClientLocationsDTO) {
return this.manageClientsService.UpdateClientLocations(body); return this.manageClientsService.UpdateClientLocations(body);
} }
@Post('CreateClientContacts') @Post('CreateClientContacts')
@Roles('ca', 'sa') @Roles('pca', 'psa')
CreateClientContact(@Body() body: CreateClientContactsDTO) { CreateClientContact(@Body() body: CreateClientContactsDTO) {
return this.manageClientsService.CreateClientContact(body); return this.manageClientsService.CreateClientContact(body);
} }
@ -57,7 +57,7 @@ export class ManageClientsController {
} }
@Post('CreateClientLocations') @Post('CreateClientLocations')
@Roles('ca', 'sa') @Roles('pca', 'psa')
CreateClientLocation(@Body() body: CreateClientLocationsDTO) { CreateClientLocation(@Body() body: CreateClientLocationsDTO) {
return this.manageClientsService.CreateClientLocation(body); return this.manageClientsService.CreateClientLocation(body);
} }
@ -73,19 +73,19 @@ export class ManageClientsController {
} }
@Get('GetPreparerContactsByClientid/:P_SPID/:P_CLIENTID') @Get('GetPreparerContactsByClientid/:P_SPID/:P_CLIENTID')
@Roles('ca', 'sa') @Roles('pca', 'psa')
GetPreparerContactsByClientid(@Param() body: GetClientDTO) { GetPreparerContactsByClientid(@Param() body: GetClientDTO) {
return this.manageClientsService.GetPreparerContactsByClientid(body); return this.manageClientsService.GetPreparerContactsByClientid(body);
} }
@Get('GetPreparerContactsbyClientLocationID/:P_SPID/:P_LOCATIONID') @Get('GetPreparerContactsbyClientLocationID/:P_SPID/:P_LOCATIONID')
@Roles('ca', 'sa') @Roles('pca', 'psa')
GetPreparerContactsbyClientLocationID(@Param() body: GetClientContactByLacationIdDTO) { GetPreparerContactsbyClientLocationID(@Param() body: GetClientContactByLacationIdDTO) {
return this.manageClientsService.GetPreparerContactsbyClientLocationID(body); return this.manageClientsService.GetPreparerContactsbyClientLocationID(body);
} }
@Get('GetPreparerLocByClientid/:P_SPID/:P_CLIENTID') @Get('GetPreparerLocByClientid/:P_SPID/:P_CLIENTID')
@Roles('ca', 'sa') @Roles('pca', 'psa')
GetPreparerLocByClientid(@Param() body: GetClientDTO) { GetPreparerLocByClientid(@Param() body: GetClientDTO) {
return this.manageClientsService.GetPreparerLocByClientid(body); return this.manageClientsService.GetPreparerLocByClientid(body);
} }

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { ManageClientsController } from './manage-clients.controller'; import { ManageClientsController } from './manage-clients.controller';
import { ManageClientsService } from './manage-clients.service'; import { ManageClientsService } from './manage-clients.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [ManageClientsController], controllers: [ManageClientsController],
providers: [ManageClientsService] providers: [ManageClientsService]
}) })

View File

@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common'; import { Injectable } from '@nestjs/common';
import { ClientContactControlsDTO, CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, GetClientContactByLacationIdDTO, GetClientDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/dto/property.dto'; import { ClientContactControlsDTO, CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, GetClientContactByLacationIdDTO, GetClientDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/dto/property.dto';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
@ -52,7 +52,7 @@ export class ManageClientsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -105,7 +105,7 @@ export class ManageClientsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -157,7 +157,7 @@ export class ManageClientsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -208,7 +208,7 @@ export class ManageClientsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -278,7 +278,7 @@ export class ManageClientsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -316,7 +316,7 @@ export class ManageClientsService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -354,7 +354,7 @@ export class ManageClientsService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.inActivate, message: ResponseStatus.inActivate,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -392,7 +392,7 @@ export class ManageClientsService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.reActivate, message: ResponseStatus.reActivate,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -459,7 +459,7 @@ export class ManageClientsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -494,7 +494,7 @@ export class ManageClientsService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -528,7 +528,7 @@ export class ManageClientsService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -562,7 +562,7 @@ export class ManageClientsService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -596,7 +596,7 @@ export class ManageClientsService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -630,7 +630,7 @@ export class ManageClientsService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -7,8 +7,8 @@ import { Roles } from 'src/decorators/roles.decorator';
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/dto/property.dto'; import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/dto/property.dto';
@ApiTags('Manage Fee - PG') @ApiTags('Manage Fee - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('sa', 'ua') @Roles('psa', 'pua')
@Controller('2') @Controller('2')
export class ManageFeeController { export class ManageFeeController {

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { ManageFeeController } from './manage-fee.controller'; import { ManageFeeController } from './manage-fee.controller';
import { ManageFeeService } from './manage-fee.service'; import { ManageFeeService } from './manage-fee.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [ManageFeeController], controllers: [ManageFeeController],
providers: [ManageFeeService] providers: [ManageFeeService]
}) })

View File

@ -3,7 +3,7 @@ import { PgDBService } from 'src/db/db.service';
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/dto/property.dto'; import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/dto/property.dto';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class ManageFeeService { export class ManageFeeService {
@ -35,7 +35,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -82,7 +82,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -129,7 +129,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -168,7 +168,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -219,7 +219,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -266,7 +266,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -305,7 +305,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -353,7 +353,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -400,7 +400,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -438,7 +438,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -488,7 +488,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -535,7 +535,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -575,7 +575,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -622,7 +622,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -668,7 +668,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -707,7 +707,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -757,7 +757,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -803,7 +803,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -842,7 +842,7 @@ export class ManageFeeService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -888,7 +888,7 @@ export class ManageFeeService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -934,7 +934,7 @@ export class ManageFeeService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {

View File

@ -8,8 +8,8 @@ import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
import { RolesGuard } from 'src/guards/roles.guard'; import { RolesGuard } from 'src/guards/roles.guard';
@ApiTags('Manage Holders - PG') @ApiTags('Manage Holders - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('ca', 'sa') @Roles('pca', 'psa')
@Controller('2') @Controller('2')
export class ManageHolderController { export class ManageHolderController {

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { ManageHolderController } from './manage-holder.controller'; import { ManageHolderController } from './manage-holder.controller';
import { ManageHolderService } from './manage-holder.service'; import { ManageHolderService } from './manage-holder.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [ManageHolderController], controllers: [ManageHolderController],
providers: [ManageHolderService] providers: [ManageHolderService]
}) })

View File

@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
import { CONTACTSTABLE_ROW_DTO, CreateHolderContactsDTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/property.dto'; import { CONTACTSTABLE_ROW_DTO, CreateHolderContactsDTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/property.dto';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class ManageHolderService { export class ManageHolderService {
@ -55,7 +55,7 @@ export class ManageHolderService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -122,7 +122,7 @@ export class ManageHolderService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {}, ...toUpperCaseKeys(fetchResult?.rows)[0],
}; };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -179,7 +179,7 @@ export class ManageHolderService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -214,7 +214,7 @@ export class ManageHolderService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -265,7 +265,7 @@ export class ManageHolderService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -300,7 +300,7 @@ export class ManageHolderService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -337,7 +337,7 @@ export class ManageHolderService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.inActivate, message: ResponseStatus.inActivate,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -375,7 +375,7 @@ export class ManageHolderService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.reActivate, message: ResponseStatus.reActivate,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -413,7 +413,7 @@ export class ManageHolderService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.inActivate, message: ResponseStatus.inActivate,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -451,7 +451,7 @@ export class ManageHolderService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.reActivate, message: ResponseStatus.reActivate,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -486,7 +486,7 @@ export class ManageHolderService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -11,15 +11,15 @@ import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
import { RolesGuard } from 'src/guards/roles.guard'; import { RolesGuard } from 'src/guards/roles.guard';
@ApiTags('Param Table - PG') @ApiTags('Param Table - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('sa', 'ua') @Roles('psa', 'pua')
@Controller('2') @Controller('2')
export class ParamTableController { export class ParamTableController {
constructor(private readonly paramTableService: ParamTableService) { } constructor(private readonly paramTableService: ParamTableService) { }
@Get('/GetParamValues') @Get('/GetParamValues')
@Roles('ca', 'sa', 'ua') @Roles('pca', 'psa', 'pua')
@ApiQuery({ @ApiQuery({
name: 'P_SPID', name: 'P_SPID',
required: false, required: false,
@ -54,7 +54,7 @@ export class ParamTableController {
} }
@Get('GetCountriesAndMessages/:P_SPID') @Get('GetCountriesAndMessages/:P_SPID')
@Roles('ca', 'sa', 'ua') @Roles('pca', 'psa', 'pua')
GET_COUNTRIES_AND_MESSAGES(@Param() body: SPID_DTO) { GET_COUNTRIES_AND_MESSAGES(@Param() body: SPID_DTO) {
return this.paramTableService.GET_COUNTRIES_AND_MESSAGES(body); return this.paramTableService.GET_COUNTRIES_AND_MESSAGES(body);
} }

View File

@ -1,9 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { ParamTableController } from './param-table.controller'; import { ParamTableController } from './param-table.controller';
import { ParamTableService } from './param-table.service'; import { ParamTableService } from './param-table.service';
import { AuthModule } from 'src/auth/auth.module'; import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [ParamTableController], controllers: [ParamTableController],
providers: [ParamTableService] providers: [ParamTableService]
}) })

View File

@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, SPID_DTO, UpdateParamRecordDTO } from 'src/dto/property.dto'; import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, SPID_DTO, UpdateParamRecordDTO } from 'src/dto/property.dto';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class ParamTableService { export class ParamTableService {
@ -32,7 +32,7 @@ export class ParamTableService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -64,7 +64,7 @@ export class ParamTableService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -95,7 +95,7 @@ export class ParamTableService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -129,8 +129,10 @@ export class ParamTableService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
let fr: any = toUpperCaseKeys(fetchResult?.rows)
// return fetchResult.rows; // return fetchResult.rows;
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] }; return { statusCode: 201, message: ResponseStatus.created, ...fr[0] };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -181,11 +183,13 @@ export class ParamTableService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
let fr: any = toUpperCaseKeys(fetchResult?.rows)
// Return response // Return response
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...fr[0] || {}
}; };
} catch (error) { } catch (error) {
@ -239,7 +243,7 @@ export class ParamTableService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {

View File

@ -7,8 +7,8 @@ import { RolesGuard } from 'src/guards/roles.guard';
import { Roles } from 'src/decorators/roles.decorator'; import { Roles } from 'src/decorators/roles.decorator';
@ApiTags('Carnet Sequence - PG') @ApiTags('Carnet Sequence - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('sa', 'ua') @Roles('psa', 'pua')
@Controller('2') @Controller('2')
export class CarnetSequenceController { export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) { } constructor(private readonly carnetSequenceService: CarnetSequenceService) { }

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { CarnetSequenceController } from './carnet-sequence.controller'; import { CarnetSequenceController } from './carnet-sequence.controller';
import { CarnetSequenceService } from './carnet-sequence.service'; import { CarnetSequenceService } from './carnet-sequence.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [CarnetSequenceController], controllers: [CarnetSequenceController],
providers: [CarnetSequenceService] providers: [CarnetSequenceService]
}) })

View File

@ -4,7 +4,7 @@ import { CreateCarnetSequenceDTO, SPID_DTO } from 'src/dto/property.dto';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
@ -37,7 +37,7 @@ export class CarnetSequenceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] }; return { statusCode: 201, message: ResponseStatus.created, ...toUpperCaseKeys(fetchResult?.rows)[0] };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -69,7 +69,7 @@ export class CarnetSequenceService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -4,7 +4,7 @@ import { InsertRegionsDto, SPID_DTO, UpdateRegionDto } from 'src/dto/property.dt
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class RegionService { export class RegionService {
@ -39,7 +39,7 @@ export class RegionService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -74,7 +74,7 @@ export class RegionService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return { statusCode: 200, message: ResponseStatus.updated, ...fetchResult?.rows[0] || {} }; return { statusCode: 200, message: ResponseStatus.updated, ...toUpperCaseKeys(fetchResult?.rows)[0] || {} };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -107,7 +107,7 @@ export class RegionService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -7,8 +7,8 @@ import { SpContactsService } from './sp-contacts.service';
import { InsertSPContactsDTO, SP_CONTACTID_DTO, SPID_DTO, UpdateSPContactsDTO } from 'src/dto/property.dto'; import { InsertSPContactsDTO, SP_CONTACTID_DTO, SPID_DTO, UpdateSPContactsDTO } from 'src/dto/property.dto';
@ApiTags('SPContacts - PG') @ApiTags('SPContacts - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('sa', 'ua') @Roles('psa', 'pua')
@Controller('2') @Controller('2')
export class SpContactsController { export class SpContactsController {
@ -21,7 +21,7 @@ export class SpContactsController {
} }
@Patch('/SetSPDefaultContact/:P_SPCONTACTID') @Patch('/SetSPDefaultContact/:P_SPCONTACTID')
@Roles('ua') @Roles('pua')
setSPDefaultcontact(@Param() param: SP_CONTACTID_DTO) { setSPDefaultcontact(@Param() param: SP_CONTACTID_DTO) {
return this.spContactsService.setSPDefaultcontact(param); return this.spContactsService.setSPDefaultcontact(param);
} }

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { SpContactsController } from './sp-contacts.controller'; import { SpContactsController } from './sp-contacts.controller';
import { SpContactsService } from './sp-contacts.service'; import { SpContactsService } from './sp-contacts.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [SpContactsController], controllers: [SpContactsController],
providers: [SpContactsService] providers: [SpContactsService]
}) })

View File

@ -4,7 +4,7 @@ import { InternalServerException } from 'src/exceptions/internalServerError.exce
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class SpContactsService { export class SpContactsService {
@ -52,7 +52,7 @@ export class SpContactsService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -128,7 +128,7 @@ export class SpContactsService {
return { return {
statusCode: 200, statusCode: 200,
message: ResponseStatus.updated, message: ResponseStatus.updated,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -194,7 +194,7 @@ export class SpContactsService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -228,7 +228,7 @@ export class SpContactsService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -7,14 +7,14 @@ import { SpService } from './sp.service';
import { InsertNewServiceProviderDTO, SPID_DTO, UpdateServiceProviderDTO } from 'src/dto/property.dto'; import { InsertNewServiceProviderDTO, SPID_DTO, UpdateServiceProviderDTO } from 'src/dto/property.dto';
@ApiTags('SP - PG') @ApiTags('SP - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('sa', 'ua') @Roles('psa', 'pua')
@Controller('2') @Controller('2')
export class SpController { export class SpController {
constructor(private readonly spService: SpService) { } constructor(private readonly spService: SpService) { }
@Post('/InsertNewServiceProvider') @Post('/InsertNewServiceProvider')
@Roles('ua') @Roles('pua')
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) { insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
return this.spService.insertNewServiceProvider(body); return this.spService.insertNewServiceProvider(body);
} }
@ -25,7 +25,7 @@ export class SpController {
} }
@Get('/GetAllServiceproviders') @Get('/GetAllServiceproviders')
@Roles('ua') @Roles('pua')
getAllServiceproviders() { getAllServiceproviders() {
return this.spService.getAllServiceproviders(); return this.spService.getAllServiceproviders();
} }

View File

@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { SpController } from './sp.controller'; import { SpController } from './sp.controller';
import { SpService } from './sp.service'; import { SpService } from './sp.service';
import { AuthModule } from 'src/auth/auth.module';
@Module({ @Module({
imports: [forwardRef(() => AuthModule)],
controllers: [SpController], controllers: [SpController],
providers: [SpService] providers: [SpService]
}) })

View File

@ -4,7 +4,7 @@ import { InsertNewServiceProviderDTO, SPID_DTO, UpdateServiceProviderDTO } from
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
@Injectable() @Injectable()
export class SpService { export class SpService {
@ -67,7 +67,7 @@ export class SpService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] || {} }; return { statusCode: 201, message: ResponseStatus.created, ...toUpperCaseKeys(fetchResult?.rows)[0] || {} };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -125,7 +125,7 @@ export class SpService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] || {} }; return { statusCode: 201, message: ResponseStatus.created, ...toUpperCaseKeys(fetchResult?.rows)[0] || {} };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -158,7 +158,7 @@ export class SpService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -192,7 +192,7 @@ export class SpService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return fetchResult.rows; return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -7,8 +7,8 @@ import { UserMaintenanceService } from './user-maintenance.service';
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, EMAIL_DTO, SPID_CLIENTID_DTO, SPID_DTO, SPID_EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto'; import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, EMAIL_DTO, SPID_CLIENTID_DTO, SPID_DTO, SPID_EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto';
@ApiTags('User Maintenance - PG') @ApiTags('User Maintenance - PG')
// @UseGuards(JwtAuthGuard, RolesGuard) @UseGuards(JwtAuthGuard, RolesGuard)
@Roles('ca', 'sa', 'ua') @Roles('pca', 'psa', 'pua')
@Controller('2') @Controller('2')
export class UserMaintenanceController { export class UserMaintenanceController {
@ -16,11 +16,15 @@ export class UserMaintenanceController {
// SP_USER_DETAILS // SP_USER_DETAILS
// @Get('GetUserDetails/:P_USERID') // [spclientuser_pkg]
async GetPreparers(@Param() params: USERID_DTO) {
@Get('GetUserDetails/:P_USERID')
async GetSPUserDetails(@Param() params: USERID_DTO) {
return await this.userMaintenanceService.GetSPUserDetails(params); return await this.userMaintenanceService.GetSPUserDetails(params);
} }
// [userlogin_pkg]
@Patch('LockUserAccount') @Patch('LockUserAccount')
async LockUserAccount(@Body() body: SPID_EMAIL_DTO) { async LockUserAccount(@Body() body: SPID_EMAIL_DTO) {
return await this.userMaintenanceService.LockUserAccount(body); return await this.userMaintenanceService.LockUserAccount(body);
@ -29,13 +33,13 @@ export class UserMaintenanceController {
// USCIB_LOGINS // USCIB_LOGINS
@Get('GetUSCIBLogins') @Get('GetUSCIBLogins')
@Roles('ua') @Roles('pua')
async GetUSCIBLogins() { async GetUSCIBLogins() {
return await this.userMaintenanceService.GetUSCIBLogins(); return await this.userMaintenanceService.GetUSCIBLogins();
} }
@Post('CreateUSCIBLogins') @Post('CreateUSCIBLogins')
@Roles('ua') @Roles('pua')
async CreateUSCIBLogins(@Body() body: CreateUSCIBLoginsDTO) { async CreateUSCIBLogins(@Body() body: CreateUSCIBLoginsDTO) {
return await this.userMaintenanceService.CreateUSCIBLogins(body); return await this.userMaintenanceService.CreateUSCIBLogins(body);
} }
@ -43,13 +47,13 @@ export class UserMaintenanceController {
// SP LOGINS // SP LOGINS
@Get('GetSPLogins/:P_SPID') @Get('GetSPLogins/:P_SPID')
@Roles('sa') @Roles('psa')
async GetSPLogins(@Param() params: SPID_DTO) { async GetSPLogins(@Param() params: SPID_DTO) {
return await this.userMaintenanceService.GetSPLogins(params); return await this.userMaintenanceService.GetSPLogins(params);
} }
@Post('CreateSPLogins') @Post('CreateSPLogins')
@Roles('sa') @Roles('psa')
async CreateSPLogins(@Body() body: CreateSPLoginsDTO) { async CreateSPLogins(@Body() body: CreateSPLoginsDTO) {
return await this.userMaintenanceService.CreateSPLogins(body); return await this.userMaintenanceService.CreateSPLogins(body);
} }
@ -57,19 +61,19 @@ export class UserMaintenanceController {
// CLIENT LOGINS // CLIENT LOGINS
@Get('GetClientloginsBySPID/:P_SPID') @Get('GetClientloginsBySPID/:P_SPID')
@Roles('sa') @Roles('psa')
async GetClientloginsBySPID(@Param() params: SPID_DTO) { async GetClientloginsBySPID(@Param() params: SPID_DTO) {
return await this.userMaintenanceService.GetSPLogins(params); return await this.userMaintenanceService.GetSPLogins(params);
} }
@Get('GetClientloginsByClientID/:P_SPID/:P_CLIENTID') @Get('GetClientloginsByClientID/:P_SPID/:P_CLIENTID')
@Roles('sa') @Roles('psa')
async GetClientloginsByClientID(@Param() params: SPID_CLIENTID_DTO) { async GetClientloginsByClientID(@Param() params: SPID_CLIENTID_DTO) {
return await this.userMaintenanceService.GetSPLogins(params); return await this.userMaintenanceService.GetSPLogins(params);
} }
@Post('CreateClientLogins') @Post('CreateClientLogins')
@Roles('sa') @Roles('psa')
async CreateClientLogins(@Body() body: CreateClientLoginsDTO) { async CreateClientLogins(@Body() body: CreateClientLoginsDTO) {
return await this.userMaintenanceService.CreateClientLogins(body); return await this.userMaintenanceService.CreateClientLogins(body);
} }

View File

@ -1,6 +1,6 @@
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common'; import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, EMAIL_DTO, SPID_CLIENTID_DTO, SPID_DTO, SPID_EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto'; import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, EMAIL_DTO, SPID_CLIENTID_DTO, SPID_DTO, SPID_EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto';
import { checkPgUserDefinedErrors, handlePgError, normalizeKeysToUpperCase, releasePgClient, ResponseStatus } from 'src/utils/helper'; import { checkPgUserDefinedErrors, handlePgError, normalizeKeysToUpperCase, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
@ -22,48 +22,58 @@ export class UserMaintenanceService {
async GetSPUserDetails(body: USERID_DTO): Promise<any> { async GetSPUserDetails(body: USERID_DTO): Promise<any> {
let client: PoolClient | null = null; let client: PoolClient | null = null;
const cursorName = 'p_cursor'; // Assign unique names to each cursor
const roleCursor = 'role_cursor';
const menuCursor = 'menu_cursor';
const menuPageCursor = 'menu_page_cursor';
const userDetailsCursor = 'user_details_cursor';
try { try {
client = await this.pgDBService.getConnection(); client = await this.pgDBService.getConnection();
await client.query('BEGIN'); await client.query('BEGIN');
const callProcQuery = ` const callProcQuery = `
CALL "CARNETSYS".userlogin_pkg_createclientlogins($1, $2, $3, $4, $5) CALL "CARNETSYS".spclientuser_pkg_getspuserdetails($1, $2, $3, $4, $5)
`; `;
await client.query(callProcQuery,
[ await client.query(callProcQuery, [
body.P_USERID, body.P_USERID,
cursorName roleCursor,
menuCursor,
menuPageCursor,
userDetailsCursor
]); ]);
// 🚫 DON'T quote the cursor name in FETCH // Fetch all data from each cursor
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`); const roleResult = await client.query(`FETCH ALL FROM ${roleCursor}`);
const menuResult = await client.query(`FETCH ALL FROM ${menuCursor}`);
const menuPageResult = await client.query(`FETCH ALL FROM ${menuPageCursor}`);
const userDetailsResult = await client.query(`FETCH ALL FROM ${userDetailsCursor}`);
// Close all cursors
await client.query(`CLOSE ${roleCursor}`);
await client.query(`CLOSE ${menuCursor}`);
await client.query(`CLOSE ${menuPageCursor}`);
await client.query(`CLOSE ${userDetailsCursor}`);
// 🚫 DON'T quote the cursor name in CLOSE
await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(roleResult);
checkPgUserDefinedErrors(menuResult);
const mailRes = await this.authService.sendMail({ P_TO: body.P_USERID, P_MAIL_TYPE: MailTypeDTO.REGISTER_CLIENT }) checkPgUserDefinedErrors(menuPageResult);
checkPgUserDefinedErrors(userDetailsResult);
if (mailRes.statusCode !== 200) {
throw new InternalServerException();
}
return { return {
statusCode: 201, roleDetails: toUpperCaseKeys(roleResult.rows),
message: ResponseStatus.clientRegistrationDone, menuDetails: toUpperCaseKeys(menuResult.rows),
...fetchResult?.rows?.[0] || {} menuPageDetails: toUpperCaseKeys(menuPageResult.rows),
userDetails: toUpperCaseKeys(userDetailsResult.rows),
}; };
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
handlePgError(error, UserMaintenanceService.name) handlePgError(error, 'getSpUserDetails');
} finally { } finally {
releasePgClient(client) releasePgClient(client);
} }
} }
@ -100,7 +110,7 @@ export class UserMaintenanceService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.lockedUserDone, message: ResponseStatus.lockedUserDone,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -138,7 +148,7 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -183,7 +193,7 @@ export class UserMaintenanceService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -221,7 +231,7 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -266,10 +276,16 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
const mailRes = await this.authService.sendMail({ P_TO: body.P_USERID, P_MAIL_TYPE: MailTypeDTO.REGISTER_SP })
if (mailRes.statusCode !== 200) {
throw new InternalServerException();
}
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.created, message: ResponseStatus.created,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -307,7 +323,7 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -341,7 +357,7 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');
@ -392,7 +408,7 @@ export class UserMaintenanceService {
return { return {
statusCode: 201, statusCode: 201,
message: ResponseStatus.clientRegistrationDone, message: ResponseStatus.clientRegistrationDone,
...fetchResult?.rows?.[0] || {} ...toUpperCaseKeys(fetchResult?.rows)[0]
}; };
} catch (error) { } catch (error) {
@ -431,7 +447,7 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
if (fetchResult?.rows.length > 0) { if (fetchResult?.rows.length > 0) {
return [normalizeKeysToUpperCase(fetchResult?.rows[0])] return [toUpperCaseKeys(fetchResult.rows)[0]]
} }
else { else {
return []; return [];
@ -473,7 +489,7 @@ export class UserMaintenanceService {
checkPgUserDefinedErrors(fetchResult); checkPgUserDefinedErrors(fetchResult);
return fetchResult?.rows ? fetchResult?.rows : [] return toUpperCaseKeys(fetchResult.rows);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -28,6 +28,15 @@ export enum ResponseStatus {
transmitted = 'Transmitted Successfully', transmitted = 'Transmitted Successfully',
added = 'Added Successfully', added = 'Added Successfully',
deleted = 'Deleted Successfully', deleted = 'Deleted Successfully',
processed = 'Processed Successfully',
voided = 'Voided Successfully',
copied = 'Coppied Successfully',
duplicated = 'Duplicated Successfully',
addl_completed = 'Additional sets completed',
extended = 'Extended Successfully',
saved = 'Saved Successfully',
closed = 'Closed Successfully',
reset_successfull = 'Reset Successfull'
} }
@ -38,6 +47,17 @@ export function normalizeKeysToUpperCase(obj) {
}, {}); }, {});
} }
export function toUpperCaseKeys(rows: Record<string, any>[]): Record<string, any>[] {
return rows.map(row => {
const transformedRow: Record<string, any> = {};
for (const key in row) {
transformedRow[key.toUpperCase()] = row[key];
}
return transformedRow;
});
}
export const handleError = (error: any, context: string = 'UnknownService'): never => { export const handleError = (error: any, context: string = 'UnknownService'): never => {
if (error instanceof BadRequestException || error instanceof BR) { if (error instanceof BadRequestException || error instanceof BR) {