28 lines
799 B
TypeScript
28 lines
799 B
TypeScript
|
|
import { Injectable } from '@nestjs/common';
|
||
|
|
import { Connection, Request } from 'mssql';
|
||
|
|
import { MssqlDBService } from 'src/db/db.service';
|
||
|
|
|
||
|
|
@Injectable()
|
||
|
|
export class SpService {
|
||
|
|
|
||
|
|
constructor(private readonly mssqlDBService: MssqlDBService) { }
|
||
|
|
|
||
|
|
async getAllServiceproviders() {
|
||
|
|
|
||
|
|
let connection: Connection;
|
||
|
|
try {
|
||
|
|
connection = await this.mssqlDBService.getConnection();
|
||
|
|
const request = new Request(connection);
|
||
|
|
const result = await request.execute('carnetsys.GETALLSPS');
|
||
|
|
return { data: result.recordsets };
|
||
|
|
|
||
|
|
} catch (error) {
|
||
|
|
console.error('Error executing stored procedure:', error);
|
||
|
|
} finally {
|
||
|
|
if (connection) {
|
||
|
|
connection.close();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|