mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-04 09:09:02 +08:00
Merge branch 'errcode' of github.com:OpenIMSDK/Open-IM-Server into errcode
This commit is contained in:
commit
23c704e93b
@ -24,7 +24,7 @@ type userServer struct {
|
||||
controller.UserDatabase
|
||||
notification *notification.Check
|
||||
userCheck *check.UserCheck
|
||||
ConversationChecker *check.ConversationChecker
|
||||
conversationChecker *check.ConversationChecker
|
||||
RegisterCenter registry.SvcDiscoveryRegistry
|
||||
friendCheck *check.FriendChecker
|
||||
}
|
||||
@ -45,10 +45,12 @@ func Start(client registry.SvcDiscoveryRegistry, server *grpc.Server) error {
|
||||
users = append(users, &tablerelation.UserModel{UserID: v, Nickname: config.Config.Manager.Nickname[k]})
|
||||
}
|
||||
u := &userServer{
|
||||
UserDatabase: controller.NewUserDatabase(relation.NewUserGorm(db)),
|
||||
notification: notification.NewCheck(client),
|
||||
userCheck: check.NewUserCheck(client),
|
||||
RegisterCenter: client,
|
||||
UserDatabase: controller.NewUserDatabase(relation.NewUserGorm(db)),
|
||||
notification: notification.NewCheck(client),
|
||||
userCheck: check.NewUserCheck(client),
|
||||
friendCheck: check.NewFriendChecker(client),
|
||||
conversationChecker: check.NewConversationChecker(client),
|
||||
RegisterCenter: client,
|
||||
}
|
||||
pbuser.RegisterUserServer(server, u)
|
||||
return u.UserDatabase.InitOnce(context.Background(), users)
|
||||
@ -79,7 +81,7 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbuser.UpdateUserI
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = s.Update(ctx, []*tablerelation.UserModel{user})
|
||||
err = s.Update(ctx, user)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ type UserDatabase interface {
|
||||
//插入多条 外部保证userID 不重复 且在db中不存在
|
||||
Create(ctx context.Context, users []*relation.UserModel) (err error)
|
||||
//更新(非零值) 外部保证userID存在
|
||||
Update(ctx context.Context, users []*relation.UserModel) (err error)
|
||||
Update(ctx context.Context, user *relation.UserModel) (err error)
|
||||
//更新(零值) 外部保证userID存在
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
//如果没找到,不返回错误
|
||||
@ -75,8 +75,8 @@ func (u *userDatabase) Create(ctx context.Context, users []*relation.UserModel)
|
||||
}
|
||||
|
||||
// 更新(非零值) 外部保证userID存在
|
||||
func (u *userDatabase) Update(ctx context.Context, users []*relation.UserModel) (err error) {
|
||||
return u.userDB.Update(ctx, users)
|
||||
func (u *userDatabase) Update(ctx context.Context, user *relation.UserModel) (err error) {
|
||||
return u.userDB.Update(ctx, user)
|
||||
}
|
||||
|
||||
// 更新(零值) 外部保证userID存在
|
||||
|
@ -26,8 +26,8 @@ func (u *UserGorm) UpdateByMap(ctx context.Context, userID string, args map[stri
|
||||
}
|
||||
|
||||
// 更新多个用户信息 非零值
|
||||
func (u *UserGorm) Update(ctx context.Context, users []*relation.UserModel) (err error) {
|
||||
return utils.Wrap(u.db(ctx).Updates(&users).Error, "")
|
||||
func (u *UserGorm) Update(ctx context.Context, user *relation.UserModel) (err error) {
|
||||
return utils.Wrap(u.db(ctx).Model(user).Updates(user).Error, "")
|
||||
}
|
||||
|
||||
// 获取指定用户信息 不存在,也不返回错误
|
||||
|
@ -31,7 +31,7 @@ func (UserModel) TableName() string {
|
||||
type UserModelInterface interface {
|
||||
Create(ctx context.Context, users []*UserModel) (err error)
|
||||
UpdateByMap(ctx context.Context, userID string, args map[string]interface{}) (err error)
|
||||
Update(ctx context.Context, users []*UserModel) (err error)
|
||||
Update(ctx context.Context, user *UserModel) (err error)
|
||||
// 获取指定用户信息 不存在,也不返回错误
|
||||
Find(ctx context.Context, userIDs []string) (users []*UserModel, err error)
|
||||
// 获取某个用户信息 不存在,则返回错误
|
||||
|
@ -29,7 +29,9 @@ func rpcServerInterceptor(ctx context.Context, req interface{}, info *grpc.Unary
|
||||
var operationID string
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.ZError(ctx, "rpc panic", nil, "FullMethod", info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r, string(debug.Stack()))
|
||||
log.ZError(ctx, "rpc panic", nil, "FullMethod", info.FullMethod, "type:", fmt.Sprintf("%T", r), "panic:", r)
|
||||
fmt.Println("stack info:", string(debug.Stack()))
|
||||
err = errs.ErrInternalServer
|
||||
}
|
||||
}()
|
||||
funcName := info.FullMethod
|
||||
|
Loading…
x
Reference in New Issue
Block a user