Documentation
¶
Index ¶
- Constants
- type M2MRole
- type Role
- func (role *Role) ContextItem(name string) any
- func (role *Role) ContextItemString(name string) string
- func (role *Role) ContextMap() map[string]any
- func (role Role) GetID() uint64
- func (role *Role) GetTitle() string
- func (role *Role) RBACResourceName() string
- func (role *Role) SetCreatedAt(t time.Time)
- func (role *Role) SetID(id uint64)
- func (role *Role) SetUpdatedAt(t time.Time)
- func (role *Role) TableName() string
Constants ¶
View Source
const ( AccessLevelBasic = 0 AccessLevelNoAnonymous = 1 AccessLevelAccount = 2 AccessLevelSystem = 3 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type M2MRole ¶
type M2MRole struct {
ParentRoleID uint64 `db:"parent_role_id" gorm:"primaryKey"`
ChildRoleID uint64 `db:"child_role_id" gorm:"primaryKey"`
CreatedAt time.Time `db:"created_at"`
}
M2MRole link parent and child role
type Role ¶
type Role struct {
ID uint64 `db:"id"`
Name string `db:"name"`
Title string `db:"title"`
Description string `db:"description"`
// Contains additional data for the role
Context gosql.NullableJSON[map[string]any] `db:"context"`
ChildRoles []*Role `db:"-" gorm:"many2many:m2m_rbac_role;ForeignKey:ID;joinForeignKey:parent_role_id;joinReferences:child_role_id;References:ID"`
PermissionPatterns gosql.NullableStringArray `db:"permissions" gorm:"column:permissions;type:text[]"`
AccessLevel int `db:"access_level"` // 0 - any, 1 - no anonymous, 2 - account, >=3 - system
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DeletedAt gorm.DeletedAt `db:"deleted_at"`
}
Role base model
func (*Role) ContextItem ¶
ContextItem returns one value by name from context
func (*Role) ContextItemString ¶
ContextItemString returns one string value by name from context
func (*Role) ContextMap ¶
ContextMap returns the map from the context
func (*Role) RBACResourceName ¶
RBACResourceName returns the name of the resource for the RBAC
func (*Role) SetCreatedAt ¶
SetCreatedAt sets the created_at field
func (*Role) SetUpdatedAt ¶
SetUpdatedAt sets the updated_at field
Click to show internal directories.
Click to hide internal directories.