Files
open-im-server/pkg/common/db/table/relation/user.go
T

55 lines
1.7 KiB
Go
Raw Normal View History

2023-02-03 12:16:48 +08:00
package relation
2023-02-21 12:59:44 +08:00
import (
"context"
"time"
)
2023-02-03 12:16:48 +08:00
const (
UserModelTableName = "users"
)
type UserModel struct {
2023-04-17 11:57:38 +08:00
UserID string `gorm:"column:user_id;primary_key;size:64"`
Nickname string `gorm:"column:name;size:255"`
FaceURL string `gorm:"column:face_url;size:255"`
2023-02-03 12:16:48 +08:00
Ex string `gorm:"column:ex;size:1024"`
2023-02-07 20:28:34 +08:00
CreateTime time.Time `gorm:"column:create_time;index:create_time; autoCreateTime"`
2023-02-21 16:48:10 +08:00
AppMangerLevel int32 `gorm:"column:app_manger_level;default:18"`
2023-02-03 12:16:48 +08:00
GlobalRecvMsgOpt int32 `gorm:"column:global_recv_msg_opt"`
}
2023-04-23 14:21:36 +08:00
func (u *UserModel) GetNickname() string {
2023-04-24 19:45:29 +08:00
return u.Nickname
2023-04-23 14:21:36 +08:00
}
func (u *UserModel) GetFaceURL() string {
return u.FaceURL
}
func (u *UserModel) GetUserID() string {
return u.UserID
}
func (u *UserModel) GetEx() string {
return u.Ex
}
2023-02-03 12:16:48 +08:00
func (UserModel) TableName() string {
2023-02-21 12:59:44 +08:00
return UserModelTableName
2023-02-03 12:16:48 +08:00
}
type UserModelInterface interface {
2023-02-21 12:59:44 +08:00
Create(ctx context.Context, users []*UserModel) (err error)
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
2023-03-16 12:07:21 +08:00
Update(ctx context.Context, user *UserModel) (err error)
2023-02-21 12:59:44 +08:00
// 获取指定用户信息 不存在,也不返回错误
Find(ctx context.Context, userIDs []string) (users []*UserModel, err error)
// 获取某个用户信息 不存在,则返回错误
Take(ctx context.Context, userID string) (user *UserModel, err error)
// 获取用户信息 不存在,不返回错误
Page(ctx context.Context, pageNumber, showNumber int32) (users []*UserModel, count int64, err error)
2023-03-10 11:42:06 +08:00
GetAllUserID(ctx context.Context) (userIDs []string, err error)
2023-03-23 19:02:20 +08:00
GetUserGlobalRecvMsgOpt(ctx context.Context, userID string) (opt int, err error)
2023-02-03 12:16:48 +08:00
}