models

package
v0.0.0-...-7de1f39 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Inactive   = 0 // sign up but has not been activated
	Normal     = 1 //
	Restricted = 2 // login is permitted, but can only receive read-only message
	Banned     = 3 // can't login
)

Define user's status

View Source
const (
	Unknown = 0
	Male    = 1
	Female  = 2
)

Gender

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(id int64, old string, new string) error

Types

type Authority

type Authority struct {
	BasicModel `xorm:"extends"`
	Role       string
	User       []User `xorm:"extends"`
}

type BasicModel

type BasicModel struct {
	Id       int64    `json:"id"`
	CreateAt JsonTime `json:"-"    xorm:"created"`
	UpdateAt JsonTime `json:"-"    xorm:"updated"`
}

type JsonTime

type JsonTime time.Time

func Now

func Now() JsonTime

func (JsonTime) MarshalJSON

func (j JsonTime) MarshalJSON() ([]byte, error)

func (*JsonTime) UnmarshalJSON

func (j *JsonTime) UnmarshalJSON(data []byte) error

type User

type User struct {
	BasicModel  `xorm:"extends"`
	Username    string      `json:"username"`
	Password    string      `json:"password,omitempty"`
	Avatar      []byte      `json:"avatar,omitempty" xorm:"-"`
	Age         int         `json:"age,omitempty"`
	Gender      int         `json:"gender,omitempty"`
	Address     string      `json:"address,omitempty"`
	Description string      `json:"description,omitempty"`
	Email       *string     `json:"email,omitempty"`
	Cellphone   *string     `json:"cellphone,omitempty"`
	Auth        []Authority `json:"-" xorm:"extends"`
	Status      int         `json:"-"`
	LastLogin   JsonTime    `json:"-"`
	LastModify  JsonTime    `json:"-"`
}

func (*User) ActivateUser

func (u *User) ActivateUser() error

func (*User) AddUser

func (u *User) AddUser() error

AddUser will add a new user. Users can sign up by email address or cellphone number.

func (*User) BanUser

func (u *User) BanUser() error

func (*User) ChangeCellphone

func (u *User) ChangeCellphone() error

func (*User) ChangeEmail

func (u *User) ChangeEmail() error

func (*User) GetUser

func (u *User) GetUser(id int64) error

GetUser provides user's information. Note that password, email address and cellphone number won't return.

func (*User) Login

func (u *User) Login() error

Login compares password provided by user and password stored in database. If user logs in successfully, login time will be recorded.

func (*User) RestrictUser

func (u *User) RestrictUser() error

func (*User) TableName

func (u *User) TableName() string

TableName specifies the table name of struct User

func (*User) UpdateUserProfile

func (u *User) UpdateUserProfile(id int64) error

UpdateUserProfile will update user's profile.

Jump to

Keyboard shortcuts

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