This commit is contained in:
Lizandro Guarnizo
2026-05-12 19:41:17 -05:00
parent 55c68b470b
commit 25e3cd6254
9 changed files with 270 additions and 3 deletions
+17
View File
@@ -1,6 +1,7 @@
package models
import (
"fmt"
"time"
"github.com/sujit-baniya/fiber-boilerplate/app"
@@ -85,3 +86,19 @@ func GetAllLogs(limit, offset int) ([]NotificacionLog, int64, error) {
func GetLogByID(id uint) (*NotificacionLog, error) {
return GetNotificacionLogByID(id)
}
// GetLogsByContratoID devuelve los logs de notificaciones que incluyen un contrato específico
func GetLogsByContratoID(contratoID uint) ([]NotificacionLog, error) {
var items []NotificacionLog
// contratos_ids es un JSON array, buscamos que contenga el ID
pattern := fmt.Sprintf(`%%[%d]%%`, contratoID)
if err := app.Http.Database.DB.
Preload("Regla").
Where("contratos_ids LIKE ?", pattern).
Order("created_at DESC").
Limit(50).
Find(&items).Error; err != nil {
return nil, err
}
return items, nil
}
+13
View File
@@ -120,3 +120,16 @@ func GetSaasDispatchLogs(limit, offset int) ([]SaasDispatchLog, int64, error) {
}
return items, total, nil
}
// GetDispatchLogsByContratoID devuelve los pagos/dispatches de un contrato específico
func GetDispatchLogsByContratoID(contratoID uint) ([]SaasDispatchLog, error) {
var items []SaasDispatchLog
if err := app.Http.Database.DB.
Where("contrato_id = ?", contratoID).
Order("created_at DESC").
Limit(50).
Find(&items).Error; err != nil {
return nil, err
}
return items, nil
}