token

package
v0.0.0-...-4e81a15 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2017 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TokenDB

type TokenDB struct {
	DB    *sqlx.DB
	Redis *redis.Redis
}

func (*TokenDB) GetByToken

func (db *TokenDB) GetByToken(token string) (int, error)

GetByToken 通过token查询用户id

查询错误的两种情况:
token不存或已失效返回 userID=0 err!=nil
token查询失败返回 userID=-1 err!=nil

func (*TokenDB) GetByTokenRedis

func (db *TokenDB) GetByTokenRedis(token string) (int, error)

GetByTokenRedis 通过token查询用户id

查询错误的两种情况:
token不存或已失效返回 userID=0 err!=nil
token查询失败返回 userID=-1 err!=nil

func (*TokenDB) Insert

func (db *TokenDB) Insert(userID int) (*UserToken, error)

Insert 获取用户token,每次创建一个新的token

func (*TokenDB) InsertRedis

func (db *TokenDB) InsertRedis(userID int) (*UserToken, error)

InsertRedis 获取用户token,每次创建一个新的token

type TokenTx

type TokenTx struct {
	Tx *sqlx.Tx
}

type UserToken

type UserToken struct {
	UserID   int       `json:"userID" db:"user_id"`     // 用户ID
	Token    string    `json:"token" db:"token"`        // token值
	ExpireAt time.Time `json:"expireAt" db:"expire_at"` // 过期时间
}

UserToken 用户token

Jump to

Keyboard shortcuts

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