models

package
v0.0.0-...-a39f7dd Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2016 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DB_UNIQUE_CONFLICT_TRY int = 3
View Source
const USERS_TABLE_NAME string = "users"
View Source
const VERIFICATIONS_TABLE_NAME string = "verifications"

Variables

This section is empty.

Functions

func CheckVerifyCode

func CheckVerifyCode(phone, code string) int

func CreateVerification

func CreateVerification(phone string) int

func UpdateUser

func UpdateUser(user *User) int

TODO return more detailed error number NOTE: this will do a fully update, so the user must be read from DB, and then update its field

func UserPhoneExists

func UserPhoneExists(phone *string) bool

Types

type User

type User struct {
	Id int64 `json:"-" orm:"pk;auto"`

	Uid    int64   `json:"uid" orm:"column(uid);unique"`
	Token  string  `json:"token,omitempty" orm:"column(token);unique;size(40)"`
	Phone  *string `json:"phone,omitempty" orm:"column(phone);null;unique;size(11)"`
	WeiXin *string `json:"-" orm:"column(weixin);null;unique;size(191)"`
	WeiBo  *string `json:"-" orm:"column(weibo);null;unique;size(191)"`
	QQ     *string `json:"-" orm:"column(qq);null;unique;size(191)"`

	Password string `json:"-" orm:"column(password);size(40)"`

	Nickname       string `json:"nickname,omitempty" orm:"column(nickname);size(12)"`
	QQNickName     string `json:"qq_nickname,omitempty" orm:"column(qq_nickname);size(127)"`
	WeiBoNickName  string `json:"weibo_nickname,omitempty" orm:"column(weibo_nickname);size(127)"`
	WeiXinNickName string `json:"weixin_nickname,omitempty" orm:"column(weixin_nickname);size(127)"`

	Gender int    `json:"gender" orm:"column(gender)"`
	Avatar string `json:"avatar,omitempty" orm:"column(avatar);size(191)"`

	CreateAt int64 `json:"create_at" orm:"column(create_at);unique"`
	UpdateAt int64 `json:"update_at" orm:"column(update_at);unique"`
}

func AuthWithQQ

func AuthWithQQ(openid, token, appId string) (*User, int)

func AuthWithWeiBo

func AuthWithWeiBo(token string) (*User, int)

func AuthWithWeiXin

func AuthWithWeiXin(openid, token string) (*User, int)

func CreateUserByPhone

func CreateUserByPhone(phone *string, secret string) (*User, int)

func GetUserByToken

func GetUserByToken(token string) (*User, int)

func GetUserByUid

func GetUserByUid(uid int64) (*User, int)

func VerifyUserByPhone

func VerifyUserByPhone(phone *string, secret string) (*User, int)

func (*User) TableName

func (u *User) TableName() string

type Verification

type Verification struct {
	Id     int64  `json:"-" orm:"pk;auto"`
	Phone  string `json:"phone" orm:"column(phone);unique;index;size(20)"`
	Code   string `json:"code" orm:"column(code);size(6)"`
	Expire int64  `json:"expire" orm:"column(expire)"`
}

func (*Verification) TableName

func (v *Verification) TableName() string

Jump to

Keyboard shortcuts

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