model

package
v0.0.0-...-d9879d9 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERROR_USER_DOES_NOT_EXIST = errors.New("User does not exist!")
	ERROR_USER_PWD            = errors.New("Password is invalid!")

	// status code for register
	ERROR_USER_ALREADY_EXISTS     = errors.New("Username already exists!")
	ERROR_PASSWORD_DOES_NOT_MATCH = errors.New("Password does not match!")
)

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

View Source
var ClientConnsMap map[int]ConnInfo

Functions

This section is empty.

Types

type ClientConn

type ClientConn struct{}

func (ClientConn) Del

func (cc ClientConn) Del(userConn net.Conn)

func (ClientConn) Save

func (cc ClientConn) Save(userID int, name string, userConn net.Conn)

func (ClientConn) SearchByUserName

func (cc ClientConn) SearchByUserName(userName string) (connInfo net.Conn, err error)

type ConnInfo

type ConnInfo struct {
	Conn     net.Conn
	UserName string
}

type User

type User struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Password string `json:"password"`
}

type UserDao

type UserDao struct {
	// contains filtered or unexported fields
}
var CurrentUserDao *UserDao

UserDao 实例,全局唯一

func InitUserDao

func InitUserDao(pool *redis.Pool) (currentUserDao *UserDao)

初始化一个 UserDao 结构体示例,

func (*UserDao) GetUserByUserName

func (this *UserDao) GetUserByUserName(userName string) (user User, err error)

根据用户 username 获取用户信息 获取成功返回 user 信息,err nil 获取失败返回 err,user 为 nil

func (*UserDao) GetUsrById

func (this *UserDao) GetUsrById(id int) (user User, err error)

根据用户 id 获取用户信息 获取成功返回 user 信息,err nil 获取失败返回 err,user 为 nil

func (*UserDao) Login

func (this *UserDao) Login(userName, password string) (user User, err error)

func (*UserDao) Register

func (this *UserDao) Register(userName, password, passwordConfirm string) (user User, err error)

注册用户 用户名不能重复

Jump to

Keyboard shortcuts

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