diff --git a/cmd/robot/friend.go b/cmd/robot/friend.go index 085220cd7..e201e6d3f 100644 --- a/cmd/robot/friend.go +++ b/cmd/robot/friend.go @@ -89,7 +89,7 @@ func (r *Robot) handleFriendApply(msg *pb.UserMessage) { printReply(msg, rsp) } -//申请列表 +// 申请列表 func (r *Robot) FriendApplyList() { req := &pb.Friend_ApplyList_Req{} head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList} diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 8c64f1f5a..48d960acd 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -83,7 +83,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) { //在这里添加玩家成功登录以后的测试方法 func (r *Robot) onUserLoaded() { //user - // r.CreateUser("乐谷616") + r.CreateUser("乐谷616") //friend // r.FriendApply("1_62aa8f30d25fb8c1a7d90b50") diff --git a/comm/core.go b/comm/core.go index f93cf4b42..cefa0bc63 100644 --- a/comm/core.go +++ b/comm/core.go @@ -96,8 +96,7 @@ type IUserSession interface { //对protobuf格式的数据进行反序列化 func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) { - any := msg.Data - err := any.UnmarshalTo(req) + err := msg.Data.UnmarshalTo(req) if err != nil { log.Errorf("UnmarshalTo %s.%s %v", msg.MainType, msg.SubType, err) return diff --git a/modules/model_comp.go b/modules/model_comp.go index 3e310db2c..b0a0a3f66 100644 --- a/modules/model_comp.go +++ b/modules/model_comp.go @@ -194,7 +194,6 @@ func (this *Model_Comp) GetHM(uid string, data interface{}) error { //update cache without mgolog return this.SetHM(this.ukey(uid), data, cache.WithDisabledMgoLog()) } - return nil } diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 04495571c..43ac9b643 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -4,7 +4,6 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/sys/event" "go_dreamfactory/pb" - "go_dreamfactory/sys/cache" "go_dreamfactory/utils" ) @@ -32,7 +31,7 @@ func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interf return } self.Name = req.NickName - err = this.module.modelUser.SetObj(session.GetUserId(), self, cache.WithND()) + err = this.module.modelUser.SetObj(session.GetUserId(), self) if err != nil { code = pb.ErrorCode_DBError return diff --git a/modules/user/api_login.go b/modules/user/api_login.go index 6ff4433e5..6bb89ac67 100644 --- a/modules/user/api_login.go +++ b/modules/user/api_login.go @@ -105,7 +105,11 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa return } } else { - session.Bind(db_user.Uid, this.service.GetId()) + err := session.Bind(db_user.Uid, this.service.GetId()) + if err != nil { + code = pb.ErrorCode_BindUser + return + } data := &pb.Cache_UserData{ Uid: db_user.Uid, SessionId: cache_user.SessionId, @@ -115,7 +119,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa // "sessionId": cache_user.SessionId, // "gatewayServiceId": cache_user.GatewayServiceId, // } - err = this.module.modelSession.SetObj(db_user.Uid, data) + err = this.module.modelSession.SetObj(db_user.Uid, data, cache.WithDisabledMgoLog()) if err != nil { code = pb.ErrorCode_DBError return diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 02c9aec68..9dc798f9d 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -41,6 +41,7 @@ const ( // user ErrorCode_SecKeyInvalid ErrorCode = 1000 //秘钥无效 ErrorCode_SecKey ErrorCode = 1001 //秘钥格式错误 + ErrorCode_BindUser ErrorCode = 1002 //用户绑定错误 // friend ErrorCode_FriendNotSelf ErrorCode = 1100 //不能是自己 ErrorCode_FriendSelfMax ErrorCode = 1101 //超出好友最大数量 @@ -76,6 +77,7 @@ var ( 100: "Exception", 1000: "SecKeyInvalid", 1001: "SecKey", + 1002: "BindUser", 1100: "FriendNotSelf", 1101: "FriendSelfMax", 1102: "FriendTargetMax", @@ -107,6 +109,7 @@ var ( "Exception": 100, "SecKeyInvalid": 1000, "SecKey": 1001, + "BindUser": 1002, "FriendNotSelf": 1100, "FriendSelfMax": 1101, "FriendTargetMax": 1102, @@ -153,7 +156,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xe5, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xf4, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -174,25 +177,26 @@ var file_errorcode_proto_rawDesc = []byte{ 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x64, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8, 0x07, 0x12, 0x0b, 0x0a, - 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12, 0x12, - 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78, 0x10, - 0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, - 0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08, 0x12, - 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, - 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17, 0x0a, - 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63, 0x6b, - 0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, - 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4, - 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, - 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x12, 0x1a, 0x0a, - 0x15, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, - 0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, - 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x0d, 0x0a, 0x08, 0x42, 0x69, + 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x10, 0xea, 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12, 0x12, 0x0a, + 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78, 0x10, 0xcd, + 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08, 0x12, 0x17, + 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x6f, + 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17, 0x0a, 0x12, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, + 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4, 0x08, + 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x12, 0x1a, 0x0a, 0x15, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index 69bbe94f2..57b33e875 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -21,6 +21,7 @@ enum ErrorCode { // user SecKeyInvalid = 1000; //秘钥无效 SecKey = 1001; //秘钥格式错误 + BindUser = 1002; //用户绑定错误 // friend FriendNotSelf = 1100; //不能是自己 diff --git a/services/worker/main.go b/services/worker/main.go index 731eaa149..cca649e65 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -3,6 +3,7 @@ package main import ( "flag" "fmt" + "go_dreamfactory/modules/dbservice" "go_dreamfactory/modules/friend" "go_dreamfactory/modules/mail" "go_dreamfactory/modules/pack" @@ -40,7 +41,7 @@ func main() { pack.NewModule(), mail.NewModule(), friend.NewModule(), - // dbservice.NewModule(), + dbservice.NewModule(), ) }