diff --git a/cmd/robot/friend.go b/cmd/robot/friend.go index e201e6d3f..98ea5eafc 100644 --- a/cmd/robot/friend.go +++ b/cmd/robot/friend.go @@ -9,6 +9,8 @@ import ( func (r *Robot) handleFriendMsg(msg *pb.UserMessage) { switch msg.SubType { + case friend.Friend_SubType_List: + r.handleFriendList(msg) case friend.Friend_SubType_Apply: r.handleFriendApply(msg) case friend.Friend_SubType_ApplyList: @@ -32,7 +34,7 @@ func (r *Robot) handleFriendMsg(msg *pb.UserMessage) { func (r *Robot) FriendList() { req := &pb.Friend_List_Req{} head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_List} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -53,7 +55,7 @@ func (r *Robot) FriendSearch(nickName string) { NickName: nickName, } head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Search} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -74,7 +76,7 @@ func (r *Robot) FriendApply(friendId string) { FriendId: friendId, } head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -93,7 +95,7 @@ func (r *Robot) handleFriendApply(msg *pb.UserMessage) { func (r *Robot) FriendApplyList() { req := &pb.Friend_ApplyList_Req{} head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -114,7 +116,7 @@ func (r *Robot) FriendAgree(friendIds []string) { FriendIds: friendIds, } head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Agree} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -135,7 +137,7 @@ func (r *Robot) FriendRefuse(friendIds []string) { FriendIds: friendIds, } head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Refuse} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -154,7 +156,7 @@ func (r *Robot) handleFriendRefuse(msg *pb.UserMessage) { func (r *Robot) FriendBlacklist() { req := &pb.Friend_BlackList_Req{} head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Blacklist} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -170,10 +172,10 @@ func (r *Robot) handleFriendBlacklist(msg *pb.UserMessage) { } //添加黑名单 -func (r *Robot) FriendAddBlack() { - req := &pb.Friend_BlackAdd_Req{} +func (r *Robot) FriendAddBlack(friendId string) { + req := &pb.Friend_BlackAdd_Req{FriendId: friendId} head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_AddBlack} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) @@ -194,7 +196,7 @@ func (r *Robot) FriendDelBlack(friendId string) { FriendId: friendId, } head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_DelBlack} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) diff --git a/cmd/robot/pack.go b/cmd/robot/pack.go index 68d29cc89..7efe5fc5e 100644 --- a/cmd/robot/pack.go +++ b/cmd/robot/pack.go @@ -17,7 +17,7 @@ func (r *Robot) handlePackMsg(msg *pb.UserMessage) { func (r *Robot) QueryUserPack() { req := &pb.Pack_Getlist_Req{IType: 1} head := &pb.UserMessage{MainType: "pack", SubType: "queryuserpackreq"} - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index b185c9ee9..8164cee38 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -85,7 +85,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) { //在这里添加玩家成功登录以后的测试方法 func (r *Robot) onUserLoaded() { //user - r.CreateUser("乐谷6171") + // r.CreateUser("乐谷6171") //friend // r.FriendApply("1_62aa8f30d25fb8c1a7d90b50") @@ -94,8 +94,8 @@ func (r *Robot) onUserLoaded() { // r.FriendApplyList() // r.FriendList() // r.FriendBlacklist() - // r.FriendAddBlack() - // r.FriendDelBlack("") + // r.FriendAddBlack("0_62b01623e4c60c3db8bfe6da") + // r.FriendDelBlack("0_62b01623e4c60c3db8bfe6da") // r.FriendSearch("乐谷5") //pack @@ -104,6 +104,7 @@ func (r *Robot) onUserLoaded() { } func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error { + //模拟客户端 每次请求都会生成新的秘钥 msg.Sec = r.BuildSecStr() if comm.ProtoMarshal(rsp, msg) { data, _ := proto.Marshal(msg) @@ -160,7 +161,11 @@ func (r *Robot) AccountRegister(account string, sid int32) { //打印响应 func printReply(msg *pb.UserMessage, rsp interface{}) { - log.Printf("rsp [%s.%s] [%v]", msg.MainType, msg.SubType, rsp) + if m, ok := rsp.(*pb.ErrorNotify); ok { + log.Printf("rsp [%s.%s] [%v:%v]", msg.MainType, msg.SubType, int32(m.Code), m.Data) + } else { + log.Printf("rsp [%s.%s] [%v]", msg.MainType, msg.SubType, rsp) + } } //方法参数跟踪 diff --git a/cmd/robot/user.go b/cmd/robot/user.go index c19ef4c89..ecb22e444 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -45,7 +45,7 @@ func (r *Robot) CreateUser(NickName string) { SubType: user.User_SubType_Create, } - defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req) + defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req) err := r.SendToClient(head, req) if err != nil { log.Fatal(err) diff --git a/comm/core.go b/comm/core.go index fddbb0a6b..03abb8d1d 100644 --- a/comm/core.go +++ b/comm/core.go @@ -19,6 +19,7 @@ const ( const ( Service_Gateway = "gateway" Service_Worker = "worker" + Service_DB = "dbservice" ) //ERR diff --git a/modules/dbservice/db_comp.go b/modules/dbservice/db_comp.go index c2537fa76..8d91af130 100644 --- a/modules/dbservice/db_comp.go +++ b/modules/dbservice/db_comp.go @@ -165,6 +165,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { return } +// 写入日志数据 func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { _, err = this.DB.InsertOne(DB_ModelTable, data) @@ -173,3 +174,13 @@ func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { } return err } + +// 查询 当前日志列表还有没有处理完条数 +func (this *DB_Comp) Model_TotalCount() int { + + _data, err := this.DB.Find("model_log", bson.M{}) + if err == nil { + return _data.RemainingBatchLength() + } + return 0 +} diff --git a/modules/friend/api_addblack.go b/modules/friend/api_addblack.go index 7883d3fa3..326c9b948 100644 --- a/modules/friend/api_addblack.go +++ b/modules/friend/api_addblack.go @@ -12,8 +12,8 @@ func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_Bl err error blackNumMax = 50 //TODO 从配置中读取 ) - self := &pb.DB_FriendData{UserId: session.GetUserId()} - target := &pb.DB_FriendData{UserId: req.FriendId} + self := &pb.DB_FriendData{UId: session.GetUserId()} + target := &pb.DB_FriendData{UId: req.FriendId} err = this.module.model_friend.Get(session.GetUserId(), self) if self == nil || err != nil { @@ -29,12 +29,18 @@ func (this *ApiComp) Addblack_Check(session comm.IUserSession, req *pb.Friend_Bl //判断目标是否在好友列表里面 if _, ok := utils.Find(self.FriendIds, req.FriendId); ok { + code = comm.ErrorCode{Code: pb.ErrorCode_FriendYet} + return + } + + //判断目标是否已经在黑名单中 + if _, ok := utils.Find(self.BlackIds, req.FriendId); ok { code = comm.ErrorCode{Code: pb.ErrorCode_FriendSelfBlackYet} return } // 判断自己是否在对方的黑名单中 - if _, ok := utils.Find(target.BlackIds, self.UserId); ok { + if _, ok := utils.Find(target.BlackIds, self.UId); ok { code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetBlackYet} return } diff --git a/modules/friend/api_agree.go b/modules/friend/api_agree.go index 6a12927ae..1b812dc1d 100644 --- a/modules/friend/api_agree.go +++ b/modules/friend/api_agree.go @@ -9,7 +9,7 @@ import ( func (this *ApiComp) Agree_Check(session comm.IUserSession, req *pb.Friend_Agree_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var err error - self := &pb.DB_FriendData{UserId: session.GetUserId()} + self := &pb.DB_FriendData{UId: session.GetUserId()} //获取玩家自己好友数据 err = this.module.model_friend.Get(session.GetUserId(), self) @@ -76,11 +76,11 @@ func (this *ApiComp) Agree(session comm.IUserSession, chk map[string]interface{} code = pb.ErrorCode_FriendTargetNoData } - if _, ok := utils.Find(target.FriendIds, self.UserId); !ok { + if _, ok := utils.Find(target.FriendIds, self.UId); !ok { if target.FriendIds == nil { target.FriendIds = []string{} } - target.FriendIds = append(target.FriendIds, self.UserId) + target.FriendIds = append(target.FriendIds, self.UId) } err = this.module.model_friend.Change(target.UserId, map[string]interface{}{ "friendIds": target.FriendIds, diff --git a/modules/friend/api_apply.go b/modules/friend/api_apply.go index cb869363e..88e6f5580 100644 --- a/modules/friend/api_apply.go +++ b/modules/friend/api_apply.go @@ -10,8 +10,8 @@ import ( func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var err error - self := &pb.DB_FriendData{UserId: session.GetUserId()} - target := &pb.DB_FriendData{UserId: req.FriendId} + self := &pb.DB_FriendData{UId: session.GetUserId()} + target := &pb.DB_FriendData{UId: req.FriendId} //获取玩家自己好友数据 err = this.module.model_friend.Get(session.GetUserId(), self) @@ -56,7 +56,7 @@ func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply } //判断自己是否在目标用户的申请列表中 - if _, ok := utils.Find(target.ApplyIds, self.UserId); ok { + if _, ok := utils.Find(target.ApplyIds, self.UId); ok { code = comm.ErrorCode{Code: pb.ErrorCode_FriendApplyYet} return } @@ -68,7 +68,7 @@ func (this *ApiComp) Apply_Check(session comm.IUserSession, req *pb.Friend_Apply } //判断是否在对方的黑名单中 - if _, ok := utils.Find(target.BlackIds, self.UserId); ok { + if _, ok := utils.Find(target.BlackIds, self.UId); ok { code = comm.ErrorCode{Code: pb.ErrorCode_FriendTargetBlackYet} return } diff --git a/modules/friend/api_delblack.go b/modules/friend/api_delblack.go index 66ff0bc4a..4e341ce17 100644 --- a/modules/friend/api_delblack.go +++ b/modules/friend/api_delblack.go @@ -31,7 +31,7 @@ func (this *ApiComp) Delblack(session comm.IUserSession, chk map[string]interfac UserId: session.GetUserId(), } } - err := session.SendMsg(string(this.module.GetType()), Friend_SubType_AddBlack, rsp) + err := session.SendMsg(string(this.module.GetType()), Friend_SubType_DelBlack, rsp) if err != nil { code = pb.ErrorCode_SystemError return diff --git a/modules/friend/api_refuse.go b/modules/friend/api_refuse.go index c0a41ee19..03b0eec12 100644 --- a/modules/friend/api_refuse.go +++ b/modules/friend/api_refuse.go @@ -9,7 +9,7 @@ import ( func (this *ApiComp) Refuse_Check(session comm.IUserSession, req *pb.Friend_Refuse_Req) (chk map[string]interface{}, code comm.ErrorCode) { chk = make(map[string]interface{}) var err error - self := &pb.DB_FriendData{UserId: session.GetUserId()} + self := &pb.DB_FriendData{UId: session.GetUserId()} //获取玩家自己好友数据 err = this.module.model_friend.Get(session.GetUserId(), self) diff --git a/modules/friend/api_search.go b/modules/friend/api_search.go index d9ef64eb8..8e5a53828 100644 --- a/modules/friend/api_search.go +++ b/modules/friend/api_search.go @@ -31,7 +31,7 @@ func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{ user := this.module.model_friend.Frined_FindCond(req.NickName) if user != nil { friend = &pb.FriendBase{ - UserId: user.Uid, + UserId: user.UId, NickName: user.Name, } } diff --git a/modules/friend/model_friend.go b/modules/friend/model_friend.go index dfe997cfc..63e4e490d 100644 --- a/modules/friend/model_friend.go +++ b/modules/friend/model_friend.go @@ -27,9 +27,10 @@ func (this *ModelFriend) Init(service core.IService, module core.IModule, comp c } //好友 +// Deprecated func (this *ModelFriend) Friend_SaveOrUpdate(data *pb.DB_FriendData) (err error) { err = this.DB.FindOneAndUpdate(DB_FriendTable, - bson.M{"_id": data.UserId}, + bson.M{"_id": data.UId}, bson.M{"$set": bson.M{ "friendids": data.FriendIds, "applyids": data.ApplyIds}}, diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 7e1620da9..bb423bfd4 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -43,15 +43,15 @@ func newAgent(gateway IGateway, conn *websocket.Conn) *Agent { //用户代理 type Agent struct { - gateway IGateway - wsConn *websocket.Conn - sessionId string - uId string - wId string - writeChan chan *pb.UserMessage - closeSignal chan bool - state int32 //状态 0 关闭 1 运行 2 关闭中 - wg sync.WaitGroup + gateway IGateway + wsConn *websocket.Conn + sessionId string + uId string + wId string + writeChan chan *pb.UserMessage + closeSignal chan bool + state int32 //状态 0 关闭 1 运行 2 关闭中 + wg sync.WaitGroup } func (this *Agent) readLoop() { @@ -132,21 +132,23 @@ func (this *Agent) secAuth(msg *pb.UserMessage) error { //解码 func decodeUserData(msg *pb.UserMessage) error { - //只有login的时候才需要解码 + base64Str := msg.Sec + dec, err := base64.StdEncoding.DecodeString(base64Str[35:]) + if err != nil { + log.Errorf("base64 decode err %v", err) + return nil + } + now := time.Now().Unix() + jsonRet := gjson.Parse(string(dec)) + timestamp := jsonRet.Get("timestamp").Int() + //秘钥30秒失效 + if now-time.Unix(timestamp, 0).Unix() > 30 { + return fmt.Errorf("sec key expire") + } + + //只有login的时候才需要设置Data if msg.MainType == "user" && msg.SubType == "login" { - base64Str := msg.Sec - dec, err := base64.StdEncoding.DecodeString(base64Str[35:]) - if err != nil { - log.Errorf("base64 decode err %v", err) - return nil - } - now := time.Now().Unix() - jsonRet := gjson.Parse(string(dec)) serverId := jsonRet.Get("serverId").Int() - timestamp := jsonRet.Get("timestamp").Int() - if now-time.Unix(timestamp, 0).Unix() > 100 { - return nil - } account := jsonRet.Get("account").String() req := &pb.UserLoginReq{ Account: account, @@ -158,7 +160,6 @@ func decodeUserData(msg *pb.UserMessage) error { } msg.Data = ad } - return nil } @@ -218,7 +219,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) error { return err } if reply.Code != pb.ErrorCode_Success { - data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: reply.Code}) + data, _ := anypb.New(&pb.ErrorNotify{ReqMainType: msg.MainType, ReqSubType: msg.SubType, Code: pb.ErrorCode(reply.Code.Number())}) err := this.WriteMsg(&pb.UserMessage{ MainType: comm.MainType_Notify, SubType: comm.SubType_ErrorNotify, diff --git a/modules/mail/api_getAttachment.go b/modules/mail/api_getAttachment.go index d76a91677..d43df3b4e 100644 --- a/modules/mail/api_getAttachment.go +++ b/modules/mail/api_getAttachment.go @@ -35,7 +35,7 @@ func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[ for _, v := range _data { _items[int32(v.ItemId)] += int32(v.ItemCount) } - bRet := this.pack.AddItemsToUserPack(mail.UserId, _items) + bRet := this.pack.AddItemsToUserPack(mail.Uid, _items) if bRet != nil { // 修改状态 this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID) diff --git a/modules/mail/module.go b/modules/mail/module.go index 8b6d2a2bc..015ce5645 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -43,7 +43,7 @@ func (this *Mail) OnInstallComp() { func (this *Mail) CreateNewMail(uId string) { mail := &pb.DB_MailData{ ObjId: primitive.NewObjectID().Hex(), - UserId: uId, + Uid: uId, Title: "系统邮件", Contex: "恭喜获得专属礼包一份", CreateTime: uint64(time.Now().Unix()), diff --git a/modules/pack/pack_test.go b/modules/pack/pack_test.go index 97db5a364..95a38164e 100644 --- a/modules/pack/pack_test.go +++ b/modules/pack/pack_test.go @@ -57,7 +57,7 @@ var module = new(Pack) //测试环境下初始化db和cache 系统 func TestMain(m *testing.M) { service = newService( - rpcx.SetConfPath("../../bin/conf/worker_1.yaml"), + rpcx.SetConfPath("../../bin/conf/worker_2.yaml"), rpcx.SetVersion("1.0.0.0"), ) service.OnInstallComp( //装备组件 @@ -156,3 +156,10 @@ func Pack_UpdateGridToUserPack(uId string, grids ...*pb.DB_UserItemData) (err er module.model_pack_comp.DB.InsertMany(DB_PackTable, data) return } + +func TestGetHM(t *testing.T) { + d := make(map[string]interface{}) + d["amount"] = 10 + d["itemid"] = 1004 + module.cache_comp.SetHM("pack:0_62a9afd994fe03b7aaee6773", d) +} diff --git a/modules/user/api.go b/modules/user/api.go index ec3681af2..68f641aed 100644 --- a/modules/user/api.go +++ b/modules/user/api.go @@ -1,10 +1,13 @@ package user import ( + "errors" "go_dreamfactory/modules" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" + + "go.mongodb.org/mongo-driver/bson" ) const ( @@ -25,3 +28,15 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core this.module = module.(*User) return } + +func (this *Api_Comp) Start() (err error) { + err = this.MComp_GateComp.Start() + _data, err := this.module.modelUser.DB.Find("model_log", bson.M{}) + if err == nil { + if _data.RemainingBatchLength() > 0 { + return errors.New("") + } + } + + return +} diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 2bac4ba22..70f754cc3 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -33,7 +33,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa code = pb.ErrorCode_SystemError return } - event.TriggerEvent(comm.Event_UserLogin, user.Uid) + event.TriggerEvent(comm.Event_UserLogin, user.UId) } }() @@ -57,7 +57,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa } //bind user - err = session.Bind(user.Uid, this.service.GetId()) + err = session.Bind(user.UId, this.service.GetId()) if err != nil { code = pb.ErrorCode_BindUser return diff --git a/modules/user/model_user.go b/modules/user/model_user.go index 7d1e8364b..82976f8a6 100644 --- a/modules/user/model_user.go +++ b/modules/user/model_user.go @@ -51,7 +51,7 @@ func (this *ModelUser) User_FindById(id string) (*pb.DB_UserData, error) { func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) { _id := primitive.NewObjectID().Hex() user.Id = _id - user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id) + user.UId = fmt.Sprintf("%d_%s", user.Sid, _id) user.Uuid = uuid.NewV4().String() user.Ctime = time.Now().Unix() _, err = this.DB.InsertOne(DB_UserTable, user) @@ -62,7 +62,7 @@ func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) { func (this *ModelUser) User_Update(data *pb.DB_UserData) (err error) { err = this.DB.FindOneAndUpdate( DB_UserTable, - bson.M{"uid": data.Uid}, + bson.M{"uid": data.UId}, bson.M{"$set": bson.M{ "name": data.Name, }}, diff --git a/modules/web/api_comp.go b/modules/web/api_comp.go index c0dd8d6f0..3caff8602 100644 --- a/modules/web/api_comp.go +++ b/modules/web/api_comp.go @@ -38,7 +38,7 @@ func (this *Api_Comp) Register(c *engine.Context) { err := c.BindJSON(&req) if err == nil { err := this.module.modelUser.User_Create(&pb.DB_UserData{ - Binduid: req.Account, + BinduId: req.Account, Sid: req.Sid, }) if err != nil { diff --git a/pb/friend_db.pb.go b/pb/friend_db.pb.go index b2fc9e3b8..963204a92 100644 --- a/pb/friend_db.pb.go +++ b/pb/friend_db.pb.go @@ -25,10 +25,10 @@ type DB_FriendData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId" bson:"_id"` // ID - FriendIds []string `protobuf:"bytes,2,rep,name=friendIds,proto3" json:"friendIds"` //好友ID - ApplyIds []string `protobuf:"bytes,3,rep,name=applyIds,proto3" json:"applyIds"` //申请用户ID - BlackIds []string `protobuf:"bytes,4,rep,name=blackIds,proto3" json:"blackIds"` //黑名单ID + UId string `protobuf:"bytes,1,opt,name=uId,proto3" json:"uId" bson:"uId"` //用户ID + FriendIds []string `protobuf:"bytes,2,rep,name=friendIds,proto3" json:"friendIds" bson:"friendIds"` //好友ID + ApplyIds []string `protobuf:"bytes,3,rep,name=applyIds,proto3" json:"applyIds" bson:"applyIds"` //申请用户ID + BlackIds []string `protobuf:"bytes,4,rep,name=blackIds,proto3" json:"blackIds" bson:"blackIds"` //黑名单ID } func (x *DB_FriendData) Reset() { @@ -63,9 +63,9 @@ func (*DB_FriendData) Descriptor() ([]byte, []int) { return file_friend_friend_db_proto_rawDescGZIP(), []int{0} } -func (x *DB_FriendData) GetUserId() string { +func (x *DB_FriendData) GetUId() string { if x != nil { - return x.UserId + return x.UId } return "" } @@ -95,16 +95,16 @@ var File_friend_friend_db_proto protoreflect.FileDescriptor var file_friend_friend_db_proto_rawDesc = []byte{ 0x0a, 0x16, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x2f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, - 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7d, 0x0a, 0x0d, 0x44, 0x42, 0x5f, 0x46, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x08, 0x61, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x62, - 0x6c, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x62, - 0x6c, 0x61, 0x63, 0x6b, 0x49, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a, 0x0d, 0x44, 0x42, 0x5f, 0x46, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, + 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x70, 0x70, + 0x6c, 0x79, 0x49, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x61, 0x70, 0x70, + 0x6c, 0x79, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x49, 0x64, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x49, 0x64, + 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/pb/mail_db.pb.go b/pb/mail_db.pb.go index 29cd81e91..9309c2e91 100644 --- a/pb/mail_db.pb.go +++ b/pb/mail_db.pb.go @@ -81,7 +81,7 @@ type DB_MailData struct { unknownFields protoimpl.UnknownFields ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId" bson:"_id"` // ID - UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId"` + Uid string `protobuf:"bytes,2,opt,name=Uid,proto3" json:"Uid"` Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title"` // 邮件标题 Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex"` // 邮件内容 CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime"` // 发送时间 @@ -130,9 +130,9 @@ func (x *DB_MailData) GetObjId() string { return "" } -func (x *DB_MailData) GetUserId() string { +func (x *DB_MailData) GetUid() string { if x != nil { - return x.UserId + return x.Uid } return "" } @@ -194,24 +194,24 @@ var file_mail_mail_db_proto_rawDesc = []byte{ 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xf8, 0x01, 0x0a, + 0x0d, 0x52, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xf2, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, - 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, - 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, - 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x55, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6e, 0x74, + 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, + 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c, + 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, + 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/pb/proto/friend/friend_db.proto b/pb/proto/friend/friend_db.proto index 8e3ba3088..f09779d6a 100644 --- a/pb/proto/friend/friend_db.proto +++ b/pb/proto/friend/friend_db.proto @@ -1,11 +1,9 @@ syntax = "proto3"; option go_package = ".;pb"; - message DB_FriendData { - string userId = 1;// @go_tags(`bson:"_id"`) ID - repeated string friendIds = 2; //好友ID - repeated string applyIds = 3;//申请用户ID - repeated string blackIds = 4;//黑名单ID - + string uId = 1; //@go_tags(`bson:"uId"`) 用户ID + repeated string friendIds = 2; //@go_tags(`bson:"friendIds"`) 好友ID + repeated string applyIds = 3; //@go_tags(`bson:"applyIds"`) 申请用户ID + repeated string blackIds = 4; //@go_tags(`bson:"blackIds"`) 黑名单ID } \ No newline at end of file diff --git a/pb/proto/mail/mail_db.proto b/pb/proto/mail/mail_db.proto index 425629b70..3db1aa47d 100644 --- a/pb/proto/mail/mail_db.proto +++ b/pb/proto/mail/mail_db.proto @@ -13,7 +13,7 @@ message MailAttachment { // 附件 message DB_MailData { string ObjId = 1; // @go_tags(`bson:"_id"`) ID - string UserId = 2; + string Uid = 2; string Title = 3; // 邮件标题 string Contex = 4; // 邮件内容 uint64 CreateTime = 5; // 发送时间 diff --git a/pb/proto/user/user_db.proto b/pb/proto/user/user_db.proto index 3c103330e..8ffe8b178 100644 --- a/pb/proto/user/user_db.proto +++ b/pb/proto/user/user_db.proto @@ -5,20 +5,20 @@ message Cache_UserData { string uid = 1; string SessionId = 2; string GatewayServiceId = 3; - // DB_UserData UserData = 4; + // DB_UserData UserData = 4; //@go_tags(`json:",inline"`) } message DB_UserData { - string id = 1; // @go_tags(`bson:"_id"`) ID - string uid = 2; - string uuid = 3; //玩家唯一uuid - string binduid = 4; //玩家账号 - string name = 5; //玩家名 - int32 sid = 6; //区服id - string createip = 7; //创建账号时的ip - string lastloginip = 8; //最后一次登录时的ip - int64 ctime = 9; //玩家创号时间戳 - int64 logintime = 10; //最后一次登录时间 - int32 FriendPoint = 11; //友情点 - int32 avatar = 12; //头像 + string id = 1; //@go_tags(`bson:"_id"`) ID + string uId = 2; //@go_tags(`bson:"uId"`) 用户ID + string uuid = 3; //@go_tags(`bson:"uuid"`) 玩家唯一uuid + string binduId = 4; //@go_tags(`bson:"binduId"`) 玩家账号 + string name = 5; //@go_tags(`bson:"name"`) 玩家名 + int32 sid = 6; //@go_tags(`bson:"sid"`) 区服id + string createip = 7; //@go_tags(`bson:"createip"`) 创建账号时的ip + string lastloginip = 8; //@go_tags(`bson:"lastloginip"`) 最后一次登录时的ip + int64 ctime = 9; //@go_tags(`bson:"ctime"`) 玩家创号时间戳 + int64 logintime = 10; //@go_tags(`bson:"logintime"`) 最后一次登录时间 + int32 friendPoint = 11; //@go_tags(`bson:"friendPoint"`) 友情点 + int32 avatar = 12; //@go_tags(`bson:"avatar"`) 头像 } \ No newline at end of file diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 4d34f828b..cc4d418a9 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -27,7 +27,7 @@ type Cache_UserData struct { Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid"` SessionId string `protobuf:"bytes,2,opt,name=SessionId,proto3" json:"SessionId"` - GatewayServiceId string `protobuf:"bytes,3,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId"` // DB_UserData UserData = 4; + GatewayServiceId string `protobuf:"bytes,3,opt,name=GatewayServiceId,proto3" json:",inline"` // DB_UserData UserData = 4; // } func (x *Cache_UserData) Reset() { @@ -88,18 +88,18 @@ type DB_UserData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` // ID - Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` - Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid"` //玩家唯一uuid - Binduid string `protobuf:"bytes,4,opt,name=binduid,proto3" json:"binduid"` //玩家账号 - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name"` //玩家名 - Sid int32 `protobuf:"varint,6,opt,name=sid,proto3" json:"sid"` //区服id - Createip string `protobuf:"bytes,7,opt,name=createip,proto3" json:"createip"` //创建账号时的ip - Lastloginip string `protobuf:"bytes,8,opt,name=lastloginip,proto3" json:"lastloginip"` //最后一次登录时的ip - Ctime int64 `protobuf:"varint,9,opt,name=ctime,proto3" json:"ctime"` //玩家创号时间戳 - Logintime int64 `protobuf:"varint,10,opt,name=logintime,proto3" json:"logintime"` //最后一次登录时间 - FriendPoint int32 `protobuf:"varint,11,opt,name=FriendPoint,proto3" json:"FriendPoint"` //友情点 - Avatar int32 `protobuf:"varint,12,opt,name=avatar,proto3" json:"avatar"` //头像 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + UId string `protobuf:"bytes,2,opt,name=uId,proto3" json:"uId" bson:"uId"` //用户ID + Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid" bson:"uuid"` //玩家唯一uuid + BinduId string `protobuf:"bytes,4,opt,name=binduId,proto3" json:"binduId" bson:"binduId"` //玩家账号 + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name" bson:"name"` //玩家名 + Sid int32 `protobuf:"varint,6,opt,name=sid,proto3" json:"sid" bson:"sid"` //区服id + Createip string `protobuf:"bytes,7,opt,name=createip,proto3" json:"createip" bson:"createip"` //创建账号时的ip + Lastloginip string `protobuf:"bytes,8,opt,name=lastloginip,proto3" json:"lastloginip" bson:"lastloginip"` //最后一次登录时的ip + Ctime int64 `protobuf:"varint,9,opt,name=ctime,proto3" json:"ctime" bson:"ctime"` //玩家创号时间戳 + Logintime int64 `protobuf:"varint,10,opt,name=logintime,proto3" json:"logintime" bson:"logintime"` //最后一次登录时间 + FriendPoint int32 `protobuf:"varint,11,opt,name=friendPoint,proto3" json:"friendPoint" bson:"friendPoint"` //友情点 + Avatar int32 `protobuf:"varint,12,opt,name=avatar,proto3" json:"avatar" bson:"avatar"` //头像 } func (x *DB_UserData) Reset() { @@ -141,9 +141,9 @@ func (x *DB_UserData) GetId() string { return "" } -func (x *DB_UserData) GetUid() string { +func (x *DB_UserData) GetUId() string { if x != nil { - return x.Uid + return x.UId } return "" } @@ -155,9 +155,9 @@ func (x *DB_UserData) GetUuid() string { return "" } -func (x *DB_UserData) GetBinduid() string { +func (x *DB_UserData) GetBinduId() string { if x != nil { - return x.Binduid + return x.BinduId } return "" } @@ -231,11 +231,11 @@ var file_user_user_db_proto_rawDesc = []byte{ 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x22, 0xaf, 0x02, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, + 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64, - 0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, - 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x75, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, + 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, @@ -244,9 +244,9 @@ var file_user_user_db_proto_rawDesc = []byte{ 0x6f, 0x67, 0x69, 0x6e, 0x69, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x46, 0x72, + 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, + 0x0b, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index e458c756b..43b4ffe1e 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -59,7 +59,7 @@ func (this *SComp_GateRouteComp) Init(service core.IService, comp core.IServiceC this.msgcheck = make(map[string]*msghandle) this.msghandles = make(map[string]*msghandle) return err -} +} // //组件启动时注册rpc服务监听 func (this *SComp_GateRouteComp) Start() (err error) { @@ -76,6 +76,9 @@ func (this *SComp_GateRouteComp) Start() (err error) { } } }) + event.RegisterGO(core.Event_FindNewService, func() { + log.Debugf("find new service") + }) return } diff --git a/sys/cache/init_test.go b/sys/cache/init_test.go index c88fdc5b2..5a5e8e5cb 100644 --- a/sys/cache/init_test.go +++ b/sys/cache/init_test.go @@ -2,19 +2,11 @@ package cache_test import ( "fmt" - "go_dreamfactory/comm" - "go_dreamfactory/lego/sys/log" - "go_dreamfactory/pb" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/db" "os" "testing" "time" - - "go_dreamfactory/utils" - - "go.mongodb.org/mongo-driver/bson" - "go.mongodb.org/mongo-driver/bson/primitive" ) //测试环境下初始化db和cache 系统 @@ -27,72 +19,72 @@ func TestMain(m *testing.M) { fmt.Printf("err:%v\n", err) return } + for i := 0; i < 50000; i++ { //go func() { - _mail := &pb.DB_MailData{ - ObjId: primitive.NewObjectID().Hex(), - UserId: "uid123", - Title: "系统邮件", + // _mail := &pb.DB_MailData{ + // ObjId: primitive.NewObjectID().Hex(), + // Uid: "uid123", + // Title: "系统邮件", + // Contex: "恭喜获得专属礼包一份", + // CreateTime: uint64(time.Now().Unix()), + // DueTime: uint64(time.Now().Unix()) + 30*24*3600, + // Check: false, + // Reward: false, + // } + // //db.InsertModelLogs("mail", "uid123", _mail) + // db.Defsys.Mgo().InsertOne("mail", _mail) + // data := &comm.Autogenerated{ + // ID: primitive.NewObjectID().Hex(), + // UID: "uid123", + // Act: string(comm.LogHandleType_Insert), + // } + // data.D = append(data.D, "mail") // D[0] + // data.D = append(data.D, _mail) // D[1] - Contex: "恭喜获得专属礼包一份", - CreateTime: uint64(time.Now().Unix()), - DueTime: uint64(time.Now().Unix()) + 30*24*3600, - Check: false, - Reward: false, - } - //db.InsertModelLogs("mail", "uid123", _mail) - db.Defsys.Mgo().InsertOne("mail", _mail) - data := &comm.Autogenerated{ - ID: primitive.NewObjectID().Hex(), - UID: "uid123", - Act: string(comm.LogHandleType_Insert), - } - data.D = append(data.D, "mail") // D[0] - data.D = append(data.D, _mail) // D[1] + // _, err1 := db.Defsys.Mgo().InsertOne("model_log", data) + // if err1 != nil { + // log.Errorf("insert model db err %v", err1) + // } + // //}() - _, err1 := db.Defsys.Mgo().InsertOne("model_log", data) - if err1 != nil { - log.Errorf("insert model db err %v", err1) - } - //}() + // /////////////////////////////////////// + // filter := bson.M{ + // "userid": "uid123", + // "title": "系统邮件", + // } + // var nd *pb.DB_MailData + // err := db.Defsys.Mgo().FindOne("mail", filter).Decode(&nd) + // if err == nil { + // nd.Check = true + // nd.Reward = true - /////////////////////////////////////// - filter := bson.M{ - "userid": "uid123", - "title": "系统邮件", - } - var nd *pb.DB_MailData - err := db.Defsys.Mgo().FindOne("mail", filter).Decode(&nd) - if err == nil { - nd.Check = true - nd.Reward = true + // data1 := &comm.Autogenerated{ + // ID: primitive.NewObjectID().Hex(), + // UID: "uid123", + // Act: string(comm.LogHandleType_Update), + // } + // filter1 := bson.M{ + // "userid": "uid123", + // "title": "系统邮件", + // } + // var ndmodify = &bson.M{ + // "title": "xxxxx", + // "check": true, + // } - data1 := &comm.Autogenerated{ - ID: primitive.NewObjectID().Hex(), - UID: "uid123", - Act: string(comm.LogHandleType_Update), - } - filter1 := bson.M{ - "userid": "uid123", - "title": "系统邮件", - } - var ndmodify = &bson.M{ - "title": "xxxxx", - "check": true, - } + // data1.D = make([]interface{}, 0) + // data1.D = append(data1.D, "mail") // D[0] + // data1.D = append(data1.D, &filter1) // D[1] + // data1.D = append(data1.D, ndmodify) // D[2] + // nd.Title = "read" + // //db.Defsys.Mgo().UpdateMany("mail", filter1, bson.M{"$set": nd}) + // _, err = db.Defsys.Mgo().InsertOne("model_log", data1) + // if err != nil { + // log.Errorf("insert model db err %v", err) + // } - data1.D = make([]interface{}, 0) - data1.D = append(data1.D, "mail") // D[0] - data1.D = append(data1.D, &filter1) // D[1] - data1.D = append(data1.D, ndmodify) // D[2] - nd.Title = "read" - //db.Defsys.Mgo().UpdateMany("mail", filter1, bson.M{"$set": nd}) - _, err = db.Defsys.Mgo().InsertOne("model_log", data1) - if err != nil { - log.Errorf("insert model db err %v", err) - } - - } + // } } time.Sleep(time.Second * 10) @@ -101,19 +93,5 @@ func TestMain(m *testing.M) { } func TestSet(t *testing.T) { - friendDb := &pb.DB_FriendData{ - UserId: "111", - FriendIds: []string{"222"}, - ApplyIds: []string{"333"}, - BlackIds: []string{"444"}, - } - data := utils.Pb2Map(friendDb) - // data2 := map[string]interface{}{ - // "userId": friendDb.UserId, - // "friendIds": friendDb.FriendIds, - // "applyIds": friendDb.ApplyIds, - // "blackIds": friendDb.BlackIds, - // } - cache.Redis().HMSet("friend:222", data) }