资源跨服

This commit is contained in:
wh_zcy 2022-10-27 11:35:57 +08:00
parent 67b74f7249
commit 8891d07d71
2 changed files with 47 additions and 10 deletions

View File

@ -6,6 +6,8 @@ import (
"go_dreamfactory/utils" "go_dreamfactory/utils"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
cfg "go_dreamfactory/sys/configure/structs"
) )
func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendRandlistReq) (code pb.ErrorCode) { func (this *apiComp) RandlistCheck(session comm.IUserSession, req *pb.FriendRandlistReq) (code pb.ErrorCode) {
@ -87,6 +89,14 @@ func (this *apiComp) Randlist(session comm.IUserSession, req *pb.FriendRandlistR
} }
this.moduleFriend.DispenseRes(session, []*cfg.Gameatn{
{
A: "attr",
T: "gold",
N: 10,
},
}, true)
rsp := &pb.FriendRandlistResp{ rsp := &pb.FriendRandlistResp{
List: userList, List: userList,
} }

View File

@ -183,7 +183,19 @@ func (this *User) SearchRmoteUser(nickname string) ([]*pb.DBUser, error) {
//查询用户属性值 例如 金币 经验 //查询用户属性值 例如 金币 经验
func (this *User) QueryAttributeValue(uid string, attr string) (value int64) { func (this *User) QueryAttributeValue(uid string, attr string) (value int64) {
user := this.modelUser.GetUser(uid) var (
user *pb.DBUser
err error
)
if this.IsCross() {
user, err = this.GetRmoteUser(uid)
if err != nil {
return
}
} else {
user = this.modelUser.GetUser(uid)
}
if user == nil { if user == nil {
return return
} }
@ -206,15 +218,30 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
return return
} }
user := this.GetUser(session.GetUserId()) uid := session.GetUserId()
if user == nil { var (
code = pb.ErrorCode_UserSessionNobeing user *pb.DBUser
return userEx *pb.DBUserExpand
err error
)
if this.IsCross() {
user, err = this.GetRmoteUser(uid)
if err != nil {
code = pb.ErrorCode_UserSessionNobeing
return
}
} else {
user = this.GetUser(uid)
userEx, err = this.GetUserExpand(uid)
if err != nil {
code = pb.ErrorCode_UserExpandNull
return
}
} }
userEx, err := this.GetUserExpand(session.GetUserId()) if user == nil {
if userEx == nil || err != nil { code = pb.ErrorCode_UserSessionNobeing
code = pb.ErrorCode_UserExpandNull
return return
} }
@ -275,12 +302,12 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
comm.ResFriend: change.Friend, comm.ResFriend: change.Friend,
} }
if err := this.modelUser.updateUserAttr(session.GetUserId(), update); err != nil { if err := this.modelUser.updateUserAttr(uid, update); err != nil {
this.Errorf("AddAttributeValue err:%v", err) this.Errorf("AddAttributeValue err:%v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
} }
if err := this.modelExpand.ChangeUserExpand(session.GetUserId(), updateEx); err != nil { if err := this.modelExpand.ChangeUserExpand(uid, updateEx); err != nil {
this.Errorf("AddAttributeValue ex err:%v", err) this.Errorf("AddAttributeValue ex err:%v", err)
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
} }