models

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

View Source
const (
	ROLE_ADMIN  = "admin"
	ROLE_NORMAL = "normal"
)
View Source
const (
	STATUS_UNKNOWN = iota
	STATUS_NORMAL
	STATUS_BANED
)

Variables

This section is empty.

Functions

func MustInitDBManager

func MustInitDBManager(dbs map[string]*gorm.DB, defaultDBType string)

func NewDBManager

func NewDBManager(dbs map[string]*gorm.DB, defaultDBType string) *dbManagerImpl

Types

type Cert

type Cert struct {
	gorm.Model
	Name     string `gorm:"uniqueIndex"`
	CertFile []byte
	KeyFile  []byte
	CaFile   []byte
}

func (*Cert) TableName

func (c *Cert) TableName() string

type Client

type Client struct {
	*ClientEntity
}

func (*Client) TableName

func (*Client) TableName() string

type ClientEntity

type ClientEntity struct {
	ClientID      string `json:"client_id" gorm:"uniqueIndex;not null;primaryKey"`
	ServerID      string `json:"server_id"`
	TenantID      int    `json:"tenant_id" gorm:"not null"`
	UserID        int    `json:"user_id" gorm:"not null"`
	ConfigContent []byte `json:"config_content"`
	ConnectSecret string `json:"connect_secret" gorm:"not null"`
	Stopped       bool   `json:"stopped"`
	Comment       string `json:"comment"`
	CreatedAt     time.Time
	UpdatedAt     time.Time
	DeletedAt     gorm.DeletedAt `gorm:"index"`
}

func (*ClientEntity) GetConfigContent

func (c *ClientEntity) GetConfigContent() (*v1.ClientConfig, error)

func (*ClientEntity) SetConfigContent

func (c *ClientEntity) SetConfigContent(cfg v1.ClientConfig) error

type DBManager

type DBManager interface {
	GetDB(dbType string) *gorm.DB
	GetDefaultDB() *gorm.DB
	SetDB(dbType string, db *gorm.DB)
	RemoveDB(dbType string)
	Init()
}

func GetDBManager

func GetDBManager() DBManager

type Server

type Server struct {
	*ServerEntity
}

func (*Server) TableName

func (*Server) TableName() string

type ServerEntity

type ServerEntity struct {
	ServerID      string `json:"client_id" gorm:"uniqueIndex;not null;primaryKey"`
	TenantID      int    `json:"tenant_id" gorm:"not null"`
	UserID        int    `json:"user_id" gorm:"not null"`
	ServerIP      string `json:"server_ip"`
	ConfigContent []byte `json:"config_content"`
	ConnectSecret string `json:"connect_secret" gorm:"not null"`
	Comment       string `json:"comment"`
	CreatedAt     time.Time
	UpdatedAt     time.Time
	DeletedAt     gorm.DeletedAt `gorm:"index"`
}

func (*ServerEntity) GetConfigContent

func (s *ServerEntity) GetConfigContent() (*v1.ServerConfig, error)

func (*ServerEntity) SetConfigContent

func (s *ServerEntity) SetConfigContent(cfg *v1.ServerConfig) error

type User

type User struct {
	*UserEntity
}

func (*User) TableName

func (u *User) TableName() string

type UserEntity

type UserEntity struct {
	UserID    int    `json:"user_id" gorm:"primaryKey"`
	UserName  string `json:"user_name" gorm:"uniqueIndex;not null"`
	Password  string `json:"password"`
	Email     string `json:"email" gorm:"uniqueIndex;not null"`
	Status    int    `json:"status"`
	Role      string `json:"role"`
	TenantID  int    `json:"tenant_id"`
	Token     string `json:"token"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func (*UserEntity) GetEmail

func (u *UserEntity) GetEmail() string

func (*UserEntity) GetHashedPassword

func (u *UserEntity) GetHashedPassword() string

func (*UserEntity) GetRole

func (u *UserEntity) GetRole() string

func (*UserEntity) GetSafeUserInfo

func (u *UserEntity) GetSafeUserInfo() UserEntity

func (*UserEntity) GetStatus

func (u *UserEntity) GetStatus() int

func (*UserEntity) GetTenantID

func (u *UserEntity) GetTenantID() int

func (*UserEntity) GetToken

func (u *UserEntity) GetToken() string

func (*UserEntity) GetUserID

func (u *UserEntity) GetUserID() int

func (*UserEntity) GetUserIDStr

func (u *UserEntity) GetUserIDStr() string

func (*UserEntity) GetUserName

func (u *UserEntity) GetUserName() string

func (*UserEntity) IsAdmin

func (u *UserEntity) IsAdmin() bool

func (*UserEntity) Valid

func (u *UserEntity) Valid() bool

type UserInfo

type UserInfo interface {
	GetUserID() int
	GetUserIDStr() string
	GetUserName() string
	GetEmail() string
	GetHashedPassword() string
	GetStatus() int
	GetRole() string
	GetToken() string
	GetTenantID() int
	GetSafeUserInfo() UserEntity
	IsAdmin() bool
	Valid() bool
}

Jump to

Keyboard shortcuts

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