dev-v2 code stable

This commit is contained in:
Kallesh B S 2025-02-24 10:32:41 +05:30
commit 89505bd2b3
115 changed files with 30301 additions and 0 deletions

56
.gitignore vendored Normal file
View File

@ -0,0 +1,56 @@
# compiled output
/dist
/node_modules
/build
# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# OS
.DS_Store
# Tests
/coverage
/.nyc_output
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# temp directory
.temp
.tmp
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

4
.prettierrc Normal file
View File

@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

99
README.md Normal file
View File

@ -0,0 +1,99 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
## Description
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
## Project setup
```bash
$ npm install
```
## Compile and run the project
```bash
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
```
## Run tests
```bash
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
```
## Deployment
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
```bash
$ npm install -g mau
$ mau deploy
```
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
## Resources
Check out a few resources that may come in handy when working with NestJS:
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
## Support
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
## Stay in touch
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)
## License
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).

266
api.http Normal file
View File

@ -0,0 +1,266 @@
// InsertRegions
POST http://localhost:3000/oracle/InsertRegions
Content-Type: application/json
{
"p_region":"p_region",
"p_name":"p_name"
}
###
//UpdateRegion
PATCH http://localhost:3000/oracle/UpdateRegion
Content-Type: application/json
{
"p_regionID": ,
"p_name":"p_name"
}
###
// GetRegions
GET http://localhost:3000/oracle/GetRegions
###
//InsertNewServiceProvider
POST http://localhost:3000/oracle/InsertNewServiceProvider
Content-Type: application/json
{
"p_name": "Service Provider Name",
"p_lookupcode": "SP001",
"p_address1": "123 Main St",
"p_address2": "Suite 100",
"p_city": "Anytown",
"p_state": "CA",
"p_zip": "90210",
"p_country": "USA",
"p_issuingregion": "Region A",
"p_replacementregion": "Region B",
"p_bondsurety": "Surety Co.",
"p_cargopolicyno": "CP123456",
"p_cargosurety": "Cargo Surety Co.",
"p_user_id": "user123"
}
###
//UpdateServiceProvider
PUT http://localhost:3000/oracle/UpdateServiceProvider
Content-Type: application/json
{
"p_spid": 1,
"p_name": "Service Provider Name",
"p_lookupcode": "SP001",
"p_address1": "123 Main St",
"p_address2": "Suite 100",
"p_city": "Anytown",
"p_state": "CA",
"p_zip": "90210",
"p_country": "USA",
"p_issuingregion": "Region A",
"p_replacementregion": "Region B",
"p_bondsurety": "Surety Co.",
"p_cargopolicyno": "CP123456",
"p_cargosurety": "Cargo Surety Co.",
"p_user_id": "user123"
}
###
// GetAllServiceproviders
GET http://localhost:3000/oracle/GetAllServiceproviders
###
//GetSelectedServiceprovider
GET http://localhost:3000/oracle/GetSelectedServiceprovider/12
###
//InsertSPContacts
POST http://localhost:3000/oracle/InsertSPContacts
Content-Type: application/json
{
"p_spid": 12345,
"p_defcontactflag":"N",
"p_firstname": "John",
"p_lastname": "Doe",
"p_title": "Mr.",
"p_phoneno": "123-456-7890",
"p_mobileno": "098-765-4321",
"p_faxno": "123-456-7891",
"p_emailaddress": "john.doe@example.com",
"p_user_id": "jdoe"
}
###
//SetSPDefaultcontact
POST http://localhost:3000/oracle/SetSPDefaultcontact/12
###
//UpdateSPContacts
PUT http://localhost:3000/oracle/UpdateSPContacts
Content-Type: application/json
{
"p_spcontactid": 12345,
"p_firstname": "Jane",
"p_lastname": "Doe",
"p_title": "Ms.",
"p_phoneno": "123-456-7890",
"p_mobileno": "098-765-4321",
"p_faxno": "123-456-7891",
"p_emailaddress": "jane.doe@example.com",
"p_user_id": "jdoe"
}
###
//InactivateSPContact
POST http://localhost:3000/oracle/InactivateSPContact/12
###
//GetSPDefaultcontact
GET http://localhost:3000/oracle/GetSPDefaultcontact/12
###
//GetAllSPcontacts
//GET http://localhost:3000/oracle/GetAllSPcontacts
###
//CreateCarnetSequence
POST http://localhost:3000/oracle/CreateCarnetSequence
Content-Type: application/json
{
"p_spid": 2,
"p_regionid": 81,
"p_startnumber": 2000,
"p_endnumber": 3000,
"p_carnettype": "original"
}
###
//GetCarnetSequence
GET http://localhost:3000/oracle/GetCarnetSequence/12
###
//GetParamValues
GET http://localhost:3000/oracle/GetParamValues?id=500&type=original
###
//CreateTableRecord
POST http://localhost:3000/oracle/CreateTableRecord
Content-Type: application/json
{
"P_USERID": "6",
"P_TABLEFULLDESC": "TypeA desc"
}
###
//CreateParamRecord
POST http://localhost:3000/oracle/CreateParamRecord
Content-Type: application/json
{
# "P_SPID": 4,
"P_PARAMTYPE": "TypeA",
"P_PARAMDESC": "Description of the parameter",
"P_PARAMVALUE": "Value of the parameter",
# "P_ADDLPARAMVALUE1": "Additional Value 1",
# "P_ADDLPARAMVALUE2": "Additional Value 2",
# "P_ADDLPARAMVALUE3": null,
# "P_ADDLPARAMVALUE4": "Additional Value 4",
# "P_ADDLPARAMVALUE5": null,
"P_SORTSEQ": 1,
"P_USERID": "12"
}
###
// UpdateParamRecord
PATCH http://localhost:3000/oracle/UpdateParamRecord
Content-Type: application/json
{
"P_SPID": 2,
"P_PARAMID": 1,
"P_PARAMDESC": "abc",
"P_ADDLPARAMVALUE1": "asd",
"P_ADDLPARAMVALUE2": "ad",
"P_ADDLPARAMVALUE3": null,
"P_ADDLPARAMVALUE4": "asd",
"P_ADDLPARAMVALUE5": null,
"P_SORTSEQ": 1,
"P_USERID": "12"
}
###
// InActivateParamRecord
PATCH http://localhost:3000/oracle/InActivateParamRecord?pid=1&uid=2
Content-Type: application/json
{
"P_PARAMID":2,
"P_USERID":"12"
}
###
// ReActivateParamRecord
PATCH http://localhost:3000/oracle/ReActivateParamRecord?pid=1&uid=2
Content-Type: application/json
{
"P_PARAMID":2,
"P_USERID":"12"
}
###

35
eslint.config.mjs Normal file
View File

@ -0,0 +1,35 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['eslint.config.mjs'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
ecmaVersion: 5,
sourceType: 'module',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn'
},
},
);

274
manageFee.http Normal file
View File

@ -0,0 +1,274 @@
GET http://localhost:3000/user-maintenance/GetSPUserDetails?P_USERID=a@s.com
###
// CreateBasicFee
POST http://localhost:3000/oracle/CreateBasicFee
Content-Type: application/json
{
"P_SPID": 1,
"P_STARTCARNETVALUE": 1000,
"P_ENDCARNETVALUE": 2000,
"P_EFFDATE": "2023-10-01",
"P_FEES": 150.75,
"P_USERID": "user123"
}
###
// CreateBondRate
POST http://localhost:3000/oracle/CreateBondRate
Content-Type: application/json
{
"P_SPID": 1,
"P_HOLDERTYPE": "Individual",
"P_USCIBMEMBERFLAG": "Yes",
"P_SPCLCOMMODITY": "Electronics",
"P_SPCLCOUNTRY": "USA",
"P_EFFDATE": "2023-10-01",
"P_RATE": 0.05,
"P_USERID": "user123"
}
###
// CreateCargoRate
POST http://localhost:3000/oracle/CreateCargoRate
Content-Type: application/json
{
"P_SPID": 1,
"P_CARNETTYPE": "Type A",
"P_STARTSETS": 10,
"P_ENDSETS": 20,
"P_EFFDATE": "2023-10-01",
"P_RATE": 0.10,
"P_USERID": "user123"
}
###
// CreateCfFee
POST http://localhost:3000/oracle/CreateCfFee
Content-Type: application/json
{
"P_SPID": 1,
"P_STARTSETS": 10,
"P_ENDSETS": 20,
"P_EFFDATE": "2023-10-01",
"P_CUSTOMERTYPE": "Regular",
"P_CARNETTYPE": "Standard",
"P_RATE": 100.5,
"P_USERID": "user123"
}
###
// CreateCsFee
POST http://localhost:3000/oracle/CreateCsFee
Content-Type: application/json
{
"P_SPID": 1,
"P_CUSTOMERTYPE": "Regular",
"P_CARNETTYPE": "Standard",
"P_EFFDATE": "2023-10-01",
"P_RATE": 100.5,
"P_USERID": "user123",
"P_CURSOR": null
}
###
// CreateEfFee
POST http://localhost:3000/oracle/CreateEfFee
Content-Type: application/json
{
"P_SPID": 1,
"P_CUSTOMERTYPE": "Regular",
"P_DELIVERYTYPE": "Express",
"P_STARTTIME": 8,
"P_ENDTIME": 17,
"P_TIMEZONE": "UTC",
"P_EFFDATE": "2023-10-01",
"P_FEES": 50.0,
"P_USERID": "user123"
}
###
// CreateFeeComm
POST http://localhost:3000/oracle/CreateFeeComm
Content-Type: application/json
{
"P_SPID": 0,
"P_PARAMID": 0,
"P_COMMRATE": 0,
"P_EFFDATE": "",
"P_USERID": ""
}
###
// UpdateBasicFee
PATCH http://localhost:3000/oracle/UpdateBasicFee
Content-Type: application/json
{
"P_BASICFEESETUPID": 1,
"P_FEES": 100.50,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user123"
}
###
// UpdateBondRate
PATCH http://localhost:3000/oracle/UpdateBondRate
Content-Type: application/json
{
"P_BONDRATESETUPID": 1,
"P_RATE": 5.25,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user456"
}
###
// UpdateCargoRate
PATCH http://localhost:3000/oracle/UpdateCargoRate
Content-Type: application/json
{
"P_CARGORATESETUPID": 1,
"P_RATE": 3.75,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user789"
}
###
// UpdateCfFee
PATCH http://localhost:3000/oracle/UpdateCfFee
Content-Type: application/json
{
"P_CFFEESETUPID": 1,
"P_RATE": 4.50,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user101"
}
###
// UpdateCsFee
PATCH http://localhost:3000/oracle/UpdateCsFee
Content-Type: application/json
{
"P_CSFEESETUPID": 1,
"P_RATE": 2.75,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user202"
}
###
// UpdateEfFee
PATCH http://localhost:3000/oracle/UpdateEfFee
Content-Type: application/json
{
"P_EFFEESETUPID": 1,
"P_FEES": 150.00,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user303"
}
###
// UpdateFeeComm
PATCH http://localhost:3000/oracle/UpdateFeeComm
Content-Type: application/json
{
"P_FEECOMMID": 1,
"P_RATE": 6.50,
"P_EFFDATE": "2023-10-01",
"P_USERID": "user404"
}
###
// GetBasicFeeRates
GET http://localhost:3000/oracle/GetBasicFeeRates/12
###
// GetBondRates
GET http://localhost:3000/oracle/GetBondRates/12
###
// GetCargoRates
GET http://localhost:3000/oracle/GetCargoRates/12
###
// GetCfFeeRates
GET http://localhost:3000/oracle/GetCfFeeRates/12
###
// GetCsFeeRates
GET http://localhost:3000/oracle/GetCsFeeRates/12
###
// GetEfFeeRates
GET http://localhost:3000/oracle/GetEfFeeRates/12
###
// GetFeeComm
GET http://localhost:3000/oracle/GetFeeComm/12
###

8
nest-cli.json Normal file
View File

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}

0
ormconfig.ts Normal file
View File

14031
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

85
package.json Normal file
View File

@ -0,0 +1,85 @@
{
"name": "test",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^11.0.1",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.0.1",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/swagger": "^11.0.6",
"@nestjs/typeorm": "^11.0.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"mssql": "^10.0.4",
"mysql2": "^3.12.0",
"oracledb": "^6.7.2",
"pg": "^8.13.3",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
"typeorm": "^0.3.20"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.18.0",
"@nestjs/cli": "^11.0.0",
"@nestjs/schematics": "^11.0.0",
"@nestjs/testing": "^11.0.1",
"@swc/cli": "^0.6.0",
"@swc/core": "^1.10.7",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.14",
"@types/mssql": "^9.1.7",
"@types/node": "^22.10.7",
"@types/oracledb": "^6.5.4",
"@types/supertest": "^6.0.2",
"eslint": "^9.18.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "^5.2.2",
"globals": "^15.14.0",
"jest": "^29.7.0",
"prettier": "^3.4.2",
"source-map-support": "^0.5.21",
"supertest": "^7.0.0",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.2",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.7.3",
"typescript-eslint": "^8.20.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}

37
src/app.module.ts Normal file
View File

@ -0,0 +1,37 @@
import { MiddlewareConsumer, Module } from '@nestjs/common';
import { DbModule } from './db/db.module';
import { OracleModule } from './oracle/oracle.module';
import { AuthModule } from './auth/auth.module';
import { MssqlModule } from './mssql/mssql.module';
import { OriginCheckMiddleware } from './middleware/OriginCheck.middleware';
import { ReqBodyKeysToUppercaseMiddleware } from './middleware/reqBodyKeysToUppercase.middleware';
import { ConfigModule } from '@nestjs/config';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
AuthModule, DbModule, OracleModule
],
controllers: [],
providers: [],
})
export class AppModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(OriginCheckMiddleware)
.forRoutes('*'); // Apply to all routes
consumer
.apply(ReqBodyKeysToUppercaseMiddleware)
.forRoutes('*'); // Apply to all routes
// .forRoutes('users'); // Applies to all methods on /users
// .forRoutes(UsersController); // Applies to all routes in this controller
// .forRoutes(
// { path: 'users', method: RequestMethod.GET },
// { path: 'auth/login', method: RequestMethod.POST },
// );
}
}

View File

@ -0,0 +1,15 @@
import { Body, Controller, Post } from '@nestjs/common';
import { AuthService } from './auth.service';
import { ApiTags } from '@nestjs/swagger';
import { AuthLoginDTO } from './auth.dto';
@Controller()
export class AuthController {
constructor(private readonly authService: AuthService) {}
@ApiTags('Auth')
@Post('/login')
login(@Body() body: AuthLoginDTO) {
return this.authService.login(body);
}
}

12
src/auth/auth.dto.ts Normal file
View File

@ -0,0 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString } from 'class-validator';
export class AuthLoginDTO {
@ApiProperty({ required: true })
@IsString()
p_emailaddr: string;
@ApiProperty({ required: true })
@IsString()
p_password: string;
}

11
src/auth/auth.module.ts Normal file
View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { DbModule } from 'src/db/db.module';
@Module({
imports: [DbModule],
providers: [AuthService],
controllers: [AuthController],
})
export class AuthModule {}

75
src/auth/auth.service.ts Normal file
View File

