added batch 2 API from mssql
This commit is contained in:
parent
430f33a218
commit
2a6329bb9e
@ -1,7 +1,7 @@
|
|||||||
import { Controller, Get, Query } from '@nestjs/common';
|
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
||||||
import { CarnetSequenceService } from './carnet-sequence.service';
|
import { CarnetSequenceService } from './carnet-sequence.service';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { GetCarnetSequenceDTO } from 'src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
|
import { CreateCarnetSequenceDTO, GetCarnetSequenceDTO } from 'src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
|
||||||
|
|
||||||
@Controller('mssql')
|
@Controller('mssql')
|
||||||
export class CarnetSequenceController {
|
export class CarnetSequenceController {
|
||||||
@ -13,4 +13,10 @@ export class CarnetSequenceController {
|
|||||||
getCarnetSequence(@Query() body: GetCarnetSequenceDTO) {
|
getCarnetSequence(@Query() body: GetCarnetSequenceDTO) {
|
||||||
return this.carnetSequenceService.getCarnetSequence(body);
|
return this.carnetSequenceService.getCarnetSequence(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiTags('Carnet Sequence - Oracle')
|
||||||
|
@Post('/CreateCarnetSequence/')
|
||||||
|
createCarnetSequence(@Body() body: CreateCarnetSequenceDTO) {
|
||||||
|
return this.carnetSequenceService.createCarnetSequence(body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,14 +2,14 @@ import { Injectable } from '@nestjs/common';
|
|||||||
import { Connection, Request } from 'mssql';
|
import { Connection, Request } from 'mssql';
|
||||||
import { MssqlDBService } from 'src/db/db.service';
|
import { MssqlDBService } from 'src/db/db.service';
|
||||||
import * as mssql from 'mssql'
|
import * as mssql from 'mssql'
|
||||||
import { GetCarnetSequenceDTO } from 'src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
|
import { CreateCarnetSequenceDTO, GetCarnetSequenceDTO } from 'src/oracle/uscib-managed-sp/carnet-sequence/carnet-sequence.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CarnetSequenceService {
|
export class CarnetSequenceService {
|
||||||
|
|
||||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||||
|
|
||||||
async getCarnetSequence(body:GetCarnetSequenceDTO) {
|
async getCarnetSequence(body: GetCarnetSequenceDTO) {
|
||||||
|
|
||||||
let connection: Connection;
|
let connection: Connection;
|
||||||
try {
|
try {
|
||||||
@ -27,4 +27,27 @@ export class CarnetSequenceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async createCarnetSequence(body: CreateCarnetSequenceDTO) {
|
||||||
|
let connection: Connection;
|
||||||
|
try {
|
||||||
|
connection = await this.mssqlDBService.getConnection();
|
||||||
|
const request = new Request(connection);
|
||||||
|
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||||
|
request.input('P_REGIONID', mssql.Float, body.p_regionid);
|
||||||
|
request.input('P_STARTNUMBER', mssql.Int, body.p_startnumber);
|
||||||
|
request.input('P_ENDNUMBER', mssql.Int, body.p_endnumber);
|
||||||
|
request.input('P_CARNETTYPE', mssql.VarChar(4000), body.p_carnettype);
|
||||||
|
const result = await request.execute('carnetsys.CREATECARNETSEQUENCE');
|
||||||
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing stored procedure:', error);
|
||||||
|
return { error: error.message }
|
||||||
|
} finally {
|
||||||
|
if (connection) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,8 +32,8 @@ export class RegionService {
|
|||||||
try {
|
try {
|
||||||
connection = await this.mssqlDBService.getConnection();
|
connection = await this.mssqlDBService.getConnection();
|
||||||
const request = new Request(connection);
|
const request = new Request(connection);
|
||||||
request.input('P_REGION', mssql.VarChar(30), body.p_region);
|
request.input('P_REGION', mssql.VarChar(mssql.MAX), body.p_region);
|
||||||
request.input('P_NAME', mssql.VarChar(30), body.p_name);
|
request.input('P_NAME', mssql.VarChar(mssql.MAX), body.p_name);
|
||||||
const result = await request.execute('carnetsys.INSERTNEWREGION');
|
const result = await request.execute('carnetsys.INSERTNEWREGION');
|
||||||
return { data: result.recordset };
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Body, Controller, Get, Post, Query } from '@nestjs/common';
|
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||||
import { SpContactsService } from './sp-contacts.service';
|
import { SpContactsService } from './sp-contacts.service';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { getSPAllContactsDTO, getSPDefaultcontactDTO, inactivateSPContactDTO } from 'src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto';
|
import { getSPAllContactsDTO, getSPDefaultcontactDTO, inactivateSPContactDTO, InsertSPContactsDTO, setSPDefaultcontactDTO, UpdateSPContactsDTO } from 'src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto';
|
||||||
|
|
||||||
@Controller('mssql')
|
@Controller('mssql')
|
||||||
export class SpContactsController {
|
export class SpContactsController {
|
||||||
@ -26,4 +26,22 @@ export class SpContactsController {
|
|||||||
getSPAllContacts(@Query() body: getSPAllContactsDTO) {
|
getSPAllContacts(@Query() body: getSPAllContactsDTO) {
|
||||||
return this.spContactsService.getSpAllContacts(body);
|
return this.spContactsService.getSpAllContacts(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiTags('SPContacts - Oracle')
|
||||||
|
@Post('/InsertSPContacts')
|
||||||
|
insertSPContacts(@Body() body: InsertSPContactsDTO) {
|
||||||
|
return this.spContactsService.insertSPContacts(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('SPContacts - Oracle')
|
||||||
|
@Post('/SetSPDefaultContact')
|
||||||
|
setSPDefaultcontact(@Query() body: setSPDefaultcontactDTO) {
|
||||||
|
return this.spContactsService.setSPDefaultcontact(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('SPContacts - Oracle')
|
||||||
|
@Put('/UpdateSPContacts')
|
||||||
|
updateSPContacts(@Body() body: UpdateSPContactsDTO) {
|
||||||
|
return this.spContactsService.updateSPContacts(body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { MssqlDBService } from 'src/db/db.service';
|
import { MssqlDBService } from 'src/db/db.service';
|
||||||
import * as mssql from 'mssql'
|
import * as mssql from 'mssql'
|
||||||
import { Connection , Request} from 'mssql';
|
import { Connection, Request } from 'mssql';
|
||||||
import { getSPAllContactsDTO, getSPDefaultcontactDTO, inactivateSPContactDTO } from 'src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto';
|
import { getSPAllContactsDTO, getSPDefaultcontactDTO, inactivateSPContactDTO, InsertSPContactsDTO, setSPDefaultcontactDTO, UpdateSPContactsDTO } from 'src/oracle/uscib-managed-sp/sp-contacts/sp-contacts.dto';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpContactsService {
|
export class SpContactsService {
|
||||||
|
|
||||||
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||||||
|
|
||||||
async getSpAllContacts(body:getSPAllContactsDTO) {
|
async getSpAllContacts(body: getSPAllContactsDTO) {
|
||||||
|
|
||||||
let connection: Connection;
|
let connection: Connection;
|
||||||
try {
|
try {
|
||||||
@ -28,7 +28,7 @@ export class SpContactsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSPDefaultcontacts(body:getSPDefaultcontactDTO) {
|
async getSPDefaultcontacts(body: getSPDefaultcontactDTO) {
|
||||||
|
|
||||||
let connection: Connection;
|
let connection: Connection;
|
||||||
try {
|
try {
|
||||||
@ -47,7 +47,7 @@ export class SpContactsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async inactivateSPContact(body:inactivateSPContactDTO) {
|
async inactivateSPContact(body: inactivateSPContactDTO) {
|
||||||
|
|
||||||
let connection: Connection;
|
let connection: Connection;
|
||||||
try {
|
try {
|
||||||
@ -65,4 +65,80 @@ export class SpContactsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async insertSPContacts(body: InsertSPContactsDTO) {
|
||||||
|
let connection: Connection;
|
||||||
|
try {
|
||||||
|
connection = await this.mssqlDBService.getConnection();
|
||||||
|
const request = new Request(connection);
|
||||||
|
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||||
|
request.input('P_DEFCONTACTFLAG', mssql.VarChar(4000), body.p_defcontactflag);
|
||||||
|
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname);
|
||||||
|
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname);
|
||||||
|
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
|
||||||
|
request.input('P_TITLE', mssql.VarChar(4000), body.p_title);
|
||||||
|
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno);
|
||||||
|
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno);
|
||||||
|
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno);
|
||||||
|
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress);
|
||||||
|
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||||
|
const result = await request.execute('carnetsys.INSERTSPCONTACTS');
|
||||||
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing stored procedure:', error);
|
||||||
|
return { error: error.message }
|
||||||
|
} finally {
|
||||||
|
if (connection) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async setSPDefaultcontact(body: setSPDefaultcontactDTO) {
|
||||||
|
let connection: Connection;
|
||||||
|
try {
|
||||||
|
connection = await this.mssqlDBService.getConnection();
|
||||||
|
const request = new Request(connection);
|
||||||
|
request.input('p_spContactid', mssql.Int, body.p_spcontactid);
|
||||||
|
const result = await request.execute('carnetsys.SETDEFAULTCONTACT');
|
||||||
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing stored procedure:', error);
|
||||||
|
return { error: error.message }
|
||||||
|
} finally {
|
||||||
|
if (connection) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateSPContacts(body: UpdateSPContactsDTO) {
|
||||||
|
let connection: Connection;
|
||||||
|
try {
|
||||||
|
connection = await this.mssqlDBService.getConnection();
|
||||||
|
const request = new Request(connection);
|
||||||
|
request.input('P_SPCONTACTID', mssql.Int, body.p_spcontactid);
|
||||||
|
request.input('P_FIRSTNAME', mssql.VarChar(4000), body.p_firstname);
|
||||||
|
request.input('P_LASTNAME', mssql.VarChar(4000), body.p_lastname);
|
||||||
|
request.input('P_MIDDLEINITIAL', mssql.VarChar(4000), body.P_MIDDLEINITIAL);
|
||||||
|
request.input('P_TITLE', mssql.VarChar(4000), body.p_title);
|
||||||
|
request.input('P_PHONENO', mssql.VarChar(4000), body.p_phoneno);
|
||||||
|
request.input('P_MOBILENO', mssql.VarChar(4000), body.p_mobileno);
|
||||||
|
request.input('P_FAXNO', mssql.VarChar(4000), body.p_faxno);
|
||||||
|
request.input('P_EMAILADDRESS', mssql.VarChar(4000), body.p_emailaddress);
|
||||||
|
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||||
|
const result = await request.execute('carnetsys.INSERTNEWREGION');
|
||||||
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing stored procedure:', error);
|
||||||
|
return { error: error.message }
|
||||||
|
} finally {
|
||||||
|
if (connection) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Controller, Get, Query } from '@nestjs/common';
|
import { Body, Controller, Get, Post, Put, Query } from '@nestjs/common';
|
||||||
import { ApiTags } from '@nestjs/swagger';
|
import { ApiTags } from '@nestjs/swagger';
|
||||||
import { SpService } from './sp.service';
|
import { SpService } from './sp.service';
|
||||||
import { getSelectedServiceproviderDTO } from 'src/oracle/uscib-managed-sp/sp/sp.dto';
|
import { getSelectedServiceproviderDTO, InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/oracle/uscib-managed-sp/sp/sp.dto';
|
||||||
|
|
||||||
@Controller('mssql')
|
@Controller('mssql')
|
||||||
export class SpController {
|
export class SpController {
|
||||||
@ -19,4 +19,16 @@ export class SpController {
|
|||||||
getSelectedServiceprovider(@Query() body: getSelectedServiceproviderDTO) {
|
getSelectedServiceprovider(@Query() body: getSelectedServiceproviderDTO) {
|
||||||
return this.spService.getSpBySpid(body);
|
return this.spService.getSpBySpid(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiTags('SP - Oracle')
|
||||||
|
@Post('/InsertNewServiceProvider')
|
||||||
|
insertNewServiceProvider(@Body() body: InsertNewServiceProviderDTO) {
|
||||||
|
return this.spService.insertNewServiceProvider(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiTags('SP - Oracle')
|
||||||
|
@Put('/UpdateServiceProvider')
|
||||||
|
updateServiceProider(@Body() body: UpdateServiceProviderDTO) {
|
||||||
|
return this.spService.updateServiceProvider(body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Connection, Request } from 'mssql';
|
import { Connection, Request } from 'mssql';
|
||||||
import { MssqlDBService } from 'src/db/db.service';
|
import { MssqlDBService } from 'src/db/db.service';
|
||||||
import { getSelectedServiceproviderDTO } from 'src/oracle/uscib-managed-sp/sp/sp.dto';
|
import { getSelectedServiceproviderDTO, InsertNewServiceProviderDTO, UpdateServiceProviderDTO } from 'src/oracle/uscib-managed-sp/sp/sp.dto';
|
||||||
import * as mssql from 'mssql'
|
import * as mssql from 'mssql'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -27,7 +27,7 @@ export class SpService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSpBySpid(body:getSelectedServiceproviderDTO) {
|
async getSpBySpid(body: getSelectedServiceproviderDTO) {
|
||||||
|
|
||||||
let connection: Connection;
|
let connection: Connection;
|
||||||
try {
|
try {
|
||||||
@ -45,4 +45,73 @@ export class SpService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async insertNewServiceProvider(body: InsertNewServiceProviderDTO) {
|
||||||
|
let connection: Connection;
|
||||||
|
try {
|
||||||
|
connection = await this.mssqlDBService.getConnection();
|
||||||
|
const request = new Request(connection);
|
||||||
|
request.input('P_NAME', mssql.VarChar(4000), body.p_name);
|
||||||
|
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.p_lookupcode);
|
||||||
|
request.input('P_ADDRESS1', mssql.VarChar(4000), body.p_address1);
|
||||||
|
request.input('P_ADDRESS2', mssql.VarChar(4000), body.p_address2);
|
||||||
|
request.input('P_CITY', mssql.VarChar(4000), body.p_city);
|
||||||
|
request.input('P_STATE', mssql.VarChar(4000), body.p_state);
|
||||||
|
request.input('P_ZIP', mssql.VarChar(4000), body.p_zip);
|
||||||
|
request.input('P_COUNTRY', mssql.VarChar(4000), body.p_country);
|
||||||
|
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.p_issuingregion);
|
||||||
|
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.p_replacementregion);
|
||||||
|
request.input('P_BONDSURETY', mssql.VarChar(4000), body.p_bondsurety);
|
||||||
|
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.p_cargopolicyno);
|
||||||
|
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.p_cargosurety);
|
||||||
|
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||||
|
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
|
||||||
|
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
|
||||||
|
const result = await request.execute('carnetsys.INSERTNEWSP');
|
||||||
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing stored procedure:', error);
|
||||||
|
return { error: error.message }
|
||||||
|
} finally {
|
||||||
|
if (connection) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateServiceProvider(body: UpdateServiceProviderDTO) {
|
||||||
|
let connection: Connection;
|
||||||
|
try {
|
||||||
|
connection = await this.mssqlDBService.getConnection();
|
||||||
|
const request = new Request(connection);
|
||||||
|
request.input('P_SPID', mssql.Int, body.p_spid);
|
||||||
|
request.input('P_NAME', mssql.VarChar(4000), body.p_name);
|
||||||
|
request.input('P_LOOKUPCODE', mssql.VarChar(4000), body.p_lookupcode);
|
||||||
|
request.input('P_ADDRESS1', mssql.VarChar(4000), body.p_address1);
|
||||||
|
request.input('P_ADDRESS2', mssql.VarChar(4000), body.p_address2);
|
||||||
|
request.input('P_CITY', mssql.VarChar(4000), body.p_city);
|
||||||
|
request.input('P_STATE', mssql.VarChar(4000), body.p_state);
|
||||||
|
request.input('P_ZIP', mssql.VarChar(4000), body.p_zip);
|
||||||
|
request.input('P_COUNTRY', mssql.VarChar(4000), body.p_country);
|
||||||
|
request.input('P_BONDSURETY', mssql.VarChar(4000), body.p_bondsurety);
|
||||||
|
request.input('P_CARGOPOLICYNO', mssql.VarChar(4000), body.p_cargopolicyno);
|
||||||
|
request.input('P_CARGOSURETY', mssql.VarChar(4000), body.p_cargosurety);
|
||||||
|
request.input('P_REPLACEMENTREGION', mssql.VarChar(4000), body.p_replacementregion);
|
||||||
|
request.input('P_ISSUINGREGION', mssql.VarChar(4000), body.p_issuingregion);
|
||||||
|
request.input('P_USER_ID', mssql.VarChar(4000), body.p_user_id);
|
||||||
|
request.input('P_NOTES', mssql.VarChar(4000), body.P_NOTES);
|
||||||
|
request.input('P_FILEIDS', mssql.VarChar(4000), body.P_FILEIDS);
|
||||||
|
const result = await request.execute('carnetsys.UPDATESP');
|
||||||
|
return { data: result.recordset };
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error executing stored procedure:', error);
|
||||||
|
return { error: error.message }
|
||||||
|
} finally {
|
||||||
|
if (connection) {
|
||||||
|
connection.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user