model

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

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

Go to latest
Published: Aug 25, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERROR_USER_NOTEXISTS = errors.New("用户不存在..")
	ERROR_USER_EXISTS    = errors.New("用户已经存在...")
	ERROR_USER_PWD       = errors.New("密码不正确")
)

根据业务逻辑需要,自定义一些错误.

Functions

This section is empty.

Types

type User

type User struct {
	//确定字段信息
	//为了序列化和反序列化成功,我们必须保证
	//用户信息的json字符串的key 和 结构体的字段对应的 tag 名字一致!!!
	UserId   int    `json:"userId"`
	UserPwd  string `json:"userPwd"`
	UserName string `json:"userName"`
}

type UserDao

type UserDao struct {
	// contains filtered or unexported fields
}
var (
	MyUserDao *UserDao
)

我们在服务器启动后,就初始化一个userDao实例, 把它做成全局的变量,在需要和redis操作时,就直接使用即可

func NewUserDao

func NewUserDao(pool *redis.Pool) (userDao *UserDao)

使用工厂模式,创建一个UserDao实例

func (*UserDao) Login

func (this *UserDao) Login(userId int, userPwd string) (user *User, err error)

完成登录的校验 Login 1. Login 完成对用户的验证 2. 如果用户的id和pwd都正确,则返回一个user实例 3. 如果用户的id或pwd有错误,则返回对应的错误信息

func (*UserDao) Register

func (this *UserDao) Register(user *message.User) (err error)

Jump to

Keyboard shortcuts

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