model

package
v0.0.0-...-7577ca9 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 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 {
	UserId   int    `json:"userId"`
	UserPwd  string `json:"userPwd"`
	UserName string `json:"userName"`
}

定义一个用户的结构体,用来接收redis中的用户数据信息 为了序列化和反序列化成功, 结构体字段对应的tag名字 应和 redis的user的key中对应的名字保持一致

type UserDao

type UserDao struct {
	// contains filtered or unexported fields
}

定义一个UserDao结构体, 用来操作User结构体

var MyUserDao *UserDao

定义一个全局的UserDao创建之后, 就可以在很多地方使用

func NewUserDao

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

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

func (*UserDao) GetUserById

func (this *UserDao) GetUserById(conn redis.Conn, userId int) (user *User, err error)

用户登录时, 根据用户的userId在redis-users中查询 返回一个User实例+err

func (*UserDao) Login

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

用户登录时, 根据用户的userId在redis-users中查询

func (*UserDao) Register

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

用户注册时, 根据用户的userId把数据插入redis-users中

Jump to

Keyboard shortcuts

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