Documentation ¶
Index ¶
- func RecordActivity(message string, gameAccount *GameAccount, session *Session) bool
- type Activity
- type GameAccount
- func (gameAccount *GameAccount) Ban(doSave bool) *GameAccount
- func (gameAccount *GameAccount) Delete()
- func (gameAccount *GameAccount) RecordActivity(message string) bool
- func (gameAccount *GameAccount) SetLevel(level int, doSave bool) *GameAccount
- func (gameAccount *GameAccount) SetUser(user *User, doSave bool) *GameAccount
- func (gameAccount *GameAccount) Unban(doSave bool) *GameAccount
- func (gameAccount *GameAccount) Update() *GameAccount
- type Serial
- type Session
- type Setting
- type User
- func (user *User) AfterCreate(scope *gorm.Scope)
- func (user *User) Ban(doSave bool) *User
- func (user *User) CreateSession(userAgent string) (*Session, string, error)
- func (user *User) CreateSetting(name string) (*Setting, error)
- func (user *User) Delete()
- func (user *User) FindSetting(name string) (*Setting, error)
- func (user *User) IsBanned() bool
- func (user *User) IsGuest() bool
- func (user *User) IsHasSubscription() bool
- func (user *User) IsMember() bool
- func (user *User) IsOwner() bool
- func (user *User) IsSubscriber() bool
- func (user *User) RegisterGameAccount(uid int, level int) (*GameAccount, error)
- func (user *User) Subscribe(serialCode string) error
- func (user *User) Unban(newRole string, doSave bool) *User
- func (user *User) Update() *User
- func (user *User) ValidateSubscription() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordActivity ¶
func RecordActivity(message string, gameAccount *GameAccount, session *Session) bool
Types ¶
type Activity ¶
type GameAccount ¶
type GameAccount struct { gorm.Model UID int `gorm:"type:varchar(69);not null;unique;unique_index;primary_key"` Level int `gorm:"type:varchar(6);not null"` LastActive int User *User `gorm:"not null"` UserID int Banned bool Activities []*Activity `gorm:"many2many:game_activities;"` }
func FindGameAccount ¶
func FindGameAccount(uid int) (*GameAccount, error)
func RegisterGameAccount ¶
func RegisterGameAccount(user *User, uid int, level int) (*GameAccount, error)
func (*GameAccount) Ban ¶
func (gameAccount *GameAccount) Ban(doSave bool) *GameAccount
func (*GameAccount) Delete ¶
func (gameAccount *GameAccount) Delete()
func (*GameAccount) RecordActivity ¶
func (gameAccount *GameAccount) RecordActivity(message string) bool
func (*GameAccount) SetLevel ¶
func (gameAccount *GameAccount) SetLevel(level int, doSave bool) *GameAccount
func (*GameAccount) SetUser ¶
func (gameAccount *GameAccount) SetUser(user *User, doSave bool) *GameAccount
func (*GameAccount) Unban ¶
func (gameAccount *GameAccount) Unban(doSave bool) *GameAccount
func (*GameAccount) Update ¶
func (gameAccount *GameAccount) Update() *GameAccount
type Serial ¶
type Serial struct { gorm.Model Code string `gorm:"type:varchar(69);not null;unique;unique_index;primary_key"` ExpireAt int64 `gorm:"not null"` SubscriptionDuration int `gorm:"default:30;not null"` Used bool `gorm:"default:false;not null"` User *User UserID int }
func FindAndValidateSerial ¶
func FindSerial ¶
func GenerateSerial ¶
func ValidateSerial ¶
type Session ¶
type Session struct { gorm.Model SessionID string `gorm:"type:varchar(69);not null;unique;unique_index;primary_key"` LastActive int `gorm:"default:0;not null"` UserAgent string `gorm:"type:varchar(180);not null"` User *User `gorm:"not null"` UserID int Expired bool Activities []*Activity `gorm:"many2many:session_activities;"` GameAccounts []*GameAccount `gorm:"many2many:session_accounts;"` }
func FindAndValidateSession ¶
func FindSession ¶
func (*Session) RecordActivity ¶
type Setting ¶
type Setting struct { gorm.Model Name string `gorm:"type:varchar(16);not null"` User *User `gorm:"not null"` UserID int }
func (*Setting) UpdateName ¶
type User ¶
type User struct { gorm.Model Username string `gorm:"type:varchar(32);not null;unique;unique_index;primary_key"` Email string `gorm:"type:varchar(69);not null;unique;"` Password string `gorm:"not null"` Subscription int64 `gorm:"default:0"` Role string `gorm:"type:varchar(16);default:'Member';not null;"` GameAccounts []*GameAccount `gorm:"many2many:user_accounts;"` Settings []*Setting Sessions []*Session }
func RegisterUser ¶
func (*User) AfterCreate ¶
func (*User) CreateSession ¶
func (*User) IsHasSubscription ¶
func (*User) IsSubscriber ¶
func (*User) RegisterGameAccount ¶
func (user *User) RegisterGameAccount(uid int, level int) (*GameAccount, error)
func (*User) ValidateSubscription ¶
Click to show internal directories.
Click to hide internal directories.