model

package
v2.3.182 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	IOSDeviceID     = 1
	AndroidDeviceID = 2
	DesktopDeviceID = 3
	WebDeviceID     = 4
	ConsoleDeviceID = 5
	LinuxDeviceID   = 6
	WindowsDeviceID = 7

	IOSDeviceStr     = "IOS"
	AndroidDeviceStr = "Android"
	DesktopDeviceStr = "Desktop"
	WebDeviceStr     = "Web"
	ConsoleDeviceStr = "Console"
	LinuxDeviceStr   = "Linux"
	WindowsDeviceStr = "Windows"
)
View Source
const SuperAdmin = "SuperAdmin"

Variables

View Source
var Permissions = []model2.Permission{
	{Method: "auth/roles", Desc: i18n.RolesPermission},
	{Method: "auth/users", Desc: i18n.UsersPermission},
	{Method: "auth/sessions", Desc: i18n.SessionsPermission},
}

Functions

func DeviceIDToName

func DeviceIDToName(num int) string

func DeviceNameToID

func DeviceNameToID(name string) int

func GetPermission

func GetPermission(key string) translator.Translate

func GetPermissions

func GetPermissions() map[string]translator.Translate

func GetPermissionsKeys

func GetPermissionsKeys() []string

func SetPermissions

func SetPermissions(perms []model2.Permission)

Types

type AuthToken

type AuthToken struct {
	Auth Token `json:"auth"`
	User User  `json:"user"`
}

type Filter added in v2.3.99

type Filter struct {
	ID       int    `json:"id"`
	UserID   int    `json:"user_id"`
	DeviceID int    `json:"device_id"`
	Endpoint string `json:"endpoint"`
	Name     string `json:"name"`
	Value    []byte `json:"value"`

	User *User `json:"user"`
}

func (Filter) TableName added in v2.3.99

func (m Filter) TableName() string

type Migration added in v2.3.155

type Migration struct {
	Version string `json:"version"`
	Dirty   bool   `json:"dirty"`
}

func (Migration) TableName added in v2.3.155

func (m Migration) TableName() string

type Permission

type Permission struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

func (Permission) TableName

func (m Permission) TableName() string

type RefreshToken

type RefreshToken struct {
	ID        int       `json:"id"`
	UserID    int       `json:"user_id"`
	DeviceID  int       `json:"device_id"`
	Token     string    `json:"token"`
	LoggedAt  time.Time `json:"logged_at"`
	UpdatedAt time.Time `json:"updated_at"`
	ExpiresAt time.Time `json:"expires_at"`
	Provider  *string   `json:"provider"`

	User *User `json:"user"`
}

func (RefreshToken) TableName

func (m RefreshToken) TableName() string

type Role

type Role struct {
	ID   int    `json:"id"`
	Name string `json:"name"`

	RolePermissions []RolePermission `json:"role_permissions"`
}

func (Role) TableName

func (m Role) TableName() string

type RolePermission

type RolePermission struct {
	RoleID       int  `json:"role_id"`
	PermissionID int  `json:"permission_id"`
	Read         bool `json:"read"`
	Write        bool `json:"write"`
	Exec         bool `json:"exec"`

	Permission *Permission `json:"auth_permission"`
}

func (RolePermission) TableName

func (m RolePermission) TableName() string

type Setting

type Setting struct {
	UserID   int    `json:"user_id"`
	DeviceID int    `json:"device_id"`
	Settings []byte `json:"settings"`

	User *User `json:"user"`
}

func (Setting) TableName

func (m Setting) TableName() string

type Token

type Token struct {
	Token        string  `json:"token"`
	RefreshToken string  `json:"refresh_token"`
	ExpiresAt    float64 `json:"expires_at"`
	TokenType    string  `json:"token_type"`
	UserID       int     `json:"user_id"`
}

type User

type User struct {
	ID         int     `json:"id"`
	Login      string  `json:"login"`
	FirstName  string  `json:"first_name"`
	SecondName *string `json:"second_name"`
	LastName   *string `json:"last_name"`
	Password   string  `json:"password"`
	Email      *string `json:"email"`
	Phone      *string `json:"phone"`
	Blocked    bool    `json:"blocked"`

	Roles   []Role      `json:"roles" gorm:"many2many:auth_user_roles;"`
	Profile interface{} `json:"profile" gorm:"-" db:"-"`
}

func (User) TableName

func (m User) TableName() string

type UserRole

type UserRole struct {
	UserID int `json:"user_id"`
	RoleID int `json:"role_id"`
}

func (UserRole) TableName

func (m UserRole) TableName() string

type Version added in v2.3.155

type Version struct {
	App string `json:"app"`
	DB  string `json:"db"`
}

Jump to

Keyboard shortcuts

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