model

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *gorm.DB
)

Functions

func AddGroup

func AddGroup(name string)

func AddGroups

func AddGroups(names ...string)

func AddPermission

func AddPermission(name string)

func AddPermissions

func AddPermissions(names ...string)

func Setup

func Setup(dbFile string)

Types

type Group

type Group struct {
	ID          uint64 `gorm:"primaryKey"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
	Name        string         `gorm:"unique;not null"`
	Users       []*User        `gorm:"many2many:user_groups;"`
	Permissions []Permission   `gorm:"many2many:group_permissions;"`
}

type Permission

type Permission struct {
	ID        uint64 `gorm:"primaryKey"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	Name      string         `gorm:"unique;not null"`
	Users     []*User        `gorm:"many2many:user_permissions;"`
	Groups    []*Group       `gorm:"many2many:group_permissions;"`
}

type User

type User struct {
	ID          uint64 `gorm:"primaryKey"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	DeletedAt   gorm.DeletedAt `gorm:"index"`
	Username    string         `gorm:"unique;not null"`
	Password    string         `gorm:"not null"`
	Disabled    bool           `gorm:"not null;default:false"`
	IsAdmin     bool           `gorm:"not null;default:false"`
	Groups      []Group        `gorm:"many2many:user_groups;"`
	Permissions []Permission   `gorm:"many2many:user_permissions;"`
	Icon        string         `gorm:"default:'';"`
}

func (*User) AfterFind

func (u *User) AfterFind(tx *gorm.DB) (err error)

func (*User) AllPermissionStrings

func (u *User) AllPermissionStrings() []string

type UsernameRequest

type UsernameRequest struct {
	ID            uint64 `gorm:"primaryKey"`
	CreatedAt     time.Time
	UpdatedAt     time.Time
	DeletedAt     gorm.DeletedAt `gorm:"index"`
	RequestUserID uint64         `gorm:"not null"`
	RequestUser   User
	Name          string `gorm:"not null"`
}

Jump to

Keyboard shortcuts

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