models

package
Version: v0.0.0-...-4415030 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseInstance

type DatabaseInstance struct {
}

DatabaseInstance is a singleton pattern database instance.

type Puzzle

type Puzzle struct {
	PID         uint32    `gorm:"column:pid;primary_key" json:"pid"`
	Type        uint8     `gorm:"column:type" json:"type"`
	Content     string    `gorm:"column:content" json:"content"`
	Descriptor  string    `gorm:"column:descriptor" json:"descriptor"`
	Level       uint8     `gorm:"column:level" json:"level"`
	Submited    uint32    `gorm:"column:submited" json:"submited"`
	Passed      uint32    `gorm:"column:passed" json:"passed"`
	CreatedTime time.Time `gorm:"column:created_time" json:"created_time"`
}

Puzzle model

func (*Puzzle) AddPuzzleByPID

func (p *Puzzle) AddPuzzleByPID(pid uint32) error

AddPuzzleByPID gets a puzzle by its PID

func (*Puzzle) GetPuzzleByPID

func (p *Puzzle) GetPuzzleByPID(pid uint32) error

GetPuzzleByPID gets a puzzle by its PID

func (*Puzzle) SavePuzzleByPID

func (p *Puzzle) SavePuzzleByPID(pid uint32) error

SavePuzzleByPID saves a puzzle's info if it already exists.

type User

type User struct {
	UID            uint32    `gorm:"column:uid;primary_key" json:"uid"`
	Type           uint8     `gorm:"column:type" json:"type"`
	Username       string    `gorm:"column:username" json:"username"`
	Authentication string    `gorm:"column:authentication" json:"-"`
	Score          uint32    `gorm:"column:score" json:"score"`
	Submited       uint32    `gorm:"column:submited" json:"submited"`
	Passed         uint32    `gorm:"column:passed" json:"passed"`
	CreatedTime    time.Time `gorm:"column:created_time" json:"created_time"`
}

User model

func (*User) CreateUser

func (u *User) CreateUser() error

CreateUser creates a new user if it doesn't exist.

func (*User) DeleteUserByUID

func (u *User) DeleteUserByUID(uid uint32) error

DeleteUserByUID deletes an user by its uid if it already exists.

func (*User) DeleteUserByUsername

func (u *User) DeleteUserByUsername(username string) error

DeleteUserByUsername deletes an user by its username if it already exists.

func (*User) GetUserByUID

func (u *User) GetUserByUID(uid uint32) error

GetUserByUID gets a user's info by its username.

func (*User) GetUserByUsername

func (u *User) GetUserByUsername(username string) error

GetUserByUsername gets a user's info by its username.

func (*User) SaveUserByUID

func (u *User) SaveUserByUID(uid uint32) error

SaveUserByUID saves an user's info if it already exists.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL