This commit is contained in:
liwei1dao 2022-10-27 14:19:41 +08:00
commit fec69e818d
3 changed files with 64 additions and 11 deletions

View File

@ -6,6 +6,8 @@ import (
"go_dreamfactory/utils"
"google.golang.org/protobuf/proto"
cfg "go_dreamfactory/sys/configure/structs"
)
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{
List: userList,
}

View File

@ -81,7 +81,18 @@ func (this *ModelUser) GetUser(uid string) (user *pb.DBUser) {
//设置属性
func (this *ModelUser) updateUserAttr(uid string, data map[string]interface{}) error {
return this.Change(uid, data)
if this.module.IsCross() {
if model, err := this.module.GetDBNoduleByUid(uid, this.TableName, this.Expired); err != nil {
this.module.Errorln(err)
} else {
if err = model.Change(uid, data); err != nil {
this.module.Errorf("err:%v", err)
}
}
} else {
return this.Change(uid, data)
}
return nil
}
//是否今天首次登录

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) {
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 {
return
}
@ -206,15 +218,35 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
return
}
user := this.GetUser(session.GetUserId())
if user == nil {
code = pb.ErrorCode_UserSessionNobeing
return
uid := session.GetUserId()
var (
user *pb.DBUser
userEx *pb.DBUserExpand
err error
)
if this.IsCross() {
user, err = this.GetRmoteUser(uid)
if err != nil {
code = pb.ErrorCode_UserSessionNobeing
return
}
userEx, err = this.GetUserExpand(uid)
if err != nil {
code = pb.ErrorCode_UserExpandNull
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 userEx == nil || err != nil {
code = pb.ErrorCode_UserExpandNull
if user == nil {
code = pb.ErrorCode_UserSessionNobeing
return
}
@ -275,12 +307,12 @@ func (this *User) change(session comm.IUserSession, attr string, add int32) (cha
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)
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)
code = pb.ErrorCode_DBError
}