REFACTOR: Alterei a ordem das instruções no glpiModel e descomentei a função que executa o glpiService no app.js.
This commit is contained in:
parent
40d0b2f4c6
commit
9926aee962
28248
servicenow_requests.json
Normal file
28248
servicenow_requests.json
Normal file
File diff suppressed because it is too large
Load Diff
9418
servicenow_tickets.json
Normal file
9418
servicenow_tickets.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ logInfo('Aplicação iniciada', {
|
|||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
await snServices();
|
await snServices();
|
||||||
//await glpiServices();
|
await glpiServices();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logInfo('Erro na aplicação:', error);
|
logInfo('Erro na aplicação:', error);
|
||||||
|
|||||||
@ -68,19 +68,18 @@ try {
|
|||||||
date_creation: ticketData.opened_at || new Date()
|
date_creation: ticketData.opened_at || new Date()
|
||||||
};
|
};
|
||||||
|
|
||||||
await connection.execute(requesterQuery, [ticketId, 917]); // Default user
|
// Construir a query dinamicamente e inserir o ticket principal
|
||||||
// Construir a query manualmente
|
|
||||||
const fields = Object.keys(glpiTicketData).join(', ');
|
const fields = Object.keys(glpiTicketData).join(', ');
|
||||||
const placeholders = Object.keys(glpiTicketData).map(() => '?').join(', ');
|
const placeholders = Object.keys(glpiTicketData).map(() => '?').join(', ');
|
||||||
const values = Object.values(glpiTicketData);
|
const values = Object.values(glpiTicketData);
|
||||||
|
|
||||||
const ticketQuery = `INSERT INTO glpi_tickets (${fields}) VALUES (${placeholders})`;
|
const ticketQuery = `INSERT INTO glpi_tickets (${fields}) VALUES (${placeholders})`;
|
||||||
|
|
||||||
// Inserir ticket principal
|
// Inserir ticket principal e obter insertId
|
||||||
const [ticketResult] = await connection.execute(ticketQuery, values);
|
const [ticketResult] = await connection.execute(ticketQuery, values);
|
||||||
const ticketId = ticketResult.insertId;
|
const ticketId = ticketResult.insertId;
|
||||||
|
|
||||||
// Adicionar requerente
|
// Adicionar requerente (usa ticketId agora que foi criado)
|
||||||
await connection.execute(
|
await connection.execute(
|
||||||
`INSERT INTO glpi_tickets_users
|
`INSERT INTO glpi_tickets_users
|
||||||
(tickets_id, users_id, type, use_notification, alternative_email)
|
(tickets_id, users_id, type, use_notification, alternative_email)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user