models

package
v0.0.0-...-ea0690e Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TYPE_ADMIN = 100
View Source
const TYPE_NORMAL = 0

Variables

This section is empty.

Functions

func GetDB

func GetDB() *gorm.DB

GetDB Get a db instance

func Login

func Login(email, password string) map[string]interface{}

Types

type Account

type Account struct {
	gorm.Model
	Email    string   `json:"email"`
	Password string   `json:"password"`
	Token    string   `json:"token" sql:"-"`
	Type     uint     `json:"type"`
	Profile  *Profile `json:"profile"`
}

a struct to rep user account

func GetUser

func GetUser(u uint) *Account

func (*Account) Create

func (account *Account) Create() map[string]interface{}

func (*Account) Validate

func (account *Account) Validate() (map[string]interface{}, bool)

validate imcoming user details

type Profile

type Profile struct {
	gorm.Model
	NickName  string `json:"nickname"`
	AvatarUrl string `json:"avatarurl"`
	Age       uint   `json:"age"`
	AccountId uint
}

Profile

type Token

type Token struct {
	UserId uint
	jwt.StandardClaims
}

JWT claims struct

Jump to

Keyboard shortcuts

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