feat(fsm): implementar gestion y asignacion de sets de herramientas a tecnicos

This commit is contained in:
2026-10-31 17:07:30 -05:00
parent 06ef042538
commit c07162c375
13 changed files with 1793 additions and 9 deletions
+39
View File
@@ -4,6 +4,7 @@ const Ticket = require('../models/Ticket');
const Company = require('../models/Company');
const Department = require('../models/Department');
const User = require('../models/User');
const HerramientaSet = require('../models/HerramientaSet');
/**
* Middleware para validar llamadas M2M mediante API Key o Token de Agente
@@ -351,4 +352,42 @@ async function handleAddNote(req, res) {
router.post('/external/tickets/:id/notas', handleAddNote);
router.post('/tickets/:id/respuestas', handleAddNote);
/**
* GET /api/external/herramientas/sets
* Consulta los sets y kits de herramientas configurados por empresa
*/
router.get('/external/herramientas/sets', async (req, res) => {
try {
const companyId = parseInt(req.query.empresa_id || req.query.company_id || 1);
const sets = await HerramientaSet.findAll(companyId);
res.json({
ok: true,
success: true,
company_id: companyId,
sets: sets.map(s => ({
id: s.id,
nombre: s.nombre,
codigo: s.codigo,
categoria: s.categoria,
descripcion: s.descripcion,
total_herramientas: s.total_herramientas,
herramientas: s.herramientas ? s.herramientas.map(h => ({
id: h.id,
nombre: h.nombre,
codigo: h.codigo,
numero_serie: h.numero_serie,
marca: h.marca,
modelo: h.modelo,
estado: h.estado
})) : []
}))
});
} catch (err) {
res.status(500).json({ ok: false, success: false, error: err.message });
}
});
router.get('/herramientas/sets', async (req, res) => {
return res.redirect(307, '/api/external/herramientas/sets');
});
module.exports = router;