Documentation ¶
Index ¶
- Constants
- Variables
- func SavePicture(base64Str string, pathPrefix string, id uint32) (string, error)
- type User
- type UserServiceProvider
- func (this *UserServiceProvider) AddPhone(conn orm.Connection, id uint32, phone string) error
- func (this *UserServiceProvider) ChangeAvatar(conn orm.Connection, userID uint32, avatar string) error
- func (this *UserServiceProvider) ChangeInfo(conn orm.Connection, id uint32, userName string, sex uint8) error
- func (this *UserServiceProvider) ChangePassword(conn orm.Connection, id uint32, oldPass, newPass string) (err error)
- func (this *UserServiceProvider) GetUserByID(conn orm.Connection, userID uint32) (*User, error)
- func (this *UserServiceProvider) PhoneLogin(conn orm.Connection, phone, password string) (*User, error)
- func (this *UserServiceProvider) PhoneRegister(conn orm.Connection, userName, phone, password string) error
- func (this *UserServiceProvider) WeChatLogin(conn orm.Connection, UnionID, name, avatar string) (*User, error)
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 ¶
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
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
Click to show internal directories.
Click to hide internal directories.