init push
commit
9e99047f72
@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
sourceType: 'module',
|
||||
},
|
||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:prettier/recommended',
|
||||
],
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
ignorePatterns: ['.eslintrc.js'],
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,109 @@
|
||||
# ---> Node
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Microbundle cache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# Next.js build output
|
||||
.next
|
||||
|
||||
# Nuxt.js build / generate output
|
||||
.nuxt
|
||||
dist
|
||||
|
||||
# Gatsby files
|
||||
.cache/
|
||||
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||
# public
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TernJS port file
|
||||
.tern-port
|
||||
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
# movie-bucket-project-api
|
||||
|
||||
Online Movie Show Management and Ticket Booking API
|
||||
@ -0,0 +1,39 @@
|
||||
// cluster.ts
|
||||
import * as cluster from 'cluster';
|
||||
import * as os from 'os';
|
||||
|
||||
export class Cluster {
|
||||
static register(workers: Number, callback: Function): void {
|
||||
if (cluster.isMaster) {
|
||||
console.log(`Master server started on ${process.pid}`);
|
||||
|
||||
//ensure workers exit cleanly
|
||||
process.on('SIGINT', function () {
|
||||
console.log('Cluster shutting down...');
|
||||
for (var id in cluster.workers) {
|
||||
cluster.workers[id].kill();
|
||||
}
|
||||
// exit the master process
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
var cpus = os.cpus().length;
|
||||
if (workers > cpus)
|
||||
workers = cpus;
|
||||
|
||||
for (let i = 0; i < workers; i++) {
|
||||
cluster.fork();
|
||||
}
|
||||
cluster.on('online', function (worker) {
|
||||
console.log('Worker %s is online', worker.process.pid);
|
||||
});
|
||||
cluster.on('exit', (worker, code, signal) => {
|
||||
console.log(`Worker ${worker.process.pid} died. Restarting`);
|
||||
cluster.fork();
|
||||
})
|
||||
} else {
|
||||
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
server:
|
||||
port: 3300
|
||||
db:
|
||||
type: 'postgres'
|
||||
port: '5432'
|
||||
sid: 'scb'
|
||||
oraclesid: 'tbnkdb'
|
||||
oracleport: '1521'
|
||||
|
||||
jwt:
|
||||
expiresIn: 3600
|
||||
|
||||
otp:
|
||||
expiresIn: 5
|
||||
|
||||
crypto:
|
||||
accessToken: 'accessToken@#123'
|
||||
refreshToken: 'refreshToken@#123'
|
||||
commonKey: 'commonKey@#123'
|
||||
|
||||
google:
|
||||
clientID: '42183132451-b2p8fit0okhec8dq8d15ddgu6msa4mro.apps.googleusercontent.com'
|
||||
clientSecret: 'EZvk3XK4_C1mhVXHm_izCDX6'
|
||||
callbackURL : 'https://myfin.api.teorainfotech.com/api/v1/auth/google/callback'
|
||||
succesRedirectURL : 'https://myfin.teorainfotech.com/#/auth/google'
|
||||
failRedirectURL: 'https://myfin.teorainfotech.com/login/failure'
|
||||
|
||||
facebook:
|
||||
appId: 2250938211710092
|
||||
appSecret: 4eabf9e73c1871a84645d1fffeb07c39
|
||||
callbackURL: 'https://myfin.api.teorainfotech.com/api/v1/auth/facebook/redirect'
|
||||
|
||||
mail:
|
||||
fromMail: 'innovationscochin@gmail.com'
|
||||
user: 'innovationscochin@gmail.com'
|
||||
pass: 'Inno@ict'
|
||||
|
||||
cron:
|
||||
scheduler: false
|
||||
|
||||
body:
|
||||
from: 'Nexmo'
|
||||
text: 'Test Message from innovations cochin'
|
||||
to: '+9181390 12392'
|
||||
api_key: '6b8c19bc'
|
||||
api_secret: 'BWbmroBtJfX0HPQ1'
|
||||
|
||||
smsPhoneNumberArgName:
|
||||
phoneno: 'to'
|
||||
message: 'text'
|
||||
|
||||
url:
|
||||
url: "https://rest.nexmo.com/sms/json"
|
||||
|
||||
bodyWay2SMS:
|
||||
apikey: "CKDG9HL5KYFLLILRMX3QX1CPKOIP8QF1"
|
||||
secret: "N373LNKAAJ079JY7"
|
||||
usetype: "stage"
|
||||
phone: "8139012392"
|
||||
message: "Haiii..."
|
||||
senderid: "WAYSMS"
|
||||
|
||||
smsPhoneNumberArgNameWay2SMS:
|
||||
phoneno: 'phone'
|
||||
messsgae: 'message'
|
||||
|
||||
urlWay2SMS:
|
||||
url: "http://www.way2sms.com/api/v1/sendCampaign"
|
||||
|
||||
sms-headers:
|
||||
headers: { "content-type": "application/json" }
|
||||
|
||||
payment-gateway:
|
||||
successRedirectUrl: "/transaction/issue-application"
|
||||
failureRedirectUrl: "/transaction/issue-application/status=failure"
|
||||
successRedirectUrlStudent: "/student/payment-redirection"
|
||||
failureRedirectUrlStudent: "/student/payment-redirection"
|
||||
successRedirectUrlStudentInternal: "/transaction/student-fee"
|
||||
failureRedirectUrlStudentInternal: "/transaction/student-fee"
|
||||
successRedirectUrlAcceptance: "/student/application"
|
||||
failureRedirectUrlAcceptance: "/student/application"
|
||||
successRedirectUrlAcceptancePublic: "/auth/public/admission-form"
|
||||
failureRedirectUrlAcceptancePublic: "auth/public/admission-form"
|
||||
furl: "http://192.168.1.24:3100/api/v1/payment-gateway/failure"
|
||||
surl: "http://192.168.1.24:3100/api/v1/payment-gateway/success"
|
||||
key : ""
|
||||
salt : ""
|
||||
testing : true
|
||||
|
||||
sms-merabt:
|
||||
url: "http://reseller.smschub.com/api/sms/format/json"
|
||||
peId: "1201160336050556744"
|
||||
# peTemplateId: 1207163341521627472
|
||||
peTemplateId: "1207164196662343521"
|
||||
apiKey: "b6bf2ebf9bb6e74d9538892569f7e9cc"
|
||||
urlEncd: "Y"
|
||||
sender: "TRISCB"
|
||||
|
||||
default-bank:
|
||||
id: "acc1"
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
db:
|
||||
host: '3.110.164.8'
|
||||
username: 'postgres'
|
||||
password: 'inv123'
|
||||
sid: 'scb'
|
||||
synchronize: false
|
||||
oraclehost: '59.94.179.105'
|
||||
oracleusername: 'simsmobapp'
|
||||
oraclepassword: 'simsmobapp'
|
||||
oraclesid: 'pacs'
|
||||
oracleType: 'oracle'
|
||||
|
||||
jwt:
|
||||
secret: 'topSecret51'
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src"
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,96 @@
|
||||
{
|
||||
"name": "scb-api",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"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": {
|
||||
"@nest-modules/mailer": "^1.3.22",
|
||||
"@nestjs/common": "^7.6.13",
|
||||
"@nestjs/core": "^7.6.13",
|
||||
"@nestjs/jwt": "^7.2.0",
|
||||
"@nestjs/passport": "^7.1.6",
|
||||
"@nestjs/platform-express": "^7.6.13",
|
||||
"@nestjs/schedule": "^1.0.1",
|
||||
"@nestjs/typeorm": "^7.1.5",
|
||||
"@types/passport-facebook": "^2.1.11",
|
||||
"bcrypt": "^5.0.0",
|
||||
"class-transformer": "^0.4.0",
|
||||
"class-validator": "^0.13.1",
|
||||
"config": "^3.3.3",
|
||||
"crypto-js": "^4.0.0",
|
||||
"ifsc": "^2.0.11",
|
||||
"jwt-payload": "^1.0.7",
|
||||
"node-oracledb": "^1.0.2",
|
||||
"oracledb": "^5.1.0",
|
||||
"passport": "^0.4.1",
|
||||
"passport-facebook": "^3.0.0",
|
||||
"passport-google-oauth20": "^2.0.0",
|
||||
"passport-jwt": "^4.0.0",
|
||||
"pg": "^8.5.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"request": "^2.88.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^6.6.6",
|
||||
"typeorm": "^0.2.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^7.5.6",
|
||||
"@nestjs/schematics": "^7.2.7",
|
||||
"@nestjs/testing": "^7.6.13",
|
||||
"@types/cron": "^1.7.3",
|
||||
"@types/crypto-js": "^4.0.1",
|
||||
"@types/express": "^4.17.11",
|
||||
"@types/jest": "^26.0.20",
|
||||
"@types/node": "^14.14.31",
|
||||
"@types/supertest": "^2.0.10",
|
||||
"@typescript-eslint/eslint-plugin": "^4.15.2",
|
||||
"@typescript-eslint/parser": "^4.15.2",
|
||||
"eslint": "^7.20.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"jest": "^26.6.3",
|
||||
"nodemailer": "^6.0.0",
|
||||
"otp-generator": "^2.0.0",
|
||||
"prettier": "^2.2.1",
|
||||
"supertest": "^6.1.3",
|
||||
"ts-jest": "^26.5.2",
|
||||
"ts-loader": "^8.0.17",
|
||||
"ts-node": "^9.1.1",
|
||||
"tsconfig-paths": "^3.9.0",
|
||||
"typescript": "^4.1.5"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { typeOrmConfig } from './config/typeorm.config';
|
||||
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { FileUploadModule } from './file-upload/file-upload.module';
|
||||
import { ScheduleModule } from '@nestjs/schedule';
|
||||
import { TenderDetailsModule } from './tender-master/tender-details.module';
|
||||
|
||||
|
||||
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ScheduleModule.forRoot(),
|
||||
TypeOrmModule.forRoot(typeOrmConfig),
|
||||
FileUploadModule,
|
||||
AuthModule,
|
||||
TenderDetailsModule,
|
||||
|
||||
],
|
||||
})
|
||||
export class AppModule { }
|
||||
@ -0,0 +1,147 @@
|
||||
import { Controller, Get, UseGuards, Res, Req, Body, ValidationPipe, Post, HttpCode, Ip, HostParam, HttpStatus, Put, Param, Patch } from '@nestjs/common';
|
||||
|
||||
import { TokenDto } from './dto/token.dto';
|
||||
//import { AuthGuard } from '@nestjs/passport';
|
||||
import * as config from 'config';
|
||||
import { AuthCreadentialsDto } from './dto/auth-credentials.dto';
|
||||
import { AuthService } from './auth.service';
|
||||
import { TempSignUpDto } from './dto/temp-sign-up.dto';
|
||||
import { AuthGuard } from '@nestjs/passport';
|
||||
import { GetUser } from './dto/get-user.decorator';
|
||||
import { Pcduser } from './pcduser.entity';
|
||||
import { PcduserDto } from './dto/pcd-user.dto';
|
||||
import { Cron } from '@nestjs/schedule';
|
||||
import { ChangePasswordDto } from './dto/change-password.dto';
|
||||
import { UserBankDto } from './dto/user-bank.dto';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthController {
|
||||
constructor(
|
||||
private authService: AuthService
|
||||
) { }
|
||||
|
||||
@Post('/user-info')
|
||||
async userInfo(@Body() authCredentialDto:AuthCreadentialsDto){
|
||||
return this.authService.userInfo(authCredentialDto)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Post('/signin')
|
||||
async signIn(@Body(ValidationPipe)
|
||||
authCredentialDto: AuthCreadentialsDto,
|
||||
@Req() req): Promise<TokenDto> {
|
||||
return this.authService.signIn(authCredentialDto, req.ip);
|
||||
}
|
||||
|
||||
// @Post('/tpin')
|
||||
// async validateTransactionPassword(@Body(ValidationPipe) authCredentialDto: AuthCreadentialsDto, @Req() req): Promise<any> {
|
||||
// console.log(authCredentialDto);
|
||||
// return this.authService.validateTransactionPassword(authCredentialDto);
|
||||
// }
|
||||
|
||||
@Get()
|
||||
async getall() {
|
||||
return this.authService
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// @Get('delete-data')
|
||||
// async deleteData() {
|
||||
// return this.authService.deleteData();
|
||||
// }
|
||||
|
||||
// @Post('/signup')
|
||||
// async signUp(@Body(ValidationPipe) signUp: TempSignUpDto, @Req() req, @Ip() ip): Promise<any> {
|
||||
// // request.connection.remoteAddress
|
||||
// return this.authService.tempSignUp(signUp, ip);
|
||||
// }
|
||||
|
||||
@Post('/forgot-password')
|
||||
async forgotPassword(
|
||||
@Body() body: { pass: string, mobNo: string },
|
||||
): Promise<any> {
|
||||
|
||||
console.log("mobile",body.mobNo);
|
||||
|
||||
|
||||
return await this.authService.forgotPassword(body);
|
||||
}
|
||||
|
||||
// @Post('/otp/:flag')
|
||||
// async sendOtp(
|
||||
// @Body() body: { email?: string, mobile: string ,deviceId?:string},
|
||||
// @Param('flag') flag: string
|
||||
// ): Promise<void> {
|
||||
// return await this.authService.sendOtp(body, flag );
|
||||
// }
|
||||
|
||||
// @Post('/resend-otp/:flag')
|
||||
// async resendOtp(
|
||||
// @Body() body: { code?: string | number, email?: string, mobile: string },
|
||||
// @Param('flag') flag: string
|
||||
// ): Promise<void> {
|
||||
// return await this.authService.resendOtp(body,flag);
|
||||
// }
|
||||
|
||||
// @Post('/verifyOtp/:flag')
|
||||
// async verifyOtp(
|
||||
// @Body() body: { otp: string, mobile: string, deviceId:string },
|
||||
// @Param('flag') flag: string
|
||||
// ): Promise<any> {
|
||||
// console.log("deviceId",body.deviceId);
|
||||
|
||||
// return await this.authService.verifyOtp(body, flag);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// @Get('/encrypt/:bc')
|
||||
// async encryptBankCode(@GetUser() user: Pcduser,
|
||||
// @Param('bc') bankCode: string) {
|
||||
// return await this.authService.encryptBankCode(bankCode);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@UseGuards(AuthGuard())
|
||||
@Controller('pcduser')
|
||||
export class AuthUserController {
|
||||
|
||||
constructor(
|
||||
private authService: AuthService
|
||||
) { }
|
||||
|
||||
|
||||
|
||||
@Put('/:id')
|
||||
async updateUser(
|
||||
@Body() body: PcduserDto,
|
||||
@GetUser() user: PcduserDto,
|
||||
@Param('id') id: string,
|
||||
): Promise<PcduserDto> {
|
||||
return await this.authService.updateUser(body, user, id);
|
||||
}
|
||||
|
||||
// @Patch('change-password')
|
||||
// async changePasswordCurrentUser(
|
||||
// @Body(ValidationPipe) passwords: ChangePasswordDto,
|
||||
// @GetUser() user: PcduserDto
|
||||
// ): Promise<{ msg: string }> {
|
||||
// return await this.authService.changePasswordCurrentUser(passwords, user.userId, user);
|
||||
// }
|
||||
// @Patch('change-tpin')
|
||||
// async changeTpinCurrentUser(
|
||||
// @Body(ValidationPipe) passwords: ChangePasswordDto,
|
||||
// @GetUser() user: PcduserDto
|
||||
// ): Promise<{ msg: string }> {
|
||||
|
||||
// return await this.authService.changeTransactionPinCurrentUser(passwords, user.userId, user);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthController, AuthUserController } from './auth.controller';
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
import * as config from 'config';
|
||||
import { PassportModule } from '@nestjs/passport';
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { CryptoService } from './crypto.service';
|
||||
import { JwtStrategy } from './jwt.stategy';
|
||||
import { PcduserRepository } from './pcduser.repository';
|
||||
import { PcdotpRepository } from './pcdotp.repository';
|
||||
|
||||
|
||||
const jwtConfig = config.get('jwt');
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
PassportModule.register({ defaultStrategy: 'jwt' }),
|
||||
JwtModule.register({
|
||||
secret: process.env.JWT_SECRET || jwtConfig.secret,
|
||||
signOptions: {
|
||||
expiresIn: jwtConfig.expiresIn,
|
||||
}
|
||||
}),
|
||||
TypeOrmModule.forFeature([
|
||||
PcduserRepository,
|
||||
PcdotpRepository,
|
||||
|
||||
]),
|
||||
],
|
||||
controllers: [AuthController, AuthUserController],
|
||||
providers: [
|
||||
AuthService,
|
||||
CryptoService,
|
||||
JwtStrategy,
|
||||
|
||||
],
|
||||
exports: [
|
||||
JwtStrategy,
|
||||
JwtModule,
|
||||
PassportModule,
|
||||
CryptoService
|
||||
],
|
||||
})
|
||||
export class AuthModule { }
|
||||
@ -0,0 +1,636 @@
|
||||
import { BadRequestException, Body, Logger, RequestTimeoutException, UnauthorizedException, } from '@nestjs/common';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import * as config from 'config';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
const https = require('https');
|
||||
const fs = require('fs');
|
||||
import { CryptoService } from './crypto.service';
|
||||
import { AuthCreadentialsDto } from './dto/auth-credentials.dto';
|
||||
import { TokenDto } from './dto/token.dto';
|
||||
import { JwtPayload } from './jwt-payload.interface';
|
||||
import { PcduserDto } from 'src/auth/dto/pcd-user.dto';
|
||||
import { Connection, createConnection, FindManyOptions, getConnection, getCustomRepository, In, IsNull, Not, QueryRunner } from 'typeorm';
|
||||
import { TempSignUpDto } from './dto/temp-sign-up.dto';
|
||||
import { PcduserRepository } from './pcduser.repository';
|
||||
import { InjectRepository } from '@nestjs/typeorm';
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import { PcdotpDto } from './dto/pcdotp.dto';
|
||||
import { PcdotpRepository } from './pcdotp.repository';
|
||||
|
||||
const { exec } = require("child_process");
|
||||
import { generateOtp } from 'otp-generator';
|
||||
|
||||
const dbConfig = config.get('db');
|
||||
const oracledb = require('oracledb');
|
||||
import { Pcduser } from './pcduser.entity';
|
||||
import { convertDateString } from 'src/pipe/pcd-date.pipe';
|
||||
import { UserBankDto } from './dto/user-bank.dto';
|
||||
|
||||
import { ChangePasswordDto } from './dto/change-password.dto';
|
||||
import { log } from 'console';
|
||||
import { version } from 'os';
|
||||
export enum Provider {
|
||||
GOOGLE = 'google'
|
||||
}
|
||||
|
||||
export class AuthService {
|
||||
private logger = new Logger('AuthService'); // for logging
|
||||
|
||||
constructor(
|
||||
@InjectRepository(PcduserRepository)
|
||||
private pcduserRepository: PcduserRepository,
|
||||
private jwtService: JwtService,
|
||||
private crypto: CryptoService,
|
||||
private pcdotpRepository: PcdotpRepository,
|
||||
|
||||
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
async getAll() {
|
||||
return await this.pcduserRepository.find();
|
||||
}
|
||||
|
||||
async userInfo(authCredentialsDto: AuthCreadentialsDto){
|
||||
const { username } = authCredentialsDto;
|
||||
let user = await this.pcduserRepository.findOne({ mobileNumber: (username.trim()).toLocaleLowerCase() });
|
||||
if(!user){
|
||||
throw new BadRequestException('User Details not found')
|
||||
}
|
||||
if(user){
|
||||
return {username:user.userName}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
async signIn(authCredentialsDto: AuthCreadentialsDto, ip?: string): Promise<TokenDto> {
|
||||
|
||||
|
||||
|
||||
|
||||
const user: PcduserDto = await this.validateUserPassword(authCredentialsDto);
|
||||
|
||||
if (!user) {
|
||||
throw new UnauthorizedException('User not Registered')
|
||||
}
|
||||
return await this.generateTokens(user, user.userName, ip, authCredentialsDto.module, user['changePassword']);
|
||||
}
|
||||
|
||||
|
||||
async validateUserPassword(authCredentialsDto: AuthCreadentialsDto): Promise<Pcduser> {
|
||||
const { username, password} = authCredentialsDto;
|
||||
|
||||
let user = await this.pcduserRepository.findOne({ mobileNumber: (username.trim()).toLocaleLowerCase() });
|
||||
console.log("user=============", user);
|
||||
if (!user) {
|
||||
throw new UnauthorizedException('User not Registered')
|
||||
}
|
||||
|
||||
if (user && await user.validatePassword(password, user)) {
|
||||
return user;
|
||||
}
|
||||
else {
|
||||
throw new BadRequestException("Wrong Password");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async forgotPassword(body: { pass: string, mobNo: string, }): Promise<any> {
|
||||
let iuserData: PcduserDto = await this.pcduserRepository.findOne({ where: { mobileNumber: body.mobNo } });
|
||||
console.log("iuserdata", iuserData.deviceId);
|
||||
|
||||
|
||||
const salt = await bcrypt.genSalt();
|
||||
iuserData.salt = salt;
|
||||
iuserData.pass = await this.pcduserRepository.encryptPassword(body.pass, salt);
|
||||
try {
|
||||
await this.pcduserRepository.save(iuserData);
|
||||
}
|
||||
catch (err) {
|
||||
throw new BadRequestException("Error in Password creation");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// }
|
||||
// async checkPhno(phno): Promise<any> {
|
||||
// const connection = await this.createConnection();
|
||||
// try {
|
||||
// const data = await connection.execute(`
|
||||
// SELECT * FROM PACS_MOB_CUST pmc WHERE pmc.MOBILE =${phno} `);
|
||||
// await connection.commit();
|
||||
// return data?.rows;
|
||||
// } catch (error) {
|
||||
// await connection.rollback();
|
||||
// console.log(error);
|
||||
// }
|
||||
// finally {
|
||||
// await this.closeConnection(connection)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// throw new UnauthorizedException('Invalid Credentials')
|
||||
|
||||
// // return await this.generateTokens(user, user.userName, ip, authCredentialsDto.module, user['changePassword']);
|
||||
// return true
|
||||
// }
|
||||
|
||||
// async sendOtp(body: { email?: string, mobile: string, deviceId?: string }, flag: string): Promise<void> {
|
||||
|
||||
// if (body.mobile) {
|
||||
// if ((body.mobile.trim() != '') && (flag == 'F' || flag == 'R')) {
|
||||
|
||||
// let isUserExist = await this.pcduserRepository.findOne({ where: { mobileNumber: body.mobile } });
|
||||
|
||||
// console.log("isUserExist",isUserExist);
|
||||
|
||||
// if (!isUserExist){
|
||||
// throw new BadRequestException("Invalid User");
|
||||
|
||||
// }
|
||||
|
||||
// if (flag === 'F' && isUserExist.deviceId !== body.deviceId && (isUserExist.bankId != 'acc1' && isUserExist.bankId != 'sims')) {
|
||||
// throw new BadRequestException("Unauthorized Device");
|
||||
// }
|
||||
|
||||
|
||||
// if (flag == 'R' && isUserExist.deviceId != null && isUserExist.deviceId != ''
|
||||
// && isUserExist.deviceId != undefined && isUserExist.bankId != 'acc1') {
|
||||
// throw new BadRequestException("User Already exist");
|
||||
// }
|
||||
// let newOtp = await this.generateOtp(isUserExist.userId.toString(), flag);
|
||||
// // if (isUserExist.email) {
|
||||
// // await this.sendMail(isUserExist.email, newOtp, 'fpwd');
|
||||
// // }
|
||||
// let config = database.filter(data => {
|
||||
// return data.corpCode == isUserExist.bankId
|
||||
// });
|
||||
// if (config[0].sms == 'globalSms' && isUserExist.mobileNumber) {
|
||||
// await this.simsSms(config[0], isUserExist, newOtp)
|
||||
|
||||
// } else {
|
||||
|
||||
|
||||
// await this.smsService.sendSms(isUserExist.mobileNumber, `${newOtp}`).then(res => {
|
||||
// console.log(res);
|
||||
|
||||
// }, err => {
|
||||
// console.log(err);
|
||||
|
||||
// });
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// async simsSms(config, isUserExist: PcduserDto, otp) {
|
||||
// const connection = await this.createConnection(isUserExist.bankId);
|
||||
// try {
|
||||
// const data = await connection.execute(`select msg_text from PACS_MSG_TEXT where depo_loan='O'`, [], { outFormat: oracledb.OBJECT })
|
||||
// let smsBody = { message: data.rows[0].MSG_TEXT.replace('#20', otp), number: isUserExist.mobileNumber, purpose: 'OTP', template: 'OTP' }
|
||||
// this.smsService.globalSms(smsBody, isUserExist)
|
||||
// }
|
||||
// catch (err) {
|
||||
// console.log(err);
|
||||
// }
|
||||
// finally { }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// async duplicateCheckingEmail(email: string, flag: string, filter?: FindManyOptions): Promise<any> {
|
||||
|
||||
// const isUserExist = await this.pcduserRepository.findOne({ where: { email: email } });
|
||||
|
||||
// if (isUserExist && flag == 'F')
|
||||
// return isUserExist;
|
||||
// if (isUserExist && flag == 'R')
|
||||
// return isUserExist;
|
||||
// else if (isUserExist && flag == 'P')
|
||||
// throw new BadRequestException(`Already registered with this email Id - ${isUserExist.email}`);
|
||||
|
||||
// }
|
||||
|
||||
// async verifyOtp(body: { otp: string, mobile: string, deviceId: string }, flag: string): Promise<any> {
|
||||
|
||||
// console.log('body===', body, flag);
|
||||
// let currentUser = await this.pcduserRepository.findOne({ where: { mobileNumber: body.mobile } });
|
||||
|
||||
// // const currentUser = await this.duplicateCheckingEmail(body.email, flag);
|
||||
// console.log(currentUser);
|
||||
|
||||
// let refCode;
|
||||
|
||||
// if (flag == 'F' && currentUser) {
|
||||
// refCode = currentUser.userId;
|
||||
// }
|
||||
// if (flag == 'R' && currentUser) {
|
||||
// refCode = currentUser.userId;
|
||||
// }
|
||||
// const filter: FindManyOptions = { where: { "refCode": refCode, "status": "I" }, order: { code: "DESC" } };
|
||||
// console.log(filter);
|
||||
|
||||
// const newOtp = await this.pcdotpRepository.find(filter);
|
||||
// console.log(newOtp);
|
||||
// if (!newOtp)
|
||||
// throw new BadRequestException("OTP Error. Resend OTP");
|
||||
// let currentDateTime = new Date().valueOf();
|
||||
// let otpTime = newOtp[0].createdDate.valueOf();
|
||||
// let diffMs = (currentDateTime - otpTime);
|
||||
// let otpExpiry = 120000
|
||||
|
||||
// let diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000);
|
||||
|
||||
// if (diffMins > config.get('otp').expiresIn)
|
||||
// throw new RequestTimeoutException('*OTP Expired');
|
||||
|
||||
// //otp expiries in 2 minutes
|
||||
// if (diffMs > otpExpiry)
|
||||
// throw new RequestTimeoutException('*OTP Expired');
|
||||
|
||||
// if (newOtp[0].otp != body.otp)
|
||||
// throw new UnauthorizedException("*Invalid OTP");
|
||||
// if (newOtp[0].otp == body.otp) {
|
||||
// newOtp[0].status = 'V';
|
||||
// await this.pcdotpRepository.save(newOtp[0]);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// if (flag == 'R') {
|
||||
// currentUser.status = 'V';
|
||||
// currentUser.deviceId = body.deviceId
|
||||
// const regUser = this.pcduserRepository.save(currentUser);
|
||||
// return regUser;
|
||||
// }
|
||||
|
||||
// if (flag == 'F')
|
||||
// return currentUser;
|
||||
|
||||
// }
|
||||
|
||||
// async resendOtp(body: { code?: string | number, email?: string, mobile: string }, flag: string): Promise<void> {
|
||||
// // const newOtp = await this.generateOtp(body.code.toString(), 'RR');
|
||||
|
||||
// // await this.smsService.sendSms(body.mobile, ` Your one time password(OTP) for Accurate Application Registration is,${newOtp}`);
|
||||
// const isUserExist = await this.pcduserRepository.findOne({ where: { mobileNumber: body.mobile } });
|
||||
// const newOtp = await this.generateOtp(isUserExist.userId.toString(), flag);
|
||||
|
||||
// if (body.mobile)
|
||||
// await this.smsService.sendSms(body.mobile, newOtp);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
async generateOtp(refCode: string, flag: string): Promise<string> {
|
||||
|
||||
var otpGenerator = require('otp-generator')
|
||||
|
||||
const newOtp = await otpGenerator.generate(6, { upperCase: false, specialChars: false, alphabets: false });
|
||||
|
||||
console.log("===newOtp====", newOtp);
|
||||
let usedFor: string = '';
|
||||
switch (flag) {
|
||||
case "R":
|
||||
usedFor = "REGISTRATION";
|
||||
case "RR":
|
||||
usedFor = "REGISTRATION RESEND"
|
||||
case "F":
|
||||
usedFor = "FORGOT PASSWORD";
|
||||
case "FR":
|
||||
usedFor = "FORGOT PASSWORD RESEND";
|
||||
|
||||
|
||||
}
|
||||
try {
|
||||
let igotp: PcdotpDto = new PcdotpDto();
|
||||
igotp.otp = newOtp;
|
||||
igotp.createdBy = 'SYSTEM';
|
||||
igotp.createdDate = new Date();
|
||||
igotp.modifiedBy = 'SYSTEM';
|
||||
igotp.modifiedDate = new Date();
|
||||
igotp.refCode = refCode;
|
||||
igotp.usedFor = usedFor;
|
||||
igotp.status = 'I';
|
||||
await this.pcdotpRepository.save(igotp);
|
||||
return newOtp;
|
||||
}
|
||||
catch (err) {
|
||||
console.log("====otperr===", err);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async updateUser(body: PcduserDto, user: PcduserDto, id: string): Promise<PcduserDto> {
|
||||
|
||||
const updatedUser = await this.pcduserRepository.findOne(id);
|
||||
if (updatedUser) {
|
||||
await this.duplicateCheckingUser(body, 'U');
|
||||
updatedUser.userName = body.userName;
|
||||
// updatedUser.email = body.email;
|
||||
updatedUser.mobileNumber = body.mobileNumber;
|
||||
updatedUser.modifiedBy = user.userId;
|
||||
updatedUser.userImagePath = body.userImagePath;
|
||||
updatedUser.memberNo = body.memberNo;
|
||||
for (let eagerCol of await this.pcduserRepository.getEagerColumns()) {
|
||||
delete body[eagerCol];
|
||||
}
|
||||
|
||||
try {
|
||||
delete updatedUser["pass"];
|
||||
delete updatedUser["salt"];
|
||||
delete updatedUser["refreshtoken"];
|
||||
return await this.pcduserRepository.save(updatedUser);
|
||||
} catch (error) {
|
||||
|
||||
console.log("====error====", error);
|
||||
throw new BadRequestException(error.message);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new BadRequestException("User does not Exist");
|
||||
}
|
||||
|
||||
async duplicateCheckingUser(body: PcduserDto, flag: string): Promise<void> {
|
||||
let existingUser: PcduserDto;
|
||||
if (flag == 'I') {
|
||||
let existingIgUser: PcduserDto = await this.pcduserRepository.findOne({ where: { email: body.email } });
|
||||
if (existingIgUser)
|
||||
throw new BadRequestException(`User with same Email exist`);
|
||||
existingUser = await this.pcduserRepository.findOne({ where: [{ "userId": body.userId }, { "email": body.email }, { "mobileNumber": body.mobileNumber }] });
|
||||
}
|
||||
else {
|
||||
existingUser = await this.pcduserRepository.findOne({ where: [{ "userId": (body.userId), "email": body.email }, { "userId": Not(body.userId), "mobileNumber": body.mobileNumber }] });
|
||||
}
|
||||
if (existingUser) {
|
||||
if (flag == 'I' && existingUser.userId == body.userId)
|
||||
throw new BadRequestException(`Duplication in UserId ${body.userId}`);
|
||||
if (existingUser.email == body.email)
|
||||
throw new BadRequestException(`Duplication in Email ${body.email}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// async googleSignIn(mediaData: any, ip?: string): Promise<TokenDto> {
|
||||
// const iuser: IuserDto = await this.iuserRepository.findOne({ email: mediaData.email });
|
||||
// if (!iuser) {
|
||||
// throw new UnauthorizedException('User Not registered..');
|
||||
// }
|
||||
|
||||
// return await this.generateTokens(iuser, iuser.userName, ip, ""); //specify the module here
|
||||
// }
|
||||
|
||||
// async getVersion(): Promise<{ versionNo: string }> {
|
||||
// const result = { versionNo: config.get('version').versionNo };
|
||||
// return result;
|
||||
// }
|
||||
// async createConnection(bankcode: string) {
|
||||
// return await connectOraDatabase(bankcode);
|
||||
// }
|
||||
|
||||
// async closeConnection(connection) {
|
||||
// await closeOraConnection(connection);
|
||||
// }
|
||||
/* The below method is used for generating the access token and refresh token when login */
|
||||
async generateTokens(user: PcduserDto, username: string, ip: string, module: string, changePassword?: string): Promise<TokenDto> {
|
||||
|
||||
const sessionId = (Math.floor((Math.random() * 100000000) + 1)).toString();
|
||||
const payload: JwtPayload = { userId: user.userId.trim(), userName: user.userName.trim(), emailId: user.email, module: module, sessionId: sessionId };
|
||||
const accessToken = await this.jwtService.sign(payload, { expiresIn: config.get('jwt').expiresIn });
|
||||
|
||||
const refreshToken = uuidv4();
|
||||
await this.pcduserRepository.updateRefreshToken(user.userId, refreshToken);
|
||||
|
||||
|
||||
this.logger.debug(`generated JWT Token with Payload ${JSON.stringify(payload)}`);
|
||||
const result: TokenDto = { accessToken: this.crypto.set(config.get('crypto').accessToken, accessToken), refreshToken: this.crypto.set(config.get('crypto').accessToken, refreshToken), emailId: user.email, module: module, changePassword: changePassword };
|
||||
|
||||
return result;
|
||||
}
|
||||
// async changePasswordManual(newPassword: ChangePasswordDto, id: string, user: PcduserDto, type?): Promise<{ msg: string, status: string }> {
|
||||
// let salt = await bcrypt.genSalt();
|
||||
// const selectedUser = await this.pcduserRepository.findOne(id);
|
||||
// console.log('newPassword=====', newPassword);
|
||||
// console.log('type=====', type);
|
||||
// if (!newPassword || !newPassword.pass || !newPassword.pass.toString())
|
||||
// throw new BadRequestException("Password can't be null");
|
||||
// if (type == 'T') {
|
||||
|
||||
// selectedUser.tSalt = salt;
|
||||
// selectedUser.tPass = await this.hashPassword(newPassword.pass, salt);
|
||||
// } else if (type == 'A') {
|
||||
|
||||
// selectedUser.tSalt = salt;
|
||||
// selectedUser.tPass = await this.hashPassword(newPassword.tpass, salt);
|
||||
// salt = await bcrypt.genSalt();
|
||||
// selectedUser.salt = salt;
|
||||
// selectedUser.pass = await this.hashPassword(newPassword.pass, salt);
|
||||
// }
|
||||
// else {
|
||||
|
||||
// selectedUser.salt = salt;
|
||||
// selectedUser.pass = await this.hashPassword(newPassword.pass, salt);
|
||||
// }
|
||||
|
||||
// try {
|
||||
// await this.pcduserRepository.save(selectedUser);
|
||||
// return { msg: "Your password changed sucessfully.", status: "Y" }
|
||||
// } catch (error) {
|
||||
// // if(error.code==23505) not working in orcale
|
||||
// console.log("====error====", error);
|
||||
// throw new BadRequestException(error.message);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// async changePasswordEmail(id: string, user: PcduserDto, body: PcduserDto): Promise<{ msg: string }> {
|
||||
// const salt = await bcrypt.genSalt();
|
||||
// const selectedUser = await this.pcduserRepository.findOne(id);
|
||||
// if (!selectedUser)
|
||||
// throw new BadRequestException("No such user exist");
|
||||
// selectedUser.salt = salt;
|
||||
// const password: string = generate({ length: 10, lowercase: true, numbers: true, uppercase: true });
|
||||
// selectedUser.pass = await this.hashPassword(password, salt);
|
||||
// try {
|
||||
// await this.iuserRepository.save(selectedUser);
|
||||
|
||||
// await this.sendMail(selectedUser.email, password);
|
||||
// await this.smsService.sendSms(selectedUser.mobileNumber, "Please check your email for new password");
|
||||
// return { msg: "Please check your email for new password" };
|
||||
// } catch (error) {
|
||||
// // if(error.code==23505) not working in orcale
|
||||
// console.log("====error====", error);
|
||||
// throw new BadRequestException(error.message);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// async changePasswordCurrentUser(passwords: { currentPwd: string, pass: string, deviceId?: string }, id: string, user: PcduserDto): Promise<{ msg: string, status: string }> {
|
||||
// let authcredentialsDto = new AuthCreadentialsDto();
|
||||
|
||||
// authcredentialsDto.password = passwords.currentPwd;
|
||||
// authcredentialsDto.username = user.mobileNumber;
|
||||
// authcredentialsDto.deviceId = passwords.deviceId;
|
||||
// const currentUser = await this.validateUserPassword(authcredentialsDto);
|
||||
// console.log(currentUser);
|
||||
|
||||
// if (currentUser) {
|
||||
|
||||
/* const connection = await this.createConnection(user.bankId);
|
||||
try {
|
||||
|
||||
let mobCustQuery = `SELECT CUST_ID "cust",mcode||'/'||memno "custId" ,CUST_NAME "custName" ,MOBILE "mobile",decript_pwd(mpin) as "mPin",
|
||||
decript_pwd(nvl(tpin,mpin)) as "tPin",'001' "bankId"
|
||||
FROM PACS_MOB_CUST PMC WHERE PMC.MOBILE = '${user.mobileNumber}' AND PMC.ISACTIVE = '1'`
|
||||
const mobCustData = await connection.execute(mobCustQuery, [], { outFormat: oracledb.OBJECT });
|
||||
console.log(mobCustData.rows[0]);
|
||||
if (mobCustData.rows[0]?.mPin == passwords.pass) {
|
||||
return { msg: "Generated Password Cannot be same as New Password", status:"N" }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err)
|
||||
} finally {
|
||||
this.closeConnection(connection)
|
||||
}*/
|
||||
|
||||
// return await this.changePasswordManual(passwords, user.userId, user, 'P');
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
// async changeTransactionPinCurrentUser(passwords: { currentPwd: string, pass: string, deviceId?: string }, id: string, user: PcduserDto): Promise<{ msg: string }> {
|
||||
// let authcredentialsDto = new AuthCreadentialsDto();
|
||||
|
||||
// authcredentialsDto.password = passwords.currentPwd;
|
||||
// authcredentialsDto.username = user.mobileNumber;
|
||||
// authcredentialsDto.deviceId = passwords.deviceId
|
||||
// const currentUser = await this.validateTransactionPassword(authcredentialsDto);
|
||||
|
||||
// if (currentUser) {
|
||||
// return await this.changePasswordManual(passwords, user.userId, user, 'T');
|
||||
// }
|
||||
// }
|
||||
// async changeTransactionPinMpinCurrentUser(passwords: ChangePasswordDto): Promise<{ msg: string }> {
|
||||
// let authcredentialsDto = new AuthCreadentialsDto();
|
||||
// let user: PcduserDto
|
||||
// user = await this.pcduserRepository.findOne({ mobileNumber: passwords.mobNo });
|
||||
|
||||
// console.log("changebothpin");
|
||||
|
||||
// authcredentialsDto.password = passwords.pass;
|
||||
// authcredentialsDto.username = user.mobileNumber;
|
||||
// authcredentialsDto.deviceId = passwords.deviceId;
|
||||
// // authcredentialsDto.tpassword = passwords.tpass;
|
||||
// // const currentUser = await this.validateUserPassword(authcredentialsDto);
|
||||
// // console.log("currentuser", currentUser);
|
||||
|
||||
// if (user) {
|
||||
|
||||
|
||||
// return await this.changePasswordManual(passwords, user.userId, user, 'A');
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
private async hashPassword(password: string, salt: string): Promise<string> {
|
||||
return await bcrypt.hash(password, salt);
|
||||
}
|
||||
|
||||
// async googleSignIn(mediaData: any, ip?: string): Promise<TokenDto> {
|
||||
// let pcduser: PcduserDto;
|
||||
// pcduser = await this.pcduserRepository.findOne({ email: mediaData.email });
|
||||
// if (!pcduser) {
|
||||
// // pcduser = await this.tempSignUp({ email: mediaData.email, username: mediaData.name, password: '' })
|
||||
// // throw new UnauthorizedException('User Not registered..');
|
||||
// }
|
||||
|
||||
// return await this.generateTokens(pcduser, pcduser.userName, ip, ""); //specify the module here
|
||||
// }
|
||||
|
||||
// async createOnlineUsers() {
|
||||
// let createdConnection: Connection;
|
||||
// try {
|
||||
// createdConnection = getConnection(dbConfig.oraclesid || 'con');
|
||||
|
||||
// } catch (e) {
|
||||
// createdConnection = await createConnection({
|
||||
// name: dbConfig.oraclesid || 'con',
|
||||
// type: "oracle",
|
||||
// host: process.env.RDS_HOSTNAME || dbConfig.oraclehost,
|
||||
// port: process.env.RDS_PORT || dbConfig.oracleport,
|
||||
// username: process.env.RDS_USERNAME || dbConfig.oracleusername,
|
||||
// password: process.env.RDS_PASSWORD || dbConfig.oraclepassword,
|
||||
// sid: process.env.RDS_DB_NAME || dbConfig.oraclesid,
|
||||
// logging: true,
|
||||
// // entities: [Iuser, IuserLog, Imotp, Book],
|
||||
// entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||
// synchronize: false,
|
||||
// });
|
||||
|
||||
// }
|
||||
// let existingUser = await this.pcduserRepository.find({ select: ["custId"] });
|
||||
// let existingUserArr = [];
|
||||
// for (let usr of existingUser) {
|
||||
// existingUserArr.push(usr.custId);
|
||||
// }
|
||||
// createdConnection.connect();
|
||||
// let oracustRep = createdConnection.getCustomRepository(CustomerRepository);
|
||||
// let newOraCust = await oracustRep.find({ select: ["intcustno", "customerMailId", "customerName", "customerMobileNo"], where: { "intcustno": Not(In(existingUserArr)), "customerMobileNo": Not(IsNull()) }, });
|
||||
// let unnewOraCust = newOraCust.filter(
|
||||
// (value, index, self) =>
|
||||
// index === self.findIndex((t) => (
|
||||
// t.intcustno === value.intcustno)
|
||||
// )
|
||||
// );
|
||||
// for (let row of newOraCust) {
|
||||
// let authCredentials = new TempSignUpDto();
|
||||
// authCredentials.custId = row.intcustno;
|
||||
// authCredentials.email = row.customerMailId ? row.customerMailId.toLowerCase() : null;
|
||||
// authCredentials.username = row.customerName;
|
||||
// authCredentials.password = 'admin';
|
||||
// console.log('|||||||||||||', authCredentials, '|||||||||||||');
|
||||
// try {
|
||||
// const result = await this.pcduserRepository.signUp(authCredentials, row.customerMobileNo, row.shareno);
|
||||
|
||||
// } catch (err) {
|
||||
// console.log(err);
|
||||
|
||||
// // throw new BadRequestException("Error in Password creation");
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// async changeAccount(acNo, memberNo: string, user: PcduserDto) {
|
||||
// return await this.pcduserRepository.update(user.userId, { "custId": acNo, "memberNo": memberNo });
|
||||
// }
|
||||
|
||||
// async sendSample() {
|
||||
// this.smsService.sendSms(8893774869, 787878);
|
||||
// console.log('==========');
|
||||
// return;
|
||||
|
||||
|
||||
// }
|
||||
// async encryptBankCode(bankCode: string) {
|
||||
// return await this.crypto.encryptAesB64(bankCode);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import * as CryptoJS from 'crypto-js';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class CryptoService {
|
||||
constructor() { }
|
||||
|
||||
//The set method is use for encrypt the value.
|
||||
set(keys, value) {
|
||||
var key = CryptoJS.enc.Utf8.parse(keys);
|
||||
var iv = CryptoJS.enc.Utf8.parse(keys);
|
||||
var encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(value.toString()), key,
|
||||
{
|
||||
keySize: 128 / 8,
|
||||
iv: iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
|
||||
return encrypted.toString();
|
||||
}
|
||||
|
||||
//The get method is used for decrypt the value.
|
||||
get(keys, value) {
|
||||
var key = CryptoJS.enc.Utf8.parse(keys);
|
||||
var iv = CryptoJS.enc.Utf8.parse(keys);
|
||||
var decrypted = CryptoJS.AES.decrypt(value, key, {
|
||||
keySize: 128 / 8,
|
||||
iv: iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
|
||||
return decrypted.toString(CryptoJS.enc.Utf8);
|
||||
}
|
||||
|
||||
//encryption method
|
||||
encryptAesB64(value) {
|
||||
let b64 = CryptoJS.AES.encrypt(value.toString(), 'etarucca').toString();
|
||||
let e64 = CryptoJS.enc.Base64.parse(b64);
|
||||
let encryptedCode = e64.toString(CryptoJS.enc.Hex);
|
||||
return { "data": encryptedCode };
|
||||
}
|
||||
|
||||
//decryption method
|
||||
decryptAesB64(value) {
|
||||
var reb64 = CryptoJS.enc.Hex.parse(value);
|
||||
var bytes = reb64.toString(CryptoJS.enc.Base64);
|
||||
var decrypt = CryptoJS.AES.decrypt(bytes, 'etarucca');
|
||||
var dycryptedCode = decrypt.toString(CryptoJS.enc.Utf8);
|
||||
return dycryptedCode
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
import { IsNotEmpty, IsString, MaxLength, maxLength, MinLength } from "class-validator";
|
||||
|
||||
export class AuthCreadentialsDto {
|
||||
|
||||
|
||||
@IsString()
|
||||
@MinLength(2)
|
||||
@MaxLength(100)
|
||||
username: string;
|
||||
|
||||
password: string;
|
||||
|
||||
module?: string;
|
||||
|
||||
custId: string;
|
||||
|
||||
email: string;
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
import { IsString, MaxLength, MinLength } from "class-validator";
|
||||
|
||||
export class ChangePasswordDto{
|
||||
|
||||
// @MinLength(4)
|
||||
// @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,
|
||||
// { message: 'password is too weak' }
|
||||
// )
|
||||
currentPwd:string;
|
||||
|
||||
// @MinLength(4)
|
||||
pass: string;
|
||||
|
||||
|
||||
tpass?: string;
|
||||
|
||||
deviceId?:string;
|
||||
|
||||
mobNo? : string
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
|
||||
import {Pcduser} from "src/auth/pcduser.entity";
|
||||
|
||||
export const GetUser = createParamDecorator(
|
||||
(data: unknown, ctx: ExecutionContext):Pcduser => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
return request.user;
|
||||
},
|
||||
);
|
||||
@ -0,0 +1,15 @@
|
||||
export class GoogleProfileDto{
|
||||
displayName: string;
|
||||
|
||||
name: { familyName: string, givenName: string};
|
||||
|
||||
emails: {value: string, verified: true}[];
|
||||
|
||||
photos: {value: string}[];
|
||||
|
||||
provider: string;
|
||||
|
||||
_row: { sub: string, name: string, given_name: string, family_name: string, picture: string, email: string, email_verified: boolean, locale: string};
|
||||
|
||||
_json: { sub: string, name: string, given_name: string, family_name: string, picture: string, email: string, email_verified: boolean };
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
export class PcduserDto {
|
||||
|
||||
userId: string;
|
||||
|
||||
userName: string;
|
||||
|
||||
groupOrUser: string;
|
||||
|
||||
pass: string | null;
|
||||
|
||||
salt: string | null;
|
||||
|
||||
secuLevel: string | null;
|
||||
|
||||
pwdExpDays: number | null;
|
||||
|
||||
email: string;
|
||||
|
||||
mobileNumber: string;
|
||||
|
||||
userImagePath: string;
|
||||
|
||||
refreshtoken: string;
|
||||
|
||||
memberNo: string;
|
||||
|
||||
custId: string;
|
||||
|
||||
status: string;
|
||||
|
||||
bankId: string;
|
||||
|
||||
tPass: string | null;
|
||||
|
||||
tSalt: string | null;
|
||||
|
||||
deviceId:string;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class PcdotpDto extends PcdBaseDto{
|
||||
|
||||
code: number;
|
||||
|
||||
otp: string;
|
||||
|
||||
refCode: number | any;
|
||||
|
||||
usedFor: string;
|
||||
|
||||
status: string;
|
||||
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
import { IsNotEmpty } from "class-validator";
|
||||
|
||||
export class RtgsDto {
|
||||
|
||||
rtgsId: string;
|
||||
|
||||
brCode: string;
|
||||
|
||||
dayDt: string;
|
||||
|
||||
code: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
accNo: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
name: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
toAccNo: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
toParti: string;
|
||||
|
||||
toEmail: null;
|
||||
|
||||
toMobile: null;
|
||||
|
||||
@IsNotEmpty()
|
||||
toBank: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
toBranch: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
ifscCode: string;
|
||||
|
||||
cashAdj: string;
|
||||
|
||||
payMode: string;
|
||||
|
||||
remarks: string;
|
||||
|
||||
uploadStatus: string;
|
||||
|
||||
credit: null;
|
||||
|
||||
@IsNotEmpty()
|
||||
debit: number;
|
||||
|
||||
slipNo: number;
|
||||
|
||||
clerk: string;
|
||||
|
||||
cashier: string;
|
||||
|
||||
manager: string;
|
||||
|
||||
clerkId: number;
|
||||
|
||||
mgrId: number;
|
||||
|
||||
cashierId: null;
|
||||
|
||||
rejectReason: null;
|
||||
|
||||
entryTime: string;
|
||||
|
||||
appScr: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
commAmt: number;
|
||||
|
||||
chNo: null;
|
||||
|
||||
chDate: null;
|
||||
|
||||
dayDate: any;
|
||||
|
||||
@IsNotEmpty()
|
||||
depType: any;
|
||||
|
||||
dayBeginDt: any;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
import { IsString, MinLength, MaxLength, Matches, IsNotEmpty, IsNumber, IsIn } from "class-validator";
|
||||
|
||||
export class TempSignUpDto {
|
||||
|
||||
// @IsString()
|
||||
// @MinLength(0)
|
||||
// @MaxLength(12)
|
||||
// @IsNotEmpty()
|
||||
email?: string;
|
||||
|
||||
|
||||
@IsNotEmpty()
|
||||
custId: string;
|
||||
|
||||
|
||||
@IsString()
|
||||
@MinLength(2)
|
||||
@MaxLength(20)
|
||||
username: string;
|
||||
|
||||
|
||||
@IsString()
|
||||
@MinLength(4)
|
||||
@MaxLength(20)
|
||||
// @Matches(/((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,
|
||||
// { message: 'password is too weak' }
|
||||
// )
|
||||
password: string;
|
||||
|
||||
tpassword?: string;
|
||||
// @IsIn(["T","C"])
|
||||
// userCategory: string;
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
export class TokenDto {
|
||||
|
||||
accessToken: string;
|
||||
|
||||
refreshToken: string;
|
||||
|
||||
emailId: string;
|
||||
|
||||
module: string;
|
||||
|
||||
changePassword?:string
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
|
||||
export class UserBankDto {
|
||||
custId:string;
|
||||
|
||||
custName:string;
|
||||
|
||||
mobile:string;
|
||||
|
||||
mPin:string;
|
||||
|
||||
tPin:string;
|
||||
|
||||
email:string;
|
||||
|
||||
bankId:string;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
export interface JwtPayload {
|
||||
|
||||
userId: string;
|
||||
|
||||
emailId: string;
|
||||
|
||||
userName: string;
|
||||
|
||||
sessionId: string;
|
||||
|
||||
module: string;
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
import { PassportStrategy } from '@nestjs/passport';
|
||||
import { Strategy, ExtractJwt } from 'passport-jwt';
|
||||
import { Injectable, UnauthorizedException, Logger, Inject, Scope } from '@nestjs/common';
|
||||
import { JwtPayload } from './jwt-payload.interface';
|
||||
import * as config from 'config';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { PcduserRepository } from './pcduser.repository';
|
||||
import { PcduserDto } from 'src/auth/dto/pcd-user.dto';
|
||||
|
||||
@Injectable()
|
||||
export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
|
||||
private logger = new Logger('Jwt Strategy'); // for logging
|
||||
|
||||
constructor(
|
||||
) {
|
||||
super({
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
ignoreExpiration: true,
|
||||
secretOrKey: process.env.JWT_SECRET || config.get('jwt').secret,
|
||||
})
|
||||
}
|
||||
|
||||
async validate(payload: JwtPayload) {
|
||||
const { userId, userName, emailId, module } = payload;
|
||||
this.logger.log(`Payload ${JSON.stringify(payload)}`);
|
||||
|
||||
let connect = getConnection();
|
||||
const repo = await connect.getCustomRepository(PcduserRepository);
|
||||
const user:PcduserDto = await repo.findOne(userId);
|
||||
delete user.pass;
|
||||
delete user.salt;
|
||||
if (!user) {
|
||||
this.logger.log(` Unauthorized `);
|
||||
throw new UnauthorizedException();
|
||||
}
|
||||
|
||||
user["payload"] = payload;
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
import { Entity, PrimaryColumn, Column, PrimaryGeneratedColumn } from "typeorm";
|
||||
import { PcdBaseEntity } from "../framework/custom/pcd-entity.custom";
|
||||
|
||||
@Entity('pcdotp')
|
||||
export class Pcdotp extends PcdBaseEntity {
|
||||
|
||||
@PrimaryGeneratedColumn({
|
||||
name: 'code',
|
||||
})
|
||||
code: number;
|
||||
|
||||
@Column({
|
||||
type: 'varchar',
|
||||
name: 'otp',
|
||||
length: 6,
|
||||
nullable: false,
|
||||
})
|
||||
otp: string;
|
||||
|
||||
@Column({
|
||||
type: 'numeric',
|
||||
name: 'ref_code',
|
||||
nullable: true,
|
||||
})
|
||||
refCode: number;
|
||||
|
||||
@Column({
|
||||
type: 'varchar',
|
||||
name: 'used_for',
|
||||
length: 500,
|
||||
nullable: true,
|
||||
})
|
||||
usedFor: string;
|
||||
|
||||
@Column({
|
||||
type: 'char',
|
||||
name: 'status',
|
||||
length: 1,
|
||||
nullable: false,
|
||||
})
|
||||
status: string;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { Logger } from "@nestjs/common";
|
||||
import { Pcdotp } from "./pcdotp.entity";
|
||||
import * as config from 'config';
|
||||
|
||||
@EntityRepository(Pcdotp)
|
||||
export class PcdotpRepository extends Repository<Pcdotp>{
|
||||
private logger = new Logger('PcdotpRepository'); // for logging
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,166 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { Column, Entity, OneToMany, PrimaryColumn } from "typeorm";
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import { BadRequestException } from "@nestjs/common";
|
||||
|
||||
@Entity('pcduser')
|
||||
export class Pcduser extends PcdBaseEntity {
|
||||
@PrimaryColumn({
|
||||
name: "user_id",
|
||||
primary: true,
|
||||
type: "varchar",
|
||||
length: 12
|
||||
})
|
||||
userId: string;
|
||||
@Column({
|
||||
name: "user_name",
|
||||
type: "varchar",
|
||||
length: 100
|
||||
})
|
||||
userName: string;
|
||||
|
||||
@Column({
|
||||
name: "group_or_user",
|
||||
type: "char",
|
||||
length: 1,
|
||||
default: () => "'U'",
|
||||
})
|
||||
groupOrUser: string;
|
||||
@Column({
|
||||
name: "pass",
|
||||
type: "varchar",
|
||||
length: 500
|
||||
})
|
||||
pass: string | null;
|
||||
|
||||
|
||||
@Column({
|
||||
name: "salt",
|
||||
type: "varchar",
|
||||
nullable: true,
|
||||
length: 50
|
||||
})
|
||||
salt: string | null;
|
||||
|
||||
|
||||
@Column({
|
||||
name: "secu_level",
|
||||
type: "char",
|
||||
nullable: true,
|
||||
length: 1
|
||||
})
|
||||
secuLevel: string | null;
|
||||
|
||||
@Column({
|
||||
name: "pwd_exp_days",
|
||||
type: "int",
|
||||
nullable: true,
|
||||
default: () => "(0)"
|
||||
})
|
||||
pwdExpDays: number | null;
|
||||
|
||||
@Column({
|
||||
name: 'email',
|
||||
type: 'varchar',
|
||||
length: 500,
|
||||
// unique: true,
|
||||
nullable: true
|
||||
})
|
||||
email: string;
|
||||
|
||||
@Column({
|
||||
name: 'mobile_number',
|
||||
type: 'varchar',
|
||||
length: 100,
|
||||
nullable: true,
|
||||
unique: false
|
||||
})
|
||||
mobileNumber: string;
|
||||
|
||||
@Column({
|
||||
name: 'refresh_token',
|
||||
type: 'varchar',
|
||||
nullable: true,
|
||||
length: 100,
|
||||
})
|
||||
refreshtoken: string;
|
||||
|
||||
@Column({
|
||||
name: 'user_image_path',
|
||||
type: 'varchar',
|
||||
length: 500,
|
||||
nullable: true
|
||||
})
|
||||
userImagePath: string;
|
||||
|
||||
@Column({
|
||||
name: 'member_no',
|
||||
type: 'varchar',
|
||||
length: 20,
|
||||
nullable: true
|
||||
})
|
||||
memberNo: string;
|
||||
|
||||
@Column({
|
||||
type: 'varchar',
|
||||
name: "cust_id",
|
||||
nullable: true,
|
||||
length: 20,
|
||||
})
|
||||
custId: string;
|
||||
|
||||
@Column({
|
||||
name: "device_id",
|
||||
type: "varchar"
|
||||
})
|
||||
deviceId:string;
|
||||
|
||||
|
||||
@Column({
|
||||
type: 'char',
|
||||
name: "status",
|
||||
nullable: true,
|
||||
length: 1
|
||||
})
|
||||
status: string;
|
||||
@Column({
|
||||
type: 'varchar',
|
||||
name: "bank_id",
|
||||
nullable: true,
|
||||
unique: true,
|
||||
length: 20,
|
||||
})
|
||||
bankId: string;
|
||||
@Column({
|
||||
name: "t_pass",
|
||||
type: "varchar",
|
||||
length: 500
|
||||
})
|
||||
tPass: string | null;
|
||||
|
||||
|
||||
@Column({
|
||||
name: "t_salt",
|
||||
type: "varchar",
|
||||
nullable: true,
|
||||
length: 50
|
||||
})
|
||||
tSalt: string | null;
|
||||
async validatePassword(password: string,user ): Promise<boolean> {
|
||||
if((user.deviceId==='null' || user.deviceId==="" || user.deviceId === undefined) && (user.bankId !='acc1' && user.bankId != 'sims')){
|
||||
throw new BadRequestException("Device not Registered.Please Register");
|
||||
}else{
|
||||
const hash = await bcrypt.hash(password, this.salt);
|
||||
return hash === this.pass;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
async validateTransactionPassword(password: string): Promise<boolean> {
|
||||
const hash = await bcrypt.hash(password, this.tSalt);
|
||||
return hash === this.tPass;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
import { BadRequestException, Logger } from "@nestjs/common";
|
||||
import { EntityRepository, ILike, Like, Repository } from "typeorm";
|
||||
import { TempSignUpDto } from "./dto/temp-sign-up.dto";
|
||||
import { Pcduser } from "./pcduser.entity";
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import { AuthCreadentialsDto } from "./dto/auth-credentials.dto";
|
||||
import { PcduserDto } from "src/auth/dto/pcd-user.dto";
|
||||
|
||||
@EntityRepository(Pcduser)
|
||||
export class PcduserRepository extends Repository<Pcduser>{
|
||||
private logger = new Logger('Pcduser Repo'); // for logging
|
||||
async updateRefreshToken(userId: string, refreshToken: string) {
|
||||
const user = await this.findOne({ userId: userId });
|
||||
user.refreshtoken = refreshToken;
|
||||
this.save(user);
|
||||
}
|
||||
|
||||
async signUp(authCredentials: TempSignUpDto, customerMobileNo, memberNo?, bankId?, secuLevel?): Promise<any> {
|
||||
|
||||
const salt = await bcrypt.genSalt();
|
||||
const tsalt = await bcrypt.genSalt();
|
||||
const user = new Pcduser();
|
||||
// user.userId = authCredentials.userId;
|
||||
let maxCode: number = 10001;
|
||||
const maxRow: PcduserDto = await this.findOne({
|
||||
where: { userId: Like('1%') },
|
||||
order: {
|
||||
"userId": "DESC"
|
||||
}
|
||||
});
|
||||
|
||||
if (maxRow) {
|
||||
maxCode = parseInt(maxRow.userId) + 1;
|
||||
}
|
||||
if (!customerMobileNo) {
|
||||
user.status = 'V';
|
||||
}
|
||||
else {
|
||||
user.status = 'N';
|
||||
user.mobileNumber = customerMobileNo;
|
||||
}
|
||||
user.userId = maxCode.toString();
|
||||
user.userName = authCredentials.username;
|
||||
user.custId = authCredentials.custId;
|
||||
user.email = authCredentials.email;
|
||||
user.createdBy = "SYSTEM";
|
||||
user.modifiedBy = "SYSTEM";
|
||||
user.groupOrUser = 'U';
|
||||
user.memberNo = authCredentials.custId;
|
||||
user.secuLevel = secuLevel;
|
||||
user.salt = salt;
|
||||
user.pass = await this.hashPassword(authCredentials.password, salt);
|
||||
user.tSalt = tsalt;
|
||||
user.tPass = await this.hashPassword(authCredentials.tpassword, tsalt);
|
||||
user.bankId = bankId;
|
||||
try {
|
||||
return await user.save();
|
||||
} catch (error) {
|
||||
// if(error.code==23505) not working in orcale
|
||||
throw new BadRequestException(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async getEagerColumns(): Promise<string[]> {
|
||||
/*
|
||||
For getting Eager true columns having Many to One relations.
|
||||
We need to remove the eager columns before insertions or updations or it will not allow to save data (But save message will show, but data not updated)
|
||||
*/
|
||||
const COLUMNS: string[] = [];
|
||||
for (let columnProperty of this.metadata.eagerRelations) {
|
||||
COLUMNS.push(columnProperty.propertyName);
|
||||
}
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async encryptPassword(password: string, salt: string): Promise<string> {
|
||||
return await this.hashPassword(password, salt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async hashPassword(password: string, salt: string): Promise<string> {
|
||||
return await bcrypt.hash(password, salt);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
import { TypeOrmModuleOptions } from "@nestjs/typeorm";
|
||||
import * as config from 'config'
|
||||
|
||||
//const dbConfig = config.get('db');
|
||||
|
||||
export const typeOrmConfig: TypeOrmModuleOptions = {
|
||||
type:'postgres',
|
||||
host:'3.110.164.8',
|
||||
port:5432,
|
||||
username:'postgres',
|
||||
password:'inv123',
|
||||
database:'scb-tender',
|
||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||
synchronize:true,
|
||||
logging:false
|
||||
|
||||
};
|
||||
@ -0,0 +1,45 @@
|
||||
|
||||
export class ScbcustomerDto {
|
||||
|
||||
custId:number;
|
||||
|
||||
branchCode:string;
|
||||
|
||||
customerCode:string;
|
||||
|
||||
customerName:string;
|
||||
|
||||
customerAddress1:string;
|
||||
|
||||
customerAddress2:string;
|
||||
|
||||
customerAddress3:string;
|
||||
|
||||
postofficeName:string;
|
||||
|
||||
landMark:string;
|
||||
|
||||
city:string;
|
||||
|
||||
taluk:string;
|
||||
|
||||
district:string;
|
||||
|
||||
state:string;
|
||||
|
||||
pincode:string;
|
||||
|
||||
dateOfBirth:Date;
|
||||
|
||||
customerMailId:string;
|
||||
|
||||
customerMobileNo:string;
|
||||
|
||||
status:number;
|
||||
|
||||
gender:string;
|
||||
|
||||
photoImage: string;
|
||||
|
||||
customerType: number;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
export class IfscListDto {
|
||||
bank: string;
|
||||
ifsc: string;
|
||||
branch: string;
|
||||
address: string;
|
||||
city1: string;
|
||||
city2: string;
|
||||
state: string;
|
||||
std_code: string;
|
||||
phone: string;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
export class MailConfigDto {
|
||||
|
||||
smtpUserName: string;
|
||||
|
||||
smtpId: number;
|
||||
|
||||
smtpPassword: string;
|
||||
|
||||
smtpHost: string;
|
||||
|
||||
encryptionType: string;
|
||||
|
||||
smtpPort: string;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
export class MenuDto {
|
||||
|
||||
menuId: number;
|
||||
|
||||
menuName: string;
|
||||
|
||||
moduleId: number;
|
||||
|
||||
menuIcon: string;
|
||||
|
||||
menuOrder: number;
|
||||
|
||||
routerLink: string;
|
||||
|
||||
menuParentId: number;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
|
||||
export interface PacsMobBenefDto {
|
||||
benefId: number;
|
||||
|
||||
custId: string;
|
||||
|
||||
bankId: string;
|
||||
|
||||
targetType: string;
|
||||
|
||||
targetId: string;
|
||||
|
||||
targetNo: string;
|
||||
|
||||
beneficiaryName: string;
|
||||
|
||||
isactive: string;
|
||||
|
||||
entryTime: string;
|
||||
|
||||
trgtId: string;
|
||||
}
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class PaymentStatusDto extends PcdBaseDto {
|
||||
|
||||
id: number;
|
||||
|
||||
paymentDate: Date;
|
||||
|
||||
paymentOption: string;
|
||||
|
||||
paymentCardDetails: string;
|
||||
|
||||
status: string;
|
||||
|
||||
type: string
|
||||
|
||||
email: string;
|
||||
|
||||
mobile: string;
|
||||
|
||||
application: number;
|
||||
|
||||
paymentId: number;
|
||||
|
||||
billingAddress1: string;
|
||||
|
||||
billingAddress2: string;
|
||||
|
||||
billingAddress3: string;
|
||||
|
||||
billingAddress4: string;
|
||||
|
||||
amount: number;
|
||||
|
||||
remarks: string;
|
||||
|
||||
txnid: number;
|
||||
|
||||
identifier: string;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
export class PaymentDto {
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
email: string;
|
||||
phone: number;
|
||||
amount: number;
|
||||
productinfo: string;
|
||||
txnid: number;
|
||||
surl: string;
|
||||
furl: string;
|
||||
service_provider: string;
|
||||
|
||||
constructor() {
|
||||
this.furl = 'http://localhost:3100/api/v1/payment-gateway/failure';
|
||||
this.surl = 'http://localhost:3100/api/v1/payment-gateway/success';
|
||||
|
||||
// this.furl = 'https://flexdata.api.teorainfotech.com/API/V1/payment-gateway/failure';
|
||||
// this.surl = 'https://flexdata.api.teorainfotech.com/API/V1/payment-gateway/success';
|
||||
|
||||
this.txnid = this.getRandomInt();
|
||||
}
|
||||
|
||||
getRandomInt() {
|
||||
return Math.floor(100000 + Math.random() * 900000);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
export interface PigmyDailyDto {
|
||||
dayDt: Date;
|
||||
|
||||
brcode: string;
|
||||
|
||||
code: string;
|
||||
|
||||
agcode: number;
|
||||
|
||||
accno: string;
|
||||
|
||||
cashAdj: string;
|
||||
|
||||
credit: number;
|
||||
|
||||
debit: null;
|
||||
|
||||
bal: number;
|
||||
|
||||
clerk: string;
|
||||
|
||||
cashier: string;
|
||||
|
||||
manager: string;
|
||||
|
||||
intCode: null;
|
||||
|
||||
intAmt: null;
|
||||
|
||||
intdt: null;
|
||||
|
||||
othCode: null;
|
||||
|
||||
othCharge: null;
|
||||
|
||||
passbook: null;
|
||||
|
||||
sdclerk: null;
|
||||
|
||||
sdmgr: null;
|
||||
|
||||
slipno: null;
|
||||
|
||||
pname: null;
|
||||
|
||||
collDt: null;
|
||||
|
||||
trSection: null;
|
||||
|
||||
transId: null;
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
|
||||
export class PurchaseDto {
|
||||
|
||||
amount: number;
|
||||
|
||||
application: number;
|
||||
|
||||
mobile: string;
|
||||
|
||||
email: string;
|
||||
|
||||
type: string;
|
||||
|
||||
menuId: string;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
export class SbNewDto {
|
||||
id: number;
|
||||
name: string;
|
||||
houseName: string;
|
||||
aadharNo: string;
|
||||
postCode: string;
|
||||
guardian: string;
|
||||
agcode: number;
|
||||
amount: number;
|
||||
createdBy: string;
|
||||
createdAt: Date;
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
export interface SbMasterDto {
|
||||
brcode: string;
|
||||
|
||||
code: string;
|
||||
|
||||
accno: string;
|
||||
|
||||
dayDt: Date;
|
||||
|
||||
custId: string;
|
||||
|
||||
memno: string;
|
||||
|
||||
mcode: string;
|
||||
|
||||
nature: string;
|
||||
|
||||
minorDob: Date;
|
||||
|
||||
operBy: string;
|
||||
|
||||
amount: number | 0;
|
||||
|
||||
yearopn: number | 0;
|
||||
|
||||
recoCode: string;
|
||||
|
||||
recoAccno: string;
|
||||
|
||||
recoName: string;
|
||||
|
||||
intrate: number | 0;
|
||||
|
||||
indInst: string;
|
||||
|
||||
closeDt: Date;
|
||||
|
||||
intFreeze: string;
|
||||
|
||||
minBalance: number | 0;
|
||||
|
||||
agentCode: number | 0;
|
||||
|
||||
userId: number | 0;
|
||||
|
||||
entryTime: string;
|
||||
|
||||
oldAccno: string;
|
||||
|
||||
newAccno: string;
|
||||
|
||||
lineNo: number | 0;
|
||||
|
||||
ordno: number | 0;
|
||||
|
||||
zeroornot: string;
|
||||
|
||||
mgrId: number | 0;
|
||||
|
||||
atmCardno: string;
|
||||
|
||||
atmCardIssdt: Date;
|
||||
|
||||
atmCard: string;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
export class ScbbankDto{
|
||||
|
||||
bankCode: number;
|
||||
|
||||
bankName: string;
|
||||
|
||||
bankAddress1: string;
|
||||
|
||||
bankAddress2: string;
|
||||
|
||||
bankMailId: string;
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
export class ScbbranchDto {
|
||||
|
||||
branchCode: number;
|
||||
|
||||
branchName: string;
|
||||
|
||||
branchAddress1: string;
|
||||
|
||||
branchAddress2: string;
|
||||
|
||||
branchMailId: string;
|
||||
|
||||
branchPone1: string;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbchequebookRequestDto extends PcdBaseDto {
|
||||
|
||||
chequebookId: number;
|
||||
|
||||
custId: number;
|
||||
|
||||
chequebookrequestType: string;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbcustomerOnlineDto extends PcdBaseDto {
|
||||
|
||||
userId: number;
|
||||
|
||||
intcusto: number;
|
||||
|
||||
onlineApplyDate: Date;
|
||||
|
||||
onlineApprovedDate: Date;
|
||||
|
||||
onlineStartDate: Date;
|
||||
|
||||
onlineEndDate: Date;
|
||||
|
||||
onlineApprovedBy: number;
|
||||
|
||||
photoImage: Buffer;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
export class ScbdepositSchemeDetailDto {
|
||||
|
||||
schemeno: number
|
||||
|
||||
interestRate: number;
|
||||
|
||||
effectiveDate: Date;
|
||||
|
||||
periodFrom: number;
|
||||
|
||||
periodTo: number;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
|
||||
export class ScbdepositSchemeDto {
|
||||
|
||||
intschemeno:number;
|
||||
|
||||
depositType:string;
|
||||
|
||||
depositSubType:string;
|
||||
|
||||
interestRate:number;
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
export class ScbemployeeDto {
|
||||
branchCode: string;
|
||||
empNo: number;
|
||||
empName: string;
|
||||
empAdd1: string;
|
||||
empAdd2: string;
|
||||
empAdd3: string;
|
||||
designation: number;
|
||||
custId: number;
|
||||
customerType: number;
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
export class ScbfdDepositDto {
|
||||
|
||||
scbFdno: number;
|
||||
|
||||
branchCode: string;
|
||||
|
||||
fdNo: number;
|
||||
|
||||
intcustno: number;
|
||||
|
||||
depositDate: Date;
|
||||
|
||||
depositAmount: number;
|
||||
|
||||
maturityDate: Date;
|
||||
|
||||
maturityAmount: number;
|
||||
|
||||
depositPeriod: number;
|
||||
|
||||
status: number;
|
||||
|
||||
modifiedBy: string;
|
||||
|
||||
modifiedDate: Date;
|
||||
|
||||
interestRate: number;
|
||||
|
||||
jointAcFlag: string;
|
||||
|
||||
jointCustName: string;
|
||||
|
||||
periodInd: string;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbloanDetailDto extends PcdBaseDto{
|
||||
|
||||
scbloanno:number;
|
||||
|
||||
branchCode:string;
|
||||
|
||||
voucherNo:string;
|
||||
|
||||
voucherDt:Date;
|
||||
|
||||
voucherDescription:string;
|
||||
|
||||
chequeNo:string;
|
||||
|
||||
chequeDate:Date;
|
||||
|
||||
amount:number;
|
||||
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbloanDto extends PcdBaseDto{
|
||||
|
||||
scbloanno:number;
|
||||
|
||||
branchCode:string;
|
||||
|
||||
loanNo:number;
|
||||
|
||||
custId:number;
|
||||
|
||||
loanType:string;
|
||||
|
||||
loanAmount:number;
|
||||
|
||||
loanTakenDate:Date;
|
||||
|
||||
maturityDate:Date;
|
||||
|
||||
closedDate:Date;
|
||||
|
||||
balanceAmount:number;
|
||||
|
||||
interestPercent:number;
|
||||
|
||||
noOfInstalment:number;
|
||||
|
||||
loanPurpose:string;
|
||||
|
||||
status:number;
|
||||
elbAmount: number;
|
||||
overDueInterest: number;
|
||||
instalmentAmount: string;
|
||||
noOfInstalmentDue: string;
|
||||
totalAmountDue: string;
|
||||
|
||||
nextDueDate: Date;
|
||||
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
|
||||
export class ScblockerDetailDto extends PcdBaseEntity {
|
||||
|
||||
branchCode: string;
|
||||
|
||||
scblockerno: number;
|
||||
|
||||
inttransno: number;
|
||||
|
||||
transactionDate: Date;
|
||||
|
||||
description: string;
|
||||
|
||||
transactionAmount: number;
|
||||
|
||||
createdBy: string;
|
||||
|
||||
createdDate: Date;
|
||||
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScblockerDto extends PcdBaseDto{
|
||||
|
||||
branchCode: string;
|
||||
|
||||
scblockerno: number;
|
||||
|
||||
lockerNo: number;
|
||||
|
||||
custId: number;
|
||||
|
||||
startDate: Date;
|
||||
|
||||
rentAmount: number;
|
||||
|
||||
endDate: Date;
|
||||
|
||||
status: number;
|
||||
|
||||
createdBy: string;
|
||||
|
||||
createdDate: Date;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
export class ScbmdsVoucherDetailDto {
|
||||
|
||||
scbmdsno: number;
|
||||
|
||||
branchCode: string;
|
||||
|
||||
voucherNo: string;
|
||||
|
||||
voucherDate: Date;
|
||||
|
||||
voucherDesc: string;
|
||||
|
||||
amount: number;
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbmdsVoucherDto extends PcdBaseDto{
|
||||
|
||||
scbmdsno: number;
|
||||
|
||||
branchCode: string;
|
||||
|
||||
mdsno: number;
|
||||
|
||||
mdsSeriesNo: string;
|
||||
|
||||
custId: number;
|
||||
|
||||
status: number;
|
||||
|
||||
salaAmount: number;
|
||||
|
||||
balanceAmount: number;
|
||||
|
||||
instalmentDate: Date;
|
||||
|
||||
instalmentAmount: number;
|
||||
|
||||
lastInstalmentPaidDate: Date;
|
||||
|
||||
dueInstalment: number;
|
||||
|
||||
dueAmount: number;
|
||||
|
||||
totalInstallment: number;
|
||||
|
||||
remittedInstallment: number;
|
||||
|
||||
nextDueAmount: number;
|
||||
|
||||
nextDueDate: number;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
|
||||
export class SbPassbookDto{
|
||||
|
||||
date: Date;
|
||||
|
||||
intr: number;
|
||||
|
||||
other: number;
|
||||
|
||||
balance: number;
|
||||
|
||||
amount:number;
|
||||
|
||||
remarks: string;
|
||||
|
||||
intshareno: number;
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbrdDepositDetailDto extends PcdBaseDto{
|
||||
|
||||
branchCode: string;
|
||||
|
||||
inttransno: number;
|
||||
|
||||
scbrdno: number;
|
||||
|
||||
voucherNo: string;
|
||||
|
||||
voucherDate: Date;
|
||||
|
||||
chequeNo: string;
|
||||
|
||||
chequeDate: Date;
|
||||
|
||||
description: string;
|
||||
|
||||
amtCashDr: number;
|
||||
|
||||
amtCashCr: number;
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbrdDepositDto extends PcdBaseDto{
|
||||
|
||||
branchCode: string;
|
||||
|
||||
scbrdno: number;
|
||||
|
||||
rdNo: number;
|
||||
|
||||
custId: number;
|
||||
|
||||
startDate: Date;
|
||||
|
||||
balanceAmount: number;
|
||||
|
||||
endDate: Date;
|
||||
|
||||
status: number;
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
export class ScbsbDepositDetailDto {
|
||||
|
||||
branchCode: string;
|
||||
|
||||
inttransno: number;
|
||||
|
||||
scbsbno: number;
|
||||
|
||||
voucherNo: string;
|
||||
|
||||
voucherDate: Date;
|
||||
|
||||
chequeNo: string;
|
||||
|
||||
chequeDate: Date;
|
||||
|
||||
description: string;
|
||||
|
||||
amtCashDr: number;
|
||||
|
||||
amtCashCr: number;
|
||||
|
||||
createdBy: string;
|
||||
|
||||
createdDate: Date;
|
||||
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
import { ScbsbDepositDetailDto } from "./scbsb-deposit-detail.dto";
|
||||
|
||||
export class ScbsbDepositDto {
|
||||
|
||||
scbsbno: number;
|
||||
|
||||
branchCode: string;
|
||||
|
||||
custId: number;
|
||||
|
||||
startDate: Date;
|
||||
|
||||
sbNo: string;
|
||||
|
||||
balanceAmount: number;
|
||||
|
||||
endDate: Date;
|
||||
|
||||
status: number;
|
||||
|
||||
createdBy: string;
|
||||
|
||||
createdDate: Date;
|
||||
|
||||
sbDeatil: ScbsbDepositDetailDto[];
|
||||
|
||||
sbNominee: string;
|
||||
|
||||
jointFlag: string;
|
||||
|
||||
jointCustName: string;
|
||||
|
||||
sbInterestRate: number;
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { PcdBaseDto } from "src/framework/custom/pcd-dto.custom";
|
||||
|
||||
export class ScbsbTransferDto extends PcdBaseDto {
|
||||
|
||||
id: number;
|
||||
|
||||
custId: number
|
||||
|
||||
depositType: string;
|
||||
|
||||
depositAmount: number;
|
||||
|
||||
intsbno: number;
|
||||
|
||||
intschemeno: number;
|
||||
|
||||
monthlyInterest: string;
|
||||
|
||||
periodFrom: number;
|
||||
|
||||
periodTo: number;
|
||||
|
||||
customerDuration: number;
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
import { PcdViewEntity } from "src/framework/custom/pcd-view-entity.custom";
|
||||
import { Column, ViewEntity } from "typeorm";
|
||||
|
||||
|
||||
export class SbShareDto {
|
||||
|
||||
shareType: string;
|
||||
|
||||
amount: number;
|
||||
|
||||
shareClass: string;
|
||||
|
||||
intcustno: number;
|
||||
|
||||
intshareno: number;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
export class ScbsmsDto {
|
||||
|
||||
id: number;
|
||||
|
||||
purpose: string;
|
||||
|
||||
message: string;
|
||||
|
||||
messageDate: Date;
|
||||
|
||||
status: string;
|
||||
|
||||
genertedBy: string;
|
||||
|
||||
messageid: string;
|
||||
|
||||
bankId: string;
|
||||
|
||||
custId:string;
|
||||
|
||||
senderId: string;
|
||||
|
||||
receiver: string;
|
||||
|
||||
additionalInfo: string;
|
||||
|
||||
type: string;
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
import { Controller, Get, Param, Post, Req, Res, UploadedFile, UseGuards, UseInterceptors } from '@nestjs/common';
|
||||
import { FileInterceptor } from '@nestjs/platform-express';
|
||||
import { existsSync, mkdirSync } from 'fs';
|
||||
import { diskStorage } from 'multer';
|
||||
import { extname } from 'path';
|
||||
import { FileUploadService } from './file-upload.service';
|
||||
|
||||
|
||||
export function createFolders(filePath: string) {
|
||||
const splitPath = filePath.split('/');
|
||||
splitPath.reduce((path, subPath) => {
|
||||
let currentPath;
|
||||
if (subPath != '.') {
|
||||
currentPath = path + '/' + subPath;
|
||||
|
||||
if (!existsSync(currentPath)) {
|
||||
mkdirSync(currentPath);
|
||||
}
|
||||
}
|
||||
else {
|
||||
currentPath = subPath;
|
||||
}
|
||||
return currentPath
|
||||
|
||||
}, '')
|
||||
}
|
||||
|
||||
|
||||
@Controller('file-upload')
|
||||
export class FileUploadController {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { FileUploadController } from './file-upload.controller';
|
||||
import { FileUploadService } from './file-upload.service';
|
||||
import { MulterModule } from '@nestjs/platform-express';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MulterModule.register({
|
||||
dest: './uploads'
|
||||
}),
|
||||
// AuthModule,
|
||||
],
|
||||
controllers: [FileUploadController],
|
||||
providers: [FileUploadService]
|
||||
})
|
||||
export class FileUploadModule { }
|
||||
@ -0,0 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class FileUploadService {}
|
||||
@ -0,0 +1,62 @@
|
||||
import { Body, DefaultValuePipe, Delete, Get, Logger, Param, ParseIntPipe, Post, Put, Query, UsePipes, ValidationPipe } from "@nestjs/common";
|
||||
import { GetUser } from "src/auth/dto/get-user.decorator";
|
||||
import { PcduserDto } from "src/auth/dto/pcd-user.dto";
|
||||
import { FindManyOptions } from "typeorm";
|
||||
import { PcdFormGridService } from "./pcd-form-grid.service";
|
||||
|
||||
export class PcdFormGridController<T>{
|
||||
private logger = new Logger('PcdFormGridController'); // for logging
|
||||
constructor(
|
||||
private service: PcdFormGridService<T>
|
||||
) {
|
||||
}
|
||||
|
||||
@Get()
|
||||
async findAll(
|
||||
@Query() filter: FindManyOptions,
|
||||
@GetUser() user: PcduserDto
|
||||
): Promise<any[]> {
|
||||
return await this.service.findAll(filter, user);
|
||||
}
|
||||
|
||||
|
||||
// @Get('/:id')
|
||||
// async getOne(
|
||||
// @Query() filterDto: FindManyOptions,
|
||||
// @Param('id') id: string,
|
||||
// @GetUser() user: PcduserDto,
|
||||
// ): Promise<any> {
|
||||
// this.logger.verbose(`User "${user.userName}" retrieving all tasks. Filters: ${JSON.stringify(filterDto)}`) //for logging
|
||||
// console.log("===filter==", filterDto);
|
||||
// return await this.service.findOne(filterDto, id, user);
|
||||
// }
|
||||
|
||||
@UsePipes(ValidationPipe)
|
||||
@Post()
|
||||
async createOne(
|
||||
@Body() body: T,
|
||||
@GetUser() user: PcduserDto
|
||||
): Promise<any> {
|
||||
|
||||
return await this.service.createOne(body, user);
|
||||
}
|
||||
|
||||
@Put('/:id')
|
||||
async updateOne(
|
||||
@Body(ValidationPipe) body: any,
|
||||
@Param('id') id: number,
|
||||
@GetUser() user: PcduserDto
|
||||
) {
|
||||
return await this.service.updateOne(body, id, user);
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
async deleteOne(
|
||||
@Query() filter: FindManyOptions,
|
||||
@Param('id') id: string,
|
||||
@GetUser() user: PcduserDto,
|
||||
): Promise<any> {
|
||||
return await this.service.deleteOne(filter, id, user);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,285 @@
|
||||
import { BadRequestException, ConflictException, HttpException, InternalServerErrorException, NotAcceptableException } from '@nestjs/common';
|
||||
import { PcduserDto } from 'src/auth/dto/pcd-user.dto';
|
||||
import { FindManyOptions, Not, Repository } from 'typeorm';
|
||||
import { PcdFormGridInterface } from '../interface/pcd-form-grid.interface';
|
||||
import * as config from 'config'
|
||||
const oracledb = require('oracledb');
|
||||
const dbConfig = config.get('db');
|
||||
|
||||
|
||||
export class PcdFormGridService<T> implements PcdFormGridInterface {
|
||||
MAIN_KEY: string = 'id';
|
||||
CUSTID: string = 'custId';
|
||||
MANDATORY_FEILDS: string[] = [];
|
||||
DUPLICATE_CHK: string[] = [];
|
||||
FK_FEILDS: { column: string, relation: Repository<any> }[] = [];
|
||||
ROW_COUNT:string='';
|
||||
constructor(
|
||||
// @Inject(TENANT_CONNECTION) conn:Connection,
|
||||
private repo: Repository<any>
|
||||
) { }
|
||||
async preFindAll(filter: FindManyOptions, user: PcduserDto): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
async findAll(filter: FindManyOptions, user: PcduserDto): Promise<any[]> {
|
||||
if (!filter.where) filter.where = {};
|
||||
if (this.CUSTID)
|
||||
filter.where[this.CUSTID] = user.custId;
|
||||
|
||||
if (!await this.preFindAll(filter, user))
|
||||
throw new BadRequestException(`Unepected Error Occured in findAll`);
|
||||
// console.log("====1==== filter===", filter);
|
||||
const result = await this.repo.find(filter);
|
||||
// console.log("====2==== result===", result);
|
||||
return await this.postFindAll(filter, user, result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
async postFindAll(filter: FindManyOptions, user: PcduserDto, result: T[]): Promise<T[]> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async preFindOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
async findOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<any> {
|
||||
if (!filter.where) filter.where = {};
|
||||
if (this.CUSTID)
|
||||
filter.where[this.CUSTID] = user.custId;
|
||||
filter.where[this.MAIN_KEY] = id;
|
||||
|
||||
if (!await this.preFindOne(filter, id, user))
|
||||
throw new BadRequestException(`Unepected Error Occured in findAll`);
|
||||
|
||||
const result = await this.repo.findOne(filter);
|
||||
|
||||
return await this.postFindOne(filter, id, user, result);
|
||||
}
|
||||
|
||||
async postFindOne(filter: FindManyOptions, id: string | number, user: PcduserDto, result: T): Promise<T> {
|
||||
return result;
|
||||
}
|
||||
async preCreateOne(body: T, user: PcduserDto): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
async createOne(body: any, user: PcduserDto): Promise<any> {
|
||||
for (let colMan of this.MANDATORY_FEILDS) {
|
||||
if (!body[colMan] || body[colMan].toString().trim() == "") {
|
||||
throw new BadRequestException(`${colMan} field Cannot be Blank`);
|
||||
}
|
||||
}
|
||||
console.log("==this.DUPLICATE_CHK===", this.DUPLICATE_CHK);
|
||||
|
||||
for (let dupCol of this.DUPLICATE_CHK) {
|
||||
const dupfilter = { where: {} };
|
||||
// if (!dupCol.isSl || (user.coCodeD.secondryLangauge && user.coCodeD.multiLanguageYn == 'Y' && dupCol.isSl)) {
|
||||
// if (dupCol && isArray(dupCol) && dupCol.column.length > 0) {
|
||||
// dupCol.forEach(element => {
|
||||
// console.log("===element====", element);
|
||||
dupfilter.where[dupCol] = body[dupCol];
|
||||
// })
|
||||
// }
|
||||
// else
|
||||
// dupfilter.where[dupCol.column] = body[dupCol.column];
|
||||
// }
|
||||
// else
|
||||
// continue;
|
||||
console.log("===dupRec filter====", dupfilter);
|
||||
|
||||
let dupRec = await this.repo.findOne(dupfilter);
|
||||
if (dupRec)
|
||||
throw new BadRequestException(`Duplication not allowed for ${dupCol}`);
|
||||
|
||||
}
|
||||
|
||||
console.log("==user.userId==", user);
|
||||
if (user && user.custId) {
|
||||
body["createdBy"] = user.userId;
|
||||
body["modifiedBy"] = user.userId;
|
||||
body[this.CUSTID] = user.custId;
|
||||
}
|
||||
|
||||
if (!await this.preCreateOne(body, user))
|
||||
throw new BadRequestException(`Unexpected Error Occured in create`);
|
||||
for (let eagerCol of await this.getEagerColumns()) {
|
||||
delete body[eagerCol];
|
||||
}
|
||||
try {
|
||||
await this.repo.save(body);
|
||||
const filter: FindManyOptions = await this.getFilterWithPrimaryKey(body);
|
||||
const result = await this.findOne(filter, body[this.MAIN_KEY], user);
|
||||
|
||||
return await this.postCreateOne(body, user, result);
|
||||
} catch (err) {
|
||||
console.log("==err==", err);
|
||||
throw new InternalServerErrorException(err);
|
||||
}
|
||||
}
|
||||
async postCreateOne(body: T, user: PcduserDto, result: T): Promise<T> {
|
||||
return result;
|
||||
}
|
||||
async preUpdateOne(body: T, id: string | number, user: PcduserDto): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
async updateOne(body: any, id: string | number, user: PcduserDto): Promise<any> {
|
||||
console.log("====user====", user);
|
||||
for (let colMan of this.MANDATORY_FEILDS) {
|
||||
|
||||
if (!body[colMan] || body[colMan].toString().trim() == "") {
|
||||
throw new BadRequestException(`${colMan} field Cannot be Blank`);
|
||||
}
|
||||
}
|
||||
|
||||
for (let dupCol of this.DUPLICATE_CHK) {
|
||||
const dupfilter = { where: {} };
|
||||
dupfilter.where[this.MAIN_KEY] = Not(body[this.MAIN_KEY]);
|
||||
|
||||
// if (!dupCol.isSl || (user.coCodeD.secondryLangauge && user.coCodeD.multiLanguageYn == 'Y' && dupCol.isSl)) {
|
||||
// if (dupCol.column && isArray(dupCol.column) && dupCol.column.length > 0) {
|
||||
// dupCol.column.forEach(element => {
|
||||
// dupfilter.where[element] = body[element];
|
||||
// })
|
||||
// }
|
||||
// else
|
||||
dupfilter.where[dupCol] = body[dupCol];
|
||||
// }
|
||||
// else
|
||||
// continue;
|
||||
|
||||
let dupRec = await this.repo.findOne(dupfilter);
|
||||
if (dupRec)
|
||||
throw new BadRequestException(`Duplication not allowed for ${dupCol}`);
|
||||
|
||||
}
|
||||
const filter: FindManyOptions = await this.getFilterWithPrimaryKey(body);
|
||||
const updateRow = await this.getOne(filter, body[this.MAIN_KEY], user);
|
||||
console.log("====updateRow====", updateRow);
|
||||
|
||||
for (let eagerCol of await this.getEagerColumns()) {
|
||||
delete body[eagerCol];
|
||||
}
|
||||
// updateRow["coCode"] = user.coCode;
|
||||
const COLUMNS = await this.getAllColumns();
|
||||
const PRIMARY_KEYS = await this.getPrimaryKeys();
|
||||
|
||||
COLUMNS.forEach((row) => {
|
||||
if (!PRIMARY_KEYS.includes(row))
|
||||
updateRow[row] = body[row];
|
||||
});
|
||||
console.log("====update row 1 ====", updateRow);
|
||||
await this.repo.save(updateRow);
|
||||
// const filter: FindManyOptions = await this.getFilterWithPrimaryKey(body);
|
||||
const result = await this.findOne(filter, body[this.MAIN_KEY], user);
|
||||
return await this.postUpdateOne(body, id, user, result);
|
||||
}
|
||||
|
||||
async postUpdateOne(body: T, id: string | number, user: PcduserDto, result: T): Promise<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async preDeleteOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<boolean> {
|
||||
for (let fkRel of this.FK_FEILDS) {
|
||||
const fkFilter = { where: {} };
|
||||
fkFilter.where[fkRel.column] = id;
|
||||
const result = await fkRel.relation.findOne(fkFilter);
|
||||
if (result)
|
||||
throw new ConflictException(`Can't delete Record. Detail Records Exists.`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
async deleteOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<any> {
|
||||
if (!filter.where) filter.where = {};
|
||||
filter.where[this.MAIN_KEY] = id;
|
||||
if (this.CUSTID)
|
||||
filter.where[this.CUSTID] = user.custId;
|
||||
if (!await this.preDeleteOne(filter, id, user))
|
||||
throw new BadRequestException(`Unexpected Error Occured in delete`);
|
||||
|
||||
const delFilter = await this.getDeleteFilter(filter);
|
||||
|
||||
if (!delFilter[this.MAIN_KEY])
|
||||
throw new NotAcceptableException(`Please select a data to delete`);
|
||||
try {
|
||||
const result = await this.repo.delete(delFilter);
|
||||
return await this.postDeleteOne(filter, id, user, result);
|
||||
} catch (err) {
|
||||
if (err.status) throw new HttpException(err.message, err.status);
|
||||
|
||||
throw new InternalServerErrorException(`${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async postDeleteOne(filter: FindManyOptions, id: string | number, user: PcduserDto, result: any): Promise<any> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async getDeleteFilter(whereFilter: FindManyOptions): Promise<any> {
|
||||
const filter: FindManyOptions = {};
|
||||
const PRIMARY_KEYS = await this.getPrimaryKeys();
|
||||
await PRIMARY_KEYS.forEach((column) => {
|
||||
filter[column] = whereFilter.where[column];
|
||||
});
|
||||
return filter;
|
||||
}
|
||||
|
||||
async getOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<any> {
|
||||
if (!filter.where) filter.where = {};
|
||||
if (this.CUSTID)
|
||||
filter.where[this.CUSTID] = user.custId;
|
||||
filter.where[this.MAIN_KEY] = id;
|
||||
|
||||
const result = await this.repo.findOne(filter);
|
||||
|
||||
return result;
|
||||
}
|
||||
async getAllColumns(): Promise<string[]> {
|
||||
const COLUMNS: string[] = [];
|
||||
for (let columnProperty in this.repo.metadata.propertiesMap) {
|
||||
COLUMNS.push(this.repo.metadata.propertiesMap[columnProperty]);
|
||||
}
|
||||
// in the below method it will not take the forignKey columns Like modelD etc..
|
||||
// await this.repo.metadata.columns.forEach((row) => {
|
||||
// COLUMNS.push(row.propertyName);
|
||||
// });
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
async getPrimaryKeys(): Promise<string[]> {
|
||||
const PRIMARY_KEYS: string[] = [];
|
||||
await this.repo.metadata.primaryColumns.forEach((row) => {
|
||||
PRIMARY_KEYS.push(row.propertyName);
|
||||
});
|
||||
return PRIMARY_KEYS;
|
||||
}
|
||||
|
||||
async getFilterWithPrimaryKey(body: T): Promise<FindManyOptions> {
|
||||
const filter: FindManyOptions = { where: {} };
|
||||
const PRIMARY_KEYS = await this.getPrimaryKeys();
|
||||
await PRIMARY_KEYS.forEach((column) => {
|
||||
filter.where[column] = body[column];
|
||||
});
|
||||
return filter;
|
||||
}
|
||||
|
||||
|
||||
async getEagerColumns(): Promise<string[]> {
|
||||
/*
|
||||
For getting Eager true columns having Many to One relations.
|
||||
We need to remove the eager columns before insertions or updations or it will not allow to save data (But save message will show, but data not updated)
|
||||
*/
|
||||
const COLUMNS: string[] = [];
|
||||
for (let columnProperty of this.repo.metadata.eagerRelations) {
|
||||
COLUMNS.push(columnProperty.propertyName);
|
||||
}
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
import { Logger, Get, Query, Delete, Post, Body, Param, UseGuards } from "@nestjs/common";
|
||||
import { AuthGuard } from "@nestjs/passport";
|
||||
import { AuthModule } from "src/auth/auth.module";
|
||||
import { FindManyOptions } from "typeorm";
|
||||
import { PcdTransactionService } from "./pcd-transaction.service";
|
||||
|
||||
export class PcdTransactionController<T> {
|
||||
|
||||
private logger = new Logger('PcdTransactionController'); // for logging
|
||||
|
||||
constructor(
|
||||
private service: PcdTransactionService<T>
|
||||
) { }
|
||||
@UseGuards(AuthGuard())
|
||||
@Get()
|
||||
async findList(@Query() filter: FindManyOptions, ): Promise<T[]> {
|
||||
return await this.service.findList(filter);
|
||||
}
|
||||
|
||||
@Get('/:id')
|
||||
async findOne(@Query() filter: FindManyOptions,@Param('id') id: string , ): Promise<T> {
|
||||
return await this.service.findOne(filter, id);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async createOne(@Body() body: T, ): Promise<T> {
|
||||
return await this.service.createOne(body,);
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
async delete(@Query() filter: FindManyOptions,@Param('id') id: string , ): Promise<any> {
|
||||
return await this.service.deleteOne(filter,id, );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,354 @@
|
||||
import { PcdtTransactionInterface } from "../interface/pcd-transaction.interface";
|
||||
import { FindManyOptions, Repository, getConnection, QueryRunner, Connection } from "typeorm";
|
||||
import { BadRequestException, NotAcceptableException, UnauthorizedException, InternalServerErrorException, MethodNotAllowedException, HttpException, Inject } from "@nestjs/common";
|
||||
import { TransactionDetailDto } from "src/framework/custom/transaction-detail.dto";
|
||||
//import { TENANT_CONNECTION } from "src/tenant/tenant.module";
|
||||
// import { IintDto } from "../../dto/iint.dto";
|
||||
// import { IintvrnoDto } from "../../dto/iintvrno.dto";
|
||||
// import { IintService } from "../../tables/iint/iint.service";
|
||||
|
||||
export class PcdTransactionService<T> implements PcdtTransactionInterface {
|
||||
|
||||
MAIN_KEY: string = "id";
|
||||
TXN_TYPE:string="";
|
||||
|
||||
DETAIL_DATA_FORMAT: TransactionDetailDto[] = [];
|
||||
|
||||
constructor(
|
||||
private connection: Connection,
|
||||
private repo: Repository<any>
|
||||
) { }
|
||||
|
||||
async preFindList(filter: FindManyOptions, ): Promise<boolean> {
|
||||
return true
|
||||
}
|
||||
|
||||
async findList(filter: FindManyOptions, ): Promise<T[]> {
|
||||
if (!filter.where) filter.where = {};
|
||||
if (this.TXN_TYPE) filter.where[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName] = this.TXN_TYPE;
|
||||
// if (!filter.where[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName])
|
||||
// return;
|
||||
|
||||
if (!await this.preFindList(filter))
|
||||
throw new BadRequestException(`Unexpected Error Occured in findList`);
|
||||
let result: T[] = await this.repo.find(filter);
|
||||
|
||||
return await this.postFindList(filter, result);
|
||||
}
|
||||
|
||||
async postFindList(filter: FindManyOptions, result: T[]): Promise<T[]> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async preFindOne(filter: FindManyOptions, ): Promise<boolean> {
|
||||
return true
|
||||
}
|
||||
|
||||
async findOne(filter: FindManyOptions, id: string | number, ): Promise<T> {
|
||||
if (!filter.where) filter.where = {};
|
||||
if (this.TXN_TYPE) filter.where[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName] = this.TXN_TYPE;
|
||||
let orgFilter = Object.create(filter);
|
||||
|
||||
filter.where[this.MAIN_KEY] = id;
|
||||
|
||||
if (!await this.preFindOne(filter))
|
||||
throw new BadRequestException(`Unepected Error Occured in findOne`);
|
||||
//branch right check();
|
||||
let result: T = await this.repo.findOne(filter);
|
||||
|
||||
if (!result)
|
||||
return result;
|
||||
|
||||
result = await this.getDetailData(result, orgFilter, this.DETAIL_DATA_FORMAT);
|
||||
|
||||
return await this.postFindOne(filter, result);
|
||||
}
|
||||
|
||||
async postFindOne(filter: FindManyOptions, result: T): Promise<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async preDeleteOne(filter: FindManyOptions, id: string | number, ): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
async deleteOne(filter: any, id: string | number, ): Promise<any> {
|
||||
if (!filter || !filter.where) filter.where = {};
|
||||
if (this.TXN_TYPE) filter.where[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName] = this.TXN_TYPE;
|
||||
filter.where[this.MAIN_KEY] = id;
|
||||
|
||||
const delFilter = await this.getDeleteFilter(filter);
|
||||
if (!delFilter[this.MAIN_KEY])
|
||||
throw new NotAcceptableException(`Please select a record`);
|
||||
if (!await this.preDeleteOne(filter, id,))
|
||||
throw new BadRequestException(`Unepected Error Occured in deleteOne`);
|
||||
const queryRunner = this.connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
await queryRunner.startTransaction();
|
||||
await this.deleteDetailDataTabels(id, this.DETAIL_DATA_FORMAT, queryRunner);
|
||||
const result = await queryRunner.manager.delete(this.repo.metadata.name, id);
|
||||
await queryRunner.commitTransaction();
|
||||
return await this.postDeleteOne(filter, result);
|
||||
} catch (err) {
|
||||
if (queryRunner.isTransactionActive)
|
||||
await queryRunner.rollbackTransaction();
|
||||
throw new InternalServerErrorException(`${err.message}`);
|
||||
}finally{
|
||||
await queryRunner.release();
|
||||
}
|
||||
// const result = await this.repo.delete(delFilter);
|
||||
|
||||
}
|
||||
|
||||
async postDeleteOne(filter: FindManyOptions, result: any): Promise<any> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async preCreateOne(body: T, ): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
async beforeCreateOne(body: T, queryRunner: QueryRunner): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
async createOne(body: T, ): Promise<T> {
|
||||
//console.log('--- incoming = ', body);
|
||||
|
||||
if (this.TXN_TYPE) body[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName] = this.TXN_TYPE;
|
||||
if (!await this.preCreateOne(body))
|
||||
throw new BadRequestException(`Unexpected Error Occured in CreateOne`);
|
||||
for (let eagerCol of await this.getEagerColumns()) {
|
||||
delete body[eagerCol];
|
||||
}
|
||||
const queryRunner = this.connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
await queryRunner.startTransaction();
|
||||
|
||||
if (this.TXN_TYPE) body[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName] = this.TXN_TYPE;
|
||||
// await this.checkAndSetVrNo(body, user, queryRunner);
|
||||
|
||||
// for deleting deleted details from the angular
|
||||
for (let row of this.DETAIL_DATA_FORMAT) {
|
||||
body[row.detailName] = await this.deleteDetailData(body[row.detailName], row, queryRunner);
|
||||
}
|
||||
|
||||
|
||||
body["createdBy"] = 'SYSTEM';
|
||||
body["modifiedBy"] = 'SYSTEM';
|
||||
if (!await this.beforeCreateOne(body, queryRunner))
|
||||
throw new BadRequestException(`Unepected Error Occured in CreateOne`);
|
||||
|
||||
const data = await queryRunner.manager.save(this.repo.metadata.name, body);
|
||||
await this.insertDetailData(body, this.DETAIL_DATA_FORMAT, queryRunner, data);
|
||||
|
||||
await this.afterCreateOne(body);
|
||||
await queryRunner.commitTransaction();
|
||||
|
||||
|
||||
const filter: FindManyOptions = await this.getFilterWithPrimaryKey(body);
|
||||
const result = await this.findOne(filter, data[this.MAIN_KEY]);
|
||||
|
||||
return await this.postCreateOne(body, result);
|
||||
|
||||
} catch (err) {
|
||||
// since we have errors lets rollback changes we made
|
||||
console.log('--- err --', err);
|
||||
console.log('QueryFailedError', err.QueryFailedError);
|
||||
console.log('*******err name*****', err.name);
|
||||
console.log('-- message------', err.message);
|
||||
console.log('-- code------', err.code);
|
||||
|
||||
console.log('--- err.status --', err.status);
|
||||
console.log("===is active===", queryRunner.isTransactionActive);
|
||||
if (queryRunner.isTransactionActive)
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log("heree===afterrollback");
|
||||
if (err.status && err.status == '401') throw new MethodNotAllowedException(`${err.message.message}`);
|
||||
if (!(err.name == "QueryFailedError")) if (queryRunner.isTransactionActive) await queryRunner.rollbackTransaction();
|
||||
//console.log("====after rollback====");
|
||||
if (err.name == "QueryFailedError") {
|
||||
if (err.precedingErrors && err.precedingErrors.length > 0 && err.precedingErrors[0].originalError)
|
||||
throw new BadRequestException(`${err.precedingErrors[0].originalError}`);
|
||||
if (err.originalError)
|
||||
throw new BadRequestException(`${err.originalError}`);
|
||||
}
|
||||
if (err.status && err.status == 500) throw new HttpException(err.message.error, err.message.statusCode);
|
||||
if (err.status) throw new HttpException(err.message, err.status);
|
||||
|
||||
throw new InternalServerErrorException(`${err.message}`);
|
||||
}
|
||||
finally {
|
||||
console.log('--- finally --- ');
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async afterCreateOne(body: T): Promise<void> {
|
||||
}
|
||||
|
||||
async postCreateOne(body: T, result: T): Promise<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
async insertDetailData(body: T, detailData: TransactionDetailDto[], queryRunner: QueryRunner, insertedData: T): Promise<void> {
|
||||
|
||||
for (let row of detailData) {
|
||||
await this.insertDetailData2ndLevel(body[row.detailName], row, queryRunner, insertedData, insertedData);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteDetailDataTabels(id: string | number, detailDataFormat: TransactionDetailDto[], queryRunner: QueryRunner): Promise<any> {
|
||||
for (let row of detailDataFormat) {
|
||||
await this.deleteDetailTableData(id, row, queryRunner);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteDetailTableData(id: string | number, detailData: TransactionDetailDto, queryRunner: QueryRunner): Promise<any> {
|
||||
if (detailData.childDetail && detailData.childDetail.length > 0) {
|
||||
for (let child of detailData.childDetail) {
|
||||
await this.deleteDetailTableData(id, child, queryRunner);
|
||||
}
|
||||
}
|
||||
if (id) {
|
||||
let filter = {};
|
||||
if(detailData.foreignKeyColumnName) {
|
||||
filter[detailData.foreignKeyColumnName] = id;
|
||||
|
||||
}else{
|
||||
filter[detailData.foreignKeyAssignmentColumnName.columnName] = id;
|
||||
}
|
||||
await queryRunner.manager.delete(detailData.repo.metadata.name, filter);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteDetailData(body: T[], detailData: TransactionDetailDto, queryRunner: QueryRunner): Promise<T[]> {
|
||||
if (detailData.childDetail && detailData.childDetail.length > 0) {
|
||||
for (let child of detailData.childDetail) {
|
||||
if (body && body.length > 0) {
|
||||
for (let row of body) {
|
||||
if (row["crud"] == "D") {
|
||||
for (let detData of row[child.detailName]) {
|
||||
detData["crud"] = "D";
|
||||
}
|
||||
}
|
||||
row[child.detailName] = await this.deleteDetailData(row[child.detailName], child, queryRunner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (body) {
|
||||
await queryRunner.manager.remove(detailData.repo.metadata.name, body.filter((row: any) => row.crud == 'D'));
|
||||
body = body.filter((row: any) => row["crud"] != 'D');
|
||||
return body;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async insertDetailData2ndLevel(body: T[], detailData: TransactionDetailDto, queryRunner: QueryRunner, headerData: T, detailHeaderData: T): Promise<void> {
|
||||
|
||||
let deatilInsResult: any;
|
||||
let eagerCols: any = await this.getEagerColumns(detailData.repo);
|
||||
if (body) {
|
||||
for (let row of body) {
|
||||
for (let col of eagerCols) {
|
||||
delete row[col];
|
||||
}
|
||||
if (this.TXN_TYPE) row[this.DETAIL_DATA_FORMAT[0].transactionTypeColumnName] = this.TXN_TYPE;
|
||||
if(detailData.foreignKeyColumnName){
|
||||
row[detailData.foreignKeyColumnName]=headerData[this.MAIN_KEY];
|
||||
}else{
|
||||
|
||||
row[detailData.foreignKeyAssignmentColumnName.columnName]
|
||||
= detailHeaderData[detailData.foreignKeyAssignmentColumnName.headerColumn];
|
||||
}
|
||||
row["createdBy"] = 'SYSTEM';
|
||||
row["modifiedBy"] = 'SYSTEM';
|
||||
if (detailData.addtionalSettingOfRowsInInsertion && detailData.addtionalSettingOfRowsInInsertion.length > 0) {
|
||||
for (let addRow of detailData.addtionalSettingOfRowsInInsertion) {
|
||||
row[addRow.columnName] = detailHeaderData[addRow.headerColumn];
|
||||
}
|
||||
}
|
||||
|
||||
deatilInsResult = await queryRunner.manager.save(detailData.repo.metadata.name, row);
|
||||
if (detailData.childDetail && detailData.childDetail.length > 0) {
|
||||
for (let child of detailData.childDetail) {
|
||||
if (body && body.length > 0) {
|
||||
await this.insertDetailData2ndLevel(row[child.detailName], child, queryRunner, headerData, deatilInsResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async getDetailData(result: any, filter: FindManyOptions, detailData: TransactionDetailDto[]): Promise<any> {
|
||||
for (let row of detailData) {
|
||||
result[row.detailName] = [];
|
||||
let filterDetail: FindManyOptions = Object.assign({}, filter);
|
||||
if (!filterDetail.where) filterDetail.where = {};
|
||||
for (let filterRow of row.filter) {
|
||||
filterDetail.where[filterRow.columnName] = filterRow.headerColumn ? result[filterRow.headerColumn] : filterRow.value;
|
||||
};
|
||||
if (row.orderByColumn) {
|
||||
if (!filterDetail.order) filterDetail["order"] = {};
|
||||
filterDetail.order[row.orderByColumn.columnName] = row.orderByColumn.sort;
|
||||
}
|
||||
result[row.detailName] = await row.repo.find(filterDetail);
|
||||
if (row.childDetail && row.childDetail.length > 0) {
|
||||
for (let detailRows of result[row.detailName])
|
||||
detailRows = await this.getDetailData(detailRows, filter, row.childDetail);
|
||||
}
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-- To get the filter using primary key --*/
|
||||
async getFilterWithPrimaryKey(body: T): Promise<FindManyOptions> {
|
||||
const filter: FindManyOptions = { where: {} };
|
||||
const PRIMARY_KEYS = await this.getPrimaryKeys();
|
||||
await PRIMARY_KEYS.forEach((column) => {
|
||||
filter.where[column] = body[column];
|
||||
});
|
||||
return filter;
|
||||
}
|
||||
|
||||
/*-- To get the filter for delete --*/
|
||||
async getDeleteFilter(whereFilter: FindManyOptions): Promise<any> {
|
||||
const filter: FindManyOptions = {};
|
||||
const PRIMARY_KEYS = await this.getPrimaryKeys();
|
||||
await PRIMARY_KEYS.forEach((column) => {
|
||||
filter[column] = whereFilter.where[column];
|
||||
});
|
||||
return filter;
|
||||
}
|
||||
|
||||
/*-- To get the Primary Keys of the entity --*/
|
||||
async getPrimaryKeys(): Promise<string[]> {
|
||||
const PRIMARY_KEYS: string[] = [];
|
||||
await this.repo.metadata.primaryColumns.forEach((row) => {
|
||||
PRIMARY_KEYS.push(row.propertyName);
|
||||
});
|
||||
return PRIMARY_KEYS;
|
||||
}
|
||||
|
||||
async getEagerColumns(repoDetail?: any): Promise<string[]> {
|
||||
/*
|
||||
For getting Eager true columns having Many to One relations.
|
||||
We need to remove the eager columns before insertions or updations or it will not allow to save data (But save message will show, but data not updated)
|
||||
*/
|
||||
const COLUMNS: string[] = [];
|
||||
for (let columnProperty of (repoDetail ? repoDetail.metadata.eagerRelations : this.repo.metadata.eagerRelations)) { //AJ
|
||||
COLUMNS.push(columnProperty.propertyName);
|
||||
}
|
||||
return COLUMNS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
export class PcdBaseDto {
|
||||
|
||||
createdBy: string;
|
||||
|
||||
createdDate: Date;
|
||||
|
||||
modifiedBy: string;
|
||||
|
||||
modifiedDate: Date;
|
||||
|
||||
versionNo: number;
|
||||
|
||||
sessionNo: number;
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
import { CreateDateColumn, Column, UpdateDateColumn, VersionColumn, BaseEntity, Entity } from "typeorm";
|
||||
|
||||
export abstract class PcdBaseEntity extends BaseEntity {
|
||||
|
||||
@Column({
|
||||
name: "created_by",
|
||||
type: "varchar",
|
||||
length: 12,
|
||||
default:() => "'SYSTEM'",
|
||||
})
|
||||
createdBy: string;
|
||||
|
||||
// @Column({
|
||||
// name: "created_country",
|
||||
// type: "numeric",
|
||||
// nullable: true
|
||||
// })
|
||||
// createdCountry: string;
|
||||
|
||||
@CreateDateColumn({
|
||||
name: "created_date",
|
||||
default:() => "CURRENT_TIMESTAMP",
|
||||
})
|
||||
createdDate: Date;
|
||||
|
||||
@Column({
|
||||
name: "modified_by",
|
||||
type: "varchar",
|
||||
length: 12,
|
||||
default:() => "'SYSTEM'",
|
||||
})
|
||||
modifiedBy: string;
|
||||
|
||||
// @Column({
|
||||
// name: "modified_country",
|
||||
// type: "numeric",
|
||||
// nullable: true
|
||||
// })
|
||||
// modifiedCountry: string;
|
||||
|
||||
@UpdateDateColumn({
|
||||
name: "modified_date",
|
||||
default:() => "CURRENT_TIMESTAMP",
|
||||
})
|
||||
modifiedDate: Date;
|
||||
|
||||
@VersionColumn({
|
||||
name: "version_no",
|
||||
type: "number",
|
||||
nullable: true
|
||||
})
|
||||
versionNo: number
|
||||
|
||||
@VersionColumn({
|
||||
name: "session_no",
|
||||
type: "number",
|
||||
nullable: true
|
||||
})
|
||||
sessionNo: number
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
import { BaseEntity, Column } from "typeorm";
|
||||
|
||||
export class PcdViewEntity extends BaseEntity {
|
||||
|
||||
@Column("string",{
|
||||
name:"CREATED_BY"
|
||||
})
|
||||
createdBy:string;
|
||||
|
||||
@Column("date",{
|
||||
name:"CREATED_DATE"
|
||||
})
|
||||
createdDate:Date;
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
export class TransactionDetailDto {
|
||||
|
||||
detailName: string;
|
||||
|
||||
foreignKeyColumnName?: string;
|
||||
|
||||
foreignKeyAssignmentColumnName?: {columnName:string,headerColumn:string};
|
||||
|
||||
repo: Repository<any>;
|
||||
|
||||
filter: { columnName: string, value?: any, headerColumn?: string }[];
|
||||
|
||||
childDetail: TransactionDetailDto[];
|
||||
|
||||
addtionalSettingOfRowsInInsertion?: { columnName: string, value?: any, headerColumn?: string }[];
|
||||
|
||||
transactionTypeColumnName?:string;
|
||||
|
||||
orderByColumn?: {columnName : string, sort : "DESC" | "ASC" };
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
import { FindManyOptions } from "typeorm";
|
||||
import { PcduserDto } from "src/auth/dto/pcd-user.dto";
|
||||
|
||||
export interface PcdFormGridInterface {
|
||||
|
||||
findAll(filter: FindManyOptions, user: PcduserDto): Promise<any[]>;
|
||||
|
||||
findOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<any>;
|
||||
|
||||
createOne(body: any, user: PcduserDto): Promise<any>
|
||||
|
||||
updateOne(body: any, id: string | number, user: PcduserDto): Promise<any>;
|
||||
|
||||
deleteOne(filter: FindManyOptions, id: string | number, user: PcduserDto): Promise<any>;
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
import { PcduserDto,} from "src/auth/dto/pcd-user.dto";
|
||||
import { FindManyOptions } from "typeorm";
|
||||
|
||||
export interface PcdtTransactionInterface {
|
||||
|
||||
findList(filter: FindManyOptions, user: PcduserDto): Promise<any[]>;
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm";
|
||||
|
||||
@Entity('imp-doc')
|
||||
export class ImportantDoc extends PcdBaseEntity{
|
||||
|
||||
@PrimaryColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
@Column({
|
||||
name:"tender_id",
|
||||
type:"numeric",
|
||||
//length:500,
|
||||
nullable:true
|
||||
})
|
||||
tenderId:number
|
||||
@Column({
|
||||
name:"category",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
category:string
|
||||
@Column({
|
||||
name:"sub_category",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
subCategory:string
|
||||
@Column({
|
||||
name:"sub_category_desc",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
subCategoryDesc:string
|
||||
|
||||
@Column({
|
||||
name:"file_format",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
fileFormat:string
|
||||
|
||||
@ManyToOne(() => TenderMaster,(tenderMaster)=> tenderMaster.importantDoc)
|
||||
@JoinColumn([{ name: "tender_id", referencedColumnName: "id" }])
|
||||
tenderIdD:TenderMaster
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { ImportantDoc } from "./imp-doc.entity";
|
||||
|
||||
@EntityRepository(ImportantDoc)
|
||||
export class importantDocRepository extends Repository<ImportantDoc>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import * as config from 'config';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import * as bodyParser from 'body-parser';
|
||||
import { Cluster } from '../cluster';
|
||||
|
||||
async function bootstrap() {
|
||||
|
||||
const serverConfig = config.get('server');
|
||||
// const whiteIp = config.get('whiteIp')
|
||||
const logger = new Logger('bootstrap');
|
||||
const app = await NestFactory.create(AppModule, { cors: true });
|
||||
const port = process.env.PORT || serverConfig.port; // for logging and config
|
||||
app.setGlobalPrefix('api/v1');
|
||||
app.enableCors();
|
||||
await app.listen(port);
|
||||
|
||||
logger.log(`Application listing on port ${port}`) // for logging
|
||||
}
|
||||
// Cluster.register(4, bootstrap);
|
||||
bootstrap()
|
||||
@ -0,0 +1,30 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm";
|
||||
|
||||
@Entity('payment-instrument')
|
||||
export class paymentInstrument extends PcdBaseEntity{
|
||||
@PrimaryColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
|
||||
@Column({
|
||||
name:"bank_name",
|
||||
type:"varchar",
|
||||
nullable:true
|
||||
})
|
||||
bankName:string
|
||||
@Column({
|
||||
name:"tender_id",
|
||||
type:"numeric",
|
||||
//length:500,
|
||||
nullable:true
|
||||
})
|
||||
tenderId:number
|
||||
|
||||
@ManyToOne(() => TenderMaster,(tenderMaster)=> tenderMaster.importantDoc)
|
||||
@JoinColumn([{ name: "tender_id", referencedColumnName: "id" }])
|
||||
tenderIdD:TenderMaster
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { paymentInstrument } from "./payment-ins.entity";
|
||||
|
||||
@EntityRepository(paymentInstrument)
|
||||
export class paymentInstrumentRepository extends Repository<paymentInstrument>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
export function convertDate(date: Date, format?: string): Date {
|
||||
if (!date || date.toString() == "" || date.toString() == "null")
|
||||
return null;
|
||||
|
||||
date = new Date(date);
|
||||
if (!format)
|
||||
format = "yyyy-MM-dd";
|
||||
let day = ('0' + date.getDate()).slice(-2);
|
||||
let month = ('0' + (date.getMonth() + 1)).slice(-2);
|
||||
let year = date.getFullYear();
|
||||
let hours = ('0' + date.getHours() || '00').slice(-2);
|
||||
let minutes = ('0' + date.getMinutes() || '00').slice(-2);
|
||||
let seconds = ('0' + date.getSeconds() || '00').slice(-2);
|
||||
let stringDt = format;
|
||||
if (format.includes("yyyy")) stringDt = stringDt.replace("yyyy", year.toString());
|
||||
if (format.includes("MM")) stringDt = stringDt.replace("MM", month.toString());
|
||||
if (format.includes("dd")) stringDt = stringDt.replace("dd", day.toString());
|
||||
if (format.includes("hh")) stringDt = stringDt.replace("hh", hours.toString());
|
||||
if (format.includes("mm")) stringDt = stringDt.replace("mm", minutes.toString());
|
||||
if (format.includes("ss")) stringDt = stringDt.replace("ss", seconds.toString());
|
||||
|
||||
let convDate = new Date(stringDt);
|
||||
|
||||
return convDate;
|
||||
}
|
||||
|
||||
export function convertDateString(date: Date, format?: string): string {
|
||||
if (!date || date.toString() == "null")
|
||||
return null;
|
||||
|
||||
date = new Date(date);
|
||||
|
||||
if (!format)
|
||||
format = "yyyy-MM-dd";
|
||||
let day = ('0' + date.getDate()).slice(-2);
|
||||
let month = ('0' + (date.getMonth() + 1)).slice(-2);
|
||||
let year = date.getFullYear();
|
||||
let hours = ('0' + date.getHours() || '00').slice(-2);
|
||||
let minutes = ('0' + date.getMinutes() || '00').slice(-2);
|
||||
let seconds = ('0' + date.getSeconds() || '00').slice(-2);
|
||||
|
||||
let stringDt = format;
|
||||
if (format.includes("yyyy")) stringDt = stringDt.replace("yyyy", year.toString());
|
||||
if (format.includes("MM")) stringDt = stringDt.replace("MM", month.toString());
|
||||
if (format.includes("dd")) stringDt = stringDt.replace("dd", day.toString());
|
||||
if (format.includes("hh")) stringDt = stringDt.replace("hh", hours.toString());
|
||||
if (format.includes("mm")) stringDt = stringDt.replace("mm", minutes.toString());
|
||||
if (format.includes("ss")) stringDt = stringDt.replace("ss", seconds.toString());
|
||||
if (format.includes("MON")) stringDt = stringDt.replace("MON", shortMonth[parseInt(month.toString()) - 1]);
|
||||
if (format.includes("MONTH")) stringDt = stringDt.replace("MONTH", month[parseInt(month.toString()) - 1]);
|
||||
|
||||
|
||||
return stringDt;
|
||||
}
|
||||
|
||||
const month = ["JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"];
|
||||
|
||||
const shortMonth = ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"];
|
||||
@ -0,0 +1,21 @@
|
||||
import { Injectable, ArgumentMetadata, BadRequestException, ValidationPipe, UnprocessableEntityException } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class IctValidateInputPipe extends ValidationPipe {
|
||||
public async transform(value, metadata: ArgumentMetadata) {
|
||||
try {
|
||||
return await super.transform(value, metadata);
|
||||
} catch (e) {
|
||||
if (e instanceof BadRequestException) {
|
||||
// throw new UnprocessableEntityException(this.handleError(e.message)); //commented after migration
|
||||
let err: Object = e.getResponse();
|
||||
console.log("====err1====",err["message"]);
|
||||
throw new UnprocessableEntityException(err["message"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private handleError(errors) {
|
||||
return errors.map(error => error.constraints);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryColumn, PrimaryColumnCannotBeNullableError, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('form_of_contract')
|
||||
export class FormOfContract extends PcdBaseEntity{
|
||||
|
||||
@PrimaryGeneratedColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
|
||||
@Column({
|
||||
name:"form_of_contract",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
formOfContract:string
|
||||
|
||||
|
||||
@OneToMany(() => TenderMaster, (tenderMaster) => tenderMaster.formOfContractD )
|
||||
tenderMaster:TenderMaster[]
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { FormOfContract } from "./form-of-contract.entity";
|
||||
|
||||
@EntityRepository(FormOfContract)
|
||||
export class FormOfContractRepository extends Repository<FormOfContract>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('payment-mode')
|
||||
export class PaymentMode extends PcdBaseEntity{
|
||||
|
||||
@PrimaryGeneratedColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
|
||||
@Column({
|
||||
name:"payment_mode",
|
||||
type:"varchar",
|
||||
nullable:true
|
||||
})
|
||||
paymentMode:string
|
||||
|
||||
@OneToMany(() => TenderMaster, (tenderMaster) => tenderMaster.paymentModeD )
|
||||
tenderMaster:TenderMaster[]
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { PaymentMode } from "./payment-mode.entity";
|
||||
|
||||
@EntityRepository(PaymentMode)
|
||||
export class PaymentModeRepository extends Repository<PaymentMode>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity("product_category")
|
||||
export class ProductCategory extends PcdBaseEntity{
|
||||
@PrimaryGeneratedColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
|
||||
@Column({
|
||||
name:"product_category",
|
||||
type:"varchar",
|
||||
nullable:true
|
||||
})
|
||||
productCategory:string
|
||||
|
||||
|
||||
@OneToMany(() => TenderMaster, (tenderMaster) => tenderMaster.productCategoryD )
|
||||
tenderMaster:TenderMaster[]
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { ProductCategory } from "./product-category.entity";
|
||||
|
||||
@EntityRepository(ProductCategory)
|
||||
export class ProductCategoryRepository extends Repository<ProductCategory>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('tender_category')
|
||||
export class TenderCategory extends PcdBaseEntity{
|
||||
|
||||
@PrimaryGeneratedColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
|
||||
@Column({
|
||||
name:"tender_category",
|
||||
type:"varchar",
|
||||
nullable:true
|
||||
})
|
||||
tenderCategory:string
|
||||
|
||||
@OneToMany(() => TenderMaster, (tenderMaster) => tenderMaster.tenderCategoryD )
|
||||
tenderMaster:TenderMaster[]
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { TenderCategory } from "./tender-category.entity";
|
||||
|
||||
@EntityRepository(TenderCategory)
|
||||
export class TenderCategoryRepository extends Repository<TenderCategory>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, OneToMany, PrimaryColumn, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity('tender-type')
|
||||
export class TenderType extends PcdBaseEntity{
|
||||
|
||||
@PrimaryGeneratedColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
|
||||
@Column({
|
||||
name:"tender_type",
|
||||
type:"varchar",
|
||||
nullable:true
|
||||
})
|
||||
tenderType:string
|
||||
|
||||
|
||||
|
||||
@OneToMany(() => TenderMaster, (tenderMaster) => tenderMaster.tenderTypeD )
|
||||
tenderMaster:TenderMaster[]
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { TenderType } from "./tender-type.entity";
|
||||
@EntityRepository(TenderType)
|
||||
export class TenderTypeRepository extends Repository<TenderType>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
import { PcdBaseEntity } from "src/framework/custom/pcd-entity.custom";
|
||||
import { TenderMaster } from "src/tender-master/tender-master.entity";
|
||||
import { Column, Entity, JoinColumn, ManyToOne, PrimaryColumn } from "typeorm";
|
||||
|
||||
@Entity("tender-doc")
|
||||
export class TenderDoc extends PcdBaseEntity{
|
||||
@PrimaryColumn({
|
||||
name:"id"
|
||||
})
|
||||
id:number
|
||||
@Column({
|
||||
name:"tender_id",
|
||||
type:"numeric",
|
||||
// length:500,
|
||||
nullable:true
|
||||
})
|
||||
tenderId:number
|
||||
@Column({
|
||||
name:"doc_name",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
docName:string
|
||||
@Column({
|
||||
name:"doc_type",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
docType:string
|
||||
@Column({
|
||||
name:"description",
|
||||
type:"varchar",
|
||||
length:500,
|
||||
nullable:true
|
||||
})
|
||||
description:string
|
||||
|
||||
|
||||
@ManyToOne(() => TenderMaster,(tenderMaster)=> tenderMaster.importantDoc)
|
||||
@JoinColumn([{ name: "tender_id", referencedColumnName: "id" }])
|
||||
tenderIdD:TenderMaster
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
import { EntityRepository, Repository } from "typeorm";
|
||||
import { TenderDoc } from "./tender-doc.entity";
|
||||
|
||||
@EntityRepository(TenderDoc)
|
||||
export class tenderDocRepository extends Repository<TenderDoc>{
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
import { Controller,Get} from '@nestjs/common';
|
||||
import { TenderDetailsService } from './tender-details.service';
|
||||
|
||||
@Controller('tender-details')
|
||||
export class TenderDetailsController {
|
||||
|
||||
constructor(
|
||||
private tenderDetailsService:TenderDetailsService
|
||||
|
||||
){
|
||||
}
|
||||
|
||||
@Get()
|
||||
async getTenderDeatil():Promise<any>{
|
||||
return await this.tenderDetailsService.getTenderDesc();
|
||||
}
|
||||
|
||||
@Get('tender-type')
|
||||
async getTenderType():Promise<any>{
|
||||
return await this.tenderDetailsService.getTenderType();
|
||||
}
|
||||
@Get('tender-category')
|
||||
async getTenderCategory():Promise<any>{
|
||||
return await this.tenderDetailsService.getTenderCategory();
|
||||
}
|
||||
@Get('payment-mode')
|
||||
async getPaymentMode():Promise<any>{
|
||||
return await this.tenderDetailsService.getPaymentMode();
|
||||
}
|
||||
@Get('form-contract')
|
||||
async getFormContract():Promise<any>{
|
||||
return await this.tenderDetailsService.getFormOfContract();
|
||||
}
|
||||
@Get('product-category')
|
||||
async getProductCategory():Promise<any>{
|
||||
return await this.tenderDetailsService.getProductCategory();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TenderDetailsController } from './tender-details.controller';
|
||||
import { TenderDetailsService } from './tender-details.service';
|
||||
import { TenderMasterRepository } from './tender-master.repository';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { FormOfContractRepository } from 'src/tables/form-of-contract/form-of-contract.repository';
|
||||
import { PaymentModeRepository } from 'src/tables/payment-mode/payment-mode.repository';
|
||||
import { ProductCategoryRepository } from 'src/tables/product-category/product-category.repository';
|
||||
import { TenderCategoryRepository } from 'src/tables/tender-category/tender-category.repository';
|
||||
import { TenderTypeRepository } from 'src/tables/tender-type/tender-type.repository';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
|
||||
TypeOrmModule.forFeature([
|
||||
FormOfContractRepository,
|
||||
TenderMasterRepository,
|
||||
PaymentModeRepository,
|
||||
ProductCategoryRepository,
|
||||
TenderCategoryRepository,
|
||||
TenderTypeRepository
|
||||
|
||||
]),
|
||||
],
|
||||
controllers: [TenderDetailsController],
|
||||
providers: [TenderDetailsService]
|
||||
})
|
||||
export class TenderDetailsModule {}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue