added param table api
This commit is contained in:
parent
f7700b09a7
commit
404caf1ee5
18
ormconfig.ts
18
ormconfig.ts
@ -15,17 +15,17 @@ export const OracleConfig: any = {
|
||||
export const MssqlConfig: any = {
|
||||
// type: 'mssql',
|
||||
|
||||
server: 'localhost',
|
||||
user: 'mssql1433',
|
||||
password: 'root',
|
||||
database: 'CarnetDB',
|
||||
|
||||
// server: '172.31.18.76',
|
||||
// port: 1433,
|
||||
// user: 'Carnetsys',
|
||||
// password: 'Carnet1234',
|
||||
// server: 'localhost',
|
||||
// user: 'mssql1433',
|
||||
// password: 'root',
|
||||
// database: 'CarnetDB',
|
||||
|
||||
server: '172.31.18.76',
|
||||
port: 1433,
|
||||
user: 'Carnetsys',
|
||||
password: 'Carnet1234',
|
||||
database: 'CarnetDB',
|
||||
|
||||
// entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||
// synchronize: true,
|
||||
|
||||
|
||||
@ -4,10 +4,11 @@ import { MssqlService } from './mssql.service';
|
||||
import { UscibManagedSpModule } from './uscib-managed-sp/uscib-managed-sp.module';
|
||||
import { ManageClientsModule } from './manage-clients/manage-clients.module';
|
||||
import { ManageHoldersModule } from './manage-holders/manage-holders.module';
|
||||
import { ParamTableModule } from './param-table/param-table.module';
|
||||
|
||||
@Module({
|
||||
controllers: [MssqlController],
|
||||
providers: [MssqlService],
|
||||
imports: [UscibManagedSpModule, ManageClientsModule, ManageHoldersModule]
|
||||
imports: [UscibManagedSpModule, ManageClientsModule, ManageHoldersModule, ParamTableModule]
|
||||
})
|
||||
export class MssqlModule {}
|
||||
|
||||
63
src/mssql/param-table/param-table.controller.ts
Normal file
63
src/mssql/param-table/param-table.controller.ts
Normal file
@ -0,0 +1,63 @@
|
||||
import { Body, Controller, Get, Patch, Post, Put, Query } from '@nestjs/common';
|
||||
import { ApiQuery, ApiTags } from '@nestjs/swagger';
|
||||
import { ParamTableService } from './param-table.service';
|
||||
import {
|
||||
ActivateOrInactivateParamRecordDTO,
|
||||
CreateParamRecordDTO,
|
||||
CreateTableRecordDTO,
|
||||
getParamValuesDTO,
|
||||
UpdateParamRecordDTO,
|
||||
} from '../../oracle/param-table/param-table.dto';
|
||||
|
||||
@Controller('oracle')
|
||||
export class ParamTableController {
|
||||
constructor(private readonly paramTableService: ParamTableService) {}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Get('/GetParamValues')
|
||||
@ApiQuery({
|
||||
name: 'P_SPID',
|
||||
required: false,
|
||||
type: Number,
|
||||
description: 'The ID of the parameter',
|
||||
})
|
||||
@ApiQuery({
|
||||
name: 'P_PARAMTYPE',
|
||||
required: false,
|
||||
type: String,
|
||||
description: 'The type of the parameter',
|
||||
})
|
||||
getParamValues(@Query() body: getParamValuesDTO) {
|
||||
return this.paramTableService.GETPARAMVALUES(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Post('/CreateTableRecord')
|
||||
createTableRecord(@Body() body: CreateTableRecordDTO) {
|
||||
return this.paramTableService.CREATETABLERECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Post('/CreateParamRecord')
|
||||
createParamRecord(@Body() body: CreateParamRecordDTO) {
|
||||
return this.paramTableService.CREATEPARAMRECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Patch('/UpdateParamRecord')
|
||||
UpdateParamRecord(@Body() body: UpdateParamRecordDTO) {
|
||||
return this.paramTableService.UPDATEPARAMRECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Put('/InActivateParamRecord')
|
||||
inActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
|
||||
return this.paramTableService.INACTIVATEPARAMRECORD(body);
|
||||
}
|
||||
|
||||
@ApiTags('Param Table - Oracle')
|
||||
@Put('/ReActivateParamRecord')
|
||||
reActivateParamRecord(@Body() body: ActivateOrInactivateParamRecordDTO) {
|
||||
return this.paramTableService.REACTIVATEPARAMRECORD(body);
|
||||
}
|
||||
}
|
||||
9
src/mssql/param-table/param-table.module.ts
Normal file
9
src/mssql/param-table/param-table.module.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ParamTableController } from './param-table.controller';
|
||||
import { ParamTableService } from './param-table.service';
|
||||
|
||||
@Module({
|
||||
controllers: [ParamTableController],
|
||||
providers: [ParamTableService]
|
||||
})
|
||||
export class ParamTableModule {}
|
||||
147
src/mssql/param-table/param-table.service.ts
Normal file
147
src/mssql/param-table/param-table.service.ts
Normal file
@ -0,0 +1,147 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { MssqlDBService } from 'src/db/db.service';
|
||||
import * as mssql from 'mssql';
|
||||
import { Request } from 'mssql';
|
||||
import {
|
||||
ActivateOrInactivateParamRecordDTO,
|
||||
CreateParamRecordDTO,
|
||||
CreateTableRecordDTO,
|
||||
getParamValuesDTO,
|
||||
UpdateParamRecordDTO,
|
||||
} from '../../oracle/param-table/param-table.dto';
|
||||
import { Connection } from 'mssql';
|
||||
|
||||
@Injectable()
|
||||
export class ParamTableService {
|
||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||
|
||||
async GETPARAMVALUES(body: getParamValuesDTO) {
|
||||
const finalBody = {
|
||||
P_SPID: body.P_SPID ? body.P_SPID : null,
|
||||
P_PARAMTYPE: body.P_PARAMTYPE ? body.P_PARAMTYPE : null,
|
||||
};
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, finalBody.P_SPID);
|
||||
request.input('P_PARAMTYPE', mssql.VarChar(100), finalBody.P_PARAMTYPE);
|
||||
const result = await request.execute('carnetsys.GETPARAMVALUES');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async CREATETABLERECORD(body: CreateTableRecordDTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
request.input('P_TABLEFULLDESC', mssql.NVarChar, body.P_TABLEFULLDESC);
|
||||
const result = await request.execute('carnetsys.CREATETABLERECORD');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async CREATEPARAMRECORD(body: CreateParamRecordDTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_PARAMTYPE', mssql.VarChar(255), body.P_PARAMTYPE);
|
||||
request.input('P_PARAMDESC', mssql.VarChar(255), body.P_PARAMDESC);
|
||||
request.input('P_PARAMVALUE', mssql.VarChar(255), body.P_PARAMVALUE);
|
||||
request.input('P_ADDLPARAMVALUE1', mssql.VarChar(255), body.P_ADDLPARAMVALUE1);
|
||||
request.input('P_ADDLPARAMVALUE2', mssql.VarChar(255), body.P_ADDLPARAMVALUE2);
|
||||
request.input('P_ADDLPARAMVALUE3', mssql.VarChar(255), body.P_ADDLPARAMVALUE3);
|
||||
request.input('P_ADDLPARAMVALUE4', mssql.VarChar(255), body.P_ADDLPARAMVALUE4);
|
||||
request.input('P_ADDLPARAMVALUE5', mssql.VarChar(255), body.P_ADDLPARAMVALUE5);
|
||||
request.input('P_SORTSEQ', mssql.Int, body.P_SORTSEQ);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.CREATEPARAMRECORD');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async UPDATEPARAMRECORD(body: UpdateParamRecordDTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
const request = new Request(connection);
|
||||
request.input('P_SPID', mssql.Int, body.P_SPID);
|
||||
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
|
||||
request.input('P_PARAMDESC', mssql.VarChar(255), body.P_PARAMDESC);
|
||||
request.input('P_ADDLPARAMVALUE1', mssql.VarChar(255), body.P_ADDLPARAMVALUE1);
|
||||
request.input('P_ADDLPARAMVALUE2', mssql.VarChar(255), body.P_ADDLPARAMVALUE2);
|
||||
request.input('P_ADDLPARAMVALUE3', mssql.VarChar(255), body.P_ADDLPARAMVALUE3);
|
||||
request.input('P_ADDLPARAMVALUE4', mssql.VarChar(255), body.P_ADDLPARAMVALUE4);
|
||||
request.input('P_ADDLPARAMVALUE5', mssql.VarChar(255), body.P_ADDLPARAMVALUE5);
|
||||
request.input('P_SORTSEQ', mssql.Int, body.P_SORTSEQ);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.UPDATEPARAMRECORD');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async INACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
|
||||
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.INACTIVATEPARAMRECORD');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async REACTIVATEPARAMRECORD(body: ActivateOrInactivateParamRecordDTO) {
|
||||
let connection: Connection;
|
||||
try {
|
||||
connection = await this.mssqlDBService.getConnection();
|
||||
const request = new Request(connection);
|
||||
request.input('P_PARAMID', mssql.Int, body.P_PARAMID);
|
||||
request.input('P_USERID', mssql.VarChar(100), body.P_USERID);
|
||||
const result = await request.execute('carnetsys.REACTIVATEPARAMRECORD');
|
||||
return { data: result.recordset };
|
||||
} catch (error) {
|
||||
return { error: error.message };
|
||||
} finally {
|
||||
if (connection) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user