models

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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

func (*M2MRole) TableName

func (m2m *M2MRole) TableName() string

TableName of the model in the database

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

func (role *Role) ContextItem(name string) any

ContextItem returns one value by name from context

func (*Role) ContextItemString

func (role *Role) ContextItemString(name string) string

ContextItemString returns one string value by name from context

func (*Role) ContextMap

func (role *Role) ContextMap() map[string]any

ContextMap returns the map from the context

func (Role) GetID

func (role Role) GetID() uint64

GetID returns the role ID

func (*Role) GetTitle

func (role *Role) GetTitle() string

GetTitle from role object nolint:unused // exported

func (*Role) RBACResourceName

func (role *Role) RBACResourceName() string

RBACResourceName returns the name of the resource for the RBAC

func (*Role) SetCreatedAt

func (role *Role) SetCreatedAt(t time.Time)

SetCreatedAt sets the created_at field

func (*Role) SetID

func (role *Role) SetID(id uint64)

SetID sets the role ID

func (*Role) SetUpdatedAt

func (role *Role) SetUpdatedAt(t time.Time)

SetUpdatedAt sets the updated_at field

func (*Role) TableName

func (role *Role) TableName() string

TableName of the model in the database

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL