From 4a557fc2838b11415d9cd70a73b815dcb8288f4c Mon Sep 17 00:00:00 2001 From: "gabriel.amancio" Date: Fri, 10 Oct 2025 15:05:05 -0300 Subject: [PATCH] =?UTF-8?q?FEAT:=20Insert=20grupo=20atribu=C3=ADdo=20de=20?= =?UTF-8?q?tickets.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/processController.js | 6 ++++-- model/glpiModel.js | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/controller/processController.js b/controller/processController.js index fd3c501..1540189 100644 --- a/controller/processController.js +++ b/controller/processController.js @@ -55,7 +55,7 @@ const formatDescription = (ticketData) => { ${ticketData.ticket_mundiale} - Protocolo Hub (ServiceNow): + Protocolo Hub: ${ticketData.protocolo_hub || 'N/A'} @@ -103,10 +103,12 @@ const formatTicketDataForGlpi = async (ticketData) => { const createGlpiTicket = async (ticketData) => { try { const formattedTicketData = await formatTicketDataForGlpi(ticketData); - console.log('Dados do ticket formatados para GLPI:', formattedTicketData); + // console.log('Dados do ticket formatados para GLPI:', formattedTicketData); const glpiTicket = await glpiModel.insertTicket(formattedTicketData); console.log('Ticket criado no GLPI:', glpiTicket); + + await glpiModel.insertGroupTickets(glpiTicket.insertId); const syncId = await hubglpiModel.get_idSyncByHubsoftId(ticketData.id_atendimento); diff --git a/model/glpiModel.js b/model/glpiModel.js index 0791bc4..3d6dc9e 100644 --- a/model/glpiModel.js +++ b/model/glpiModel.js @@ -84,6 +84,24 @@ class GlpiModel { throw err; } } + + static async insertGroupTickets(glpiTicketId) { + const query = ` + INSERT INTO glpi_groups_tickets (tickets_id, groups_id, type) + VALUES (?, ?, ?) + `; + const values = [glpiTicketId, 25, 2]; + try { + const res = await pool.query(query, values); + logInfo('ID de sync_data obtido com sucesso:', res.rows[0]); + return res.rows[0] ? res.rows[0].id : null; + } + catch (err) { + logError('Erro ao obter ID de sync_data', err); + throw err; + } + } + } module.exports = GlpiModel; \ No newline at end of file