nbum

package
v0.0.0-...-2c5cb3b Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SessionKeyUser             = "user"
	SessionKeyWXResAccessToken = "wxResAccessToken"
	SessionKeyVerifyCode       = "verifyCode"
)
View Source
const (
	HeaderUserType = "Nb-User-Type"
	HeaderNBSign   = "Nb-Sign"
)
View Source
const (
	NBSignTypeMd5Sign    = "md5sign"
	SignParamTS          = "ts"
	SignParamUserId      = "userId"
	SignParamSign        = "sign"
	SignParamRequestBody = "requestbody"
	SignParamSecretKey   = "_secretKey_"

	CtxInputDataKeyUser = "user"
)
View Source
const (
	UserTypeWX     = "wechat"
	UserTypeEmail  = "email"
	UserTypeUnkown = "unkown"
)
View Source
const (
	AuthLoginWXCallbackURI             = "/api/u/login/wxcb"
	AuthLoginWXCallbackSuccKey         = "succcb"
	AuthLoginWXCallbackPlaceholdOnSucc = "SUCC_REDIRECT"
	AuthLoginWXCallbackErrKey          = "errcb"
	AuthLoginWXCallbackPlaceholdOnErr  = "ERR_REDIRECT"
)
View Source
const (
	ErrCodeBadRequest   = 400
	ErrCodeNotLogin     = 401
	ErrCodeGeneralError = 507
	ErrCodeUnkownError  = 599
)

Variables

View Source
var (
	ErrGeneralServerError = errors.New("service error, please try again")
	ErrUnkownError        = errors.New("got unkown error, please concat admin")
)

Functions

func DBInit

func DBInit(dbAlias, dbTablePrefix string)

func GetUserIdByExternalId

func GetUserIdByExternalId(exType, exID, exPassword string) (userId int64, err error)

func GetUserLoginTypesByUserId

func GetUserLoginTypesByUserId(userId int64) (ret map[string]*UserLoginTypes, err error)

func InitWechatConfig

func InitWechatConfig()

func RegisterModel

func RegisterModel()

Types

type User

type User struct {
	Id         int64                      `json:"id"`
	Name       string                     `json:"name"`
	Sex        int32                      `json:"sex"` //1 男性; 2 女性; 0 未知
	Province   string                     `json:"province"`
	City       string                     `json:"city"`
	Country    string                     `json:"country"`
	HeadImgURL string                     `json:"headimgurl" orm:"column(headimgurl)"`
	Created    time.Time                  `json:"created" orm:"auto_now_add;type(datetime)"`
	Updated    time.Time                  `json:"updated" orm:"auto_now;type(datetime)"`
	UserTypes  map[string]*UserLoginTypes `json:"userTypes" orm:"-"`
}

func GetUserById

func GetUserById(userId int64) (u *User, err error)

func (*User) CreateNew

func (self *User) CreateNew(o ...orm.Ormer) error

func (*User) TableEngine

func (self *User) TableEngine() string

设置引擎为 INNODB

type UserLoginTypes

type UserLoginTypes struct {
	Id         int64
	UserId     int64  `json:"userId"`
	ExType     string `json:"extype"`
	ExId       string `json:"exid"`
	ExPassword string `json:"null"`
}

func (*UserLoginTypes) CreateNew

func (self *UserLoginTypes) CreateNew(o ...orm.Ormer) error

func (*UserLoginTypes) TableEngine

func (self *UserLoginTypes) TableEngine() string

设置引擎为 INNODB

func (*UserLoginTypes) TableUnique

func (self *UserLoginTypes) TableUnique() [][]string

多字段唯一键

type UserSignAuth

type UserSignAuth struct {
	Id        int64     `json:"id"`
	UserId    int64     `json:"userId" orm:"unique"`
	SecretKey string    `json:"secretKey"`
	Created   time.Time `json:"created" orm:"auto_now_add;type(datetime)"`
	Updated   time.Time `json:"updated" orm:"auto_now;type(datetime)"`
}

func GetUserSignByUserId

func GetUserSignByUserId(userId int64) (usa *UserSignAuth, err error)

func (*UserSignAuth) Auth

func (self *UserSignAuth) Auth(params map[string]string, rawSign string) (*User, error)

func (*UserSignAuth) Sign

func (self *UserSignAuth) Sign(params map[string]string) string

type VerifyCode

type VerifyCode struct {
	Code    string
	Created time.Time
}

func (*VerifyCode) GenerateNew

func (self *VerifyCode) GenerateNew()

func (*VerifyCode) NotifyBody

func (self *VerifyCode) NotifyBody() string

func (*VerifyCode) NotifyTitle

func (self *VerifyCode) NotifyTitle() string

func (*VerifyCode) Verify

func (self *VerifyCode) Verify(code string) bool

type WX

type WX struct {
	Wechat *wechat.Wechat
	// contains filtered or unexported fields
}

WX 微信 lib

## wechat config example wxRedisHost = 127.0.0.1:6379 wxAppID = wx62e37b113489e3d4 wxAppSecret = 32075673ab541e977ba3176f56fcdac5 wxToken = w77Y96KxdQ69AU8sVN97BCXLvRwx7sjt wxEncodingAESKey = Nybu6rYRWFVgAptXeKAh3TX3JvgFMheZnexxN68kxtsxamTMsvF7GDE7E89FPmG8

var DefaultWX *WX

func (*WX) Init

func (self *WX) Init()

Jump to

Keyboard shortcuts

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