user

package
v0.0.0-...-eb64f0e Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// invalid sex
	NilSex = 0
	// WeChat
	WeChat = iota
	// Mobile
	Mobile
)

Variables

View Source
var (
	// UserService
	UserService = &UserServiceProvider{}

	// ErrInvalidPass
	ErrInvalidPass = errors.New("the password error.")
	// Mobile phone registration cannot add phone number.
	ErrAddPhone = errors.New("Mobile phone registration cannot add phone number.")
)

Functions

func SavePicture

func SavePicture(base64Str string, pathPrefix string, id uint32) (string, error)

Types

type User

type User struct {
	UserID    uint32    `gorm:"column:id;primary_key;auto_increment" json:"user_id"`
	UserName  string    `gorm:"column:username;type:varchar(128)" json:"user_name"`
	Avatar    string    `gorm:"column:avatar" json:"avatar"`
	Sex       uint8     `gorm:"column:sex" json:"sex"` // 1 -> male, 2 -> female
	Password  string    `gorm:"column:password;type:varchar(128)" json:"password"`
	Phone     string    `gorm:"type:varchar(16)" json:"phone"`
	Type      int       `gorm:"column:type"` // 0 -> Wechat, 1 -> Mobile
	UnionID   string    `gorm:"column:unionid;type:varchar(128)" json:"union_id"`
	Created   time.Time `gorm:"column:created"`
	LastLogin time.Time `gorm:"column:lastlogin"`
	IsAdmin   bool      `gorm:"column:isadmin;not null;default:0"`
	IsActive  bool      `gorm:"column:isactive;not null;default:1"`
}

User represents users information

func (User) TableName

func (u User) TableName() string

TableName

type UserServiceProvider

type UserServiceProvider struct{}

UserServiceProvider

func (*UserServiceProvider) AddPhone

func (this *UserServiceProvider) AddPhone(conn orm.Connection, id uint32, phone string) error

AddPhone wechat add a phone number

func (*UserServiceProvider) ChangeAvatar

func (this *UserServiceProvider) ChangeAvatar(conn orm.Connection, userID uint32, avatar string) error

ChangeAvatar change avatar

func (*UserServiceProvider) ChangeInfo

func (this *UserServiceProvider) ChangeInfo(conn orm.Connection, id uint32, userName string, sex uint8) error

ChangeInfo change user information

func (*UserServiceProvider) ChangePassword

func (this *UserServiceProvider) ChangePassword(conn orm.Connection, id uint32, oldPass, newPass string) (err error)

ChangePassword change password

func (*UserServiceProvider) GetUserByID

func (this *UserServiceProvider) GetUserByID(conn orm.Connection, userID uint32) (*User, error)

GetUserByID gets user's information by userId.

func (*UserServiceProvider) PhoneLogin

func (this *UserServiceProvider) PhoneLogin(conn orm.Connection, phone, password string) (*User, error)

PhoneLogin login by phone

func (*UserServiceProvider) PhoneRegister

func (this *UserServiceProvider) PhoneRegister(conn orm.Connection, userName, phone, password string) error

PhoneRegister register by phone

func (*UserServiceProvider) WeChatLogin

func (this *UserServiceProvider) WeChatLogin(conn orm.Connection, UnionID, name, avatar string) (*User, error)

WeChatLogin login by wechat

Jump to

Keyboard shortcuts

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