add global recv opt

pull/236/head
Gordon 2 years ago
parent 5e51eebe8a
commit 7e6e214f08

@ -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) 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 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) etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImFriendName)
client := pbFriend.NewFriendClient(etcdConn) client := pbFriend.NewFriendClient(etcdConn)
newReq := &pbFriend.GetFriendListReq{ newReq := &pbFriend.GetFriendListReq{

@ -96,16 +96,24 @@ func GetUserNameByUserID(userID string) (string, error) {
return user.Nickname, nil 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() dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil { if err != nil {
return err return err
} }
dbConn.LogMode(false) dbConn.LogMode(false)
err = dbConn.Table("users").Where("user_id=?", user.UserID).Update(&user).Error 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 return err
} }

Loading…
Cancel
Save