up
This commit is contained in:
+17
-5
@@ -9,11 +9,13 @@ import (
|
||||
|
||||
type Roles struct {
|
||||
gorm.Model
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
Description string `json:"description" gorm:"column:description"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
Submodules []Submodules `json:"submodules" gorm:"many2many:roles_submodules"` // Asegúrate de que Submodules esté definido
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
|
||||
Description string `json:"description" gorm:"column:description"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
EsPortalCliente bool `json:"es_portal_cliente" gorm:"column:es_portal_cliente;default:false"`
|
||||
EsPortalPartner bool `json:"es_portal_partner" gorm:"column:es_portal_partner;default:false"`
|
||||
Submodules []Submodules `json:"submodules" gorm:"many2many:roles_submodules"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Modules to `modules`
|
||||
@@ -88,3 +90,13 @@ func FindRoleByName(name string) (Roles, error) {
|
||||
}
|
||||
return role, nil
|
||||
}
|
||||
|
||||
// GetPortalRoles devuelve los roles marcados como portal cliente o portal partner.
|
||||
func GetPortalRoles() ([]Roles, error) {
|
||||
var roles []Roles
|
||||
err := app.Http.Database.DB.
|
||||
Where("es_portal_cliente = ? OR es_portal_partner = ?", true, true).
|
||||
Order("name ASC").
|
||||
Find(&roles).Error
|
||||
return roles, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user