database

package
v0.0.0-...-afc335f Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Database *gorm.DB

Functions

func CloseConnection

func CloseConnection()

func CreateConnection

func CreateConnection()

func CreateTable

func CreateTable()

func EncryptPassword

func EncryptPassword(passwd string) string

Types

type User

type User struct {
	Id        int64
	Username  string `gorm:"unique;not null"`
	Password  string `gorm:"not null"`
	Email     string `gorm:"unique;not null"`
	Role      int
	Level     int
	CreatedAt time.Time
}

func GetUserByEmail

func GetUserByEmail(email string) *User

func GetUserById

func GetUserById(id int) *User

func GetUserByUsername

func GetUserByUsername(username string) *User

func Login

func Login(email, password string) (*User, error)

func NewUser

func NewUser(username, password, email string, role, level int) *User

func (*User) Delete

func (this *User) Delete()

func (*User) EncryptPassword

func (this *User) EncryptPassword()

func (*User) Save

func (this *User) Save() (bool, error)

func (*User) Valid

func (this *User) Valid() error

type Users

type Users []User

func GetUsers

func GetUsers() Users

Jump to

Keyboard shortcuts

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