up
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user