diff --git a/pkg/models/partner_recurso.go b/pkg/models/partner_recurso.go index f441ee9..818c0cf 100644 --- a/pkg/models/partner_recurso.go +++ b/pkg/models/partner_recurso.go @@ -15,6 +15,7 @@ type PartnerRecurso struct { Categoria string `json:"categoria" gorm:"column:categoria;default:'general'"` // general|tecnico|comercial|marketing Archivo string `json:"archivo" gorm:"column:archivo"` NombreOrig string `json:"nombre_orig" gorm:"column:nombre_orig"` + Enlace string `json:"enlace" gorm:"column:enlace"` // URL externa opcional Activo bool `json:"activo" gorm:"column:activo;default:true"` } diff --git a/pkg/services/notif_dispatch.go b/pkg/services/notif_dispatch.go index 093cc07..ded5df3 100644 --- a/pkg/services/notif_dispatch.go +++ b/pkg/services/notif_dispatch.go @@ -213,9 +213,19 @@ func sendTelegramAdmin(mensaje string) { continue } ts := &TelegramService{BotToken: cfg.BotToken} - if err := ts.SendMessage(cfg.ChatID, mensaje); err != nil { - log.Printf("[Notif] Error enviando telegram admin (cfg %d): %v", cfg.ID, err) + sendErr := ts.SendMessage(cfg.ChatID, mensaje) + logEntry := &models.TelegramLog{ + TelegramConfigID: cfg.ID, + Titulo: "Notificación del sistema", + Mensaje: mensaje, + Estado: "ok", } + if sendErr != nil { + log.Printf("[Notif] Error enviando telegram admin (cfg %d): %v", cfg.ID, sendErr) + logEntry.Estado = "failed" + logEntry.ErrorMsg = sendErr.Error() + } + _ = models.CreateTelegramLog(logEntry) } } diff --git a/resources/views/partner_recursos.html b/resources/views/partner_recursos.html index 30b6f97..9b529cc 100644 --- a/resources/views/partner_recursos.html +++ b/resources/views/partner_recursos.html @@ -37,6 +37,7 @@ Marketing + Visible para partners @@ -85,7 +86,22 @@ - + + + + + + + + + + + + + + + + @@ -243,7 +259,7 @@ function partnerRecursos() { tab: 'recursos', recursos: [], comunicados: [], - newR: { nombre:'', descripcion:'', categoria:'general', activo:true }, + newR: { nombre:'', descripcion:'', categoria:'general', enlace:'', activo:true }, newC: { titulo:'', contenido:'', activo:true }, editR: null, editC: null, @@ -267,7 +283,7 @@ function partnerRecursos() { try { const r = await axios.post('/app/partner-recursos', this.newR); this.recursos.unshift(r.data); - this.newR = { nombre:'', descripcion:'', categoria:'general', activo:true }; + this.newR = { nombre:'', descripcion:'', categoria:'general', enlace:'', activo:true }; } catch(e) { alert(e.response?.data?.error || 'Error al crear'); } }, diff --git a/resources/views/portal/dashboard.html b/resources/views/portal/dashboard.html index aadbef1..b9169b6 100644 --- a/resources/views/portal/dashboard.html +++ b/resources/views/portal/dashboard.html @@ -162,7 +162,14 @@ Descargar - + + + + Ver enlace + + + Sin archivo adjunto diff --git a/rest/controllers/partner_recurso_controller.go b/rest/controllers/partner_recurso_controller.go index 19ffe6e..5cde2e6 100644 --- a/rest/controllers/partner_recurso_controller.go +++ b/rest/controllers/partner_recurso_controller.go @@ -35,6 +35,7 @@ func CreatePartnerRecurso(c *fiber.Ctx) error { Nombre string `json:"nombre"` Descripcion string `json:"descripcion"` Categoria string `json:"categoria"` + Enlace string `json:"enlace"` Activo bool `json:"activo"` } var req Req @@ -45,6 +46,7 @@ func CreatePartnerRecurso(c *fiber.Ctx) error { Nombre: req.Nombre, Descripcion: req.Descripcion, Categoria: req.Categoria, + Enlace: req.Enlace, Activo: req.Activo, } if err := models.CreatePartnerRecurso(r); err != nil { @@ -59,6 +61,7 @@ func UpdatePartnerRecurso(c *fiber.Ctx) error { Nombre string `json:"nombre"` Descripcion string `json:"descripcion"` Categoria string `json:"categoria"` + Enlace string `json:"enlace"` Activo bool `json:"activo"` } var req Req @@ -72,6 +75,7 @@ func UpdatePartnerRecurso(c *fiber.Ctx) error { r.Nombre = req.Nombre r.Descripcion = req.Descripcion r.Categoria = req.Categoria + r.Enlace = req.Enlace r.Activo = req.Activo if err := models.UpdatePartnerRecurso(r); err != nil { return c.Status(500).JSON(fiber.Map{"error": err.Error()})