From fa18c1ab7be86118c6d497d9ec39272503499d5c Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Tue, 20 May 2025 15:14:33 +0530 Subject: [PATCH] modified for fee api --- src/mssql/manage-fee/manage-fee.service.ts | 76 ++++++++++--------- src/mssql/param-table/param-table.service.ts | 12 +-- .../uscib-managed-sp/region/region.service.ts | 6 +- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/src/mssql/manage-fee/manage-fee.service.ts b/src/mssql/manage-fee/manage-fee.service.ts index ed13fe0..e019c3d 100644 --- a/src/mssql/manage-fee/manage-fee.service.ts +++ b/src/mssql/manage-fee/manage-fee.service.ts @@ -30,9 +30,9 @@ export class ManageFeeService { } return result.recordset; } - throw new InternalServerException(); + throw new BadRequestException(); } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -52,9 +52,9 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -72,9 +72,9 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -96,11 +96,11 @@ export class ManageFeeService { } return result.recordset; } - throw new InternalServerException(); + throw new BadRequestException(); } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -124,10 +124,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -147,9 +147,9 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -176,7 +176,7 @@ export class ManageFeeService { if (error instanceof BadRequestException) { throw error } - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -197,10 +197,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -218,10 +218,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -248,7 +248,7 @@ export class ManageFeeService { if (error instanceof BadRequestException) { throw error } - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -271,10 +271,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -294,10 +294,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -323,7 +323,7 @@ export class ManageFeeService { if (error instanceof BadRequestException) { throw error } - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -344,10 +344,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -366,10 +366,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -396,7 +396,7 @@ export class ManageFeeService { if (error instanceof BadRequestException) { throw error } - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -419,10 +419,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -441,10 +441,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -473,7 +473,7 @@ export class ManageFeeService { if (error instanceof BadRequestException) { throw error } - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -489,14 +489,16 @@ export class ManageFeeService { 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.CreateFeeComm'); + console.log(result); + if (result.recordset && result.recordset.length > 0 && result.recordset[0].ERRORMESG) { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 201, message: "Created Successfully" }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -514,10 +516,10 @@ export class ManageFeeService { this.logger.warn(`error from DB: ${result.recordset[0].ERRORMESG}`); throw new BadRequestException(result.recordset[0].ERRORMESG); } - return { statusCode: 200, message: "Updated Successfully" }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { console.log(error); - throw new InternalServerException(); + throw new InternalServerException(error.message); } } } diff --git a/src/mssql/param-table/param-table.service.ts b/src/mssql/param-table/param-table.service.ts index bbf5849..ee9d310 100644 --- a/src/mssql/param-table/param-table.service.ts +++ b/src/mssql/param-table/param-table.service.ts @@ -35,7 +35,7 @@ export class ParamTableService { const result = await request.execute('carnetsys.GETPARAMVALUES'); return result.recordset; } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -56,7 +56,9 @@ export class ParamTableService { return { statusCode: 201, message: "Created Successfully" } } } catch (error) { - throw new InternalServerException(); + console.log(error); + + throw new InternalServerException(error.message); } } @@ -114,7 +116,7 @@ export class ParamTableService { return { statusCode: 200, message: "Updated Successfully" } } } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -135,7 +137,7 @@ export class ParamTableService { return { statusCode: 200, message: result['recordset'][0].message } } } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } @@ -155,7 +157,7 @@ export class ParamTableService { return { statusCode: 200, message: result['recordset'][0].message } } } catch (error) { - throw new InternalServerException(); + throw new InternalServerException(error.message); } } } diff --git a/src/mssql/uscib-managed-sp/region/region.service.ts b/src/mssql/uscib-managed-sp/region/region.service.ts index 24b52c5..72713f0 100644 --- a/src/mssql/uscib-managed-sp/region/region.service.ts +++ b/src/mssql/uscib-managed-sp/region/region.service.ts @@ -16,7 +16,7 @@ export class RegionService { connection = await this.mssqlDBService.getConnection(); const request = new Request(connection); const result = await request.execute('carnetsys.GETREGIONS'); - return { data: result.recordset }; + return result.recordset; } catch (error) { throw new InternalServerException(); } @@ -31,7 +31,7 @@ export class RegionService { request.input('P_REGION', mssql.VarChar(mssql.MAX), body.p_region); request.input('P_NAME', mssql.VarChar(mssql.MAX), body.p_name); const result = await request.execute('carnetsys.INSERTNEWREGION'); - return { data: result.recordset }; + return { statusCode: 201, message: "Created Successfully", ...result.recordset[0] }; } catch (error) { throw new InternalServerException(); @@ -46,7 +46,7 @@ export class RegionService { request.input('p_regionID', mssql.Int, body.p_regionID); request.input('P_NAME', mssql.VarChar(mssql.MAX), body.p_name); const result = await request.execute('carnetsys.UpdateRegion'); - return { data: result.recordset }; + return { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] }; } catch (error) { throw new InternalServerException();