@ -0,0 +1,75 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import { AuthLoginDTO } from './auth.dto';
import * as oracledb from 'oracledb';
@Injectable()
export class AuthService {
constructor(private readonly oracleDBService: OracleDBService) { }
async login(body: AuthLoginDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
USERLOGIN_PKG.ValidateUser(:p_emailaddr,:p_password,:p_login_cursor);
END;`,
{
p_emailaddr: {
val: body.p_emailaddr,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_password: {
val: body.p_password,
type: oracledb.DB_TYPE_NVARCHAR,
},
p_login_cursor: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
if (result.outBinds && result.outBinds.p_login_cursor) {
const cursor = result.outBinds.p_login_cursor;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new BadRequestException({
Error: 'Error executing request try after some time!',
});
}
if (rows[0]['ERRORMESG']) {
throw new BadRequestException({ error: 'Invalid username or password!' });
}
return { msg: 'Logged in successfully' };
} catch (err) {
throw new BadRequestException({ error: 'Invalid username or password' });
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
}
}
}

20
src/db/db.config.ts Normal file
View File

@ -0,0 +1,20 @@
import { ConfigService } from '@nestjs/config';
export const getOracleConfig = (configService: ConfigService) => ({
user: configService.get<string>('ORACLE_USER'),
password: configService.get<string>('ORACLE_PASSWORD'),
connectString: configService.get<string>('ORACLE_CONNECT_STRING'),
});
export const getMssqlConfig = (configService: ConfigService) => ({
server: configService.get<string>('MSSQL_SERVER'),
port: configService.get<string>('MSSQL_PORT'),
user: configService.get<string>('MSSQL_USER'),
password: configService.get<string>('MSSQL_PASSWORD'),
database: configService.get<string>('MSSQL_DATABASE'),
options: {
enableArithAbort: true,
trustServerCertificate: true,
encrypt: true
},
});

9
src/db/db.module.ts Normal file
View File

@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common';
import { MssqlDBService, OracleDBService } from './db.service';
@Global()
@Module({
providers: [OracleDBService, MssqlDBService],
exports: [OracleDBService, MssqlDBService],
})
export class DbModule {}

126
src/db/db.service.ts Normal file
View File

@ -0,0 +1,126 @@
// import { MssqlConfig, OracleConfig } from 'ormconfig';
import { createPool, Pool, Connection as cob } from 'oracledb';
import { Connection, ConnectionPool } from 'mssql';
import { Injectable, Logger } from '@nestjs/common';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { ConfigService } from '@nestjs/config';
import { getMssqlConfig, getOracleConfig } from './db.config';
// @Injectable()
// export class OracleDBService {
// private pool: Pool;
// constructor() {
// this.initializePool();
// }
// private async initializePool() {
// this.pool = await createPool({
// ...OracleConfig,
// poolMin: 1,
// poolMax: 10,
// poolIncrement: 1,
// });
// }
// async getConnection(): Promise<cob> {
// const connection = await this.pool.getConnection();
// return connection;
// }
// }
@Injectable()
export class OracleDBService {
private pool: Pool | null = null;
private readonly logger = new Logger(OracleDBService.name);
constructor(private readonly configService: ConfigService) {
this.initializePool().catch(err => {
this.logger.error('Error initializing Oracle DB pool', err);
throw new InternalServerException();
});
}
private async initializePool(): Promise<void> {
try {
const config = getOracleConfig(this.configService);
this.pool = await createPool({
...config,
poolMin: 1,
poolMax: 10,
poolIncrement: 1,
});
this.logger.log('Oracle connection pool created successfully');
} catch (error) {
this.logger.error('Failed to create Oracle DB pool:', error);
throw error;
}
}
async getConnection(): Promise<Connection> {
if (!this.pool) {
this.logger.error('Attempted to get a connection before pool was initialized');
throw new InternalServerException('Database connection pool not initialized');
}
try {
return await this.pool.getConnection();
} catch (error) {
this.logger.error('Failed to get Oracle DB connection:', error);
throw error;
}
}
async closePool(): Promise<void> {
if (this.pool) {
try {
await this.pool.close(10);
this.logger.log('Oracle DB pool closed successfully');
} catch (error) {
this.logger.error('Error closing Oracle DB pool:', error);
throw new InternalServerException();
}
}
}
}
@Injectable()
export class MssqlDBService {
private pool: ConnectionPool;
private poolConnected = false;
constructor(private readonly configService: ConfigService) {
const config: any = getMssqlConfig(configService);
this.pool = new ConnectionPool({
...config,
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 30000,
},
});
}
async getConnection(): Promise<ConnectionPool> {
try {
if (!this.poolConnected) {
this.pool.on('error', err => {
console.error('SQL Pool Error:', err);
this.poolConnected = false;
});
await this.pool.connect();
this.poolConnected = true;
console.log('Database connection pool initialized.');
}
return this.pool;
} catch (error) {
console.error('Failed to get connection from pool:', error);
throw error;
}
}
}

View File

@ -0,0 +1,294 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import {
IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString,
Length, Matches, Max, MaxLength, Min, ValidateNested
} from "class-validator";
export enum YON {
YES = "Y",
NO = "N",
}
export class CARNETSTATUS_DTO {
@ApiProperty({ required: true })
@Length(0, 20, {
message: 'Property P_CARNETSTATUS must be between 0 to 20 characters',
})
@IsString()
@IsDefined({ message: 'Property P_CARNETSTATUS is required' })
P_CARNETSTATUS: string;
}
export class HEADERID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property P_HEADERID must not exceed 999999999',
})
@Min(0, { message: 'Property P_HEADERID must be at least 0 or more' })
@IsInt({ message: 'Property P_HEADERID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_HEADERID must be a number' })
@IsDefined({ message: 'Property P_HEADERID is required' })
P_HEADERID: number;
}
export class APPLICATIONNAME_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_APPLICATIONNAME must be a string' })
@IsDefined({ message: 'Property P_APPLICATIONNAME is required' })
P_APPLICATIONNAME: string;
}
export class ORDERTYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ORDERTYPE must be a string' })
@IsDefined({ message: 'Property P_ORDERTYPE is required' })
P_ORDERTYPE: string;
}
export class COMMERCIAL_SAMPLE_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_COMMERCIALSAMPLEFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_COMMERCIALSAMPLEFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_COMMERCIALSAMPLEFLAG: YON;
}
export class PROF_EQUIPMENT_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_PROFEQUIMENTFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_PROFEQUIMENTFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_PROFEQUIPMENTFLAG: YON;
}
export class EXIBITIONS_FAIR_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_EXIBITIONSFAIRFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_EXIBITIONSFAIRFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_EXHIBITIONSFAIRFLAG: YON;
}
export class AUTO_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_AUTOFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_AUTOFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_AUTOFLAG: YON;
}
export class HORSE_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_HORSEFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_HORSEFLAG must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_HORSEFLAG: YON;
}
export class AUTHREP_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_AUTHREP must be a string' })
@IsDefined({ message: 'Property P_AUTHREP is required' })
P_AUTHREP: string;
}
export class GLTABLE_ROW_DTO {
@ApiProperty({ required: true })
@Max(99999, { message: 'Property ITEMNO must not exceed 99999' })
@Min(0, { message: 'Property ITEMNO must be at least 0 or more' })
@IsInt({ message: 'Property ITEMNO allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property ITEMNO must be a number' })
@IsDefined({ message: 'Property ITEMNO is required' })
ITEMNO: number;
@ApiProperty({ required: true })
@MaxLength(200, { message: 'Property ITEMDESCRIPTION must not exceed 200 characters' })
@IsString({ message: 'Property ITEMDESCRIPTION must be a string' })
@IsDefined({ message: 'Property ITEMDESCRIPTION is required' })
ITEMDESCRIPTION: string;
@ApiProperty({ required: true })
@Max(999999999.99, { message: 'Property ITEMVALUE must not exceed 999999999.99' })
@Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' })
@Transform(({ value }) => Number(value))
@IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' })
@IsDefined({ message: 'Property ITEMVALUE is required' })
ITEMVALUE: number;
@ApiProperty({ required: true })
@Max(99999, { message: 'Property NOOFPIECES must not exceed 99999' })
@Min(0, { message: 'Property NOOFPIECES must be at least 0 or more' })
@IsInt({ message: 'Property NOOFPIECES allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property NOOFPIECES must be a number' })
@IsDefined({ message: 'Property NOOFPIECES is required' })
NOOFPIECES: number;
@ApiProperty({ required: true })
@Max(99999.9999, { message: 'Property ITEMVALUE must not exceed 999999999.99' })
@Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' })
@Transform(({ value }) => Number(value))
@IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' })
@IsDefined({ message: 'Property ITEMVALUE is required' })
ITEMWEIGHT: number;
@ApiProperty({ required: true })
@MaxLength(10, { message: 'Property ITEMWEIGHTUOM must not exceed 10 characters' })
@IsString({ message: 'Property ITEMWEIGHTUOM must be a string' })
@IsDefined({ message: 'Property ITEMWEIGHTUOM is required' })
ITEMWEIGHTUOM: string;
@ApiProperty({ required: true })
@MaxLength(2, { message: 'Property GOODSORIGINCOUNTRY must not exceed 2 characters' })
@IsString({ message: 'Property GOODSORIGINCOUNTRY must be a string' })
@IsDefined({ message: 'Property GOODSORIGINCOUNTRY is required' })
GOODSORIGINCOUNTRY: string;
}
export class GLTABLE_DTO {
@ApiProperty({ required: true, type: () => [GLTABLE_ROW_DTO] })
@Type(() => GLTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({ message: 'Property P_GLTABLE allows only array type' })
@IsDefined({ message: 'Property P_GLTABLE is required' })
P_GLTABLE: GLTABLE_ROW_DTO[];
}
export class USSETS_DTO {
@ApiProperty({ required: true })
// @Max(99999, { message: 'Property P_USSETS must not exceed 99999' })
@Min(0, { message: 'Property P_USSETS must be at least 0 or more' })
@IsInt({ message: 'Property P_USSETS allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_USSETS must be a number' })
@IsDefined({ message: 'Property P_USSETS is required' })
P_USSETS: number;
}
export enum VOT {
V = "V",
T = "T",
}
export class COUNTRYTABLE_ROW_DTO {
@ApiProperty({ required: true, enum: VOT })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(VOT, { message: 'P_VISISTTRANSITIND must be either "V" or "T"' })
@Length(1, 1, { message: 'P_VISISTTRANSITIND must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_VISISTTRANSITIND: VOT;
@ApiProperty({ required: true })
@MaxLength(2, { message: 'Property COUNTRYCODE must not exceed 2 characters' })
@IsString({ message: 'Property COUNTRYCODE must be a string' })
@IsDefined({ message: 'Property COUNTRYCODE is required' })
COUNTRYCODE: string;
@ApiProperty({ required: true })
@Max(999, { message: 'Property NOOFTIMESENTLEAVE must not exceed 999' })
@Min(0, { message: 'Property NOOFTIMESENTLEAVE must be at least 0 or more' })
@IsInt({ message: 'Property NOOFTIMESENTLEAVE allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property NOOFTIMESENTLEAVE must be a number' })
@IsDefined({ message: 'Property NOOFTIMESENTLEAVE is required' })
NOOFTIMESENTLEAVE: number;
}
export class COUNTRYTABLE_DTO {
@ApiProperty({ required: true, type: () => [COUNTRYTABLE_ROW_DTO] })
@Type(() => COUNTRYTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({ message: 'Property P_COUNTRYTABLE allows only array type' })
@IsDefined({ message: 'Property P_COUNTRYTABLE is required' })
P_COUNTRYTABLE: COUNTRYTABLE_ROW_DTO[];
}
export class SHIPTOTYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_SHIPTOTYPE must be a string' })
@IsDefined({ message: 'Property P_SHIPTOTYPE is required' })
P_SHIPTOTYPE: string;
}
export class SHIPADDRID_DTO {
@ApiProperty({ required: true })
// @Max(99999, { message: 'Property P_USSETS must not exceed 99999' })
@Min(0, { message: 'Property P_SHIPADDRID must be at least 0 or more' })
@IsInt({ message: 'Property P_SHIPADDRID allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SHIPADDRID must be a number' })
@IsDefined({ message: 'Property P_SHIPADDRID is required' })
P_SHIPADDRID: number;
}
export class FORMOFSECURITY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_FORMOFSECURITY must be a string' })
@IsDefined({ message: 'Property P_FORMOFSECURITY is required' })
P_FORMOFSECURITY: string;
}
export class INSPROTECTION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_INSPROTECTION must be a string' })
@IsDefined({ message: 'Property P_INSPROTECTION is required' })
P_INSPROTECTION: string;
}
export class LDIPROTECTION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_LDIPROTECTION must be a string' })
@IsDefined({ message: 'Property P_LDIPROTECTION is required' })
P_LDIPROTECTION: string;
}
export class DELIVERYTYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_DELIVERYTYPE must be a string' })
@IsDefined({ message: 'Property P_DELIVERYTYPE is required' })
P_DELIVERYTYPE: string;
}
export class DELIVERYMETHOD_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_DELIVERYTYPE must be a string' })
@IsDefined({ message: 'Property P_DELIVERYTYPE is required' })
P_DELIVERYMETHOD: string;
}
export class PAYMENTMETHOD_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_PAYMENTMETHOD must be a string' })
@IsDefined({ message: 'Property P_PAYMENTMETHOD is required' })
P_PAYMENTMETHOD: string;
}
export class CUSTCOURIERNO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_CUSTCOURIERNO must be a string' })
@IsDefined({ message: 'Property P_CUSTCOURIERNO is required' })
P_CUSTCOURIERNO: string;
}
export class REFNO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_REFNO must be a string' })
@IsDefined({ message: 'Property P_REFNO is required' })
P_REFNO: string;
}

View File

@ -0,0 +1,84 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import {
APPLICATIONNAME_DTO, AUTHREP_DTO, AUTO_FLAG_DTO, COMMERCIAL_SAMPLE_FLAG_DTO,
COUNTRYTABLE_DTO, CUSTCOURIERNO_DTO, DELIVERYMETHOD_DTO, DELIVERYTYPE_DTO,
EXIBITIONS_FAIR_FLAG_DTO, FORMOFSECURITY_DTO, GLTABLE_DTO, HEADERID_DTO,
HORSE_FLAG_DTO, INSPROTECTION_DTO, LDIPROTECTION_DTO, ORDERTYPE_DTO, PAYMENTMETHOD_DTO,
PROF_EQUIPMENT_FLAG_DTO, REFNO_DTO, SHIPADDRID_DTO, SHIPTOTYPE_DTO, USSETS_DTO
} from "./carnet-application-property.dto";
import { NOTES_DTO, SPID_DTO, USERID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
import { CLIENTID_DTO } from "../manage-clients/manage-clients-property.dto";
import { HOLDERID_DTO, LOCATIONID_DTO } from "../manage-holders/manage-holders-property.dto";
export class SaveCarnetApplicationDTO extends IntersectionType(
PartialType(SPID_DTO),
PartialType(CLIENTID_DTO),
PartialType(LOCATIONID_DTO),
PartialType(USERID_DTO),
PartialType(HEADERID_DTO),
(APPLICATIONNAME_DTO),
PartialType(HOLDERID_DTO),
PartialType(COMMERCIAL_SAMPLE_FLAG_DTO),
PartialType(PROF_EQUIPMENT_FLAG_DTO),
PartialType(EXIBITIONS_FAIR_FLAG_DTO),
PartialType(AUTO_FLAG_DTO),
PartialType(HORSE_FLAG_DTO),
PartialType(AUTHREP_DTO),
PartialType(GLTABLE_DTO),
PartialType(USSETS_DTO),
PartialType(COUNTRYTABLE_DTO),
PartialType(SHIPTOTYPE_DTO),
PartialType(SHIPADDRID_DTO),
PartialType(FORMOFSECURITY_DTO),
PartialType(INSPROTECTION_DTO),
PartialType(LDIPROTECTION_DTO),
PartialType(DELIVERYTYPE_DTO),
PartialType(DELIVERYMETHOD_DTO),
PartialType(PAYMENTMETHOD_DTO),
PartialType(CUSTCOURIERNO_DTO),
PartialType(REFNO_DTO),
PartialType(NOTES_DTO)
) { }
export class TransmitApplicationtoProcessDTO extends IntersectionType(
SPID_DTO, USERID_DTO, HEADERID_DTO
) { }
// processing [ PROCESSINGCENTER_PKG ]
export class CarnetProcessingCenterDTO extends (IntersectionType(USERID_DTO, HEADERID_DTO)) { }
export class CreateApplicationDTO extends IntersectionType(
SPID_DTO, CLIENTID_DTO, LOCATIONID_DTO, USERID_DTO, APPLICATIONNAME_DTO,
ORDERTYPE_DTO
) { }
export class CA_UpdateHolderDTO extends IntersectionType(
HEADERID_DTO, HOLDERID_DTO
) { }
export class UpdateExpGoodsAuthRepDTO extends IntersectionType(
HEADERID_DTO, COMMERCIAL_SAMPLE_FLAG_DTO, PROF_EQUIPMENT_FLAG_DTO,
EXIBITIONS_FAIR_FLAG_DTO, AUTO_FLAG_DTO, HORSE_FLAG_DTO,
AUTHREP_DTO
) { }
export class AddGenerallistItemsDTO extends IntersectionType(
HEADERID_DTO, GLTABLE_DTO, USERID_DTO
) { }
export class AddCountriesDTO extends IntersectionType(
HEADERID_DTO, USSETS_DTO, COUNTRYTABLE_DTO, USERID_DTO
) { }
export class UpdateShippingDetailsDTO extends IntersectionType(
HEADERID_DTO, SHIPTOTYPE_DTO, SHIPADDRID_DTO, FORMOFSECURITY_DTO,
INSPROTECTION_DTO, LDIPROTECTION_DTO, DELIVERYTYPE_DTO, DELIVERYMETHOD_DTO,
PAYMENTMETHOD_DTO, CUSTCOURIERNO_DTO, REFNO_DTO, NOTES_DTO, USERID_DTO
) { }

View File

@ -0,0 +1,12 @@
import { IntersectionType } from "@nestjs/swagger";
import { SPID_DTO, USERID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
import { CARNETSTATUS_DTO } from "../carnet-application/carnet-application-property.dto";
// homepage
export class GetCarnetDetailsbyCarnetStatusDTO extends IntersectionType(
SPID_DTO,
USERID_DTO,
CARNETSTATUS_DTO
) { }

View File

@ -0,0 +1,133 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { Type } from "class-transformer";
import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator";
import {
ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, STATE_DTO, ZIP_DTO
} from "../uscib-managed-sp/sp/sp-property.dto";
export class CLIENTID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property p_clientid must not exceed 999999999',
})
@Min(0, { message: 'Property p_clientid must be at least 0 or more' })
@IsInt({ message: 'Property p_clientid allows only whole numbers' })
@IsNumber({}, { message: 'Property p_clientid must be a number' })
@IsDefined({ message: 'Property p_clientid is required' })
P_CLIENTID: number;
}
export class CLIENT_CONTACTID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property P_CLIENTCONTACTID must not exceed 999999999',
})
@Min(0, { message: 'Property P_CLIENTCONTACTID must be at least 0 or more' })
@IsInt({ message: 'Property P_CLIENTCONTACTID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_CLIENTCONTACTID must be a number' })
@IsDefined({ message: 'Property P_CLIENTCONTACTID is required' })
P_CLIENTCONTACTID: number;
}
export class NAMEOF_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property Nameof must be between 0 to 50 characters',
})
@IsString({ message: 'Property Nameof must be a string' })
@IsDefined({ message: 'Property Nameof is required' })
P_NAMEOF: string;
}
export class CLIENTNAME_DTO {
@ApiProperty({ required: true })
// @Max(999999999, { message: "Property P_CLIENTNAME must not exceed 999999999" })
// @Min(0, { message: "Property P_CLIENTNAME must be at least 0 or more" })
// @IsInt({ message: "Property P_CLIENTNAME allows only whole numbers" })
// @IsNumber({}, { message: "Property P_CLIENTNAME must be a number" })
// @IsDefined({ message: "Property P_CLIENTNAME is required" })
@Length(0, 50, {
message: 'Property P_CLIENTNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_CLIENTNAME must be a string' })
@IsDefined({ message: 'Property P_CLIENTNAME is required' })
P_CLIENTNAME: string;
}
export class REVENUELOCATION_DTO {
@ApiProperty({ required: true })
@Length(0, 2, {
message: 'Property P_REVENUELOCATION must be between 0 to 2 characters',
})
@IsString({ message: 'Property P_REVENUELOCATION must be a string' })
@IsDefined({ message: 'Property P_REVENUELOCATION is required' })
P_REVENUELOCATION: string;
}
export class PREPARERNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_PREPARERNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_PREPARERNAME must be a string' })
@IsDefined({ message: 'Property P_PREPARERNAME is required' })
P_PREPARERNAME: string;
}
export class STATUS_DTO {
@ApiProperty({ required: true })
@Length(0, 10, {
message: 'Property P_STATUS must be between 0 to 10 characters',
})
@IsString({ message: 'Property P_STATUS must be a string' })
@IsDefined({ message: 'Property P_STATUS is required' })
P_STATUS: string;
}
export class CLIENTLOCADDRESSTABLE_ROW_DTO extends IntersectionType(
NAMEOF_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO
) { }
export class CLIENTLOCADDRESSTABLE_DTO {
@ApiProperty({ required: true, type: () => [CLIENTLOCADDRESSTABLE_ROW_DTO] })
@Type(() => CLIENTLOCADDRESSTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({
message: 'Property P_CLIENTLOCADDRESSTABLE allows only array type',
})
@IsDefined({ message: 'Property P_CLIENTLOCADDRESSTABLE is required' })
P_CLIENTLOCADDRESSTABLE: CLIENTLOCADDRESSTABLE_ROW_DTO[];
}
export class CLIENTLOCATIONID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property P_CLIENTLOCATIONID must not exceed 999999999',
})
@Min(0, { message: 'Property P_CLIENTLOCATIONID must be at least 0 or more' })
@IsInt({ message: 'Property P_CLIENTLOCATIONID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_CLIENTLOCATIONID must be a number' })
@IsDefined({ message: 'Property P_CLIENTLOCATIONID is required' })
P_CLIENTLOCATIONID: number;
}
export class LOCATIONNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_LOCATIONNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_LOCATIONNAME must be a string' })
@IsDefined({ message: 'Property P_LOCATIONNAME is required' })
P_LOCATIONNAME: string;
}

View File

@ -0,0 +1,109 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import { CONTACTSTABLE_DTO } from "../manage-holders/manage-holders-property.dto";
import {
DEFAULT_CONTACT_FLAG_DTO, EMAIL_ADDRESS_DTO, FAX_NO_DTO, FIRSTNAME_DTO, LASTNAME_DTO,
MIDDLE_INITIAL_DTO, MOBILE_NO_DTO, PHONE_NO_DTO, TITLE_DTO
} from "../uscib-managed-sp/sp-contacts/sp-contacts-property.dto";
import {
CLIENT_CONTACTID_DTO, CLIENTID_DTO, CLIENTLOCADDRESSTABLE_DTO, CLIENTLOCATIONID_DTO,
CLIENTNAME_DTO, LOCATIONNAME_DTO, NAMEOF_DTO, PREPARERNAME_DTO, REVENUELOCATION_DTO, STATUS_DTO
} from "./manage-clients-property.dto";
import {
ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, ISSUING_REGION_DTO, LOOKUP_CODE_DTO,
NAME_DTO, SPID_DTO, STATE_DTO, USERID_DTO, ZIP_DTO
} from "../uscib-managed-sp/sp/sp-property.dto";
export class CreateClientDataDTO extends IntersectionType(
SPID_DTO,
CLIENTNAME_DTO,
LOOKUP_CODE_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
PartialType(ZIP_DTO),
PartialType(COUNTRY_DTO),
ISSUING_REGION_DTO,
REVENUELOCATION_DTO,
USERID_DTO
) { }
export class UpdateClientDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO,
PREPARERNAME_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
REVENUELOCATION_DTO,
USERID_DTO
) { }
export class UpdateClientContactsDTO extends IntersectionType(
SPID_DTO,
CLIENT_CONTACTID_DTO,
FIRSTNAME_DTO,
LASTNAME_DTO,
PartialType(MIDDLE_INITIAL_DTO),
PartialType(TITLE_DTO),
PHONE_NO_DTO,
FAX_NO_DTO,
PartialType(MOBILE_NO_DTO),
EMAIL_ADDRESS_DTO,
USERID_DTO
) { }
export class GetPreparersDTO extends IntersectionType(
SPID_DTO,
PartialType(NAME_DTO),
PartialType(LOOKUP_CODE_DTO),
PartialType(CITY_DTO),
PartialType(STATE_DTO),
STATUS_DTO
) { }
export class UpdateClientLocationsDTO extends IntersectionType(
SPID_DTO,
CLIENTLOCATIONID_DTO,
LOCATIONNAME_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
PartialType(CITY_DTO),
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
USERID_DTO
) { }
export class CreateClientContactsDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO,
CONTACTSTABLE_DTO,
DEFAULT_CONTACT_FLAG_DTO,
USERID_DTO
) { }
export class CreateClientLocationsDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO,
CLIENTLOCADDRESSTABLE_DTO,
USERID_DTO
) { }
export class GetPreparerByClientidContactsByClientidLocByClientidDTO extends IntersectionType(
SPID_DTO,
CLIENTID_DTO
) { }

View File

@ -0,0 +1,117 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsNumber, IsString } from "class-validator";
export class EFFDATE_DTO {
@ApiProperty({ required: true })
@IsString()
P_EFFDATE: string;
}
export class FEES_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_FEES: number;
}
export class SPCLCOMMODITY_DTO {
@ApiProperty({ required: true })
@IsString()
P_SPCLCOMMODITY: string;
}
export class SPCLCOUNTRY_DTO {
@ApiProperty({ required: true })
@IsString()
P_SPCLCOUNTRY: string;
}
export class RATE_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_RATE: number;
}
export class STARTSETS_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_STARTSETS: number;
}
export class ENDSETS_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_ENDSETS: number;
}
export class CUSTOMERTYPE_DTO {
@ApiProperty({ required: true })
@IsString()
P_CUSTOMERTYPE: string;
}
export class STARTTIME_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_STARTTIME: number;
}
export class ENDTIME_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_ENDTIME: number;
}
export class TIMEZONE_DTO {
@ApiProperty({ required: true })
@IsString()
P_TIMEZONE: string;
}
export class COMMRATE_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_COMMRATE: number;
}
export class BASICFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_BASICFEESETUPID: number;
}
export class BONDRATESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_BONDRATESETUPID: number;
}
export class CARGORATESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_CARGORATESETUPID: number;
}
export class CFFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_CFFEESETUPID: number;
}
export class CSFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_CSFEESETUPID: number;
}
export class EFFEESETUPID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_EFFEESETUPID: number;
}
export class FEECOMMID_DTO {
@ApiProperty({ required: true })
@IsNumber()
P_FEECOMMID: number;
}

View File

@ -0,0 +1,144 @@
import { IntersectionType } from "@nestjs/swagger";
import { ACTIVE_INACTIVE_STATUS_DTO, SPID_DTO, USERID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
import { HOLDERTYPE_DTO, USCIBMEMBERFLAG_DTO } from "../manage-holders/manage-holders-property.dto";
import {
BASICFEESETUPID_DTO, BONDRATESETUPID_DTO, CARGORATESETUPID_DTO, CFFEESETUPID_DTO,
COMMRATE_DTO, CSFEESETUPID_DTO, CUSTOMERTYPE_DTO, EFFDATE_DTO, EFFEESETUPID_DTO, ENDSETS_DTO,
ENDTIME_DTO, FEECOMMID_DTO, FEES_DTO, RATE_DTO, SPCLCOMMODITY_DTO, SPCLCOUNTRY_DTO,
STARTSETS_DTO, STARTTIME_DTO, TIMEZONE_DTO
} from "./manage-fee-property.dto";
import { PARAMID_DTO } from "../param-table/param-table-property.dto";
import { CARNET_TYPE_DTO, END_NUMBER_DTO, START_NUMBER_DTO } from "../uscib-managed-sp/carnet-sequence/carnet-sequence-property.dto";
import { DELIVERYTYPE_DTO } from "../carnet-application/carnet-application-property.dto";
export class GetFeeGeneralDTO extends IntersectionType(
SPID_DTO,
ACTIVE_INACTIVE_STATUS_DTO
) { }
export class CreateBasicFeeDTO extends IntersectionType(
SPID_DTO,
START_NUMBER_DTO,
END_NUMBER_DTO,
EFFDATE_DTO,
FEES_DTO,
USERID_DTO
) { }
export class CreateBondRateDTO extends IntersectionType(
SPID_DTO,
HOLDERTYPE_DTO,
USCIBMEMBERFLAG_DTO,
SPCLCOMMODITY_DTO,
SPCLCOUNTRY_DTO,
EFFDATE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateCargoRateDTO extends IntersectionType(
SPID_DTO,
CARNET_TYPE_DTO,
STARTSETS_DTO,
ENDSETS_DTO,
EFFDATE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateCfFeeDTO extends IntersectionType(
SPID_DTO,
STARTSETS_DTO,
ENDSETS_DTO,
EFFDATE_DTO,
CUSTOMERTYPE_DTO,
CARNET_TYPE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateCsFeeDTO extends IntersectionType(
SPID_DTO,
CUSTOMERTYPE_DTO,
CARNET_TYPE_DTO,
EFFDATE_DTO,
RATE_DTO,
USERID_DTO
) { }
export class CreateEfFeeDTO extends IntersectionType(
SPID_DTO,
CUSTOMERTYPE_DTO,
DELIVERYTYPE_DTO,
STARTTIME_DTO,
ENDTIME_DTO,
TIMEZONE_DTO,
EFFDATE_DTO,
FEES_DTO,
USERID_DTO
) { }
export class CreateFeeCommDTO extends IntersectionType(
SPID_DTO,
PARAMID_DTO,
COMMRATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateBasicFeeDTO extends IntersectionType(
BASICFEESETUPID_DTO,
FEES_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateBondRateDTO extends IntersectionType(
BONDRATESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateCargoRateDTO extends IntersectionType(
CARGORATESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateCfFeeDTO extends IntersectionType(
CFFEESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateCsFeeDTO extends IntersectionType(
CSFEESETUPID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateEfFeeDTO extends IntersectionType(
EFFEESETUPID_DTO,
FEES_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
export class UpdateFeeCommDTO extends IntersectionType(
FEECOMMID_DTO,
RATE_DTO,
EFFDATE_DTO,
USERID_DTO
) { }
// export class UpdateFeeCommBodyDTO {
// @ApiProperty({ type: UpdateFeeCommDTO, required: true }) // Correctly reference UpdateFeeCommDTO
// p_fees_comm: UpdateFeeCommDTO; // No need for @IsObject()
// }

View File

@ -0,0 +1,121 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { IsArray, IsDefined, IsInt, IsNumber, IsString, Length, Max, Min, ValidateNested } from "class-validator";
import { Transform, Type } from "class-transformer";
import {
EMAIL_ADDRESS_DTO, FAX_NO_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO,
MOBILE_NO_DTO, PHONE_NO_DTO, TITLE_DTO
} from "../uscib-managed-sp/sp-contacts/sp-contacts-property.dto";
export class GOVAGENCYFLAG_DTO {
@ApiProperty({ required: true })
@Length(0, 1, {
message: 'Property P_GOVAGENCYFLAG must be between 0 to 1 character',
})
@IsString({ message: 'Property P_GOVAGENCYFLAG must be a string' })
@IsDefined({ message: 'Property P_GOVAGENCYFLAG is required' })
P_GOVAGENCYFLAG: string;
}
export class USCIBMEMBERFLAG_DTO {
@ApiProperty({ required: true })
@Length(0, 1, { message: 'Property P_USCIBMEMBERFLAG must be between 0 to 1 character' })
@IsString({ message: 'Property P_USCIBMEMBERFLAG must be a string' })
@IsDefined({ message: 'Property P_USCIBMEMBERFLAG is required' })
P_USCIBMEMBERFLAG: string;
}
export class LOCATIONID_DTO {
@ApiProperty({ required: true })
@Max(999999999, { message: 'Property p_locationid must not exceed 999999999' })
@Min(0, { message: 'Property p_locationid must be at least 0 or more' })
@IsInt({ message: 'Property p_locationid allows only whole numbers' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property p_locationid must be a number' })
@IsDefined({ message: 'Property p_locationid is required' })
P_LOCATIONID: number;
}
export class HOLDERID_DTO {
@ApiProperty({ required: true })
@Max(999999999, {
message: 'Property P_HOLDERID must not exceed 999999999',
})
@Min(0, { message: 'Property P_HOLDERID must be at least 0 or more' })
@IsInt({ message: 'Property P_HOLDERID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_HOLDERID must be a number' })
@IsDefined({ message: 'Property P_HOLDERID is required' })
P_HOLDERID: number;
}
export class HOLDERNO_DTO {
@ApiProperty({ required: true })
@Length(0, 15, { message: 'Property P_HOLDERNO must be between 0 to 15 characters' })
@IsString({ message: 'Property P_HOLDERNO must be a string' })
@IsDefined({ message: 'Property P_HOLDERNO is required' })
P_HOLDERNO: string;
}
export class HOLDERTYPE_DTO {
@ApiProperty({ required: true })
@Length(0, 3, { message: 'Property P_HOLDERTYPE must be between 0 to 3 characters' })
@IsString({ message: 'Property P_HOLDERTYPE must be a string' })
@IsDefined({ message: 'Property P_HOLDERTYPE is required' })
P_HOLDERTYPE: string;
}
export class HOLDERNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_HOLDERNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_HOLDERNAME must be a string' })
@IsDefined({ message: 'Property P_HOLDERNAME is required' })
P_HOLDERNAME: string;
}
export class NAMEQUALIFIER_DTO {
@ApiProperty({ required: true })
@Length(0, 10, { message: 'Property P_NAMEQUALIFIER must be between 0 to 10 characters' })
@IsString({ message: 'Property P_NAMEQUALIFIER must be a string' })
P_NAMEQUALIFIER: string;
}
export class ADDLNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_ADDLNAME must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_ADDLNAME must be a string' })
P_ADDLNAME: string;
}
export class CONTACTSTABLE_ROW_DTO extends IntersectionType(
FIRSTNAME_DTO,
LASTNAME_DTO,
PartialType(MIDDLE_INITIAL_DTO),
PartialType(TITLE_DTO),
EMAIL_ADDRESS_DTO,
PHONE_NO_DTO,
MOBILE_NO_DTO,
FAX_NO_DTO
) { }
export class CONTACTSTABLE_DTO {
@ApiProperty({ required: true, type: () => [CONTACTSTABLE_ROW_DTO] })
@Type(() => CONTACTSTABLE_ROW_DTO)
@ValidateNested({ each: true })
@IsArray({ message: 'Property P_CONTACTSTABLE allows only array type' })
P_CONTACTSTABLE: CONTACTSTABLE_ROW_DTO[];
}
export class HOLDERCONTACTID_DTO {
@ApiProperty({ required: true })
@Max(999999999, { message: 'Property P_HOLDERCONTACTID must not exceed 999999999' })
@Min(0, { message: 'Property P_HOLDERCONTACTID must be at least 0 or more' })
@IsInt({ message: 'Property P_HOLDERCONTACTID allows only whole numbers' })
@IsNumber({}, { message: 'Property P_HOLDERCONTACTID must be a number' })
@IsDefined({ message: 'Property P_HOLDERCONTACTID is required' })
P_HOLDERCONTACTID: number;
}

View File

@ -0,0 +1,92 @@
import { IntersectionType, PartialType } from "@nestjs/swagger";
import { SPID_DTO } from "src/dto/property.dto";
import { CLIENTLOCATIONID_DTO } from "src/dto/property.dto";
import {
ADDLNAME_DTO, CONTACTSTABLE_DTO, HOLDERCONTACTID_DTO, HOLDERNAME_DTO, HOLDERNO_DTO,
HOLDERTYPE_DTO, NAMEQUALIFIER_DTO
} from "src/dto/property.dto";
import { GOVAGENCYFLAG_DTO, USCIBMEMBERFLAG_DTO } from "src/dto/property.dto";
import {
ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, COUNTRY_DTO, EMAIL_DTO, HOLDERID_DTO,
LOCATIONID_DTO, STATE_DTO, USERID_DTO, ZIP_DTO
} from "src/dto/property.dto";
import {
EMAIL_ADDRESS_DTO, FAX_NO_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO,
MOBILE_NO_DTO, PHONE_NO_DTO, TITLE_DTO
} from "src/dto/property.dto";
export class CreateHoldersDTO extends IntersectionType(
SPID_DTO,
CLIENTLOCATIONID_DTO,
HOLDERNO_DTO,
HOLDERTYPE_DTO,
USCIBMEMBERFLAG_DTO,
GOVAGENCYFLAG_DTO,
HOLDERNAME_DTO,
PartialType(NAMEQUALIFIER_DTO),
ADDLNAME_DTO,
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
USERID_DTO,
PartialType(CONTACTSTABLE_DTO)
) { }
export class UpdateHolderDTO extends IntersectionType(
HOLDERID_DTO,
SPID_DTO,
LOCATIONID_DTO,
HOLDERNO_DTO,
HOLDERTYPE_DTO,
USCIBMEMBERFLAG_DTO,
GOVAGENCYFLAG_DTO,
HOLDERNAME_DTO,
PartialType(NAMEQUALIFIER_DTO),
PartialType(ADDLNAME_DTO),
ADDRESS1_DTO,
PartialType(ADDRESS2_DTO),
CITY_DTO,
STATE_DTO,
ZIP_DTO,
COUNTRY_DTO,
USERID_DTO
) { }
export class UpdateHolderContactDTO extends IntersectionType(
HOLDERCONTACTID_DTO,
SPID_DTO,
FIRSTNAME_DTO,
LASTNAME_DTO,
PartialType(MIDDLE_INITIAL_DTO),
TITLE_DTO,
PHONE_NO_DTO,
MOBILE_NO_DTO,
PartialType(FAX_NO_DTO),
EMAIL_ADDRESS_DTO,
USERID_DTO
) { }
export class GetHolderDTO extends IntersectionType(
SPID_DTO,
HOLDERID_DTO
) { }
export class HolderActivateOrInactivateDTO extends IntersectionType(
SPID_DTO,
HOLDERID_DTO,
USERID_DTO
) { }
export class HolderContactActivateOrInactivateDTO extends IntersectionType(
SPID_DTO,
HOLDERCONTACTID_DTO,
USERID_DTO
) {
}

View File

@ -0,0 +1,80 @@
import { ApiProperty, IntersectionType } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsDefined, IsInt, IsNumber, IsString, Min } from "class-validator";
export class TABLEFULLDESC_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_TABLEFULLDESC must be a string' })
@IsDefined({ message: 'Property P_TABLEFULLDESC is required' })
P_TABLEFULLDESC: string;
}
export class PARAMTYPE_DTO {
@ApiProperty({ required: true })
@IsString()
P_PARAMTYPE: string;
}
export class PARAMDESC_DTO {
@ApiProperty({ required: true })
@IsString()
P_PARAMDESC: string;
}
export class PARAMVALUE_DTO {
@ApiProperty({ required: true })
@IsString()
P_PARAMVALUE: string;
}
export class ADDPAAMVALUE1_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE1: string;
}
export class ADDPAAMVALUE2_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE2: string;
}
export class ADDPAAMVALUE3_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE3: string;
}
export class ADDPAAMVALUE4_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE4: string;
}
export class ADDPAAMVALUE5_DTO {
@ApiProperty({ required: true })
@IsString()
P_ADDLPARAMVALUE5: string;
}
export class SORTSEQ_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property P_SORTSEQ must be at least 0' })
@IsInt({ message: 'Property P_SORTSEQ must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SORTSEQ must be a number' })
@IsDefined({ message: 'Property P_SORTSEQ is required' })
P_SORTSEQ: number;
}
export class PARAMID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property P_PARAMID must be at least 0' })
@IsInt({ message: 'Property P_PARAMID must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_PARAMID must be a number' })
@IsDefined({ message: 'Property P_PARAMID is required' })
P_PARAMID: number;
}

View File

@ -0,0 +1,44 @@
import { ApiProperty, IntersectionType, PartialType } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsOptional, IsString } from "class-validator";
import { USERID_DTO } from "../property.dto";
import { ADDPAAMVALUE1_DTO, ADDPAAMVALUE2_DTO, ADDPAAMVALUE3_DTO, ADDPAAMVALUE4_DTO, ADDPAAMVALUE5_DTO, PARAMDESC_DTO, PARAMID_DTO, PARAMTYPE_DTO, PARAMVALUE_DTO, SORTSEQ_DTO, TABLEFULLDESC_DTO } from "./param-table-property.dto";
import { SPID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
export class CreateTableRecordDTO extends IntersectionType(USERID_DTO, TABLEFULLDESC_DTO) { }
export class CreateParamRecordDTO extends IntersectionType(
PartialType(SPID_DTO),
PARAMTYPE_DTO,
PARAMDESC_DTO,
PARAMVALUE_DTO,
PartialType(ADDPAAMVALUE1_DTO),
PartialType(ADDPAAMVALUE2_DTO),
PartialType(ADDPAAMVALUE3_DTO),
PartialType(ADDPAAMVALUE4_DTO),
PartialType(ADDPAAMVALUE5_DTO),
SORTSEQ_DTO,
USERID_DTO
) { }
export class UpdateParamRecordDTO extends IntersectionType(
PartialType(SPID_DTO),
PARAMID_DTO,
PARAMDESC_DTO,
PartialType(ADDPAAMVALUE1_DTO),
PartialType(ADDPAAMVALUE2_DTO),
PartialType(ADDPAAMVALUE3_DTO),
PartialType(ADDPAAMVALUE4_DTO),
PartialType(ADDPAAMVALUE5_DTO),
SORTSEQ_DTO,
USERID_DTO
) { }
export class getParamValuesDTO extends IntersectionType(
PartialType(SPID_DTO),
PartialType(PARAMTYPE_DTO)
) { }
export class ActivateOrInactivateParamRecordDTO extends IntersectionType(
PARAMID_DTO,
USERID_DTO
) { }

37
src/dto/property.dto.ts Normal file
View File

@ -0,0 +1,37 @@
export * from './carnet-application/carnet-application-property.dto' // ind
export * from './uscib-managed-sp/sp/sp-property.dto' // ind
export * from './manage-holders/manage-holders-property.dto' // dep c-a-p (YON)
export * from './user-maintenance/user-maintenance-property.dto' // dep c-a-p (YON)
export * from './uscib-managed-sp/sp-contacts/sp-contacts-property.dto' // ind
export * from './manage-clients/manage-clients-property.dto' // ind
export * from './param-table/param-table-property.dto' // ind
export * from './manage-fee/manage-fee-property.dto' // ind
export * from './uscib-managed-sp/carnet-sequence/carnet-sequence-property.dto' // ind
export * from './uscib-managed-sp/region/region-property.dto' // ind
export * from './manage-clients/manage-clients.dto'
export * from './carnet-application/carnet-application.dto'
// export * from './home-page/home-page-property.dto' // NA
export * from './home-page/home-page.dto'
export * from './manage-fee/manage-fee.dto'
export * from './param-table/param-table.dto'
export * from './uscib-managed-sp/carnet-sequence/carnet-sequence.dto'
export * from './uscib-managed-sp/region/region.dto'
export * from './uscib-managed-sp/sp/sp.dto'
export * from './uscib-managed-sp/sp-contacts/sp-contacts.dto'
export * from './user-maintenance/user-maintenance.dto'
export * from './manage-holders/manage-holders.dto'

View File

@ -0,0 +1,23 @@
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsString, Length, Min } from "class-validator";
export class START_NUMBER_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_startnumber must be a number' })
@IsDefined({ message: 'Property p_startnumber is required' })
@Min(0, { message: 'Property p_startnumber must be at least 0' })
P_STARTNUMBER: number;
}
export class END_NUMBER_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_endnumber must be a number' })
@IsDefined({ message: 'Property p_endnumber is required' })
@Min(0, { message: 'Property p_endnumber must be at least 0' })
P_ENDNUMBER: number;
}
export class CARNET_TYPE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_carnettype must be a string' })
@IsDefined({ message: 'Property p_carnettype is required' })
P_CARNETTYPE: string;
}

View File

@ -0,0 +1,8 @@
import { IntersectionType } from '@nestjs/swagger';
import { CARNET_TYPE_DTO, END_NUMBER_DTO, START_NUMBER_DTO } from './carnet-sequence-property.dto';
import { SPID_DTO } from '../sp/sp-property.dto';
import { REGIONID_DTO } from '../region/region-property.dto';
export class CreateCarnetSequenceDTO extends IntersectionType(
SPID_DTO, REGIONID_DTO, START_NUMBER_DTO, END_NUMBER_DTO, CARNET_TYPE_DTO
) { }

View File

@ -0,0 +1,18 @@
// Region
import { ApiProperty } from "@nestjs/swagger";
import { IsDefined, IsNumber, IsString } from "class-validator";
export class REGION_CODE_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property p_region must be a string' })
@IsDefined({ message: 'Property p_region is required' })
P_REGION: string;
}
export class REGIONID_DTO {
@ApiProperty({ required: true })
@IsNumber({}, { message: 'Property p_regionID must be a number' })
@IsDefined({ message: 'Property p_regionID is required' })
P_REGIONID: number;
}

View File

@ -0,0 +1,7 @@
import { IntersectionType } from '@nestjs/swagger';
import { REGION_CODE_DTO, REGIONID_DTO } from './region-property.dto';
import { NAME_DTO } from '../../property.dto';
export class InsertRegionsDto extends IntersectionType(REGION_CODE_DTO, NAME_DTO) { }
export class UpdateRegionDto extends IntersectionType(REGIONID_DTO, NAME_DTO) { }

View File

@ -0,0 +1,85 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsString, Length, Min } from "class-validator";
import { YON } from "src/dto/carnet-application/carnet-application-property.dto";
export class SP_CONTACTID_DTO {
@ApiProperty({ required: true })
@Min(0, { message: 'Property P_SPCONTACTID must be at least 0' })
@IsInt({ message: 'Property P_SPCONTACTID must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SPCONTACTID must be a number' })
@IsDefined({ message: 'Property P_SPCONTACTID is required' })
P_SPCONTACTID: number;
}
export class DEFAULT_CONTACT_FLAG_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_DEFCONTACTFLAG must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_DEFCONTACTFLAG must be between 5 and 6 characters' }) // Note: This message may not match actual length constraint
@IsString()
@IsDefined({ message: "Invalid Request" })
P_DEFCONTACTFLAG: YON;
}
export class FIRSTNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, { message: 'Property P_FIRSTNAME must be between 0 to 50 characters' })
@IsString({ message: 'Property FirP_FIRSTNAMEstName must be a string' })
@IsDefined({ message: 'Property P_FIRSTNAME is required' })
P_FIRSTNAME: string;
}
export class LASTNAME_DTO {
@ApiProperty({ required: true })
@Length(0, 50, { message: 'Property P_LASTNAME must be between 0 to 50 characters' })
@IsString({ message: 'Property P_LASTNAME must be a string' })
@IsDefined({ message: 'Property P_LASTNAME is required' })
P_LASTNAME: string;
}
export class MIDDLE_INITIAL_DTO {
@ApiProperty({ required: true })
@Length(0, 3, { message: 'Property P_MIDDLEINITIAL must be between 0 to 3 characters' })
@IsString({ message: 'Property P_MIDDLEINITIAL must be a string' })
P_MIDDLEINITIAL: string;
}
export class TITLE_DTO {
@ApiProperty({ required: true })
@Length(0, 50, { message: 'Property P_TITLE must be between 0 to 50 characters' })
@IsString({ message: 'Property P_TITLE must be a string' })
P_TITLE: string;
}
export class PHONE_NO_DTO {
@ApiProperty({ required: true })
@Length(0, 20, { message: 'Property P_PHONENO must be between 0 to 20 characters' })
@IsString({ message: 'Property P_PHONENO must be a string' })
@IsDefined({ message: 'Property P_PHONENO is required' })
P_PHONENO: string;
}
export class MOBILE_NO_DTO {
@ApiProperty({ required: true })
@Length(0, 20, { message: 'Property P_MOBILENO must be between 0 to 20 characters' })
@IsString({ message: 'Property P_MOBILENO must be a string' })
@IsDefined({ message: 'Property P_MOBILENO is required' })
P_MOBILENO: string;
}
export class FAX_NO_DTO {
@ApiProperty({ required: true })
@Length(0, 20, { message: 'Property FAXNO must be between 0 to 20 characters' })
@IsString({ message: 'Property FAXNO must be a string' })
P_FAXNO: string;
}
export class EMAIL_ADDRESS_DTO {
@ApiProperty({ required: true })
@Length(0, 100, { message: 'Property P_EMAILADDRESS must be between 0 to 100 characters' })
@IsString({ message: 'Property P_EMAILADDRESS must be a string' })
@IsDefined({ message: 'Property P_EMAILADDRESS is required' })
P_EMAILADDRESS: string;
}

View File

@ -0,0 +1,20 @@
import { IntersectionType } from '@nestjs/swagger';
import {
DEFAULT_CONTACT_FLAG_DTO, EMAIL_ADDRESS_DTO, FAX_NO_DTO,
FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, MOBILE_NO_DTO, PHONE_NO_DTO,
SP_CONTACTID_DTO, TITLE_DTO
} from 'src/dto/property.dto';
import { USER_ID_DTO } from '../../property.dto';
import { SPID_DTO } from '../sp/sp-property.dto';
export class InsertSPContactsDTO extends IntersectionType(
SPID_DTO, DEFAULT_CONTACT_FLAG_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, TITLE_DTO,
PHONE_NO_DTO, MOBILE_NO_DTO, FAX_NO_DTO, EMAIL_ADDRESS_DTO, USER_ID_DTO
) { }
export class UpdateSPContactsDTO extends IntersectionType(
SP_CONTACTID_DTO, FIRSTNAME_DTO, LASTNAME_DTO, MIDDLE_INITIAL_DTO, TITLE_DTO, PHONE_NO_DTO,
MOBILE_NO_DTO, FAX_NO_DTO, EMAIL_ADDRESS_DTO, USER_ID_DTO
) { }

View File

@ -0,0 +1,183 @@
// SP
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString,
Length, Matches, Max, MaxLength, Min, ValidateNested } from "class-validator";
export class SPID_DTO {
@ApiProperty({ required: true })
@Max(999999999, { message: 'Property P_SPID must not exceed 999999999' })
@Min(0, { message: 'Property P_SPID must be at least 0' })
@IsInt({ message: 'Property P_SPID must be a whole number' })
@Transform(({ value }) => Number(value))
@IsNumber({}, { message: 'Property P_SPID must be a number' })
@IsDefined({ message: 'Property P_SPID is required' })
P_SPID: number;
}
export class USERID_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_USERID must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_USERID must be a string' })
@IsDefined({ message: 'Property P_USERID is required' })
P_USERID: string;
}
export class USER_ID_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_USER_ID must be a string' })
@IsDefined({ message: 'Property P_USER_ID is required' })
P_USER_ID: string;
}
export class EMAIL_DTO {
@ApiProperty({ required: true })
@IsEmail({}, { message: "Invalid P_EMAILADDR property" })
@Length(0, 50, {
message: 'Property P_EMAILADDR must be between 0 to 50 characters',
})
@IsString({ message: 'P_EMAILADDR p_userid must be string' })
@IsDefined({ message: 'P_EMAILADDR p_userid is required' })
P_EMAILADDR: string;
}
export class LOOKUP_CODE_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_LOOKUPCODE: string;
}
export class PASSWORD_DTO {
@ApiProperty({ required: true })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_PASSWORD: string;
}
export class NAME_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_NAME must be a string' })
@IsDefined({ message: 'Property P_NAME is required' })
P_NAME: string;
}
export class ADDRESS1_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ADDRESS1 must be a string' })
@IsDefined({ message: 'Property P_ADDRESS1 is required' })
P_ADDRESS1: string;
}
export class ADDRESS2_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ADDRESS2 must be a string' })
@IsDefined({ message: 'Property P_ADDRESS2 is required' })
P_ADDRESS2: string;
}
export class CITY_DTO {
@ApiProperty({ required: true })
@Length(0, 30, {
message: 'Property P_CITY must be between 0 to 30 characters',
})
@IsString({ message: 'Property P_CITY must be a string' })
@IsDefined({ message: 'Property P_CITY is required' })
P_CITY: string;
}
export class STATE_DTO {
@ApiProperty({ required: true })
@Length(0, 2, {
message: 'Property P_STATE must be between 0 to 2 characters',
})
@IsString({ message: 'Property P_STATE must be a string' })
@IsDefined({ message: 'Property P_STATE is required' })
P_STATE: string;
}
export class COUNTRY_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_COUNTRY must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_COUNTRY must be a string' })
@IsDefined({ message: 'Property P_COUNTRY is required' })
P_COUNTRY: string;
}
export class ZIP_DTO {
@ApiProperty({ required: true })
@Length(0, 10, {
message: 'Property P_ZIP must be between 0 to 10 characters',
})
@IsString({ message: 'Property P_ZIP must be a string' })
@IsDefined({ message: 'Property P_ZIP is required' })
P_ZIP: string;
}
export class ISSUING_REGION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_ISSUINGREGION must be a string' })
@IsDefined({ message: 'Property P_ISSUINGREGION is required' })
P_ISSUINGREGION: string;
}
export class REPLACEMENT_REGION_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_REPLACEMENTREGION must be a string' })
@IsDefined({ message: 'Property P_REPLACEMENTREGION is required' })
P_REPLACEMENTREGION: string;
}
export class BOND_SURETY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_BONDSURETY must be a string' })
@IsDefined({ message: 'Property P_BONDSURETY is required' })
P_BONDSURETY: string;
}
export class CARGO_POLICY_NO_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_CARGOPOLICYNO must be a string' })
@IsDefined({ message: 'Property P_CARGOPOLICYNO is required' })
P_CARGOPOLICYNO: string;
}
export class CARGO_SURETY_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_CARGOSURETY must be a string' })
@IsDefined({ message: 'Property P_CARGOSURETY is required' })
P_CARGOSURETY: string;
}
export class NOTES_DTO {
@ApiProperty({ required: true })
@IsString({ message: 'Property P_NOTES must be a string' })
P_NOTES: string;
}
export class FILE_ID_DTO {
@ApiProperty({ required: false })
@IsString({ message: 'Property P_FILEIDS must be a string' })
@IsOptional()
P_FILEIDS?: string;
}
export class ACTIVE_INACTIVE_STATUS_DTO {
@ApiProperty({ required: true })
@Matches(/^.{6}$|^.{8}$/, {
message: 'Property P_ACTIVE_INACTIVE is invalid',
})
@IsString({ message: 'Property P_ACTIVE_INACTIVE must be a string' })
@IsDefined({ message: 'Property P_ACTIVE_INACTIVE is required' })
P_ACTIVE_INACTIVE: string;
}

View File

@ -0,0 +1,21 @@
import { IntersectionType, PartialType } from '@nestjs/swagger';
import {
ADDRESS1_DTO, ADDRESS2_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO,
CARGO_SURETY_DTO, CITY_DTO, COUNTRY_DTO, FILE_ID_DTO,
ISSUING_REGION_DTO, LOOKUP_CODE_DTO, NAME_DTO, NOTES_DTO,
REPLACEMENT_REGION_DTO, STATE_DTO, USER_ID_DTO, ZIP_DTO
} from 'src/dto/property.dto';
import { SPID_DTO } from './sp-property.dto';
export class InsertNewServiceProviderDTO extends IntersectionType(
NAME_DTO, LOOKUP_CODE_DTO, ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, STATE_DTO, COUNTRY_DTO, ZIP_DTO,
ISSUING_REGION_DTO, REPLACEMENT_REGION_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO, CARGO_SURETY_DTO,
USER_ID_DTO, PartialType(NOTES_DTO), FILE_ID_DTO
) { }
export class UpdateServiceProviderDTO extends IntersectionType(
SPID_DTO, NAME_DTO, LOOKUP_CODE_DTO, ADDRESS1_DTO, ADDRESS2_DTO, CITY_DTO, STATE_DTO, COUNTRY_DTO,
ISSUING_REGION_DTO, REPLACEMENT_REGION_DTO, BOND_SURETY_DTO, CARGO_POLICY_NO_DTO, CARGO_SURETY_DTO,
ZIP_DTO, USER_ID_DTO, PartialType(NOTES_DTO), FILE_ID_DTO
) { }

View File

@ -0,0 +1,29 @@
import { ApiProperty } from "@nestjs/swagger";
import { Transform, Type } from "class-transformer";
import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString,
Length, Matches, Max, MaxLength, Min, ValidateNested } from "class-validator";
import { YON } from "../carnet-application/carnet-application-property.dto";
// user maintenance
export class ENABLE_PASSWORD_POLICY_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_ENABLEPASSWORDPOLICY must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_ENABLEPASSWORDPOLICY must be between 5 and 6 characters' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_ENABLEPASSWORDPOLICY: YON;
}
export class DOMAIN_DTO {
@ApiProperty({ required: true })
@Length(0, 50, {
message: 'Property P_DOMAIN must be between 0 to 50 characters',
})
@IsString({ message: 'Property P_DOMAIN must be a string' })
@IsDefined({ message: 'Property P_DOMAIN is required' })
P_DOMAIN: string;
}

View File

@ -0,0 +1,21 @@
import { IntersectionType } from "@nestjs/swagger";
import { CLIENT_CONTACTID_DTO, CLIENTID_DTO, DOMAIN_DTO,
EMAIL_DTO, ENABLE_PASSWORD_POLICY_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO,
USERID_DTO } from "src/dto/property.dto";
import { SPID_DTO } from "../uscib-managed-sp/sp/sp-property.dto";
export class SPID_CLIENTID_DTO extends IntersectionType(SPID_DTO, CLIENTID_DTO) { }
export class SPID_EMAIL_DTO extends IntersectionType(SPID_DTO, EMAIL_DTO) { }
export class CreateUSCIBLoginsDTO extends IntersectionType(
USERID_DTO, EMAIL_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO, ENABLE_PASSWORD_POLICY_DTO
) { }
export class CreateClientLoginsDTO extends IntersectionType(
SPID_DTO, USERID_DTO, CLIENT_CONTACTID_DTO, PASSWORD_DTO, ENABLE_PASSWORD_POLICY_DTO
) { }
export class CreateSPLoginsDTO extends IntersectionType(
SPID_DTO, USERID_DTO, DOMAIN_DTO, EMAIL_DTO, LOOKUP_CODE_DTO, PASSWORD_DTO, ENABLE_PASSWORD_POLICY_DTO
) { }

View File

@ -0,0 +1,19 @@
import { HttpException, HttpStatus } from '@nestjs/common';
export class BadRequestException extends HttpException {
constructor(
message = 'Bad Request',
errorCode = 'INTERNAL_ERROR',
data: any = null,
) {
super(
{
statusCode: HttpStatus.BAD_REQUEST ,
message,
// errorCode,
// data,
},
HttpStatus.BAD_REQUEST,
);
}
}

View File

@ -0,0 +1,19 @@
import { HttpException, HttpStatus } from '@nestjs/common';
export class InternalServerException extends HttpException {
constructor(
message = 'Internal server error',
errorCode = 'INTERNAL_ERROR',
data: any = null,
) {
super(
{
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
message,
// errorCode,
// data,
},
HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}

97
src/main.ts Normal file
View File

@ -0,0 +1,97 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import {
ValidationError,
ValidationPipe,
} from '@nestjs/common';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { SwaggerDocumentOptions } from '@nestjs/swagger';
import { BadRequestException } from './exceptions/badRequest.exception';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
logger: ['error', 'warn'],
cors: {
// origin: 'https://dev.alphaomegainfosys.com/',
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
},
});
function extractConstraints(validationErrors: ValidationError[]) {
const constraints: { [key: string]: string }[] = [];
function traverse(errors: ValidationError[]) {
// console.log(errors);
// console.log("--------------");
for (const error of errors) {
// If the error has constraints, add them to the list
// console.log(error);
// console.log("--------------");
if (error.constraints) {
constraints.push(error.constraints);
}
// // If there are children, recursively traverse them
if (error.children && error.children.length > 0) {
traverse(error.children);
}
}
}
traverse(validationErrors);
return constraints;
}
const customExceptionFactory = (validationErrors: ValidationError[]) => {
const res = extractConstraints(validationErrors);
const newResult = res
.map((x) => {
const errorMessage = x[Object.keys(x)[0]];
return { message: errorMessage };
})
.filter(Boolean);
throw new BadRequestException(`Bad Request${newResult[0].message !== 'Bad Request' ? " : " + newResult[0].message : ""}`);
};
app.useGlobalPipes(
new ValidationPipe({
transform: true,
exceptionFactory: customExceptionFactory,
whitelist: true,
stopAtFirstError: true,
forbidNonWhitelisted: true,
}),
);
// app.useGlobalPipes(new ValidationPipe({ exceptionFactory:customExceptionFactory, whitelist: true, forbidNonWhitelisted: true, transform: true }));
const config = new DocumentBuilder()
.setTitle('API')
.setDescription('API description')
.setVersion('1.0')
.addServer(
'https://dev.alphaomegainfosys.com/test-api',
'Development Server 2',
)
.addServer('http://localhost:3000', 'Development Server 1')
.build();
const options: SwaggerDocumentOptions = { autoTagControllers: false };
const documentFactory = () => SwaggerModule.createDocument(app, config, options);
SwaggerModule.setup('api', app, documentFactory);
app.use('/api-json', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.send(document);
});
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();

View File

@ -0,0 +1,21 @@
import { Injectable, Logger, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
@Injectable()
export class OriginCheckMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
const allowedOrigin = 'http://your-specified-domain.com'; // Replace with your domain
const origin = req.headers.origin;
// const logger = new Logger('OriginCheckMiddleware');
// logger.log('user-agent', `${req.headers['user-agent']} ${origin} ${req.headers.host}`);
// console.log(req.headers['user-agent']);
// if (origin === allowedOrigin) {
next();
// } else {
// res.status(403).send('Access denied');
// }
}
}

View File

@ -0,0 +1,30 @@
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
@Injectable()
export class ReqBodyKeysToUppercaseMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
if (req.body && typeof req.body === 'object' && !Array.isArray(req.body)) {
console.log('I am here will start operation shortly...');
req.body = this.uppercaseKeys(req.body);
}
next();
}
private uppercaseKeys(obj: Record<string, any>): Record<string, any> {
const newObj: Record<string, any> = {};
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
const upperKey = key.toUpperCase();
const value = obj[key];
newObj[upperKey] =
value !== null && typeof value === 'object' && !Array.isArray(value)
? this.uppercaseKeys(value)
: value;
}
}
return newObj;
}
}

View File

@ -0,0 +1,80 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ManageClientsService } from './manage-clients.service';
import { ApiTags } from '@nestjs/swagger';
import {
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/manage-clients/manage-clients.dto';
@Controller('mssql')
export class ManageClientsController {
constructor(private readonly manageClientsService: ManageClientsService) { }
@ApiTags('Manage Clients - Mssql')
@Post('CreateNewClients')
async CreateClientData(@Body() body: CreateClientDataDTO) {
return this.manageClientsService.CreateClientData(body);
}
@ApiTags('Manage Clients - Mssql')
@Put('UpdateClient')
async UpdateClient(@Body() body: UpdateClientDTO) {
return this.manageClientsService.UpdateClient(body);
}
@ApiTags('Manage Clients - Mssql')
@Put('UpdateClientContacts')
UpdateClientContacts(@Body() body: UpdateClientContactsDTO) {
return this.manageClientsService.UpdateClientContacts(body);
}
@ApiTags('Manage Clients - Mssql')
@Put('UpdateClientLocations')
UpdateClientLocations(@Body() body: UpdateClientLocationsDTO) {
return this.manageClientsService.UpdateClientLocations(body);
}
@ApiTags('Manage Clients - Mssql')
@Post('CreateAdditionalClientContacts')
CreateClientContact(@Body() body: CreateClientContactsDTO) {
return this.manageClientsService.CreateClientContact(body);
}
@ApiTags('Manage Clients - Mssql')
@Post('CreateAdditionalClientLocations')
CreateClientLocation(@Body() body: CreateClientLocationsDTO) {
return this.manageClientsService.CreateClientLocation(body);
}
@ApiTags('Manage Clients - Mssql')
@Get('GetPreparers')
async GetPreparers(@Query() query: GetPreparersDTO) {
return await this.manageClientsService.GetPreparers(query);
}
@ApiTags('Manage Clients - Mssql')
@Get('GetPreparerByClientid')
GetPreparerByClientid(
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) {
return this.manageClientsService.GetPreparerByClientid(body);
}
@ApiTags('Manage Clients - Mssql')
@Get('GetPreparerContactsByClientid')
GetPreparerContactsByClientid(
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) {
return this.manageClientsService.GetPreparerContactsByClientid(body);
}
@ApiTags('Manage Clients - Mssql')
@Get('GetPreparerLocByClientid')
GetPreparerLocByClientid(
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) {
return this.manageClientsService.GetPreparerLocByClientid(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageClientsController } from './manage-clients.controller';
import { ManageClientsService } from './manage-clients.service';
@Module({
controllers: [ManageClientsController],
providers: [ManageClientsService]
})
export class ManageClientsModule {}

View File

@ -0,0 +1,571 @@
import { Injectable } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql';
import {
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/manage-clients/manage-clients.dto';
@Injectable()
export class ManageClientsService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
CreateClientData = async (body: CreateClientDataDTO) => {
const newBody = {
P_SPID: null,
P_CLIENTNAME: null,
P_LOOKUPCODE: null,
P_ADDRESS1: null,
P_ADDRESS2: null,
P_CITY: null,
P_STATE: null,
P_ZIP: null,
P_COUNTRY: null,
P_ISSUINGREGION: null,
P_REVENUELOCATION: null,
P_USERID: null,
p_contactstable: null,
p_clientlocaddresstable: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj: any) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: CreateClientDataDTO = { ...newBody, ...reqBody };
let connection: Connection; // Fixed duplicate declaration
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTNAME', mssql.VarChar(50), finalBody.P_CLIENTNAME);
request.input('P_LOOKUPCODE', mssql.VarChar(20), finalBody.P_LOOKUPCODE);
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
request.input('P_ISSUINGREGION', mssql.VarChar(2), finalBody.P_ISSUINGREGION);
request.input('P_REVENUELOCATION', mssql.VarChar(2), finalBody.P_REVENUELOCATION);
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const contactTable = new mssql.Table('carnetsys.ContactsTable');
contactTable.create = true;
contactTable.columns.add('FirstName', mssql.VarChar(50));
contactTable.columns.add('LastName', mssql.VarChar(50));
contactTable.columns.add('MiddleInitial', mssql.VarChar(3));
contactTable.columns.add('Title', mssql.VarChar(50));
contactTable.columns.add('EmailAddress', mssql.VarChar(100));
contactTable.columns.add('PhoneNo', mssql.VarChar(20));
contactTable.columns.add('MobileNo', mssql.VarChar(20));
contactTable.columns.add('FaxNo', mssql.VarChar(20));
request.input('p_contactstable', contactTable);
const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable');
clientLocAddressTable.create = true;
clientLocAddressTable.columns.add('Nameof', mssql.VarChar(50));
clientLocAddressTable.columns.add('Address1', mssql.VarChar(50));
clientLocAddressTable.columns.add('Address2', mssql.VarChar(50));
clientLocAddressTable.columns.add('City', mssql.VarChar(30));
clientLocAddressTable.columns.add('State', mssql.VarChar(2));
clientLocAddressTable.columns.add('Zip', mssql.VarChar(10));
clientLocAddressTable.columns.add('Country', mssql.VarChar(2));
request.input('p_clientlocaddresstable', clientLocAddressTable);
const result = await request.execute('carnetsys.CreateClientData');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
GetPreparerByClientid = async (body: GetPreparerByClientidContactsByClientidLocByClientidDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_CLIENTID', mssql.Int, body.P_CLIENTID);
const result = await request.execute('carnetsys.GetPreparerbyClientID');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
UpdateClient = async (body: UpdateClientDTO) => {
const newBody = {
P_SPID: null,
P_CLIENTID: null,
P_PREPARERNAME: null,
P_ADDRESS1: null,
P_ADDRESS2: null,
P_CITY: null,
P_STATE: null,
P_ZIP: null,
P_COUNTRY: null,
P_REVENUELOCATION: null,
P_USERID: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: UpdateClientDTO = { ...newBody, ...reqBody };
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
request.input('P_PREPARERNAME', mssql.VarChar(50), finalBody.P_PREPARERNAME);
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
request.input('P_REVENUELOCATION', mssql.VarChar(2), finalBody.P_REVENUELOCATION);
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.UpdateClient');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
CreateClientContact = async (body: CreateClientContactsDTO) => {
const newBody = {
P_SPID: null,
P_CLIENTID: null,
p_contactstable: null,
P_DEFCONTACTFLAG: null,
P_USERID: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: CreateClientContactsDTO = {
...newBody,
...reqBody,
};
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const contactTable = new mssql.Table('carnetsys.ContactsTable');
contactTable.create = true;
contactTable.columns.add('FirstName', mssql.VarChar(50));
contactTable.columns.add('LastName', mssql.VarChar(50));
contactTable.columns.add('MiddleInitial', mssql.VarChar(3));
contactTable.columns.add('Title', mssql.VarChar(50));
contactTable.columns.add('EmailAddress', mssql.VarChar(100));
contactTable.columns.add('PhoneNo', mssql.VarChar(20));
contactTable.columns.add('MobileNo', mssql.VarChar(20));
contactTable.columns.add('FaxNo', mssql.VarChar(20));
finalBody.P_CONTACTSTABLE.forEach((contact) => {
contactTable.rows.add(
contact.P_FIRSTNAME,
contact.P_LASTNAME,
contact.P_MIDDLEINITIAL,
contact.P_TITLE,
contact.P_EMAILADDRESS,
contact.P_PHONENO,
contact.P_MOBILENO,
contact.P_FAXNO,
);
});
request.input('p_contactstable', contactTable);
request.input('P_DEFCONTACTFLAG', mssql.VarChar(1), finalBody.P_DEFCONTACTFLAG);
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.CreateClientContact');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
UpdateClientContacts = async (body: UpdateClientContactsDTO) => {
const newBody = {
P_SPID: null,
P_CLIENTCONTACTID: null,
P_FIRSTNAME: null,
P_LASTNAME: null,
P_MIDDLEINITIAL: null,
P_TITLE: null,
P_PHONENO: null,
P_FAXNO: null,
P_MOBILENO: null,
P_EMAILADDRESS: null,
P_USERID: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: UpdateClientContactsDTO = { ...newBody, ...reqBody };
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTCONTACTID', mssql.Int, finalBody.P_CLIENTCONTACTID);
request.input('P_FIRSTNAME', mssql.VarChar(50), finalBody.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(50), finalBody.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(3), finalBody.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(50), finalBody.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(20), finalBody.P_PHONENO);
request.input('P_FAXNO', mssql.VarChar(20), finalBody.P_FAXNO);
request.input('P_MOBILENO', mssql.VarChar(20), finalBody.P_MOBILENO);
request.input('P_EMAILADDRESS', mssql.VarChar(100), finalBody.P_EMAILADDRESS);
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.UpdateClientContacts');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
UpdateClientLocations = async (body: UpdateClientLocationsDTO) => {
const newBody = {
P_SPID: null,
P_CLIENTLOCATIONID: null,
P_LOCATIONNAME: null,
P_ADDRESS1: null,
P_ADDRESS2: null,
P_CITY: null,
P_STATE: null,
P_ZIP: null,
P_COUNTRY: null,
P_USERID: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: UpdateClientLocationsDTO = { ...newBody, ...reqBody };
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTLOCATIONID', mssql.Int, finalBody.P_CLIENTLOCATIONID);
request.input('P_LOCATIONNAME', mssql.VarChar(50), finalBody.P_LOCATIONNAME);
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.UpdateClientlocations');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
CreateClientLocation = async (body: CreateClientLocationsDTO) => {
const newBody = {
P_SPID: null,
P_CLIENTID: null,
p_clientlocaddresstable: null,
P_DEFCONTACTFLAG: null,
P_USERID: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: CreateClientLocationsDTO = {
...newBody,
...reqBody,
};
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const clientLocAddressTable = new mssql.Table('carnetsys.ClientLocAddressTable');
clientLocAddressTable.create = true;
clientLocAddressTable.columns.add('Nameof', mssql.VarChar(50));
clientLocAddressTable.columns.add('Address1', mssql.VarChar(50));
clientLocAddressTable.columns.add('Address2', mssql.VarChar(50));
clientLocAddressTable.columns.add('City', mssql.VarChar(30));
clientLocAddressTable.columns.add('State', mssql.VarChar(2));
clientLocAddressTable.columns.add('Zip', mssql.VarChar(10));
clientLocAddressTable.columns.add('Country', mssql.VarChar(2));
finalBody.P_CLIENTLOCADDRESSTABLE.forEach((contact) => {
clientLocAddressTable.rows.add(
contact.P_NAMEOF,
contact.P_ADDRESS1,
contact.P_ADDRESS2,
contact.P_CITY,
contact.P_STATE,
contact.P_ZIP,
contact.P_COUNTRY,
);
});
request.input('p_clientlocaddresstable', clientLocAddressTable);
request.input('P_USERID', mssql.VarChar(100), finalBody.P_USERID);
const result = await request.execute('carnetsys.CreateClientLocation');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
GetPreparers = async (body: GetPreparersDTO) => {
const newBody = {
P_SPID: null,
P_NAME: null,
P_LOOKUPCODE: null,
P_CITY: null,
P_STATE: null,
P_STATUS: null
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: GetPreparersDTO = {
...newBody,
...reqBody,
};
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_NAME', mssql.VarChar(50), finalBody.P_NAME);
request.input('P_LOOKUPCODE', mssql.VarChar(30), finalBody.P_LOOKUPCODE);
request.input('P_CITY', mssql.VarChar(20), finalBody.P_CITY);
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
request.input('P_STATUS', mssql.VarChar(10), finalBody.P_STATUS);
const result = await request.execute('carnetsys.GetPreparers');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
GetPreparerContactsByClientid = async (
body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) => {
const newBody = {
P_SPID: null,
P_NAME: null,
P_LOOKUPCODE: null,
P_CITY: null,
P_STATE: null,
P_STATUS: null
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: GetPreparerByClientidContactsByClientidLocByClientidDTO = {
...newBody,
...reqBody,
};
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const result = await request.execute('carnetsys.GetPreparerContactsbyClientID');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
GetPreparerLocByClientid = async (
body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) => {
const newBody = {
P_SPID: null,
P_NAME: null,
P_LOOKUPCODE: null,
P_CITY: null,
P_STATE: null,
P_STATUS: null
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: GetPreparerByClientidContactsByClientidLocByClientidDTO = {
...newBody,
...reqBody,
};
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTID', mssql.Int, finalBody.P_CLIENTID);
const result = await request.execute('carnetsys.GetPreparerLocbyClientID');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
}

View File

@ -0,0 +1,150 @@
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
import { ManageFeeService } from './manage-fee.service';
import { ApiTags } from '@nestjs/swagger';
import {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/manage-fee/manage-fee.dto';
@Controller('mssql')
export class ManageFeeController {
constructor(private readonly manageFeeService: ManageFeeService) { }
@ApiTags('Manage Fee - Mssql')
@Get('/GetBasicFeeRates')
GetBasicFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBASICFEERATES(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateBasicFee')
CreateBasicFee(@Body() body: CreateBasicFeeDTO) {
return this.manageFeeService.CREATEBASICFEE(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateBasicFee')
UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) {
return this.manageFeeService.UPDATEBASICFEE(body);
}
@ApiTags('Manage Fee - Mssql')
@Get('/GetBondRates')
GetBondRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBONDRATES(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateBondRate')
CreateBondRate(@Body() body: CreateBondRateDTO) {
return this.manageFeeService.CREATEBONDRATE(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateBondRate')
UpdateBondRate(@Body() body: UpdateBondRateDTO) {
return this.manageFeeService.UPDATEBONDRATE(body);
}
// Cargo Rate
@ApiTags('Manage Fee - Mssql')
@Get('/GetCargoRates')
GetCargoRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCARGORATES(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateCargoRate')
CreateCargoRate(@Body() body: CreateCargoRateDTO) {
return this.manageFeeService.CREATECARGORATE(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateCargoRate')
UpdateCargoRate(@Body() body: UpdateCargoRateDTO) {
return this.manageFeeService.UPDATECARGORATE(body);
}
// Counter Foil
@ApiTags('Manage Fee - Mssql')
@Get('/GetCfFeeRates')
GetCfFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCFFEERATES(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateCfFee')
CreateCfFee(@Body() body: CreateCfFeeDTO) {
return this.manageFeeService.CREATECFFEE(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateCfFee')
UpdateCfFee(@Body() body: UpdateCfFeeDTO) {
return this.manageFeeService.UPDATECFFEE(body);
}
// Continuation sheet
@ApiTags('Manage Fee - Mssql')
@Get('/GetCsFeeRates')
GetCsFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCSFEERATES(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateCsFee')
CreateCsFee(@Body() body: CreateCsFeeDTO) {
return this.manageFeeService.CREATECSFEE(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateCsFee')
UpdateCsFee(@Body() body: UpdateCsFeeDTO) {
return this.manageFeeService.UPDATECSFEE(body);
}
// Expedited Fee
@ApiTags('Manage Fee - Mssql')
@Get('/GetEfFeeRates')
GetEfFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETEFFEERATES(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateEfFee')
CreateEeFee(@Body() body: CreateEfFeeDTO) {
return this.manageFeeService.CREATEEFFEE(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateEfFee')
UpdateEfFee(@Body() body: UpdateEfFeeDTO) {
return this.manageFeeService.UPDATEEFFEE(body);
}
// Fee Comm
@ApiTags('Manage Fee - Mssql')
@Get('/GetFeeComm')
GetFeeComm(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETFEECOMM(body);
}
@ApiTags('Manage Fee - Mssql')
@Post('/CreateFeeComm')
CreateFeeComm(@Body() body: CreateFeeCommDTO) {
return this.manageFeeService.CREATEFEECOMM(body);
}
@ApiTags('Manage Fee - Mssql')
@Patch('/UpdateFeeComm')
UpdateFeeComm(@Body() body: UpdateFeeCommDTO) {
return this.manageFeeService.UPDATEFEECOMM(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageFeeController } from './manage-fee.controller';
import { ManageFeeService } from './manage-fee.service';
@Module({
controllers: [ManageFeeController],
providers: [ManageFeeService]
})
export class ManageFeeModule {}

View File

@ -0,0 +1,529 @@
import { Injectable, Logger } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { Connection, Request } from 'mssql';
import * as mssql from 'mssql';
import {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/manage-fee/manage-fee.dto';
@Injectable()
export class ManageFeeService {
private readonly logger = new Logger(ManageFeeService.name);
constructor(private readonly mssqlDBService: MssqlDBService) { }
// Basic Fee Setup
async GETBASICFEERATES(body: GetFeeGeneralDTO): Promise<any[] | Object> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetBasicFeeRates');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
throw new InternalServerException(error.message);
}
}
async CREATEBASICFEE(body: CreateBasicFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_STARTCARNETVALUE', mssql.Int, body.P_STARTNUMBER);
request.input('P_ENDCARNETVALUE', mssql.Int, body.P_ENDNUMBER);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_FEES', mssql.Int, body.P_FEES);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateBasicFee');
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", ...result.recordset[0] };
} catch (error) {
throw new InternalServerException(error.message);
}
}
async UPDATEBASICFEE(body: UpdateBasicFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_BASICFEESETUPID', mssql.Int, body.P_BASICFEESETUPID);
request.input('P_FEES', mssql.Int, body.P_FEES);
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.UpdateBasicFee');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
throw new InternalServerException(error.message);
}
}
// Bond Rate Setup
async GETBONDRATES(body: GetFeeGeneralDTO): Promise<any[] | object> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetBondRates');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async CREATEBONDRATE(body: CreateBondRateDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERTYPE', mssql.VarChar(3), body.P_HOLDERTYPE);
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(100), body.P_USCIBMEMBERFLAG);
request.input('P_SPCLCOMMODITY', mssql.VarChar(100), body.P_SPCLCOMMODITY);
request.input('P_SPCLCOUNTRY', mssql.VarChar(100), body.P_SPCLCOUNTRY);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateBondRate');
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", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async UPDATEBONDRATE(body: UpdateBondRateDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_BONDRATESETUPID', mssql.Int, body.P_BONDRATESETUPID);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateBondRate');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
throw new InternalServerException(error.message);
}
}
// CArgo Rate
async GETCARGORATES(body: GetFeeGeneralDTO): Promise<any[] | object> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetCargoRates');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
if (error instanceof BadRequestException) {
throw error
}
throw new InternalServerException(error.message);
}
}
async CREATECARGORATE(body: CreateCargoRateDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_CARNETTYPE', mssql.VarChar(20), body.P_CARNETTYPE);
request.input('P_STARTSETS', mssql.Int, body.P_STARTSETS);
request.input('P_ENDSETS', mssql.Int, body.P_ENDSETS);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateCargoRate');
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", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async UPDATECARGORATE(body: UpdateCargoRateDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_CARGORATESETUPID', mssql.Int, body.P_CARGORATESETUPID);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateCargoRate');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
// Counter Foil
async GETCFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetCFFeeRates');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
if (error instanceof BadRequestException) {
throw error
}
throw new InternalServerException(error.message);
}
}
async CREATECFFEE(body: CreateCfFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_STARTSETS', mssql.Int, body.P_STARTSETS);
request.input('P_ENDSETS', mssql.Int, body.P_ENDSETS);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_CUSTOMERTYPE', mssql.VarChar(20), body.P_CUSTOMERTYPE);
request.input('P_CARNETTYPE', mssql.VarChar(20), body.P_CARNETTYPE);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateCFFee');
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", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async UPDATECFFEE(body: UpdateCfFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_CFFEESETUPID', mssql.Int, body.P_CFFEESETUPID);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateCFFee');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
// Continuation sheet
async GETCSFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetCSFeeRates');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
if (error instanceof BadRequestException) {
throw error
}
throw new InternalServerException(error.message);
}
}
async CREATECSFEE(body: CreateCsFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_CUSTOMERTYPE', mssql.VarChar(20), body.P_CUSTOMERTYPE);
request.input('P_CARNETTYPE', mssql.VarChar(20), body.P_CARNETTYPE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateCSFee');
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", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async UPDATECSFEE(body: UpdateCsFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_CSFEESETUPID', mssql.Int, body.P_CSFEESETUPID);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateCSFee');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
// Expedited fee
async GETEFFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetEFFeeRates');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
if (error instanceof BadRequestException) {
throw error
}
throw new InternalServerException(error.message);
}
}
async CREATEEFFEE(body: CreateEfFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_CUSTOMERTYPE', mssql.VarChar(20), body.P_CUSTOMERTYPE);
request.input('P_DELIVERYTYPE', mssql.VarChar(20), body.P_DELIVERYTYPE);
request.input('P_STARTTIME', mssql.Int, body.P_STARTTIME);
request.input('P_ENDTIME', mssql.Int, body.P_ENDTIME);
request.input('P_TIMEZONE', mssql.VarChar(3), body.P_TIMEZONE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_FEES', mssql.Float, body.P_FEES);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CreateEFFee');
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", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async UPDATEEFFEE(body: UpdateEfFeeDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_EFFEESETUPID', mssql.Int, body.P_EFFEESETUPID);
request.input('P_FEES', mssql.Float, body.P_FEES);
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.UpdateEFFee');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
// fee comm
async GETFEECOMM(body: GetFeeGeneralDTO): Promise<any[]> {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spid', mssql.Int, body.P_SPID);
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
const result = await request.execute('carnetsys.GetFeecomm');
if (result.recordset) {
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 result.recordset;
}
throw new BadRequestException();
} catch (error) {
console.log(error);
if (error instanceof BadRequestException) {
throw error
}
throw new InternalServerException(error.message);
}
}
async CREATEFEECOMM(body: CreateFeeCommDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
request.input('P_COMMRATE', mssql.Float, body.P_COMMRATE);
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", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async UPDATEFEECOMM(body: UpdateFeeCommDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_FEECOMMID', mssql.Int, body.P_FEECOMMID);
request.input('P_RATE', mssql.Float, body.P_RATE);
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateFeeComm');
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: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
}

View File

@ -0,0 +1,122 @@
import { BadRequestException, Body, Controller, Get, Param, ParseIntPipe, Patch, Post, Put } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ManageHoldersService } from './manage-holders.service';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/manage-holders/manage-holders.dto';
@Controller('mssql')
export class ManageHoldersController {
constructor(private readonly manageHoldersService: ManageHoldersService) { }
@ApiTags('Manage Holders - Mssql')
@Post('/CreateHolderData')
CreateHolders(@Body() body: CreateHoldersDTO) {
return this.manageHoldersService.CreateHolders(body);
}
@ApiTags('Manage Holders - Mssql')
@Put('/UpdateHolder')
UpdateHolder(@Body() body: UpdateHolderDTO) {
return this.manageHoldersService.UpdateHolder(body);
}
@ApiTags('Manage Holders - Mssql')
@Put('/UpdateHolderContact')
UpdateHolderContact(@Body() body: UpdateHolderContactDTO) {
return this.manageHoldersService.UpdateHolderContact(body);
}
@ApiTags('Manage Holders - Mssql')
@Get('/GetHolderRecord/:p_spid/:p_holderid')
GetHolderMaster(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderRecord(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Get('/GetHolderContacts/:p_spid/:p_holderid')
GetHolderContacts(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderContacts(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
InactivateHolder(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.InactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
ReactivateHolder(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.ReactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
InactivateHolderContact(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.InactivateHolderContact(reqParams);
}
@ApiTags('Manage Holders - Mssql')
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
ReactivateHolderContact(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.ReactivateHolderContact(reqParams);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageHoldersController } from './manage-holders.controller';
import { ManageHoldersService } from './manage-holders.service';
@Module({
controllers: [ManageHoldersController],
providers: [ManageHoldersService]
})
export class ManageHoldersModule {}

View File

@ -0,0 +1,268 @@
import { Injectable } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql';
import { CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/manage-holders/manage-holders.dto';
@Injectable()
export class ManageHoldersService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
CreateHolders = async (body: CreateHoldersDTO) => {
const newBody = {
p_spid: null,
p_clientlocationid: null,
p_holderno: null,
p_holdertype: null,
p_uscibmemberflag: null,
p_govagencyflag: null,
p_holdername: null,
p_namequalifier: null,
p_addlname: null,
p_address1: null,
p_address2: null,
p_city: null,
p_state: null,
p_zip: null,
p_country: null,
p_userid: null,
p_contactstable: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: CreateHoldersDTO = { ...newBody, ...reqBody };
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_CLIENTLOCATIONID', mssql.Int, finalBody.P_CLIENTLOCATIONID);
request.input('P_HOLDERNO', mssql.VarChar(15), finalBody.P_HOLDERNO);
request.input('P_HOLDERTYPE', mssql.VarChar(3), finalBody.P_HOLDERTYPE);
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(1), finalBody.P_USCIBMEMBERFLAG);
request.input('P_GOVAGENCYFLAG', mssql.VarChar(1), finalBody.P_GOVAGENCYFLAG);
request.input('P_HOLDERNAME', mssql.VarChar(50), finalBody.P_HOLDERNAME);
request.input('P_NAMEQUALIFIER', mssql.VarChar(10), finalBody.P_NAMEQUALIFIER);
request.input('P_ADDLNAME', mssql.VarChar(50), finalBody.P_ADDLNAME);
request.input('P_ADDRESS1', mssql.VarChar(50), finalBody.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), finalBody.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), finalBody.P_CITY);
request.input('P_STATE', mssql.VarChar(2), finalBody.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), finalBody.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), finalBody.P_COUNTRY);
request.input('P_USERID', mssql.VarChar(50), finalBody.P_USERID);
const contactTable = new mssql.Table('carnetsys.ContactsTable');
contactTable.create = true;
contactTable.columns.add('FirstName', mssql.VarChar(50));
contactTable.columns.add('LastName', mssql.VarChar(50));
contactTable.columns.add('MiddleInitial', mssql.VarChar(3));
contactTable.columns.add('Title', mssql.VarChar(50));
contactTable.columns.add('EmailAddress', mssql.VarChar(100));
contactTable.columns.add('PhoneNo', mssql.VarChar(20));
contactTable.columns.add('MobileNo', mssql.VarChar(20));
contactTable.columns.add('FaxNo', mssql.VarChar(20));
finalBody.P_CONTACTSTABLE && finalBody.P_CONTACTSTABLE.forEach((contact) => {
contactTable.rows.add(
contact.P_FIRSTNAME,
contact.P_LASTNAME,
contact.P_MIDDLEINITIAL,
contact.P_TITLE,
contact.P_EMAILADDRESS,
contact.P_PHONENO,
contact.P_MOBILENO,
contact.P_FAXNO,
);
});
request.input('p_contactstable', contactTable);
const result = await request.execute('carnetsys.CreateHolderData');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
GetHolderRecord = async (body: GetHolderDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
const result = await request.execute('carnetsys.GetHolderMaster');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
UpdateHolder = async (body: UpdateHolderDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new mssql.Request(connection);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_LOCATIONID', mssql.Int, body.P_LOCATIONID);
request.input('P_HOLDERNO', mssql.VarChar(15), body.P_HOLDERNO);
request.input('P_HOLDERTYPE', mssql.VarChar(3), body.P_HOLDERTYPE);
request.input('P_USCIBMEMBERFLAG', mssql.VarChar(1), body.P_USCIBMEMBERFLAG);
request.input('P_GOVAGENCYFLAG', mssql.VarChar(1), body.P_GOVAGENCYFLAG);
request.input('P_HOLDERNAME', mssql.VarChar(50), body.P_HOLDERNAME);
request.input('P_NAMEQUALIFIER', mssql.VarChar(10), body.P_NAMEQUALIFIER);
request.input('P_ADDLNAME', mssql.VarChar(50), body.P_ADDLNAME);
request.input('P_ADDRESS1', mssql.VarChar(50), body.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(50), body.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(30), body.P_CITY);
request.input('P_STATE', mssql.VarChar(2), body.P_STATE);
request.input('P_ZIP', mssql.VarChar(10), body.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(2), body.P_COUNTRY);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateHolders');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
UpdateHolderContact = async (body: UpdateHolderContactDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new mssql.Request(connection);
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_FIRSTNAME', mssql.VarChar(50), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(50), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(3), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(50), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(20), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(20), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(20), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(100), body.P_EMAILADDRESS);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UpdateHolderContacts');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
GetHolderContacts = async (body: GetHolderDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
const result = await request.execute('carnetsys.GetHolderContacts');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
InactivateHolder = async (body: HolderActivateOrInactivateDTO) => {
console.log(body);
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.InactivateHolder');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
ReactivateHolder = async (body: HolderActivateOrInactivateDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERID', mssql.Int, body.P_HOLDERID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.ReactivateHolder');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
InactivateHolderContact = async (body: HolderContactActivateOrInactivateDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.InactivateHolderContact');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
ReactivateHolderContact = async (body: HolderContactActivateOrInactivateDTO) => {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request: Request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_HOLDERCONTACTID', mssql.Int, body.P_HOLDERCONTACTID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.ReactivateHolderContact');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
};
}

View File

@ -0,0 +1,15 @@
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { MssqlService } from './mssql.service';
@Controller('mssql')
export class MssqlController {
constructor(private readonly mssqlService: MssqlService) { }
// @ApiTags('Connection - Mssql')
// @Get('/checkConnection')
checkConnection() {
return this.mssqlService.checkConnection();
}
}

15
src/mssql/mssql.module.ts Normal file
View File

@ -0,0 +1,15 @@
import { Module } from '@nestjs/common';
import { MssqlController } from './mssql.controller';
import { MssqlService } from './mssql.service';
import { UscibManagedSpModule } from './uscib-managed-sp/uscib-managed-sp.module';
import { ManageClientsModule } from './manage-clients/manage-clients.module';
import { ManageHoldersModule } from './manage-holders/manage-holders.module';
import { ParamTableModule } from './param-table/param-table.module';
import { ManageFeeModule } from './manage-fee/manage-fee.module';
@Module({
controllers: [MssqlController],
providers: [MssqlService],
imports: [UscibManagedSpModule, ManageClientsModule, ManageHoldersModule, ParamTableModule, ManageFeeModule]
})
export class MssqlModule {}

View File

@ -0,0 +1,25 @@
import { Injectable } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
@Injectable()
export class MssqlService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async checkConnection() {
let connection : Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
const result = await request.query('SELECT GETDATE() AS CurrentDateTime');
return { data: result.recordset[0].CurrentDateTime }
} catch (error) {
console.error('Error checking connection:', error);
return {error:error.message}
}
}
}

View File

@ -0,0 +1,57 @@
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { ParamTableService } from './param-table.service';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@Controller('mssql')
export class ParamTableController {
constructor(private readonly paramTableService: ParamTableService) { }
@ApiTags('Param Table - Mssql')
@Get('/GetParamValues')
@ApiQuery({
name: 'P_SPID',
required: false,
type: Number,
description: 'The ID of the parameter',
})
@ApiQuery({
name: 'P_PARAMTYPE',
required: false,
type: String,
description: 'The type of the parameter',
})
getParamValues(@Query() body: getParamValuesDTO) {
return this.paramTableService.GETPARAMVALUES(body);
}
@ApiTags('Param Table - Mssql')
@Post('/CreateTableRecord')
createTableRecord(@Body() body: CreateTableRecordDTO) {
return this.paramTableService.CREATETABLERECORD(body);
}
@ApiTags('Param Table - Mssql')
@Post('/CreateParamRecord')
createParamRecord(@Body() body: CreateParamRecordDTO) {
return this.paramTableService.CREATEPARAMRECORD(body);
}
@ApiTags('Param Table - Mssql')
@Patch('/UpdateParamRecord')
UpdateParamRecord(@Body() body: UpdateParamRecordDTO) {
return this.paramTableService.UPDATEPARAMRECORD(body);
}
@ApiTags('Param Table - Mssql')
@Put('/InActivateParamRecord')
inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.INACTIVATEPARAMRECORD(body);
}
@ApiTags('Param Table - Mssql')
@Put('/ReActivateParamRecord')
reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.REACTIVATEPARAMRECORD(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ParamTableController } from './param-table.controller';
import { ParamTableService } from './param-table.service';
@Module({
controllers: [ParamTableController],
providers: [ParamTableService]
})
export class ParamTableModule {}

View File

@ -0,0 +1,157 @@
import { Injectable } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql';
import { Request } from 'mssql';
import { Connection } from 'mssql';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/param-table/param-table.dto';
@Injectable()
export class ParamTableService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async GETPARAMVALUES(body: getParamValuesDTO) {
const finalBody = {
P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null,
P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null,
};
console.log(finalBody);
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
request.input('P_PARAMTYPE', mssql.VarChar(100), finalBody.P_PARAMTYPE);
const result = await request.execute('carnetsys.GETPARAMVALUES');
return result.recordset;
} catch (error) {
throw new InternalServerException(error.message);
}
}
async CREATETABLERECORD(body: CreateTableRecordDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
request.input('P_TABLEFULLDESC', mssql.NVarChar, body.P_TABLEFULLDESC);
const result = await request.execute('carnetsys.CREATETABLERECORD');
// return { data: result.recordset };
if (result['recordset'][0].ERRORMSG) {
throw new BadRequestException(result[0].ERRORMSG);
}
else {
return { statusCode: 201, message: "Created Successfully" }
}
} catch (error) {
console.log(error);
throw new InternalServerException(error.message);
}
}
async CREATEPARAMRECORD(body: CreateParamRecordDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_PARAMTYPE', mssql.VarChar(255), body.P_PARAMTYPE);
request.input('P_PARAMDESC', mssql.VarChar(255), body.P_PARAMDESC);
request.input('P_PARAMVALUE', mssql.VarChar(255), body.P_PARAMVALUE);
request.input('P_ADDLPARAMVALUE1', mssql.VarChar(255), body.P_ADDLPARAMVALUE1);
request.input('P_ADDLPARAMVALUE2', mssql.VarChar(255), body.P_ADDLPARAMVALUE2);
request.input('P_ADDLPARAMVALUE3', mssql.VarChar(255), body.P_ADDLPARAMVALUE3);
request.input('P_ADDLPARAMVALUE4', mssql.VarChar(255), body.P_ADDLPARAMVALUE4);
request.input('P_ADDLPARAMVALUE5', mssql.VarChar(255), body.P_ADDLPARAMVALUE5);
request.input('P_SORTSEQ', mssql.Int, body.P_SORTSEQ);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.CREATEPARAMRECORD');
// return { data: result.recordset };
if (result['recordset'][0].ERRORMSG) {
throw new BadRequestException(result[0].ERRORMSG);
}
else {
return { statusCode: 201, message: "Created Successfully" }
}
} catch (error) {
// return { error: error.message };
throw new InternalServerException()
}
}
async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
request.input('P_PARAMDESC', mssql.VarChar(255), body.P_PARAMDESC);
request.input('P_ADDLPARAMVALUE1', mssql.VarChar(255), body.P_ADDLPARAMVALUE1);
request.input('P_ADDLPARAMVALUE2', mssql.VarChar(255), body.P_ADDLPARAMVALUE2);
request.input('P_ADDLPARAMVALUE3', mssql.VarChar(255), body.P_ADDLPARAMVALUE3);
request.input('P_ADDLPARAMVALUE4', mssql.VarChar(255), body.P_ADDLPARAMVALUE4);
request.input('P_ADDLPARAMVALUE5', mssql.VarChar(255), body.P_ADDLPARAMVALUE5);
request.input('P_SORTSEQ', mssql.Int, body.P_SORTSEQ);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.UPDATEPARAMRECORD');
// return { data: result.recordset };
if (result['recordset'][0].ERRORMSG) {
throw new BadRequestException(result[0].ERRORMSG);
}
else {
return { statusCode: 200, message: "Updated Successfully" }
}
} catch (error) {
throw new InternalServerException(error.message);
}
}
async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.INACTIVATEPARAMRECORD');
// return { data: result.recordset };
if (result['recordset'][0].ERRORMSG) {
throw new BadRequestException(result[0].ERRORMSG);
}
else {
return { statusCode: 200, message: result['recordset'][0].message }
}
} catch (error) {
throw new InternalServerException(error.message);
}
}
async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
const result = await request.execute('carnetsys.REACTIVATEPARAMRECORD');
// return { data: result.recordset };
if (result['recordset'][0].ERRORMSG) {
throw new BadRequestException(result[0].ERRORMSG);
}
else {
return { statusCode: 200, message: result['recordset'][0].message }
}
} catch (error) {
throw new InternalServerException(error.message);
}
}
}

View File

@ -0,0 +1,23 @@
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
import { CarnetSequenceService } from './carnet-sequence.service';
import { ApiTags } from '@nestjs/swagger';
import { CreateCarnetSequenceDTO } from 'src/dto/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@ApiTags('Carnet Sequence - Mssql')
@Controller('mssql')
export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
@Get('/GetCarnetSequence')
getCarnetSequence(@Query() body: SPID_DTO) {
return this.carnetSequenceService.getCarnetSequence(body);
}
@Post('/CreateCarnetSequence/')
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
return this.carnetSequenceService.createCarnetSequence(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { CarnetSequenceController } from './carnet-sequence.controller';
import { CarnetSequenceService } from './carnet-sequence.service';
@Module({
controllers: [CarnetSequenceController],
providers: [CarnetSequenceService]
})
export class CarnetSequenceModule {}

View File

@ -0,0 +1,46 @@
import { Injectable } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql'
import { CreateCarnetSequenceDTO } from 'src/dto/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@Injectable()
export class CarnetSequenceService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async getCarnetSequence(body: SPID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETCARNETSEQUENCE');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_REGIONID', mssql.Float, body.P_REGIONID);
request.input('P_STARTNUMBER', mssql.Int, body.P_STARTNUMBER);
request.input('P_ENDNUMBER', mssql.Int, body.P_ENDNUMBER);
request.input('P_CARNETTYPE', mssql.VarChar(4000), body.P_CARNETTYPE);
const result = await request.execute('carnetsys.CREATECARNETSEQUENCE');
return { data: result.recordset };
} catch (error) {
console.error('Error executing stored procedure:', error);
return { error: error.message };
}
}
}

View File

@ -0,0 +1,30 @@
import { Body, Controller, Get, Patch, Post } from '@nestjs/common';
import { ApiInternalServerErrorResponse, ApiOkResponse, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { RegionService } from './region.service';
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/uscib-managed-sp/region/region.dto';
@Controller('mssql')
export class RegionController {
constructor(private readonly regionService: RegionService) { }
@ApiTags('Regions - Mssql')
@ApiOperation({ summary: 'Get all regions for issuing and replacement.' })
@ApiInternalServerErrorResponse({ description: 'Server error' })
@Get('/GetRegions')
getRegions() {
return this.regionService.getRegions();
}
@ApiTags('Regions - Mssql')
@Post('/InsertRegions')
insertRegions(@Body() body: InsertRegionsDto) {
return this.regionService.insetNewRegions(body);
}
@ApiTags('Regions - Mssql')
@Patch('/UpdateRegion')
updateRegions(@Body() body: UpdateRegionDto) {
return this.regionService.updateRegions(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { RegionController } from './region.controller';
import { RegionService } from './region.service';
@Module({
controllers: [RegionController],
providers: [RegionService]
})
export class RegionModule {}

View File

@ -0,0 +1,55 @@
import { Injectable, InternalServerErrorException } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/uscib-managed-sp/region/region.dto';
import * as mssql from 'mssql';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
@Injectable()
export class RegionService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async getRegions() {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
const result = await request.execute('carnetsys.GETREGIONS');
return result.recordset;
} catch (error) {
throw new InternalServerException();
}
}
async insetNewRegions(body: InsertRegionsDto) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
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 { statusCode: 201, message: "Created Successfully", ...result.recordset[0] };
} catch (error) {
throw new InternalServerException();
}
}
async updateRegions(body: UpdateRegionDto){
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
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 { statusCode: 200, message: "Updated Successfully", ...result.recordset[0] };
} catch (error) {
throw new InternalServerException();
}
}
}

View File

@ -0,0 +1,52 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { SpContactsService } from './sp-contacts.service';
import { ApiTags } from '@nestjs/swagger';
import {
SPID_DTO,
SP_CONTACTID_DTO,
InsertSPContactsDTO, UpdateSPContactsDTO
} from 'src/dto/property.dto';
@Controller('mssql')
export class SpContactsController {
constructor(private readonly spContactsService: SpContactsService) { }
@ApiTags('SPContacts - Mssql')
@Post('/InactivateSPContact')
inactivateSPContact(@Query() body: SP_CONTACTID_DTO) {
return this.spContactsService.inactivateSPContact(body);
}
@ApiTags('SPContacts - Mssql')
@Get('/GetSPDefaultContact')
getSPDefaultcontact(@Query() body: SPID_DTO) {
return this.spContactsService.getSPDefaultcontacts(body);
}
@ApiTags('SPContacts - Mssql')
@Get('/GetSPAllContacts')
getSPAllContacts(@Query() body: SPID_DTO) {
return this.spContactsService.getSpAllContacts(body);
}
@ApiTags('SPContacts - Mssql')
@Post('/InsertSPContacts')
insertSPContacts(@Body() body: InsertSPContactsDTO) {
return this.spContactsService.insertSPContacts(body);
}
@ApiTags('SPContacts - Mssql')
@Post('/SetSPDefaultContact')
setSPDefaultcontact(@Query() body: SP_CONTACTID_DTO) {
return this.spContactsService.setSPDefaultcontact(body);
}
@ApiTags('SPContacts - Mssql')
@Put('/UpdateSPContacts')
updateSPContacts(@Body() body: UpdateSPContactsDTO) {
return this.spContactsService.updateSPContacts(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { SpContactsController } from './sp-contacts.controller';
import { SpContactsService } from './sp-contacts.service';
@Module({
controllers: [SpContactsController],
providers: [SpContactsService]
})
export class SpContactsModule {}

View File

@ -0,0 +1,121 @@
import { Injectable } from '@nestjs/common';
import { MssqlDBService } from 'src/db/db.service';
import * as mssql from 'mssql'
import { Connection, Request } from 'mssql';
import { SP_CONTACTID_DTO,
SPID_DTO,
InsertSPContactsDTO, UpdateSPContactsDTO
} from 'src/dto/property.dto';
@Injectable()
export class SpContactsService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async getSpAllContacts(body: SPID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETSPALLCONTACTS');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async getSPDefaultcontacts(body: SPID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETSPDEFAULTCONTACTS');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async inactivateSPContact(body: SP_CONTACTID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
const result = await request.execute('carnetsys.INACTIVATESPCONTACTS');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async insertSPContacts(body: InsertSPContactsDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.P_DEFCONTACTFLAG);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.P_EMAILADDRESS);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
const result = await request.execute('carnetsys.INSERTSPCONTACTS');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async setSPDefaultcontact(body: SP_CONTACTID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('p_spContactid', mssql.Int, body.P_SPCONTACTID);
const result = await request.execute('carnetsys.SETDEFAULTCONTACT');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async updateSPContacts(body: UpdateSPContactsDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPCONTACTID', mssql.Int, body.P_SPCONTACTID);
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.P_FIRSTNAME);
request.input('P_LASTNAME', mssql.VarChar(4000), body.P_LASTNAME);
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
request.input('P_TITLE', mssql.VarChar(4000), body.P_TITLE);
request.input('P_PHONENO', mssql.VarChar(4000), body.P_PHONENO);
request.input('P_MOBILENO', mssql.VarChar(4000), body.P_MOBILENO);
request.input('P_FAXNO', mssql.VarChar(4000), body.P_FAXNO);
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.P_EMAILADDRESS);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
const result = await request.execute('carnetsys.UPDATESPCONTACTS');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
}

View File

@ -0,0 +1,35 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { SpService } from './sp.service';
import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/dto/uscib-managed-sp/sp/sp.dto';
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@Controller('mssql')
export class SpController {
constructor(private readonly spService: SpService) { }
@ApiTags('SP - Mssql')
@Get('/GetAllServiceproviders')
getAllServiceproviders() {
return this.spService.getAllServiceproviders();
}
@ApiTags('SP - Mssql')
@Get('/GetSelectedServiceprovider')
getSelectedServiceprovider(@Query() body: SPID_DTO) {
return this.spService.getSpBySpid(body);
}
@ApiTags('SP - Mssql')
@Post('/InsertNewServiceProvider')
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
return this.spService.insertNewServiceProvider(body);
}
@ApiTags('SP - Mssql')
@Put('/UpdateServiceProvider')
updateServiceProider(@Body() body: UpdateServiceProviderDTO) {
return this.spService.updateServiceProvider(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { SpController } from './sp.controller';
import { SpService } from './sp.service';
@Module({
controllers: [SpController],
providers: [SpService]
})
export class SpModule {}

View File

@ -0,0 +1,100 @@
import { Injectable } from '@nestjs/common';
import { Connection, Request } from 'mssql';
import { MssqlDBService } from 'src/db/db.service';
import { InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/dto/uscib-managed-sp/sp/sp.dto';
import * as mssql from 'mssql'
import { SPID_DTO } from 'src/dto/uscib-managed-sp/sp/sp-property.dto';
@Injectable()
export class SpService {
constructor(private readonly mssqlDBService: MssqlDBService) { }
async getAllServiceproviders() {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
const result = await request.execute('carnetsys.GETALLSPS');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async getSpBySpid(body: SPID_DTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
const result = await request.execute('carnetsys.GETSPBYSPID');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async insertNewServiceProvider(body: InsertNewServiceProviderDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_NAME', mssql.VarChar(4000), body.P_NAME);
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.P_LOOKUPCODE);
request.input('P_ADDRESS1', mssql.VarChar(4000), body.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(4000), body.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(4000), body.P_CITY);
request.input('P_STATE', mssql.VarChar(4000), body.P_STATE);
request.input('P_ZIP', mssql.VarChar(4000), body.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(4000), body.P_COUNTRY);
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.P_ISSUINGREGION);
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.P_REPLACEMENTREGION);
request.input('P_BONDSURETY', mssql.VarChar(4000), body.P_BONDSURETY);
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.P_CARGOPOLICYNO);
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.P_CARGOSURETY);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
const result = await request.execute('carnetsys.INSERTNEWSP');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
async updateServiceProvider(body: UpdateServiceProviderDTO) {
let connection: Connection;
try {
connection = await this.mssqlDBService.getConnection();
const request = new Request(connection);
request.input('P_SPID', mssql.Int, body.P_SPID);
request.input('P_NAME', mssql.VarChar(4000), body.P_NAME);
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.P_LOOKUPCODE);
request.input('P_ADDRESS1', mssql.VarChar(4000), body.P_ADDRESS1);
request.input('P_ADDRESS2', mssql.VarChar(4000), body.P_ADDRESS2);
request.input('P_CITY', mssql.VarChar(4000), body.P_CITY);
request.input('P_STATE', mssql.VarChar(4000), body.P_STATE);
request.input('P_ZIP', mssql.VarChar(4000), body.P_ZIP);
request.input('P_COUNTRY', mssql.VarChar(4000), body.P_COUNTRY);
request.input('P_BONDSURETY', mssql.VarChar(4000), body.P_BONDSURETY);
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.P_CARGOPOLICYNO);
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.P_CARGOSURETY);
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.P_REPLACEMENTREGION);
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.P_ISSUINGREGION);
request.input('P_USER_ID', mssql.VarChar(4000), body.P_USER_ID);
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
const result = await request.execute('carnetsys.UPDATESP');
return { data: result.recordset };
} catch (error) {
return { error: error.message };
}
}
}

View File

@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { RegionModule } from './region/region.module';
import { SpModule } from './sp/sp.module';
import { CarnetSequenceModule } from './carnet-sequence/carnet-sequence.module';
import { SpContactsModule } from './sp-contacts/sp-contacts.module';
@Module({
imports: [RegionModule, SpModule, CarnetSequenceModule, SpContactsModule]
})
export class UscibManagedSpModule {}

View File

@ -0,0 +1,86 @@
import { Body, Controller, Patch, Post, Put } from '@nestjs/common';
import { CarnetApplicationService } from './carnet-application.service';
import { ApiTags } from '@nestjs/swagger';
import {
AddCountriesDTO,
AddGenerallistItemsDTO,
CA_UpdateHolderDTO,
CarnetProcessingCenterDTO, CreateApplicationDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
UpdateExpGoodsAuthRepDTO,
UpdateShippingDetailsDTO
} from 'src/dto/property.dto';
@ApiTags('Carnet Application - Oracle')
@Controller('oracle')
export class CarnetApplicationController {
constructor(private readonly carnetApplicationService: CarnetApplicationService) { }
// [ CARNETAPPLICATION_PKG ]
@Post('SaveCarnetApplication')
async CreateClientData(@Body() body: SaveCarnetApplicationDTO) {
return this.carnetApplicationService.SaveCarnetApplication(body);
}
@Post('TransmitApplicationtoProcess')
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
return this.carnetApplicationService.TransmitApplicationtoProcess(body);
}
@Post('CreateApplication')
CreateApplication(@Body() body: CreateApplicationDTO) {
return this.carnetApplicationService.CreateApplication(body);
}
@Patch('update-holder')
UpdateHolder(@Body() body: CA_UpdateHolderDTO) {
return this.carnetApplicationService.UpdateHolder(body);
}
@Patch('UpdateExpGoodsAuthRep')
UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) {
return this.carnetApplicationService.UpdateExpGoodsAuthRep(body);
}
@Post('AddGenerallistItems')
AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
return this.carnetApplicationService.AddGenerallistItems(body);
}
@Post('AddCountries')
AddCountries(@Body() body: AddCountriesDTO) {
return this.carnetApplicationService.AddCountries(body);
}
@Patch('UpdateShippingDetails')
UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
return this.carnetApplicationService.UpdateShippingDetails(body);
}
// processing [ PROCESSINGCENTER_PKG ]
@Patch('ProcessOriginalCarnet')
ProcessOriginalCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.ProcessOriginalCarnet(body);
}
@Patch('UpdatePrintCarnet')
UpdatePrintCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.UpdatePrintCarnet(body);
}
@Patch('VoidCarnet')
VoidCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.VoidCarnet(body);
}
@Patch('DuplicateCarnet')
DuplicateCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.DuplicateCarnet(body);
}
@Patch('CloseCarnet')
CloseCarnet(@Body() body: CarnetProcessingCenterDTO) {
return this.carnetApplicationService.CloseCarnet(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { CarnetApplicationController } from './carnet-application.controller';
import { CarnetApplicationService } from './carnet-application.service';
@Module({
controllers: [CarnetApplicationController],
providers: [CarnetApplicationService]
})
export class CarnetApplicationModule {}

View File

@ -0,0 +1,705 @@
import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import {
COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO,
CarnetProcessingCenterDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
CreateApplicationDTO,
UpdateExpGoodsAuthRepDTO,
AddGenerallistItemsDTO,
AddCountriesDTO,
UpdateShippingDetailsDTO,
CA_UpdateHolderDTO
} from 'src/dto/property.dto';
import { OracleService } from '../oracle.service';
@Injectable()
export class CarnetApplicationService {
private readonly logger = new Logger(CarnetApplicationService.name);
constructor(
private readonly oracleDBService: OracleDBService,
private readonly oracleService: OracleService
) { }
// [ CARNETAPPLICATION_PKG ]
async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
const newBody = {
P_SPID: null, //
P_CLIENTID: null,
P_LOCATIONID: null,
P_USERID: null, //
P_HEADERID: null,
P_APPLICATIONNAME: null,
P_HOLDERID: null,
P_COMMERCIALSAMPLEFLAG: null,
P_PROFEQUIPMENTFLAG: null,
P_EXHIBITIONSFAIRFLAG: null,
P_AUTOFLAG: null,
P_HORSEFLAG: null,
P_AUTHREP: null,
P_GLTABLE: null,
P_USSETS: null,
P_COUNTRYTABLE: null,
P_SHIPTOTYPE: null,
P_SHIPADDRID: null,
P_FORMOFSECURITY: null,
P_INSPROTECTION: null,
P_LDIPROTECTION: null,
P_DELIVERYTYPE: null,
P_DELIVERYMETHOD: null,
P_PAYMENTMETHOD: null,
P_CUSTCOURIERNO: null,
P_REFNO: null,
P_NOTES: null,
};
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody = { ...newBody, ...reqBody };
let connection;
try {
connection = await this.oracleDBService.getConnection();
// const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
// return res;
// const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
// if (typeof GLTABLE !== 'function') {
// throw new InternalServerException('GLTABLE is not a constructor');
// }
// async function createGLArrayInstance(
// ITEMNO,
// ITEMDESCRIPTION,
// ITEMVALUE,
// NOOFPIECES,
// ITEMWEIGHT,
// ITEMWEIGHTUOM,
// GOODSORIGINCOUNTRY,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.GLARRAY(:ITEMNO, :ITEMDESCRIPTION, :ITEMVALUE, :NOOFPIECES, :ITEMWEIGHT, :ITEMWEIGHTUOM, :GOODSORIGINCOUNTRY) FROM dual`,
// {
// ITEMNO,
// ITEMDESCRIPTION,
// ITEMVALUE,
// NOOFPIECES,
// ITEMWEIGHT,
// ITEMWEIGHTUOM,
// GOODSORIGINCOUNTRY,
// },
// );
// console.log(result.rows);
// return result.rows[0][0];
// }
// const GLTABLE_ARRAY: GLTABLE_DTO = {
// P_GLTABLE: await Promise.all(
// (finalBody.P_GLTABLE ?? []).map(async (x: GLTABLE_ROW_DTO) => {
// return await createGLArrayInstance(
// x.ITEMNO,
// x.ITEMDESCRIPTION,
// x.ITEMVALUE,
// x.NOOFPIECES,
// x.ITEMWEIGHT,
// x.ITEMWEIGHTUOM,
// x.GOODSORIGINCOUNTRY,
// );
// })
// )
// };
// const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY.P_GLTABLE ?? []);
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(finalBody);
// const COUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
// if (typeof COUNTRYTABLE !== 'function') {
// throw new Error('COUNTRYTABLE is not a constructor');
// }
// async function createCarnetCountryArrayInstance(
// P_VISISTTRANSITIND,
// COUNTRYCODE,
// NOOFTIMESENTLEAVE,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.CARNETCOUNTRYARRAY(:P_VISISTTRANSITIND, :COUNTRYCODE, :NOOFTIMESENTLEAVE) FROM dual`,
// {
// P_VISISTTRANSITIND,
// COUNTRYCODE,
// NOOFTIMESENTLEAVE,
// },
// );
// console.log(result.rows);
// return result.rows[0][0];
// }
// const COUNTRYTABLE_ARRAY: COUNTRYTABLE_DTO = {
// P_COUNTRYTABLE: await Promise.all(
// (finalBody.P_COUNTRYTABLE ?? []).map(async (x: COUNTRYTABLE_ROW_DTO) => {
// return await createCarnetCountryArrayInstance(
// x.P_VISISTTRANSITIND,
// x.COUNTRYCODE,
// x.NOOFTIMESENTLEAVE,
// );
// })
// )
// };
// const COUNTRYTABLE_INSTANCE = new COUNTRYTABLE(COUNTRYTABLE_ARRAY.P_COUNTRYTABLE ?? []);
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(finalBody);
// return { aa:GLTABLE_ARRAY, ab:COUNTRYTABLE_ARRAY, a: GLTABLE_INSTANCE, b: COUNTRYTABLE_INSTANCE }
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.SaveCarnetApplication(
:P_SPID, :P_CLIENTID, :P_LOCATIONID, :P_USERID, :P_HEADERID, :P_APPLICATIONNAME, :P_HOLDERID, :P_COMMERCIALSAMPLEFLAG, :P_PROFEQUIPMENTFLAG, :P_EXHIBITIONSFAIRFLAG, :P_AUTOFLAG, :P_HORSEFLAG, :P_AUTHREP, :P_GLTABLE, :P_USSETS, :P_COUNTRYTABLE, :P_SHIPTOTYPE, :P_SHIPADDRID, :P_FORMOFSECURITY, :P_INSPROTECTION, :P_LDIPROTECTION, :P_DELIVERYTYPE, :P_DELIVERYMETHOD, :P_PAYMENTMETHOD, :P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_VARCHAR },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
P_COMMERCIALSAMPLEFLAG: { val: body.P_COMMERCIALSAMPLEFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_PROFEQUIPMENTFLAG: { val: body.P_PROFEQUIPMENTFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_EXHIBITIONSFAIRFLAG: { val: body.P_EXHIBITIONSFAIRFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_AUTOFLAG: { val: body.P_AUTOFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_HORSEFLAG: { val: body.P_HORSEFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_VARCHAR },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER },
P_FORMOFSECURITY: { val: body.P_FORMOFSECURITY, type: oracledb.DB_TYPE_VARCHAR },
P_INSPROTECTION: { val: body.P_INSPROTECTION, type: oracledb.DB_TYPE_VARCHAR },
P_LDIPROTECTION: { val: body.P_LDIPROTECTION, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYMETHOD: { val: body.P_DELIVERYMETHOD, type: oracledb.DB_TYPE_VARCHAR },
P_PAYMENTMETHOD: { val: body.P_PAYMENTMETHOD, type: oracledb.DB_TYPE_VARCHAR },
P_CUSTCOURIERNO: { val: body.P_CUSTCOURIERNO, type: oracledb.DB_TYPE_VARCHAR },
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_VARCHAR },
P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
:P_SPID, :P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async CreateApplication(body: CreateApplicationDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.CreateApplication(
:P_SPID, :P_CLIENTID, :P_LOCATIONID, :P_USERID,
:P_APPLICATIONNAME, :P_ORDERTYPE, :P_ERRORMESG
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_ORDERTYPE: { val: body.P_ORDERTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateHolder(body: CA_UpdateHolderDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateHolder(
:P_HEADERID, :P_HOLDERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateExpGoodsAuthRep(
:P_HEADERID, :P_COMMERCIALSAMPLEFLAG, :P_PROFEQUIPMENTFLAG,
:P_EXHIBITIONSFAIRFLAG, :P_AUTOFLAG, :P_HORSEFLAG, :P_AUTHREP,
:P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_COMMERCIALSAMPLEFLAG: { val: body.P_COMMERCIALSAMPLEFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_PROFEQUIPMENTFLAG: { val: body.P_PROFEQUIPMENTFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_EXHIBITIONSFAIRFLAG: { val: body.P_EXHIBITIONSFAIRFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_AUTOFLAG: { val: body.P_AUTOFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_HORSEFLAG: { val: body.P_HORSEFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddGenerallistItems(body: AddGenerallistItemsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddGenerallistItems(
:P_HEADERID, :P_GLTABLE, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddCountries(body: AddCountriesDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddCountries(
:P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT, typeName: 'CARNETCOUNTRYTABLE' },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateHolder(
:P_HEADERID, :P_SHIPTOTYPE, :P_SHIPADDRID, :P_FORMOFSECURITY, :P_INSPROTECTION,
:P_LDIPROTECTION, :P_DELIVERYTYPE, :P_DELIVERYMETHOD, :P_PAYMENTMETHOD,
:P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER },
P_FORMOFSECURITY: { val: body.P_FORMOFSECURITY, type: oracledb.DB_TYPE_NVARCHAR },
P_INSPROTECTION: { val: body.P_INSPROTECTION, type: oracledb.DB_TYPE_NVARCHAR },
P_LDIPROTECTION: { val: body.P_LDIPROTECTION, type: oracledb.DB_TYPE_NVARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_DELIVERYMETHOD: { val: body.P_DELIVERYMETHOD, type: oracledb.DB_TYPE_NVARCHAR },
P_PAYMENTMETHOD: { val: body.P_PAYMENTMETHOD, type: oracledb.DB_TYPE_NVARCHAR },
P_CUSTCOURIERNO: { val: body.P_CUSTCOURIERNO, type: oracledb.DB_TYPE_NVARCHAR },
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_NVARCHAR },
P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_NVARCHAR },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
// processing [ PROCESSINGCENTER_PKG ]
async ProcessOriginalCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.ProcessOriginalCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdatePrintCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.UpdatePrintCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async VoidCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.VoidCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async DuplicateCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.DuplicateCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async CloseCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.CloseCarnet(
:P_USERID, :P_HEADERID :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
}

View File

@ -0,0 +1,51 @@
import {
Get,
Param,
Controller,
} from '@nestjs/common';
import { HomePageService } from './home-page.service';
import { ApiTags } from '@nestjs/swagger';
import {
EMAIL_DTO,
GetCarnetDetailsbyCarnetStatusDTO,
SPID_DTO,
USERID_DTO
} from 'src/dto/property.dto';
@ApiTags('HomePage - Oracle')
@Controller('oracle')
export class HomePageController {
constructor(private readonly homePageService: HomePageService) { }
@Get('GetHomePageData/:P_SPID')
GetHomePageData(@Param() params: SPID_DTO) {
return this.homePageService.GetHomePageData(params);
}
@Get('GetCarnetSummaryData/:P_USERID')
GetCarnetSummaryData(@Param() params: USERID_DTO) {
return this.homePageService.GetCarnetSummaryData(params);
}
@Get('GetCarnetDetailsbyCarnetStatus/:P_SPID/:P_USERID/:P_CARNETSTATUS')
GetCarnetDetailsbyCarnetStatus(@Param() params: GetCarnetDetailsbyCarnetStatusDTO) {
return this.homePageService.GetCarnetDetailsbyCarnetStatus(params);
}
// NOTE : this has been moved to carent-application module
// @Post('/oracle/SaveCarnetApplication')
// SaveCarnetApplication(@Body() body: SaveCarnetApplicationDTO) {
// return this.homePageService.SaveCarnetApplication(body);
// }
// NOTE : this has been moved to carent-application module
// @Post('/oracle/TransmitApplicationtoProcess')
// TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
// return this.homePageService.TransmitApplicationtoProcess(body);
// }
}

View File

@ -0,0 +1,363 @@
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
IsArray,
IsDefined,
IsInt,
IsNumber,
IsOptional,
IsString,
Length,
Max,
Min,
ValidateNested,
} from 'class-validator';
// export class p_gltableDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property ItemNo must not exceed 999999999' })
// @Min(0, { message: 'Property ItemNo must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property ItemNo must be a number' })
// @IsDefined({ message: 'Property ItemNo is required' })
// ItemNo: number;
// @ApiProperty({ required: true })
// @Length(0, 1000, {
// message: 'Property ItemDescription must be between 1 and 1000 characters',
// })
// @IsString({ message: 'Property ItemDescription should be string' })
// @IsDefined({ message: 'Property ItemDescription is required' })
// ItemDescription: string;
// @ApiProperty({ required: true })
// @IsNumber({}, { message: 'Property ItemValue should be number' })
// @IsDefined({ message: 'Property ItemValue is required' })
// ItemValue: number;
// @ApiProperty({ required: true })
// @Max(99999999999, {
// message: 'Property Noofpieces must not exceed 99999999999',
// })
// @Min(0, { message: 'Property Noofpieces must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property Noofpieces must be a number' })
// @IsDefined({ message: 'Property Noofpieces is required' })
// Noofpieces: number;
// @ApiProperty({ required: false })
// @IsNumber()
// @IsOptional()
// ItemWeight?: number;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property ItemWeightUOM must be between 0 and 10 characters',
// })
// @IsString()
// @IsOptional()
// ItemWeightUOM?: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property GoodsOriginCountry must be between 0 and 2 characters',
// })
// @IsString({ message: 'Property GoodsOriginCountry should be string' })
// @IsDefined({ message: 'Property name is required' })
// GoodsOriginCountry: string;
// }
// export class p_countrytableDTO {
// @ApiProperty({ required: true })
// @Length(0, 1, {
// message: 'Property VisitTransitInd must be 0 to 1 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property VisitTransitInd is required' })
// VisitTransitInd: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property CountryCode must be between 0 to 2 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property CountryCode is required' })
// CountryCode: string;
// @ApiProperty({ required: true })
// @Max(999, { message: 'Property NoOfTimesEntLeave must not exceed 999' })
// @Min(0, { message: 'Property NoOfTimesEntLeave must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property NoOfTimesEntLeave must be a number' })
// @IsDefined({ message: 'Property NoOfTimesEntLeave is required' })
// NoOfTimesEntLeave: number;
// }
// export class SaveCarnetApplicationDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// p_clientid: number;
// @ApiProperty({ required: true })
// @Max(999999999, {
// message: 'Property p_locationid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_locationid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_locationid must be a number' })
// p_locationid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_userid must be between 0 to 50 characters',
// })
// @IsString()
// p_userid: string;
// @ApiProperty({ required: false })
// @Max(999999999, { message: 'Property p_headerid must not exceed 999999999' })
// @Min(0, { message: 'Property p_headerid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_headerid must be a number' })
// @IsOptional()
// p_headerid?: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_applicationname must be between 0 to 50 characters',
// })
// @IsString()
// p_applicationname: string;
// @ApiProperty({ required: false })
// @Max(999999999, { message: 'Property p_holderid must not exceed 999999999' })
// @Min(0, { message: 'Property p_holderid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_holderid must be a number' })
// @IsOptional()
// p_holderid?: number;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message:
// 'Property p_commercialsampleflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_commercialsampleflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_profequipmentflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_profequipmentflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_exhibitionsfairflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_exhibitionsfairflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_autoflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_autoflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_horseflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_horseflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 200, {
// message: 'Property p_authrep must be between 0 to 200 characters',
// })
// @IsString()
// @IsOptional()
// p_authrep?: string;
// @ApiProperty({ required: false, type: () => [p_gltableDTO] })
// @Type(() => p_gltableDTO)
// @ValidateNested({ each: true })
// @IsArray()
// // @ArrayNotEmpty({message:"Property gltable should not be empty"})
// @IsOptional()
// p_gltable?: p_gltableDTO[];
// @ApiProperty({ required: false })
// @Max(99999, { message: 'Property p_ussets must not exceed 99999' })
// @Min(0, { message: 'Property p_ussets must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_ussets must be a number' })
// @IsOptional()
// p_ussets?: number;
// @ApiProperty({ required: false, type: () => [p_countrytableDTO] })
// @ValidateNested({ each: true })
// @IsArray()
// @Type(() => p_countrytableDTO)
// @IsOptional()
// p_countrytable?: p_countrytableDTO[];
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_shiptotype must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_shiptotype?: string;
// @ApiProperty({ required: false })
// @Max(999999999, {
// message: 'Property p_shipaddrid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_shipaddrid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_shipaddrid must be a number' })
// @IsOptional()
// p_shipaddrid?: number;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_formofsecurity must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_formofsecurity?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_insprotection must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_insprotection?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_ldiprotection must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_ldiprotection?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_deliverytype must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_deliverytype?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_deliverymethod must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_deliverymethod?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_paymentmethod must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_paymentmethod?: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_custcourierno must be between 0 to 20 characters',
// })
// @IsString()
// @IsOptional()
// p_custcourierno?: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_refno must be between 0 to 20 characters',
// })
// @IsString()
// @IsOptional()
// p_refno?: string;
// @ApiProperty({ required: false })
// @Length(0, 2000, {
// message: 'Property p_notes must be between 0 to 2000 characters',
// })
// @IsString()
// @IsOptional()
// p_notes?: string;
// }
// export class TransmitApplicationtoProcessDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_userid must be between 0 to 50 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_headerid must be a number' })
// @IsDefined({ message: 'Property p_headerid is required' })
// p_headerid: number;
// }
// export class GetCarnetDetailsbyCarnetStatusDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_userid must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_userid must be string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// @ApiProperty({ required: true })
// @Length(0, 20, {
// message: 'Property p_CarnetStatus must be between 0 to 20 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property p_CarnetStatus is required' })
// p_CarnetStatus: string;
// }

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { HomePageService } from './home-page.service';
import { HomePageController } from './home-page.controller';
import { DbModule } from 'src/db/db.module';
@Module({
imports: [DbModule],
providers: [HomePageService],
controllers: [HomePageController],
})
export class HomePageModule {}

View File

@ -0,0 +1,890 @@
import { Injectable } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb';
import {
EMAIL_DTO,
GetCarnetDetailsbyCarnetStatusDTO,
SPID_DTO,
USERID_DTO
} from 'src/dto/property.dto';
@Injectable()
export class HomePageService {
constructor(private readonly oracleDBService: OracleDBService) { }
async GetHomePageData(params: SPID_DTO) {
let connection;
let p_basic_details = [];
let p_contacts = [];
let p_sequence = [];
let p_fees_comm = [];
let p_bf_fee = [];
let p_cf_Fee = [];
let p_cont_sheet_fee = [];
let p_ef_fee = [];
let p_security_deposit = [];
let p_param = [];
let p_region = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
USERLOGIN_PKG.GetHomePageData(
:P_SPID,
:p_basic_details_cur,
:p_contacts_cur,
:p_sequence_cur,
:p_fees_comm_cur,
:p_bf_fee_cur,
:p_cf_Fee_cur,
:p_cont_sheet_fee_cur,
:p_ef_fee_cur,
:p_security_deposit_cur,
:p_param_cur,
:p_region_cur
);
END;`,
{
P_SPID: {
val: params.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
p_basic_details_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_contacts_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_sequence_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_fees_comm_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_bf_fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_cf_Fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_cont_sheet_fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_ef_fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_security_deposit_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_param_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_region_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
if (result.outBinds && result.outBinds.p_basic_details_cur) {
const cursor = result.outBinds.p_basic_details_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_basic_details = p_basic_details.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_contacts_cur) {
const cursor = result.outBinds.p_contacts_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_contacts = p_contacts.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_sequence_cur) {
const cursor = result.outBinds.p_sequence_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_sequence = p_sequence.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_fees_comm_cur) {
const cursor = result.outBinds.p_fees_comm_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_fees_comm = p_fees_comm.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_bf_fee_cur) {
const cursor = result.outBinds.p_bf_fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_bf_fee = p_bf_fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_cf_Fee_cur) {
const cursor = result.outBinds.p_cf_Fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_cf_Fee = p_cf_Fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_cont_sheet_fee_cur) {
const cursor = result.outBinds.p_cont_sheet_fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_cont_sheet_fee = p_cont_sheet_fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_ef_fee_cur) {
const cursor = result.outBinds.p_ef_fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_ef_fee = p_ef_fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_security_deposit_cur) {
const cursor = result.outBinds.p_security_deposit_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_security_deposit = p_security_deposit.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_param_cur) {
const cursor = result.outBinds.p_param_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_param = p_param.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_region_cur) {
const cursor = result.outBinds.p_region_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_region = p_region.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
const tableData = {
p_basic_details,
p_contacts,
p_sequence,
p_fees_comm,
p_bf_fee,
p_cf_Fee,
p_cont_sheet_fee,
p_ef_fee,
p_security_deposit,
p_param,
p_region,
};
const output = {};
for (const key in tableData) {
// console.log(key);
output[key] = tableData[key].map((obj) => {
const newObj = { ...obj };
for (const innerKey in obj) {
if (key === 'p_fees_comm') {
if (innerKey.includes(' ')) {
// Check if the key has a space
const newKey = innerKey.replace(/ /g, '_').toUpperCase(); // Replace spaces and convert to uppercase
newObj[newKey] = obj[innerKey]; // Add the new key
delete newObj[innerKey]; // Remove the old key
}
}
}
return newObj;
});
}
return output;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
}
}
async GetCarnetSummaryData(body: USERID_DTO) {
let connection;
let rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
USERLOGIN_PKG.GetCarnetSummaryData(:P_USERID,:P_CURSOR);
END;`,
{
P_USERID: {
val: body.P_USERID,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
rows = rows.map((obj) => {
// Create a new object to hold the modified keys
const newObj = {};
// Iterate over the keys of the current object
for (const key in obj) {
// Replace spaces with underscores in the key
const newKey = key.replace(/ /g, '_');
newObj[newKey] = obj[key];
}
return newObj;
});
rows = rows.reduce((acc, curr) => {
// Find if the current item already exists in the accumulator
const existing = acc.find(
(item) =>
item['Service_Provider_Name'] === curr['Service_Provider_Name'] &&
item.SPID === curr.SPID,
);
if (existing) {
// If it exists, push the current "cs" and "c c" values into the arrays
existing.CARNETSTATUS.push(curr.CARNETSTATUS);
existing['Carnet_Count'].push(curr['Carnet_Count']);
} else {
// If it doesn't exist, create a new entry
acc.push({
Service_Provider_Name: curr['Service_Provider_Name'],
SPID: curr.SPID,
CARNETSTATUS: [curr.CARNETSTATUS],
Carnet_Count: [curr['Carnet_Count']],
});
}
return acc;
}, []);
return rows;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
}
}
// NOTE : this has been moved to carent-application module
// async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
// const newBody = {
// p_headerid: null,
// p_holderid: null,
// p_commercialsampleflag: null,
// p_profequipmentflag: null,
// p_exhibitionsfairflag: null,
// p_autoflag: null,
// p_horseflag: null,
// p_authrep: null,
// p_gltable: null,
// p_ussets: null,
// p_countrytable: null,
// p_shiptotype: null,
// p_shipaddrid: null,
// p_formofsecurity: null,
// p_insprotection: null,
// p_ldiprotection: null,
// p_deliverytype: null,
// p_deliverymethod: null,
// p_paymentmethod: null,
// p_custcourierno: null,
// p_refno: null,
// p_notes: null,
// };
// const reqBody = JSON.parse(JSON.stringify(body));
// function setEmptyStringsToNull(obj) {
// Object.keys(obj).forEach((key) => {
// if (typeof obj[key] === 'object' && obj[key] !== null) {
// setEmptyStringsToNull(obj[key]);
// } else if (obj[key] === '') {
// obj[key] = null;
// }
// });
// }
// setEmptyStringsToNull(reqBody);
// const finalBody = { ...newBody, ...reqBody };
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new Error('No DB Connected');
// }
// console.log('here ------------ 1');
// // const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
// async function createGLArrayInstance(
// connection,
// itemNo,
// itemDescription,
// itemValue,
// noOfPieces,
// itemWeight,
// itemWeightUOM,
// goodsOriginCountry,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.GLARRAY(:itemNo, :itemDescription, :itemValue, :noOfPieces, :itemWeight, :itemWeightUOM, :goodsOriginCountry) FROM dual`,
// {
// itemNo,
// itemDescription,
// itemValue,
// noOfPieces,
// itemWeight,
// itemWeightUOM,
// goodsOriginCountry,
// },
// );
// return result.rows[0][0]; // Access the first row and first column to get the GLARRAY instance
// }
// async function createCarnetCountryArrayInstance(
// connection,
// visitTransitInd,
// countryCode,
// noOfTimesEntLeave,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.CARNETCOUNTRYARRAY(:visitTransitInd, :countryCode, :noOfTimesEntLeave) FROM dual`,
// {
// visitTransitInd,
// countryCode,
// noOfTimesEntLeave,
// },
// );
// return result.rows[0][0]; // Access the first row and first column to get the CARNETCOUNTRYARRAY instance
// }
// // let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
// // let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
// const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
// // const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
// const CARNETCOUNTRYTABLE = await connection.getDbObjectClass(
// 'CARNETSYS.CARNETCOUNTRYTABLE',
// );
// // Check if GLTABLE is a constructor
// if (typeof GLTABLE !== 'function') {
// throw new Error('GLTABLE is not a constructor');
// }
// if (typeof CARNETCOUNTRYTABLE !== 'function') {
// throw new Error('CARNETCOUNTRYTABLE is not a constructor');
// }
// const GLTABLE_ARRAY = finalBody.p_gltable
// ? await Promise.all(
// finalBody.p_gltable.map(async (x: p_gltableDTO) => {
// return await createGLArrayInstance(
// connection,
// x.ItemNo,
// x.ItemDescription,
// x.ItemValue,
// x.Noofpieces,
// x.ItemWeight,
// x.ItemWeightUOM,
// x.GoodsOriginCountry,
// );
// }),
// )
// : [];
// const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable
// ? await Promise.all(
// finalBody.p_countrytable.map(async (x) => {
// return await createCarnetCountryArrayInstance(
// connection,
// x.VisitTransitInd,
// x.CountryCode,
// x.NoOfTimesEntLeave,
// );
// }),
// )
// : [];
// const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
// const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(
// CARNETCOUNTRYTABLE_ARRAY,
// );
// const result = await connection.execute(
// `BEGIN
// CARNETAPPLICATION_PKG.SaveCarnetApplication(
// :P_SPID,
// :p_clientid,
// :p_locationid,
// :P_USERID,
// :p_headerid,
// :p_applicationname,
// :p_holderid,
// :p_commercialsampleflag,
// :p_profequipmentflag,
// :p_exhibitionsfairflag,
// :p_autoflag,
// :p_horseflag,
// :p_authrep,
// :p_gltable,
// :p_ussets,
// :p_countrytable,
// :p_shiptotype,
// :p_shipaddrid,
// :p_formofsecurity,
// :p_insprotection,
// :p_ldiprotection,
// :p_deliverytype,
// :p_deliverymethod,
// :p_paymentmethod,
// :p_custcourierno,
// :p_refno,
// :p_notes,
// :P_CURSOR
// );
// END;`,
// {
// P_SPID: {
// val: finalBody.P_SPID ? finalBody.P_SPID : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_clientid: {
// val: finalBody.p_clientid ? finalBody.p_clientid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_locationid: {
// val: finalBody.p_locationid ? finalBody.p_locationid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: finalBody.P_USERID ? finalBody.P_USERID : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_headerid: {
// val: finalBody.p_headerid ? finalBody.p_headerid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_applicationname: {
// val: finalBody.p_applicationname
// ? finalBody.p_applicationname
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_holderid: {
// val: finalBody.p_holderid ? finalBody.p_holderid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_commercialsampleflag: {
// val: finalBody.p_commercialsampleflag
// ? finalBody.p_commercialsampleflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_profequipmentflag: {
// val: finalBody.p_profequipmentflag
// ? finalBody.p_profequipmentflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_exhibitionsfairflag: {
// val: finalBody.p_exhibitionsfairflag
// ? finalBody.p_exhibitionsfairflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_autoflag: {
// val: finalBody.p_autoflag ? finalBody.p_autoflag : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_horseflag: {
// val: finalBody.p_horseflag ? finalBody.p_horseflag : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_authrep: {
// val: finalBody.p_authrep ? finalBody.p_authrep : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_gltable: {
// val: GLTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_ussets: {
// val: finalBody.p_ussets ? finalBody.p_ussets : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_countrytable: {
// val: CARNETCOUNTRYTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_shiptotype: {
// val: finalBody.p_shiptotype ? finalBody.p_shiptotype : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_shipaddrid: {
// val: finalBody.p_shipaddrid ? finalBody.p_shipaddrid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_formofsecurity: {
// val: finalBody.p_formofsecurity ? finalBody.p_formofsecurity : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_insprotection: {
// val: finalBody.p_insprotection ? finalBody.p_insprotection : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_ldiprotection: {
// val: finalBody.p_ldiprotection ? finalBody.p_ldiprotection : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_deliverytype: {
// val: finalBody.p_deliverytype ? finalBody.p_deliverytype : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_deliverymethod: {
// val: finalBody.p_deliverymethod ? finalBody.p_deliverymethod : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_paymentmethod: {
// val: finalBody.p_paymentmethod ? finalBody.p_paymentmethod : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_custcourierno: {
// val: finalBody.p_custcourierno ? finalBody.p_custcourierno : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_refno: {
// val: finalBody.p_refno ? finalBody.p_refno : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_notes: {
// val: finalBody.p_notes ? finalBody.p_notes : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new Error('No cursor returned from the stored procedure');
// }
// return rows;
// } catch (err) {
// if (err instanceof Error) {
// return { error: err.message };
// } else {
// return { error: 'An unknown error occurred' };
// }
// }
// finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// console.error('Failed to close connection:', closeErr);
// }
// }
// }
// }
// NOTE : this has been moved to carent-application module
// async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new Error('No DB Connected');
// }
// const result = await connection.execute(
// `BEGIN
// CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
// :P_SPID,
// :P_USERID,
// :p_headerid,
// :P_CURSOR
// );
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_headerid: {
// val: body.p_headerid,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new Error('No cursor returned from the stored procedure');
// }
// return rows;
// // return fres
// } catch (err) {
// if (err instanceof Error) {
// return { error: err.message };
// } else {
// return { error: 'An unknown error occurred' };
// }
// }
// finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// console.error('Failed to close connection:', closeErr);
// }
// }
// }
// }
async GetCarnetDetailsbyCarnetStatus(body: GetCarnetDetailsbyCarnetStatusDTO) {
let connection;
let rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetCarnetDetails(:P_SPID,:P_USERID,:P_CARNETSTATUS,:P_CURSOR);
END;`,
{
P_SPID: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_USERID: {
val: body.P_USERID,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_CARNETSTATUS: {
val: body.P_CARNETSTATUS,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
}
return rows;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
}
}
}

View File

@ -0,0 +1,80 @@
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
import { ManageClientsService } from './manage-clients.service';
import { ApiTags } from '@nestjs/swagger';
import {
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO, GetPreparerByClientidContactsByClientidLocByClientidDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/property.dto';
@Controller('oracle')
export class ManageClientsController {
constructor(private readonly manageClientsService: ManageClientsService) { }
@ApiTags('Manage Clients - Oracle')
@Post('CreateNewClients')
async CreateClientData(@Body() body: CreateClientDataDTO) {
return this.manageClientsService.CreateClientData(body);
}
@ApiTags('Manage Clients - Oracle')
@Put('UpdateClient')
async UpdateClient(@Body() body: UpdateClientDTO) {
return this.manageClientsService.UpdateClient(body);
}
@ApiTags('Manage Clients - Oracle')
@Put('UpdateClientContacts')
UpdateClientContacts(@Body() body: UpdateClientContactsDTO) {
return this.manageClientsService.UpdateClientContacts(body);
}
@ApiTags('Manage Clients - Oracle')
@Put('UpdateClientLocations')
UpdateClientLocations(@Body() body: UpdateClientLocationsDTO) {
return this.manageClientsService.UpdateClientLocations(body);
}
@ApiTags('Manage Clients - Oracle')
@Post('CreateClientContacts')
CreateClientContact(@Body() body: CreateClientContactsDTO) {
return this.manageClientsService.CreateClientContact(body);
}
@ApiTags('Manage Clients - Oracle')
@Post('CreateClientLocations')
CreateClientLocation(@Body() body: CreateClientLocationsDTO) {
return this.manageClientsService.CreateClientLocation(body);
}
@ApiTags('Manage Clients - Oracle')
@Get('GetPreparers')
async GetPreparers(@Query() query: GetPreparersDTO) {
return await this.manageClientsService.GetPreparers(query);
}
@ApiTags('Manage Clients - Oracle')
@Get('GetPreparerByClientid')
GetPreparerByClientid(
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) {
return this.manageClientsService.GetPreparerByClientid(body);
}
@ApiTags('Manage Clients - Oracle')
@Get('GetPreparerContactsByClientid')
GetPreparerContactsByClientid(
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) {
return this.manageClientsService.GetPreparerContactsByClientid(body);
}
@ApiTags('Manage Clients - Oracle')
@Get('GetPreparerLocByClientid')
GetPreparerLocByClientid(
@Query() body: GetPreparerByClientidContactsByClientidLocByClientidDTO,
) {
return this.manageClientsService.GetPreparerLocByClientid(body);
}
}

View File

@ -0,0 +1,613 @@
// import { ApiProperty } from '@nestjs/swagger';
// import {
// IsDefined,
// IsInt,
// IsNumber,
// IsOptional,
// IsString,
// Length,
// Max,
// Min,
// ValidateNested,
// IsArray,
// IsEmail,
// } from 'class-validator';
// import { Transform, Type } from 'class-transformer';
// import { CONTACTSTABLE_ROW_DTO } from 'src/dto/holder/holder.dto';
// export class p_clientlocaddresstableDTO {
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property Nameof must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property Nameof must be a string' })
// @IsDefined({ message: 'Property Nameof is required' })
// Nameof: string;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property Address1 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property Address1 must be a string' })
// @IsDefined({ message: 'Property Address1 is required' })
// Address1: string;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property Address2 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property Address2 must be a string' })
// @IsOptional()
// Address2?: string;
// @ApiProperty({ required: true })
// @Length(0, 30, {
// message: 'Property City must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property City must be a string' })
// @IsDefined({ message: 'Property City is required' })
// City: string;
// @ApiProperty({ required: true })
// @Length(0, 2, { message: 'Property State must be between 0 to 2 characters' })
// @IsString({ message: 'Property State must be a string' })
// @IsDefined({ message: 'Property State is required' })
// State: string;
// @ApiProperty({ required: true })
// @Length(0, 10, { message: 'Property Zip must be between 0 to 10 characters' })
// @IsString({ message: 'Property Zip must be a string' })
// @IsDefined({ message: 'Property Zip is required' })
// Zip: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property Country must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property Country must be a string' })
// @IsDefined({ message: 'Property Country is required' })
// Country: string;
// }
// export class CreateClientDataDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// // @Max(999999999, { message: "Property p_clientname must not exceed 999999999" })
// // @Min(0, { message: "Property p_clientname must be at least 0 or more" })
// // @IsInt({ message: "Property p_clientname allows only whole numbers" })
// // @IsNumber({}, { message: "Property p_clientname must be a number" })
// // @IsDefined({ message: "Property p_clientname is required" })
// @Length(0, 50, {
// message: 'Property p_clientname must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_clientname must be a string' })
// @IsDefined({ message: 'Property p_clientname is required' })
// p_clientname: string;
// @ApiProperty({ required: true })
// @Length(0, 20, {
// message: 'Property p_lookupcode must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_lookupcode must be a string' })
// @IsDefined({ message: 'Property p_lookupcode is required' })
// p_lookupcode: string;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_address1 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_address1 must be a string' })
// @IsDefined({ message: 'Property p_address1 is required' })
// p_address1: string;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property p_address2 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_address2 must be a string' })
// @IsOptional()
// p_address2?: string;
// @ApiProperty({ required: true })
// @Length(0, 30, {
// message: 'Property p_city must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property p_city must be a string' })
// @IsDefined({ message: 'Property p_city is required' })
// p_city: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_state must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_state must be a string' })
// @IsDefined({ message: 'Property p_state is required' })
// p_state: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_zip must be between 0 to 10 characters',
// })
// @IsString({ message: 'Property p_zip must be a string' })
// @IsOptional()
// p_zip?: string;
// @ApiProperty({ required: false })
// @Length(0, 2, {
// message: 'Property p_country must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_country must be a string' })
// @IsOptional()
// p_country?: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_issuingregion must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_issuingregion must be a string' })
// @IsDefined({ message: 'Property p_issuingregion is required' })
// p_issuingregion: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_revenuelocation must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_revenuelocation must be a string' })
// @IsDefined({ message: 'Property p_revenuelocation is required' })
// p_revenuelocation: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_userid must be between 0 to 100 characters',
// })
// @IsString({ message: 'Property p_userid must be a string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// // @ApiProperty({ required: true, type: () => [p_contactstableDTO] })
// // @Type(() => p_contactstableDTO)
// // @ValidateNested({ each: true })
// // @IsArray({ message: 'Property p_contactstable allows only array type' })
// // @IsDefined({ message: 'Property p_contactstable is required' })
// // p_contactstable: p_contactstableDTO[];
// // @ApiProperty({ required: true, type: () => [p_clientlocaddresstableDTO] })
// // @Type(() => p_clientlocaddresstableDTO)
// // @ValidateNested({ each: true })
// // @IsArray({
// // message: 'Property p_clientlocaddresstable allows only array type',
// // })
// // @IsDefined({ message: 'Property p_clientlocaddresstable is required' })
// // p_clientlocaddresstable: p_clientlocaddresstableDTO[];
// }
// export class UpdateClientDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_preparername must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_preparername must be a string' })
// @IsDefined({ message: 'Property p_preparername is required' })
// p_preparername: string;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_address1 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_address1 must be a string' })
// @IsDefined({ message: 'Property p_address1 is required' })
// p_address1: string;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property p_address2 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_address2 must be a string' })
// @IsOptional()
// p_address2?: string;
// @ApiProperty({ required: true })
// @Length(0, 30, {
// message: 'Property p_city must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property p_city must be a string' })
// @IsDefined({ message: 'Property p_city is required' })
// p_city: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_state must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_state must be a string' })
// @IsDefined({ message: 'Property p_state is required' })
// p_state: string;
// @ApiProperty({ required: true })
// @Length(0, 10, {
// message: 'Property p_zip must be between 0 to 10 characters',
// })
// @IsString({ message: 'Property p_zip must be a string' })
// @IsDefined({ message: 'Property p_zip is required' })
// p_zip: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_country must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_country must be a string' })
// @IsDefined({ message: 'Property p_country is required' })
// p_country: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_revenuelocation must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_revenuelocation must be a string' })
// @IsDefined({ message: 'Property p_revenuelocation is required' })
// p_revenuelocation: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_userid must be between 0 to 100 characters',
// })
// @IsString({ message: 'Property p_userid must be a string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// }
// export class UpdateClientContactsDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, {
// message: 'Property p_clientcontactid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_clientcontactid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientcontactid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientcontactid must be a number' })
// @IsDefined({ message: 'Property p_clientcontactid is required' })
// p_clientcontactid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_firstname must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_firstname must be a string' })
// @IsDefined({ message: 'Property p_firstname is required' })
// p_firstname: string;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_lastname must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_lastname must be a string' })
// @IsDefined({ message: 'Property p_lastname is required' })
// p_lastname: string;
// @ApiProperty({ required: false })
// @Length(0, 3, {
// message: 'Property p_middleinitial must be between 0 to 3 characters',
// })
// @IsString({ message: 'Property p_middleinitial must be a string' })
// @IsOptional()
// p_middleinitial?: string;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property p_title must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_title must be a string' })
// @IsOptional()
// p_title?: string;
// @ApiProperty({ required: true })
// @Length(0, 20, {
// message: 'Property p_phone must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_phone must be a string' })
// @IsDefined({ message: 'Property p_phone is required' })
// p_phone: string;
// @ApiProperty({ required: true })
// @Length(0, 20, {
// message: 'Property p_fax must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_fax must be a string' })
// @IsDefined({ message: 'Property p_fax is required' })
// p_fax: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_mobileno must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_mobileno must be a string' })
// @IsOptional()
// p_mobileno?: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_emailaddress must be between 0 to 100 characters',
// })
// @IsEmail(
// {},
// { message: 'Property p_emailaddress must be a valid email address' },
// )
// @IsDefined({ message: 'Property p_emailaddress is required' })
// p_emailaddress: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_userid must be between 0 to 100 characters',
// })
// @IsString({ message: 'Property p_userid must be a string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// }
// export class GetPreparersDTO {
// @ApiProperty({ required: true })
// @Transform(({ value }) => Number(value))
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property p_name must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_name must be a string' })
// @IsOptional()
// p_name?: string;
// @ApiProperty({ required: false })
// @Length(0, 30, {
// message: 'Property p_lookupcode must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property p_lookupcode must be a string' })
// @IsOptional()
// p_lookupcode?: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_city must be between 0 to 20 characters',
// })
// @IsString({ message: 'Property p_city must be a string' })
// @IsOptional()
// p_city?: string;
// @ApiProperty({ required: false })
// @Length(0, 2, {
// message: 'Property p_state must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_state must be a string' })
// @IsOptional()
// p_state?: string;
// @ApiProperty({ required: true })
// @Length(0, 10, {
// message: 'Property p_status must be between 0 to 10 characters',
// })
// @IsString({ message: 'Property p_status must be a string' })
// @IsDefined({ message: 'Property p_status is required' })
// p_status: string;
// }
// export class UpdateClientLocationsDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, {
// message: 'Property p_clientlocationid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_clientlocationid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientlocationid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientlocationid must be a number' })
// @IsDefined({ message: 'Property p_clientlocationid is required' })
// p_clientlocationid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_lcoationname must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_lcoationname must be a string' })
// @IsDefined({ message: 'Property p_lcoationname is required' })
// p_lcoationname: string;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_address1 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_address1 must be a string' })
// @IsDefined({ message: 'Property p_address1 is required' })
// p_address1: string;
// @ApiProperty({ required: false })
// @Length(0, 50, {
// message: 'Property p_address2 must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_address2 must be a string' })
// @IsOptional()
// p_address2?: string;
// @ApiProperty({ required: false })
// @Length(0, 30, {
// message: 'Property p_city must be between 0 to 30 characters',
// })
// @IsString({ message: 'Property p_city must be a string' })
// @IsOptional()
// p_city?: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_state must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_state must be a string' })
// @IsDefined({ message: 'Property p_state is required' })
// p_state: string;
// @ApiProperty({ required: true })
// @Length(0, 10, {
// message: 'Property p_zip must be between 0 to 10 characters',
// })
// @IsString({ message: 'Property p_zip must be a string' })
// @IsDefined({ message: 'Property p_zip is required' })
// p_zip: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property p_country must be between 0 to 2 characters',
// })
// @IsString({ message: 'Property p_country must be a string' })
// @IsDefined({ message: 'Property p_country is required' })
// p_country: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_userid must be between 0 to 100 characters',
// })
// @IsString({ message: 'Property p_userid must be a string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// }
// export class CreateClientContactsDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// @ApiProperty({ required: true, type: () => [CONTACTSTABLE_ROW_DTO] })
// @Type(() => CONTACTSTABLE_ROW_DTO)
// @ValidateNested({ each: true })
// @IsArray({ message: 'Property p_contactstable allows only array type' })
// @IsDefined({ message: 'Property p_contactstable is required' })
// p_contactstable: CONTACTSTABLE_ROW_DTO[];
// @ApiProperty({ required: true })
// @Length(0, 1, {
// message: 'Property p_defcontactflag must be exactly 1 character',
// })
// @IsString({ message: 'Property p_defcontactflag must be a string' })
// @IsDefined({ message: 'Property p_defcontactflag is required' })
// p_defcontactflag: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_userid must be between 0 to 100 characters',
// })
// @IsString({ message: 'Property p_userid must be a string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// }
// export class CreateClientLocationsDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// @ApiProperty({ required: true, type: () => [p_clientlocaddresstableDTO] })
// @Type(() => p_clientlocaddresstableDTO)
// @ValidateNested({ each: true })
// @IsArray({
// message: 'Property p_clientlocaddresstable allows only array type',
// })
// @IsDefined({ message: 'Property p_clientlocaddresstable is required' })
// p_clientlocaddresstable: p_clientlocaddresstableDTO[];
// // @ApiProperty({ required: true })
// // @Length(0, 1, {
// // message: 'Property p_defcontactflag must be exactly 1 character',
// // })
// // @IsString({ message: 'Property p_defcontactflag must be a string' })
// // @IsDefined({ message: 'Property p_defcontactflag is required' })
// // p_defcontactflag: string;
// @ApiProperty({ required: true })
// @Length(0, 100, {
// message: 'Property p_userid must be between 0 to 100 characters',
// })
// @IsString({ message: 'Property p_userid must be a string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// }
// export class GetPreparerByClientidContactsByClientidLocByClientidDTO {
// @ApiProperty({ required: true })
// @Transform(({ value }) => Number(value))
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt({ message: 'Property p_spid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Transform(({ value }) => Number(value))
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt({ message: 'Property p_clientid allows only whole numbers' })
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// @IsDefined({ message: 'Property p_clientid is required' })
// p_clientid: number;
// }

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageClientsController } from './manage-clients.controller';
import { ManageClientsService } from './manage-clients.service';
@Module({
controllers: [ManageClientsController],
providers: [ManageClientsService],
})
export class ManageClientsModule {}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
import { ManageFeeService } from './manage-fee.service';
import { ApiTags } from '@nestjs/swagger';
import {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/property.dto';
@Controller('oracle')
export class ManageFeeController {
constructor(private readonly manageFeeService: ManageFeeService) { }
@ApiTags('Manage Fee - Oracle')
@Get('/GetBasicFeeRates')
GetBasicFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBASICFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetBondRates')
GetBondRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBONDRATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetCargoRates')
GetCargoRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCARGORATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetCfFeeRates')
GetCfFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCFFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetCsFeeRates')
GetCsFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCSFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetEfFeeRates')
GetEfFeeRates(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETEFFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetFeeComm')
GetFeeComm(@Query() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETFEECOMM(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateBasicFee')
CreateBasicFee(@Body() body: CreateBasicFeeDTO) {
return this.manageFeeService.CREATEBASICFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateBondRate')
CreateBondRate(@Body() body: CreateBondRateDTO) {
return this.manageFeeService.CREATEBONDRATE(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateCargoRate')
CreateCargoRate(@Body() body: CreateCargoRateDTO) {
return this.manageFeeService.CREATECARGORATE(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateCfFee')
CreateCfFee(@Body() body: CreateCfFeeDTO) {
return this.manageFeeService.CREATECFFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateCsFee')
CreateCsFee(@Body() body: CreateCsFeeDTO) {
return this.manageFeeService.CREATECSFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateEfFee')
CreateEeFee(@Body() body: CreateEfFeeDTO) {
return this.manageFeeService.CREATEEFFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Post('/CreateFeeComm')
CreateFeeComm(@Body() body: CreateFeeCommDTO) {
return this.manageFeeService.CREATEFEECOMM(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateBasicFee')
UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) {
return this.manageFeeService.UPDATEBASICFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateBondRate')
UpdateBondRate(@Body() body: UpdateBondRateDTO) {
return this.manageFeeService.UPDATEBONDRATE(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateCargoRate')
UpdateCargoRate(@Body() body: UpdateCargoRateDTO) {
return this.manageFeeService.UPDATECARGORATE(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateCfFee')
UpdateCfFee(@Body() body: UpdateCfFeeDTO) {
return this.manageFeeService.UPDATECFFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateCsFee')
UpdateCsFee(@Body() body: UpdateCsFeeDTO) {
return this.manageFeeService.UPDATECSFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateEfFee')
UpdateEfFee(@Body() body: UpdateEfFeeDTO) {
return this.manageFeeService.UPDATEEFFEE(body);
}
@ApiTags('Manage Fee - Oracle')
@Patch('/UpdateFeeComm')
UpdateFeeComm(@Body() body: UpdateFeeCommDTO) {
return this.manageFeeService.UPDATEFEECOMM(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ManageFeeController } from './manage-fee.controller';
import { ManageFeeService } from './manage-fee.service';
@Module({
controllers: [ManageFeeController],
providers: [ManageFeeService],
})
export class ManageFeeModule {}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,136 @@
import {
BadRequestException,
Body,
Controller,
Get,
Param,
ParseIntPipe,
Patch,
Post,
Put,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { ManageHoldersService } from './manage-holders.service';
import {
CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO,
HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO
} from 'src/dto/property.dto';
@Controller('oracle')
export class ManageHoldersController {
constructor(private readonly manageHoldersService: ManageHoldersService) { }
@ApiTags('Manage Holders - Oracle')
@Post('/CreateHolderData')
CreateHolders(@Body() body: CreateHoldersDTO) {
return this.manageHoldersService.CreateHolders(body);
// return {message:"Request received.."}
}
@ApiTags('Manage Holders - Oracle')
@Put('/UpdateHolder')
UpdateHolder(@Body() body: UpdateHolderDTO) {
return this.manageHoldersService.UpdateHolder(body);
}
@ApiTags('Manage Holders - Oracle')
@Put('/UpdateHolderContact')
UpdateHolderContact(@Body() body: UpdateHolderContactDTO) {
return this.manageHoldersService.UpdateHolderContact(body);
}
@ApiTags('Manage Holders - Oracle')
@Get('/GetHolderRecord/:P_SPID/:P_HOLDERID')
GetHolderMaster(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderRecord(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Get('/GetHolderContacts/:P_SPID/:P_HOLDERID')
GetHolderContacts(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderContacts(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
InactivateHolder(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.InactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
ReactivateHolder(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.ReactivateHolder(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
InactivateHolderContact(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.InactivateHolderContact(reqParams);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
ReactivateHolderContact(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.ReactivateHolderContact(reqParams);
}
}

View File

@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { ManageHoldersService } from './manage-holders.service';
import { ManageHoldersController } from './manage-holders.controller';
import { DbModule } from 'src/db/db.module';
@Module({
imports: [DbModule],
providers: [ManageHoldersService],
controllers: [ManageHoldersController],
})
export class ManageHoldersModule {}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
import { Global, Module } from '@nestjs/common';
import { DbModule } from 'src/db/db.module';
import { ManageHoldersModule } from './manage-holders/manage-holders.module';
import { HomePageModule } from './home-page/home-page.module';
import { UscibManagedSpModule } from './uscib-managed-sp/uscib-managed-sp.module';
import { ParamTableModule } from './param-table/param-table.module';
import { ManageFeeModule } from './manage-fee/manage-fee.module';
import { ManageClientsModule } from './manage-clients/manage-clients.module';
import { UserMaintenanceModule } from './user-maintenance/user-maintenance.module';
import { CarnetApplicationModule } from './carnet-application/carnet-application.module';
import { OracleService } from './oracle.service';
@Global()
@Module({
imports: [
DbModule,
CarnetApplicationModule,
UserMaintenanceModule,
HomePageModule,
UscibManagedSpModule,
ParamTableModule,
ManageFeeModule,
ManageHoldersModule,
ManageClientsModule,
],
providers: [OracleService],
controllers: [],
exports: [OracleService],
})
export class OracleModule {}

View File

@ -0,0 +1,121 @@
import { Injectable, Logger } from "@nestjs/common";
import { OracleDBService } from "src/db/db.service";
import { COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO } from "src/dto/property.dto";
import { InternalServerException } from "src/exceptions/internalServerError.exception";
import { closeOracleDbConnection, handleError } from "src/utils/helper";
@Injectable()
export class OracleService {
private readonly logger = new Logger(OracleService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
async get_GL_TABLE_INSTANCE(finalBody: any) {
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
if (typeof GLTABLE !== 'function') {
throw new InternalServerException('GLTABLE is not a constructor');
}
async function createGLArrayInstance(
ITEMNO, ITEMDESCRIPTION, ITEMVALUE, NOOFPIECES,
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
) {
const result = await connection.execute(
`SELECT CARNETSYS.GLARRAY(
:ITEMNO, :ITEMDESCRIPTION, :ITEMVALUE, :NOOFPIECES,
:ITEMWEIGHT, :ITEMWEIGHTUOM, :GOODSORIGINCOUNTRY
) FROM dual`,
{
ITEMNO, ITEMDESCRIPTION, ITEMVALUE, NOOFPIECES,
ITEMWEIGHT, ITEMWEIGHTUOM, GOODSORIGINCOUNTRY,
}
);
console.log(result.rows);
return result.rows[0][0];
}
const GLTABLE_ARRAY: GLTABLE_DTO = {
P_GLTABLE: await Promise.all(
(finalBody.P_GLTABLE ?? []).map(async (x: GLTABLE_ROW_DTO) => {
return await createGLArrayInstance(
x.ITEMNO, x.ITEMDESCRIPTION, x.ITEMVALUE, x.NOOFPIECES,
x.ITEMWEIGHT, x.ITEMWEIGHTUOM, x.GOODSORIGINCOUNTRY,
);
})
)
};
const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY.P_GLTABLE ?? []);
return GLTABLE_INSTANCE;
} catch (error) {
throw new Error("Error occured completing this process")
} finally {
await closeOracleDbConnection(connection, OracleService.name)
}
}
async get_COUNTRY_TABLE_INSTANCE(finalBody: any) {
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' }
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }
let connection;
try {
connection = await this.oracleDBService.getConnection();
const COUNTRYTABLE = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYTABLE');
if (typeof COUNTRYTABLE !== 'function') {
throw new Error('COUNTRYTABLE is not a constructor');
}
async function createCarnetCountryArrayInstance(
P_VISISTTRANSITIND, COUNTRYCODE, NOOFTIMESENTLEAVE,
) {
const result = await connection.execute(
`SELECT CARNETSYS.CARNETCOUNTRYARRAY(
:P_VISISTTRANSITIND, :COUNTRYCODE, :NOOFTIMESENTLEAVE
) FROM dual`,
{
P_VISISTTRANSITIND, COUNTRYCODE, NOOFTIMESENTLEAVE,
},
);
console.log(result.rows);
return result.rows[0][0];
}
const COUNTRYTABLE_ARRAY: COUNTRYTABLE_DTO = {
P_COUNTRYTABLE: await Promise.all(
(finalBody.P_COUNTRYTABLE ?? []).map(async (x: COUNTRYTABLE_ROW_DTO) => {
return await createCarnetCountryArrayInstance(
x.P_VISISTTRANSITIND, x.COUNTRYCODE, x.NOOFTIMESENTLEAVE,
);
})
)
};
const COUNTRYTABLE_INSTANCE = new COUNTRYTABLE(COUNTRYTABLE_ARRAY.P_COUNTRYTABLE ?? []);
return COUNTRYTABLE_INSTANCE;
} catch (error) {
throw new Error("Error occured completing this process")
} finally {
await closeOracleDbConnection(connection, OracleService.name)
}
}
}

View File

@ -0,0 +1,55 @@
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
import { ApiQuery, ApiTags } from '@nestjs/swagger';
import { ParamTableService } from './param-table.service';
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO,
getParamValuesDTO, UpdateParamRecordDTO } from 'src/dto/property.dto';
@ApiTags('Param Table - Oracle')
@Controller('oracle')
export class ParamTableController {
constructor(private readonly paramTableService: ParamTableService) { }
@Get('/GetParamValues')
@ApiQuery({
name: 'P_SPID',
required: false,
type: Number,
description: 'The ID of the parameter',
})
@ApiQuery({
name: 'P_PARAMTYPE',
required: false,
type: String,
description: 'The type of the parameter',
})
getParamValues(@Query() body: getParamValuesDTO) {
return this.paramTableService.GETPARAMVALUES(body);
}
@Post('/CreateTableRecord')
createTableRecord(@Body() body: CreateTableRecordDTO) {
return this.paramTableService.CREATETABLERECORD(body);
}
@Post('/CreateParamRecord')
createParamRecord(@Body() body: CreateParamRecordDTO) {
return this.paramTableService.CREATEPARAMRECORD(body);
}
@Patch('/UpdateParamRecord')
UpdateParamRecord(@Body() body: UpdateParamRecordDTO) {
return this.paramTableService.UPDATEPARAMRECORD(body);
}
@Patch('/InActivateParamRecord')
inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.INACTIVATEPARAMRECORD(body);
}
@Patch('/ReActivateParamRecord')
reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
return this.paramTableService.REACTIVATEPARAMRECORD(body);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ParamTableController } from './param-table.controller';
import { ParamTableService } from './param-table.service';
@Module({
controllers: [ParamTableController],
providers: [ParamTableService],
})
export class ParamTableModule {}

View File

@ -0,0 +1,727 @@
import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import {
ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO,
getParamValuesDTO, UpdateParamRecordDTO
} from 'src/dto/property.dto';
@Injectable()
export class ParamTableService {
private readonly logger = new Logger(ParamTableService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
// async GETPARAMVALUESX(body: getParamValuesDTO) {
// const finalBody = {
// P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null,
// P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null,
// };
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.GETPARAMVALUES(:P_SPID,:P_PARAMTYPE,:P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: finalBody.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMTYPE: {
// val: finalBody.P_PARAMTYPE,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new BadRequestException();
// }
// return rows;
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// this.logger.warn(error.message);
// throw new BadRequestException();
// }
// this.logger.error('GETPARAMVALUES failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async GETPARAMVALUES(body: getParamValuesDTO) {
const finalBody = {
P_SPID: body.P_SPID === 0 ? body.P_SPID : body.P_SPID ? body.P_SPID : null,
P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null,
};
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.GETPARAMVALUES(:P_SPID,:P_PARAMTYPE,:P_CURSOR);
END;`,
{
P_SPID: { val: finalBody.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_PARAMTYPE: { val: finalBody.P_PARAMTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
// const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
return await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
} catch (error) {
handleError(error, ParamTableService.name)
} finally {
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// async CREATETABLERECORDX(body: CreateTableRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.CREATETABLERECORD(:P_USERID,:P_TABLEFULLDESC,:P_CURSOR);
// END;`,
// {
// P_TABLEFULLDESC: {
// val: body.P_TABLEFULLDESC,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('CREATETABLERECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async CREATETABLERECORD(body: CreateTableRecordDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.CREATETABLERECORD(:P_USERID,:P_TABLEFULLDESC,:P_CURSOR);
END;`,
{
P_TABLEFULLDESC: { val: body.P_TABLEFULLDESC, type: oracledb.DB_TYPE_VARCHAR },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) {
handleError(error, ParamTableService.name)
} finally {
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// async CREATEPARAMRECORDX(body: CreateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD(
// :P_SPID,
// :P_PARAMTYPE,
// :P_PARAMDESC,
// :P_PARAMVALUE,
// :P_ADDLPARAMVALUE1,
// :P_ADDLPARAMVALUE2,
// :P_ADDLPARAMVALUE3,
// :P_ADDLPARAMVALUE4,
// :P_ADDLPARAMVALUE5,
// :P_SORTSEQ,
// :P_USERID,
// :P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMTYPE: {
// val: body.P_PARAMTYPE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_PARAMDESC: {
// val: body.P_PARAMDESC,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_PARAMVALUE: {
// val: body.P_PARAMVALUE,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE1: {
// val: body.P_ADDLPARAMVALUE1,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE2: {
// val: body.P_ADDLPARAMVALUE2,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE3: {
// val: body.P_ADDLPARAMVALUE3,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE4: {
// val: body.P_ADDLPARAMVALUE4,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE5: {
// val: body.P_ADDLPARAMVALUE5,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_SORTSEQ: {
// val: body.P_SORTSEQ,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// throw error;
// }
// else if (error.message === "NJS-107: invalid cursor") {
// throw new BadRequestException();
// }
// this.logger.error('CREATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async CREATEPARAMRECORD(body: CreateParamRecordDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD(
:P_SPID,
:P_PARAMTYPE,
:P_PARAMDESC,
:P_PARAMVALUE,
:P_ADDLPARAMVALUE1,
:P_ADDLPARAMVALUE2,
:P_ADDLPARAMVALUE3,
:P_ADDLPARAMVALUE4,
:P_ADDLPARAMVALUE5,
:P_SORTSEQ,
:P_USERID,
:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_PARAMTYPE: { val: body.P_PARAMTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_PARAMDESC: { val: body.P_PARAMDESC, type: oracledb.DB_TYPE_VARCHAR },
P_PARAMVALUE: { val: body.P_PARAMVALUE, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE1: { val: body.P_ADDLPARAMVALUE1, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE2: { val: body.P_ADDLPARAMVALUE2, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE3: { val: body.P_ADDLPARAMVALUE3, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE4: { val: body.P_ADDLPARAMVALUE4, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE5: { val: body.P_ADDLPARAMVALUE5, type: oracledb.DB_TYPE_VARCHAR },
P_SORTSEQ: { val: body.P_SORTSEQ, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) {
handleError(error, ParamTableService.name)
} finally {
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// async UPDATEPARAMRECORDX(body: UpdateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD(
// :P_SPID,
// :P_PARAMID,
// :P_PARAMDESC,
// :P_ADDLPARAMVALUE1,
// :P_ADDLPARAMVALUE2,
// :P_ADDLPARAMVALUE3,
// :P_ADDLPARAMVALUE4,
// :P_ADDLPARAMVALUE5,
// :P_SORTSEQ,
// :P_USERID,
// :P_CURSOR);
// END;`,
// {
// P_SPID: {
// val: body.P_SPID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMID: {
// val: body.P_PARAMID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_PARAMDESC: {
// val: body.P_PARAMDESC,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE1: {
// val: body.P_ADDLPARAMVALUE1,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE2: {
// val: body.P_ADDLPARAMVALUE2,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE3: {
// val: body.P_ADDLPARAMVALUE3,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE4: {
// val: body.P_ADDLPARAMVALUE4,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_ADDLPARAMVALUE5: {
// val: body.P_ADDLPARAMVALUE5,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_SORTSEQ: {
// val: body.P_SORTSEQ,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// const fres = await result.outBinds.P_CURSOR.getRows();
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
// return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
// } catch (error) {
// if (error instanceof BadRequestException) {
// this.logger.warn(error.message);
// throw error;
// }
// this.logger.error('UPDATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD(
:P_SPID,
:P_PARAMID,
:P_PARAMDESC,
:P_ADDLPARAMVALUE1,
:P_ADDLPARAMVALUE2,
:P_ADDLPARAMVALUE3,
:P_ADDLPARAMVALUE4,
:P_ADDLPARAMVALUE5,
:P_SORTSEQ,
:P_USERID,
:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },
P_PARAMDESC: { val: body.P_PARAMDESC, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE1: { val: body.P_ADDLPARAMVALUE1, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE2: { val: body.P_ADDLPARAMVALUE2, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE3: { val: body.P_ADDLPARAMVALUE3, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE4: { val: body.P_ADDLPARAMVALUE4, type: oracledb.DB_TYPE_VARCHAR },
P_ADDLPARAMVALUE5: { val: body.P_ADDLPARAMVALUE5, type: oracledb.DB_TYPE_VARCHAR },
P_SORTSEQ: { val: body.P_SORTSEQ, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ParamTableService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully", ...fres[0] };
} catch (error) {
handleError(error, ParamTableService.name)
} finally {
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// async INACTIVATEPARAMRECORDX(body: ActivateOrInactivateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.INACTIVATEPARAMRECORD(
// :P_PARAMID,
// :P_USERID);
// END;`,
// {
// P_PARAMID: {
// val: body.P_PARAMID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Inactivated Successfully' };
// } catch (error) {
// this.logger.error('INACTIVATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD(:P_PARAMID,:P_USERID);
END;`,
{
P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
// const outBinds = result.outBinds;
// if (!outBinds?.P_CURSOR) {
// this.logger.error('One or more expected cursors are missing from stored procedure output.');
// throw new InternalServerException("Incomplete data received from the database.");
// }
return { statusCode: 200, message: 'Inactivated Successfully' };
} catch (error) {
handleError(error, ParamTableService.name)
} finally {
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
// async REACTIVATEPARAMRECORDX(body: ActivateOrInactivateParamRecordDTO) {
// let connection;
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new InternalServerException();
// }
// const result = await connection.execute(
// `BEGIN
// MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD(
// :P_PARAMID,
// :P_USERID);
// END;`,
// {
// P_PARAMID: {
// val: body.P_PARAMID,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: body.P_USERID,
// type: oracledb.DB_TYPE_VARCHAR,
// },
// },
// );
// await connection.commit();
// return { statusCode: 200, message: 'Reactivated Successfully' };
// } catch (error) {
// this.logger.error('REACTIVATEPARAMRECORD failed', error.stack || error);
// throw new InternalServerException();
// } finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// this.logger.error('Failed to close DB connection', closeErr);
// }
// }
// }
// }
async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.REACTIVATEPARAMRECORD(:P_PARAMID,:P_USERID);
END;`,
{
P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
// const outBinds = result.outBinds;
// if (!outBinds?.P_CURSOR) {
// this.logger.error('One or more expected cursors are missing from stored procedure output.');
// throw new InternalServerException("Incomplete data received from the database.");
// }
return { statusCode: 200, message: 'Reactivated Successfully' };
} catch (error) {
handleError(error, ParamTableService.name)
} finally {
await closeOracleDbConnection(connection, ParamTableService.name)
}
}
}

View File

@ -0,0 +1,21 @@
import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { CarnetSequenceService } from './carnet-sequence.service';
import { SPID_DTO, CreateCarnetSequenceDTO } from 'src/dto/property.dto';
@ApiTags('Carnet Sequence - Oracle')
@Controller('oracle')
export class CarnetSequenceController {
constructor(private readonly carnetSequenceService: CarnetSequenceService) { }
@Post('/CreateCarnetSequence/')
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
return this.carnetSequenceService.createCarnetSequence(body);
}
@Get('/GetCarnetSequence/:P_SPID')
getCarnetSequence(@Param() params: SPID_DTO) {
return this.carnetSequenceService.getCarnetSequence(params);
}
}

View File

@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { CarnetSequenceController } from './carnet-sequence.controller';
import { CarnetSequenceService } from './carnet-sequence.service';
@Module({
controllers: [CarnetSequenceController],
providers: [CarnetSequenceService],
})
export class CarnetSequenceModule {}

View File

@ -0,0 +1,239 @@
import { Injectable, Logger } from '@nestjs/common';
import * as oracledb from 'oracledb';
import { OracleDBService } from 'src/db/db.service';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { SPID_DTO, CreateCarnetSequenceDTO } from 'src/dto/property.dto';
@Injectable()
export class CarnetSequenceService {
private readonly logger = new Logger(CarnetSequenceService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
async createCarnetSequenceX(body: CreateCarnetSequenceDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.CreateCarnetSequence(
:P_SPID,
:P_REGIONID,
:P_STARTNUMBER,
:P_ENDNUMBER,
:P_CARNETTYPE,
:P_CURSOR);
END;`,
{
P_SPID: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_REGIONID: {
val: body.P_REGIONID,
type: oracledb.DB_TYPE_NUMBER,
},
P_STARTNUMBER: {
val: body.P_STARTNUMBER,
type: oracledb.DB_TYPE_NUMBER,
},
P_ENDNUMBER: {
val: body.P_ENDNUMBER,
type: oracledb.DB_TYPE_NUMBER,
},
P_CARNETTYPE: {
val: body.P_CARNETTYPE,
type: oracledb.DB_TYPE_VARCHAR,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
await result.outBinds.P_CURSOR.close();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
}
this.logger.error('createCarnetSequence failed', error.stack || error);
throw new InternalServerException();
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
}
}
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.SaveCarnetApplication(
:P_SPID, :P_REGIONID, :P_STARTNUMBER, :P_ENDNUMBER, :P_CARNETTYPE, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_REGIONID: { val: body.P_REGIONID, type: oracledb.DB_TYPE_NUMBER },
P_STARTNUMBER: { val: body.P_STARTNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_ENDNUMBER: { val: body.P_ENDNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_CARNETTYPE: { val: body.P_CARNETTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
let fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetSequenceService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Createdted Successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetSequenceService.name)
} finally {
await closeOracleDbConnection(connection, CarnetSequenceService.name)
}
}
async getCarnetSequenceX(body: SPID_DTO) {
let connection;
let rows = [];
try {
// Connect to the Oracle database using oracledb
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new InternalServerException();
}
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR);
END;`,
{
P_SPID: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new BadRequestException();
}
return rows;
} catch (error) {
if (error instanceof BadRequestException) {
this.logger.warn(error.message);
throw error;
}
else if (error.message === "NJS-107: invalid cursor") {
this.logger.warn(error.message);
throw new BadRequestException();
}
this.logger.error('getCarnetSequence failed', error.stack || error);
throw new InternalServerException();
} finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
this.logger.error('Failed to close DB connection', closeErr);
}
}
}
}
async getCarnetSequence(body: SPID_DTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.GetCarnetSequence(:P_SPID,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetSequenceService.name);
} catch (error) {
handleError(error, CarnetSequenceService.name)
} finally {
await closeOracleDbConnection(connection, CarnetSequenceService.name)
}
}
}

View File

@ -0,0 +1,29 @@
import { RegionService } from './region.service';
import { Get, Post, Body, Controller, Patch } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto';
@ApiTags('Regions - Oracle')
@Controller('oracle')
export class RegionController {
constructor(private readonly regionService: RegionService) { }
@Post('/InsertRegions')
insertRegions(@Body() body: InsertRegionsDto) {
return this.regionService.insertRegions(body);
}
@Patch('/UpdateRegion')
updateRegions(@Body() body: UpdateRegionDto) {
return this.regionService.updateRegions(body);
}
@Get('/GetRegions')
getRegions() {
return this.regionService.getRegions();
}
}

Some files were not shown because too many files have changed in this diff Show More