model

package
v2.3.38 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: MIT Imports: 4 Imported by: 0

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/permissions", Desc: i18n.PermissionsPermission},
	{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 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"`

	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 *string `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;"`
}

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

Jump to

Keyboard shortcuts

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