上传月之秘境代码

This commit is contained in:
liwei1dao 2022-10-12 17:17:17 +08:00
parent c53a6c294e
commit a2858fda57
4 changed files with 18 additions and 8 deletions

View File

@ -7,10 +7,12 @@ import (
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
"time"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
@ -307,6 +309,15 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
return
}
//跨服对象获取数据操作对象
func (this *ModuleBase) GetDBNodule(session comm.IUserSession, tableName string, expired time.Duration) *db.DBModel {
if session.GetServiecTag() == this.service.GetTag() {
return db.NewDBModel(tableName, expired, db.Local())
} else {
return db.NewDBModel(tableName, expired, db.ServerDBConn(session.GetServiecTag()))
}
}
//日志接口
func (this *ModuleBase) Debug(msg string, args ...log.Field) {
this.options.GetLog().Debug(msg, args...)

View File

@ -30,6 +30,7 @@ func (this *apiComp) Ask(session comm.IUserSession, req *pb.MoonfantasyAskReq) (
if cd = this.AskCheck(session, req); cd != pb.ErrorCode_Success {
return
}
if mdata, err = this.module.modelDream.querymfantasy(req.Mid); err != nil {
cd = pb.ErrorCode_DBError
return

View File

@ -8,7 +8,6 @@ import (
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -128,19 +127,19 @@ func (this *modelDreamComp) trigger(session comm.IUserSession, source *pb.Battle
Content: mdata.Monster,
AppendStr: mdata.Id,
}
this.module.modelDream.noticeuserfriend(session.GetServiecTag(), session.GetUserId(), mdata.Id, chat)
this.module.modelDream.noticeuserfriend(session, mdata.Id, chat)
session.SendMsg(string(this.module.GetType()), "trigger", &pb.MoonfantasyTriggerResp{Issucc: true, Mid: mdata.Id, Monster: mdata.Monster})
return
}
///查询好友数据
func (this *modelDreamComp) noticeuserfriend(stag, uid, mid string, chat *pb.DBChat) (code pb.ErrorCode) {
func (this *modelDreamComp) noticeuserfriend(session comm.IUserSession, mid string, chat *pb.DBChat) (code pb.ErrorCode) {
var (
err error
)
model := db.NewDBModel(comm.TableFriend, 0, db.ServerDBConn(stag))
friend := &pb.DBFriend{Uid: uid, FriendIds: make([]string, 0)}
if err = model.Get(uid, friend); err != nil && err != mgo.MongodbNil {
model := this.module.GetDBNodule(session, comm.TableFriend, 0)
friend := &pb.DBFriend{Uid: session.GetUserId(), FriendIds: make([]string, 0)}
if err = model.Get(session.GetUserId(), friend); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err)
return
}
@ -154,7 +153,7 @@ func (this *modelDreamComp) noticeuserfriend(stag, uid, mid string, chat *pb.DBC
chat.Id = primitive.NewObjectID().Hex()
chat.Channel = pb.ChatChannel_World
// code = this.module.chat.SendWorldChat(stag, chat)
this.delaynoticeWorld(stag, mid, chat)
this.delaynoticeWorld(session.GetServiecTag(), mid, chat)
return
}

View File

@ -79,5 +79,4 @@ func (this *Moonfantasy) Trigger(session comm.IUserSession, source *pb.BattleRep
this.modelDream.trigger(session, source)
}
}
}