added for mssql mf
This commit is contained in:
parent
3f5a6d45ca
commit
05c0e9dc43
@ -6,7 +6,7 @@ export const OracleConfig: any = {
|
||||
password: 'Carnet1234',
|
||||
connectString: '172.31.18.76/xe',
|
||||
|
||||
// user: 'system',
|
||||
// user: 'C##carnetsys',
|
||||
// password: 'root',
|
||||
// connectString: '192.168.1.96/xe',
|
||||
|
||||
|
||||
28
src/mssql/manage-fee/manage-fee.controller.ts
Normal file
28
src/mssql/manage-fee/manage-fee.controller.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
|
||||
import { ManageFeeService } from './manage-fee.service';
|
||||
import { CreateBasicFeeDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO } from 'src/oracle/manage-fee/manage-fee.dto';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@Controller('mssql')
|
||||
export class ManageFeeController {
|
||||
|
||||
constructor(private readonly manageFeeService: ManageFeeService) { }
|
||||
|
||||
@ApiTags('Manage Fee - Mssql')
|
||||
@Get('/GetBasicFeeRates')
|
||||
GetBasicFeeRates(@Query() body: GetFeeGeneralDTO) {
|
||||
return this.manageFeeService.GETBASICFEERATES(body);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Fee - Mssql')
|
||||
@Post('/CreateBasicFee')
|
||||
CreateBasicFee(@Body() body: CreateBasicFeeDTO) {
|
||||
return this.manageFeeService.CREATEBASICFEE(body);
|
||||
}
|
||||
|
||||
@ApiTags('Manage Fee - Mssql')
|
||||
@Patch('/UpdateBasicFee')
|
||||
UpdateBasicFee(@Body() body: UpdateBasicFeeDTO) {
|
||||
return this.manageFeeService.UPDATEBASICFEE(body);
|
||||
}
|
||||
}
|
||||
9
src/mssql/manage-fee/manage-fee.module.ts
Normal file
9
src/mssql/manage-fee/manage-fee.module.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ManageFeeController } from './manage-fee.controller';
|
||||
import { ManageFeeService } from './manage-fee.service';
|
||||
|
||||
@Module({
|
||||
controllers: [ManageFeeController],
|
||||
providers: [ManageFeeService]
|
||||
})
|
||||
export class ManageFeeModule {}
|
||||
70
src/mssql/manage-fee/manage-fee.service.ts
Normal file
70
src/mssql/manage-fee/manage-fee.service.ts
Normal file
@ -0,0 +1,70 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { MssqlDBService, OracleDBService } from 'src/db/db.service';
|
||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||
import { CreateBasicFeeDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO } from 'src/oracle/manage-fee/manage-fee.dto';
|
||||
import * as oracledb from 'oracledb';
|
||||
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||
import { Connection, Request } from 'mssql';
|
||||
import * as mssql from 'mssql';
|
||||
|
||||
@Injectable()
|
||||
export class ManageFeeService {
|
||||
|
||||
private readonly logger = new Logger(ManageFeeService.name);
|
||||
|
||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||
|
||||
// get
|
||||
|
||||
async GETBASICFEERATES(body: GetFeeGeneralDTO): Promise<any[]> {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('p_spid', mssql.Int, body.P_SPID);
|
||||
request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE);
|
||||
const result = await request.execute('carnetsys.GetBasicFeeRates');
|
||||
return result.recordset;
|
||||
} catch (error) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
}
|
||||
|
||||
// post
|
||||
|
||||
async CREATEBASICFEE(body: CreateBasicFeeDTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_STARTCARNETVALUE', mssql.Int, body.P_STARTCARNETVALUE);
|
||||
request.input('P_ENDCARNETVALUE', mssql.Int, body.P_ENDCARNETVALUE);
|
||||
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
|
||||
request.input('P_FEES', mssql.Int, body.P_FEES);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.CreateBasicFee');
|
||||
return result.recordset;
|
||||
} catch (error) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
}
|
||||
|
||||
// update
|
||||
|
||||
async UPDATEBASICFEE(body: UpdateBasicFeeDTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_BASICFEESETUPID', mssql.Int, body.P_BASICFEESETUPID);
|
||||
request.input('P_FEES', mssql.Int, body.P_FEES);
|
||||
request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.UpdateBasicFee');
|
||||
return result.recordset;
|
||||
} catch (error) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,10 +5,11 @@ import { UscibManagedSpModule } from './uscib-managed-sp/uscib-managed-sp.module
|
||||
import { ManageClientsModule } from './manage-clients/manage-clients.module';
|
||||
import { ManageHoldersModule } from './manage-holders/manage-holders.module';
|
||||
import { ParamTableModule } from './param-table/param-table.module';
|
||||
import { ManageFeeModule } from './manage-fee/manage-fee.module';
|
||||
|
||||
@Module({
|
||||
controllers: [MssqlController],
|
||||
providers: [MssqlService],
|
||||
imports: [UscibManagedSpModule, ManageClientsModule, ManageHoldersModule, ParamTableModule]
|
||||
imports: [UscibManagedSpModule, ManageClientsModule, ManageHoldersModule, ParamTableModule, ManageFeeModule]
|
||||
})
|
||||
export class MssqlModule {}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { Transform } from 'class-transformer';
|
||||
import { IsDefined, IsInt, IsNumber, IsString, Min } from 'class-validator';
|
||||
import { IsDefined, IsInt, IsNumber, IsString, Matches, Min } from 'class-validator';
|
||||
|
||||
export class GetFeeGeneralDTO {
|
||||
@ApiProperty({ required: true })
|
||||
@ -12,6 +12,9 @@ export class GetFeeGeneralDTO {
|
||||
P_SPID: number;
|
||||
|
||||
@ApiProperty({ required: true })
|
||||
@Matches(/^.{6}$|^.{8}$/, {
|
||||
message: 'Property P_ACTIVE_INACTIVE must be either too long or short',
|
||||
})
|
||||
@IsString({ message: 'Property P_ACTIVE_INACTIVE must be a string' })
|
||||
@IsDefined({ message: 'Property P_ACTIVE_INACTIVE is required' })
|
||||
P_ACTIVE_INACTIVE: string;
|
||||
|
||||
@ -26,4 +26,10 @@ export class RegionController {
|
||||
getRegions() {
|
||||
return this.regionService.getRegions();
|
||||
}
|
||||
|
||||
// @ApiTags('Regions - Oracle')
|
||||
// @Get('/getDetails')
|
||||
selectAll() {
|
||||
return this.regionService.selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,39 @@ export class RegionService {
|
||||
|
||||
constructor(private readonly oracleDBService: OracleDBService) { }
|
||||
|
||||
async selectAll() {
|
||||
let connection: oracledb.Connection | undefined;
|
||||
try {
|
||||
connection = await this.oracleDBService.getConnection();
|
||||
if (!connection) {
|
||||
throw new InternalServerException();
|
||||
}
|
||||
|
||||
const result = await connection.execute(
|
||||
`SELECT * FROM BasicFeeSetup`,
|
||||
[],
|
||||
{
|
||||
outFormat: oracledb.OUT_FORMAT_OBJECT,
|
||||
}
|
||||
);
|
||||
|
||||
return result.rows;
|
||||
} catch (error) {
|
||||
this.logger.error('selectAll failed', error.stack || error);
|
||||
throw new InternalServerException();
|
||||
} finally {
|
||||
if (connection) {
|
||||
try {
|
||||
await connection.close();
|
||||
} catch (closeErr) {
|
||||
this.logger.error('Failed to close DB connection', closeErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async insertRegions(body: InsertRegionsDto) {
|
||||
let connection;
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user