add global recv opt

pull/455/head
Gordon 2 years ago committed by Xinwei Xiong(cubxxw-openim)
parent e923cbd53e
commit 389ea2c726

@ -364,12 +364,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{

@ -86,16 +86,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