go-chat/user/user.go

27 lines
411 B
Go
Raw Normal View History

2021-04-22 06:12:35 +00:00
package user
2021-04-28 08:16:18 +00:00
import (
"errors"
"fmt"
)
const Key = "go_chat_Users:%d"
2021-04-22 06:12:35 +00:00
type User struct {
2021-04-25 08:29:30 +00:00
Id int `json:"id"`
Name string `json:"name"`
Sex int8 `json:"sex"`
Password string `json:"password"`
2021-04-22 06:12:35 +00:00
}
2021-04-28 08:16:18 +00:00
func GetUserKey(id int) string {
return fmt.Sprintf(Key, id)
}
2021-04-22 06:12:35 +00:00
func (u *User) CheckPassword(p string) error {
if p != u.Password {
return errors.New("password error")
}
return nil
}