This commit is contained in:
Lizandro Guarnizo
2026-05-15 23:22:35 -05:00
parent c91383882c
commit 49cc56123b
12 changed files with 1371 additions and 4 deletions
+9
View File
@@ -153,3 +153,12 @@ func CheckPortalLogin(email, password string) (*PortalUser, error) {
}
return u, nil
}
// GetPortalUsersByClienteID devuelve todos los portal users activos de un cliente.
func GetPortalUsersByClienteID(clienteID uint) ([]PortalUser, error) {
var users []PortalUser
err := app.Http.Database.DB.
Where("cliente_id = ? AND activo = true", clienteID).
Find(&users).Error
return users, err
}
+39
View File
@@ -0,0 +1,39 @@
package models
import (
"github.com/sujit-baniya/fiber-boilerplate/app"
"gorm.io/gorm"
)
// ShieldConfig almacena las credenciales para la API de USITE Shield.
type ShieldConfig struct {
gorm.Model
BaseUrl string `json:"base_url" gorm:"column:base_url;type:text;default:'https://api-shield.u-s.app'"`
AdminToken string `json:"admin_token" gorm:"column:admin_token;type:text"`
Activo bool `json:"activo" gorm:"column:activo;default:true"`
Nota string `json:"nota" gorm:"column:nota;type:text"`
}
func (ShieldConfig) TableName() string { return "shield_config" }
func GetShieldConfig() (*ShieldConfig, error) {
var cfg ShieldConfig
err := app.Http.Database.DB.Where("activo = true").First(&cfg).Error
if err != nil {
return nil, err
}
return &cfg, nil
}
func UpsertShieldConfig(cfg *ShieldConfig) error {
var existing ShieldConfig
if err := app.Http.Database.DB.First(&existing).Error; err != nil {
return app.Http.Database.DB.Create(cfg).Error
}
return app.Http.Database.DB.Model(&existing).Updates(map[string]interface{}{
"base_url": cfg.BaseUrl,
"admin_token": cfg.AdminToken,
"activo": cfg.Activo,
"nota": cfg.Nota,
}).Error
}