Merge branch 'superGroup' of github.com:OpenIMSDK/Open-IM-Server into superGroup

pull/236/head
wangchuxiao 2 years ago
commit 59743ef071

@ -391,12 +391,19 @@ func (s *userServer) UpdateUserInfo(ctx context.Context, req *pbUser.UpdateUserI
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetUserGlobalMsgRecvOpt failed ", err.Error(), user)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
err = imdb.UpdateUserInfoByMap(user, m)
if err != nil {
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), user)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
} else {
err := imdb.UpdateUserInfo(user)
if err != nil {
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), user)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
}
err := imdb.UpdateUserInfo(user, m)
if err != nil {
log.NewError(req.OperationID, "UpdateUserInfo failed ", err.Error(), user)
return &pbUser.UpdateUserInfoResp{CommonResp: &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}}, nil
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn)
newReq := &pbFriend.GetFriendListReq{

@ -96,16 +96,24 @@ func GetUserNameByUserID(userID string) (string, error) {
return user.Nickname, nil
}
func UpdateUserInfo(user db.User, m ...map[string]interface{}) error {
func UpdateUserInfo(user db.User) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
dbConn.LogMode(false)
err = dbConn.Table("users").Where("user_id=?", user.UserID).Update(&user).Error
if len(m) > 0 {
err = dbConn.Table("users").Where("user_id=?", user.UserID).Updates(m[0]).Error
return err
}
func UpdateUserInfoByMap(user db.User, m map[string]interface{}) error {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err
}
dbConn.LogMode(false)
err = dbConn.Table("users").Where("user_id=?", user.UserID).Updates(m).Error
return err
}

Loading…
Cancel
Save