From e8c9f63901800bda79ef927fbcd4580764aa3027 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Mon, 6 Jun 2022 18:42:03 +0800 Subject: [PATCH 1/5] update Robot --- cmd/cmd.go | 6 +- cmd/robot/login.go | 41 ++++++--- cmd/robot/readme.md | 12 +++ cmd/robot/robot.go | 62 +++++-------- cmd/robot/user.go | 38 ++++++++ comm/core.go | 8 +- comm/usersession.go | 8 +- go.mod | 2 +- modules/core.go | 4 +- modules/gateway/agent.go | 5 +- modules/gateway/agentmgr_comp.go | 15 +-- modules/gateway/client_test.go | 5 +- modules/modulebase.go | 14 +-- modules/{login => user}/login_comp.go | 10 +- modules/{login => user}/module.go | 14 +-- modules/user/user_comp.go | 17 ++++ modules/web/api_comp.go | 3 +- pb/comm.pb.go | 128 +++++++++++++++++--------- pb/proto/comm.proto | 20 ++-- pb/proto/user_msg.proto | 16 ++++ pb/user_msg.pb.go | 117 +++++++++++++++++++---- 21 files changed, 380 insertions(+), 165 deletions(-) create mode 100644 cmd/robot/readme.md rename modules/{login => user}/login_comp.go (87%) rename modules/{login => user}/module.go (51%) create mode 100644 modules/user/user_comp.go diff --git a/cmd/cmd.go b/cmd/cmd.go index a1e6bed68..87dcd8dd9 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -43,10 +43,8 @@ var runCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { opts := robot.DefaultOpts() - opts.Create = *create - if *create { - opts.Account = *account - } + opts.Create = *create + opts.Account = *account r := robot.NewRobot(opts) r.Run() diff --git a/cmd/robot/login.go b/cmd/robot/login.go index 654e4361a..7e0f2d049 100644 --- a/cmd/robot/login.go +++ b/cmd/robot/login.go @@ -1,38 +1,49 @@ package robot import ( - "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" "log" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) -func (r *Robot) handleLogin(methodName string) { - switch methodName { +func (r *Robot) handleLogin(msg *pb.UserMessage) { + switch msg.SubType { case "login": - handleLogin(r) + handleLogin(r, msg) default: log.Fatal("methodName no exist") } } -func handleLogin(r *Robot) { - loginreq := &pb.UserLoginReq{ - Name: "aaa", +//处理接口响应数据 +func handleLogin(r *Robot, msg *pb.UserMessage) { + rsp := &pb.UserLoginResp{} + if !comm.ProtoDecode(msg, rsp) { + return } - logindata, _ := proto.Marshal(loginreq) - head := &pb.UserMessage{ - ServiceMethod: "login.login", - Data: logindata, + log.Printf("to client: %v", rsp.Data) +} + +//处理登录请求 +func (r *Robot) AccountLogin() { + //登录 + loginReg := &pb.UserLoginReq{ + Name: r.Opts.Account, } - if comm.ProtoEncode(loginreq, head) { - err := r.SendToClient(head.Data) + head := &pb.UserMessage{ + MainType: "login", + SubType: "login", + } + if comm.ProtoEncode(loginReg, head) { + data, _ := proto.Marshal(head) + err := r.SendToClient(data) if err != nil { - fmt.Printf("err:%v\n", err) + log.Fatal(err) } } + log.Printf("%s login ", r.Opts.Account) } diff --git a/cmd/robot/readme.md b/cmd/robot/readme.md new file mode 100644 index 000000000..345e2fc58 --- /dev/null +++ b/cmd/robot/readme.md @@ -0,0 +1,12 @@ +# Robot使用 + +## 命令行 +```sh +#使用已存在的账号测试接口 +go run cmd.go run --account yourAccount +``` + +```sh +#使用新账号测试接口 +go run cmd.go run --account newAccount --create true +``` diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 5ca3a97c9..9f83a1a19 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -5,7 +5,6 @@ import ( "encoding/json" "go_dreamfactory/comm" "go_dreamfactory/pb" - "go_dreamfactory/utils" "io/ioutil" "log" "net/http" @@ -44,33 +43,40 @@ func (r *Robot) Run() { r.AccountLogin() } - for { - var msg *pb.UserMessage = &pb.UserMessage{} - _, data, err := r.ws.ReadMessage() - if err != nil { - log.Fatal(err) - } + //处理响应 + go func() { + for { + var msg *pb.UserMessage = &pb.UserMessage{} + _, data, err := r.ws.ReadMessage() + if err != nil { + log.Println(err) + } - if err = proto.Unmarshal(data, msg); err != nil { - log.Fatal(err) + if err = proto.Unmarshal(data, msg); err != nil { + log.Fatal(err) + } + r.handleMsg(msg) } - r.handleMsg(msg) - } + }() + + select {} } func (r *Robot) handleMsg(msg *pb.UserMessage) { - m, f, ok := utils.ParseP(msg.ServiceMethod) - if !ok { - log.Fatal("route error") - } - switch m { + switch msg.MainType { case "login": - r.handleLogin(f) + r.handleLogin(msg) + case "user": + r.handleUserMsg(msg) default: log.Fatal("module route no exist") } } +func (r *Robot) onUserLoaded() { + +} + func (r *Robot) SendToClient(data []byte) error { return r.ws.WriteMessage(websocket.BinaryMessage, data) } @@ -103,7 +109,8 @@ func (r *Robot) AccountRegister() { } head := &pb.UserMessage{ - ServiceMethod: "login.login", + MainType: "login", + SubType: "login", } if comm.ProtoEncode(loginReg, head) { err = r.SendToClient(head.Data) @@ -113,23 +120,4 @@ func (r *Robot) AccountRegister() { } } - -} - -//登录认证 -func (r *Robot) AccountLogin() { - //登录 - loginReg := &pb.UserLoginReq{ - Name: r.Opts.Account, - } - - head := &pb.UserMessage{ - ServiceMethod: "login.login", - } - if comm.ProtoEncode(loginReg, head) { - err := r.SendToClient(head.Data) - if err != nil { - log.Fatal(err) - } - } } diff --git a/cmd/robot/user.go b/cmd/robot/user.go index 8e1a8faab..ced98e66f 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -1 +1,39 @@ package robot + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "github.com/liwei1dao/lego/sys/log" +) + +func (r *Robot) handleUserMsg(msg *pb.UserMessage) { + + switch msg.SubType { + //创建账号 + case "create": + case "load": + + } + + //加载玩家数据 + if msg.SubType == "load" { + rsp := &pb.UserLoadRsp{} + if !comm.ProtoDecode(msg, rsp) { + log.Fatal("load user err") + } + + if rsp.Data.UserData.UserId != 0 { + r.onUserLoaded() + } else { + log.Debugf("%s不存在", r.Opts.Account) + //创建 + + } + + } +} + +func (r *Robot) CreateUser() { + +} diff --git a/comm/core.go b/comm/core.go index 76763383f..3d4ac5d45 100644 --- a/comm/core.go +++ b/comm/core.go @@ -16,7 +16,7 @@ const ( const ( SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 SM_WebModule core.M_Modules = "web" //web模块 - SM_LoginModule core.M_Modules = "login" //web模块 + SM_LoginModule core.M_Modules = "login" ) const ( //Rpc @@ -42,7 +42,7 @@ type IUserSession interface { GetGatewayServiceId() string Build(uid uint32) (err error) UnBuild(ServiceMethod string, msg proto.Message) (err error) - SendMsg(ServiceMethod string, msg proto.Message) (err error) + SendMsg(mainType, subType string, msg proto.Message) (err error) Close() (err error) ToString() string } @@ -61,7 +61,7 @@ type Message struct { func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) { err := proto.Unmarshal(msg.Data, req) if err != nil { - log.Errorf("%s %v", msg.ServiceMethod, err) + log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err) return } return true @@ -70,7 +70,7 @@ func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) { func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) { data, err := proto.Marshal(rsp) if err != nil { - log.Errorf("%s %v", msg.ServiceMethod, err) + log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err) return } msg.Data = data diff --git a/comm/usersession.go b/comm/usersession.go index 4fa7c2eff..13c07b350 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -63,15 +63,17 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e return } -func (this *UserSession) SendMsg(ServiceMethod string, msg proto.Message) (err error) { +func (this *UserSession) SendMsg(mainType, subType string, msg proto.Message) (err error) { reply := &pb.RPCMessageReply{} data, _ := proto.Marshal(msg) + log.Debugf("SendMsg Data: %v", msg) if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{ UserSessionId: this.SessionId, - ServiceMethod: ServiceMethod, + MainType: mainType, + SubType: subType, Data: data, }, reply); err != nil { - log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, ServiceMethod, err) + log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err) } return } diff --git a/go.mod b/go.mod index daf1be6cd..d3a36b9cb 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/liwei1dao/lego v0.0.0-20220531091126-a21bb3766fbc github.com/spf13/cobra v1.2.1 + github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.1 go.mongodb.org/mongo-driver v1.5.1 google.golang.org/protobuf v1.28.0 @@ -95,7 +96,6 @@ require ( github.com/smallnest/quick v0.0.0-20220103065406-780def6371e6 // indirect github.com/smallnest/rpcx v1.7.4 // indirect github.com/soheilhy/cmux v0.1.5 // indirect - github.com/spf13/pflag v1.0.5 // indirect github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect github.com/tinylib/msgp v1.1.6 // indirect diff --git a/modules/core.go b/modules/core.go index 3740cd5f0..64a62035e 100644 --- a/modules/core.go +++ b/modules/core.go @@ -10,7 +10,7 @@ import ( type ( IModule interface { core.IModule - SendMsgToUser(ServiceMethod string, msg proto.Message, user *pb.Cache_UserData) (err error) - SendMsgToUsers(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error) + SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) + SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error) } ) diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index 768bf5b9d..bc79f4c86 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -2,6 +2,7 @@ package gateway import ( "context" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" "sync" @@ -134,13 +135,13 @@ func (this *Agent) Close() { //分发用户消息 func (this *Agent) messageDistribution(msg *pb.UserMessage) { reply := &pb.RPCMessageReply{} - log.Debugf("agent:%s uId:%d MessageDistribution msg:%s", this.sessionId, this.uId, msg.ServiceMethod) + log.Debugf("agent:%s uId:%d MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{ Ip: this.IP(), UserSessionId: this.sessionId, UserId: this.uId, GatewayServiceId: this.gateway.Service().GetId(), - Method: msg.ServiceMethod, + Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType), Message: msg.Data, }, reply); err != nil { log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err) diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 2cf811d0e..804e57a8b 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -53,8 +53,9 @@ func (this *AgentMgr_Comp) UnBuild(ctx context.Context, args *pb.AgentUnBuildReq func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error { if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).WriteMsg(&pb.UserMessage{ - ServiceMethod: args.ServiceMethod, - Data: args.Data, + MainType: args.MainType, + SubType: args.SubType, + Data: args.Data, }) } else { reply.Code = int32(comm.ErrorCode_UserSessionNobeing) @@ -66,8 +67,9 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen //向多个户发送消息 func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error { msg := &pb.UserMessage{ - ServiceMethod: args.ServiceMethod, - Data: args.Data, + MainType: args.MainType, + SubType: args.SubType, + Data: args.Data, } for _, v := range args.UserSessionIds { if a, ok := this.agents.Load(v); ok { @@ -80,8 +82,9 @@ func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMe //向所有户发送消息 func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error { msg := &pb.UserMessage{ - ServiceMethod: args.ServiceMethod, - Data: args.Data, + MainType: args.MainType, + SubType: args.SubType, + Data: args.Data, } this.agents.Range(func(key, value any) bool { value.(IAgent).WriteMsg(msg) diff --git a/modules/gateway/client_test.go b/modules/gateway/client_test.go index 4f94db495..921e3590b 100644 --- a/modules/gateway/client_test.go +++ b/modules/gateway/client_test.go @@ -40,8 +40,9 @@ func Test_WebSocket(t *testing.T) { } logindata, _ := proto.Marshal(loginreq) message := &pb.UserMessage{ - ServiceMethod: "login.login", - Data: logindata, + MainType: "login", + SubType: "login", + Data: logindata, } data, _ := proto.Marshal(message) err = ws.WriteMessage(websocket.BinaryMessage, data) diff --git a/modules/modulebase.go b/modules/modulebase.go index 4edccae72..253916490 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -23,20 +23,21 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options return } -func (this *ModuleBase) SendMsgToUser(ServiceMethod string, msg proto.Message, user *pb.Cache_UserData) (err error) { +func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) { reply := &pb.RPCMessageReply{} data, _ := proto.Marshal(msg) if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{ UserSessionId: user.SessionId, - ServiceMethod: ServiceMethod, + MainType: mainType, + SubType: subType, Data: data, }, reply); err != nil { - log.Errorf("SendMsgToUser%d:%s [%s] err:%v", user.UserData.UserId, user.SessionId, ServiceMethod, err) + log.Errorf("SendMsgToUser%d:%s [%s.%s] err:%v", user.UserData.UserId, user.SessionId, mainType, subType, err) } return } -func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error) { +func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error) { var ( gateways map[string][]string = make(map[string][]string) gateway []string @@ -54,10 +55,11 @@ func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message, for k, v := range gateways { if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{ UserSessionIds: v, - ServiceMethod: ServiceMethod, + MainType: mainType, + SubType: subType, Data: data, }, reply); err != nil { - log.Errorf("SendMsgToUsers:%s->%s err:%v", k, ServiceMethod, err) + log.Errorf("SendMsgToUsers:%s->%s.%s err:%v", k, mainType, subType, err) } } return diff --git a/modules/login/login_comp.go b/modules/user/login_comp.go similarity index 87% rename from modules/login/login_comp.go rename to modules/user/login_comp.go index b7eee99cd..eca7fde70 100644 --- a/modules/login/login_comp.go +++ b/modules/user/login_comp.go @@ -1,4 +1,4 @@ -package login +package user import ( "context" @@ -47,13 +47,19 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req return err } - session.SendMsg("loginRsp", &pb.UserLoginResp{ + session.SendMsg("login", "login", &pb.UserLoginResp{ Code: comm.ErrorCode_Success, + Data: &pb.Cache_UserData{ + UserData: &pb.DB_UserData{ + UserId: db_user.UserId, + }, + }, }) return nil } +//注销 func (this *LoginComp) Logout(ctx context.Context, session comm.IUserSession, rsp *pb.UserLoginReq) error { log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp) diff --git a/modules/login/module.go b/modules/user/module.go similarity index 51% rename from modules/login/module.go rename to modules/user/module.go index 282d94a0f..47afe980f 100644 --- a/modules/login/module.go +++ b/modules/user/module.go @@ -1,4 +1,4 @@ -package login +package user import ( "go_dreamfactory/comm" @@ -8,20 +8,20 @@ import ( ) func NewModule() core.IModule { - m := new(Login) + m := new(User) return m } -type Login struct { +type User struct { modules.ModuleBase - user_comp *LoginComp + login_comp *LoginComp } -func (this *Login) GetType() core.M_Modules { +func (this *User) GetType() core.M_Modules { return comm.SM_LoginModule } -func (this *Login) OnInstallComp() { +func (this *User) OnInstallComp() { this.ModuleBase.OnInstallComp() - this.user_comp = this.RegisterComp(new(LoginComp)).(*LoginComp) + this.login_comp = this.RegisterComp(new(LoginComp)).(*LoginComp) } diff --git a/modules/user/user_comp.go b/modules/user/user_comp.go new file mode 100644 index 000000000..64b51ba9b --- /dev/null +++ b/modules/user/user_comp.go @@ -0,0 +1,17 @@ +package user + +import ( + "context" + "go_dreamfactory/comm" + "go_dreamfactory/modules" + "go_dreamfactory/pb" +) + +type UserComp struct { + modules.MComp_GateComp +} + +//创角 +func (this *UserComp) CreateUser(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error { + return nil +} diff --git a/modules/web/api_comp.go b/modules/web/api_comp.go index 2193112d4..2f9fa9334 100644 --- a/modules/web/api_comp.go +++ b/modules/web/api_comp.go @@ -16,6 +16,7 @@ import ( type Api_Comp struct { cbase.ModuleCompBase options *Options + module *Web gin gin.ISys } @@ -33,7 +34,7 @@ func (this *Api_Comp) Register(c *engine.Context) { rsp := &pb.UserRegisterRsp{} err := c.BindJSON(&req) if err == nil { - err := db.Defsys.CreateUser(&pb.DB_UserData{ + err := db.Defsys.User_CreateUser(&pb.DB_UserData{ Account: req.Account, }) if err != nil { diff --git a/pb/comm.pb.go b/pb/comm.pb.go index 74f718a8a..e69fe29bf 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -26,8 +26,9 @@ type UserMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 - Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` + MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` + SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *UserMessage) Reset() { @@ -62,9 +63,16 @@ func (*UserMessage) Descriptor() ([]byte, []int) { return file_comm_proto_rawDescGZIP(), []int{0} } -func (x *UserMessage) GetServiceMethod() string { +func (x *UserMessage) GetMainType() string { if x != nil { - return x.ServiceMethod + return x.MainType + } + return "" +} + +func (x *UserMessage) GetSubType() string { + if x != nil { + return x.SubType } return "" } @@ -331,8 +339,9 @@ type AgentSendMessageReq struct { unknownFields protoimpl.UnknownFields UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` - ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 - Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` + MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"` + SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *AgentSendMessageReq) Reset() { @@ -374,9 +383,16 @@ func (x *AgentSendMessageReq) GetUserSessionId() string { return "" } -func (x *AgentSendMessageReq) GetServiceMethod() string { +func (x *AgentSendMessageReq) GetMainType() string { if x != nil { - return x.ServiceMethod + return x.MainType + } + return "" +} + +func (x *AgentSendMessageReq) GetSubType() string { + if x != nil { + return x.SubType } return "" } @@ -395,8 +411,9 @@ type BatchMessageReq struct { unknownFields protoimpl.UnknownFields UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"` - ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` + MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"` + SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *BatchMessageReq) Reset() { @@ -438,9 +455,16 @@ func (x *BatchMessageReq) GetUserSessionIds() []string { return nil } -func (x *BatchMessageReq) GetServiceMethod() string { +func (x *BatchMessageReq) GetMainType() string { if x != nil { - return x.ServiceMethod + return x.MainType + } + return "" +} + +func (x *BatchMessageReq) GetSubType() string { + if x != nil { + return x.SubType } return "" } @@ -458,8 +482,9 @@ type BroadCastMessageReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 - Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"` + MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名 + SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *BroadCastMessageReq) Reset() { @@ -494,9 +519,16 @@ func (*BroadCastMessageReq) Descriptor() ([]byte, []int) { return file_comm_proto_rawDescGZIP(), []int{7} } -func (x *BroadCastMessageReq) GetServiceMethod() string { +func (x *BroadCastMessageReq) GetMainType() string { if x != nil { - return x.ServiceMethod + return x.MainType + } + return "" +} + +func (x *BroadCastMessageReq) GetSubType() string { + if x != nil { + return x.SubType } return "" } @@ -559,11 +591,12 @@ func (x *AgentCloseeReq) GetUserSessionId() string { var File_comm_proto protoreflect.FileDescriptor var file_comm_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, 0x0b, - 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b, + 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d, + 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, + 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, + 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, @@ -588,31 +621,34 @@ var file_comm_proto_rawDesc = []byte{ 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x22, 0x75, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, - 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, - 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, - 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, - 0x4f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, - 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, - 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x49, 0x64, 0x22, 0x85, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, + 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, + 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 0x0a, 0x0f, + 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, + 0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, + 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, + 0x61, 0x22, 0x5f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, + 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, + 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, + 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, + 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index 5c9efaa36..72d2136f3 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -3,8 +3,9 @@ option go_package = ".;pb"; //用户消息流结构 message UserMessage { - string ServiceMethod =1; //服务名 - bytes Data = 2; + string MainType =1; + string SubType = 2; + bytes Data = 3; } //代理用户转发消息结构 @@ -36,21 +37,24 @@ message AgentUnBuildReq { //向用户代理发送消息请求 message AgentSendMessageReq { string UserSessionId = 1; - string ServiceMethod = 2; //服务名 - bytes Data = 3; + string MainType = 2; + string SubType = 3; + bytes Data = 4; } //发送批量消息 message BatchMessageReq { repeated string UserSessionIds = 1; - string ServiceMethod = 2; - bytes Data = 3; + string MainType = 2; + string SubType = 3; + bytes Data = 4; } //发送广播消息 message BroadCastMessageReq { - string ServiceMethod = 1; //服务名 - bytes Data = 2; + string MainType = 1; //服务名 + string SubType = 2; + bytes Data = 3; } //关闭用户代理 diff --git a/pb/proto/user_msg.proto b/pb/proto/user_msg.proto index fad4a93b6..76b03d3eb 100644 --- a/pb/proto/user_msg.proto +++ b/pb/proto/user_msg.proto @@ -1,12 +1,15 @@ syntax = "proto3"; option go_package = ".;pb"; +import "user_db.proto"; + message UserLoginReq { string Name = 1; } message UserLoginResp { int32 Code = 1; + Cache_UserData data = 2; } @@ -16,4 +19,17 @@ message UserRegisterReq{ message UserRegisterRsp{ int32 Code = 1; +} + +message UserLoadRsp { + Cache_UserData data = 1; +} + +message UserCreateReq{ + string NickName = 1;//昵称 + int32 gender = 2; //性别 +} + +message UserCreateRsp{ + } \ No newline at end of file diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index 69042d7a9..ecf0e49fd 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -72,7 +72,8 @@ type UserLoginResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Data *Cache_UserData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } func (x *UserLoginResp) Reset() { @@ -114,6 +115,13 @@ func (x *UserLoginResp) GetCode() int32 { return 0 } +func (x *UserLoginResp) GetData() *Cache_UserData { + if x != nil { + return x.Data + } + return nil +} + type UserRegisterReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -208,21 +216,75 @@ func (x *UserRegisterRsp) GetCode() int32 { return 0 } +type UserLoadRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data *Cache_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *UserLoadRsp) Reset() { + *x = UserLoadRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_user_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserLoadRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserLoadRsp) ProtoMessage() {} + +func (x *UserLoadRsp) ProtoReflect() protoreflect.Message { + mi := &file_user_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserLoadRsp.ProtoReflect.Descriptor instead. +func (*UserLoadRsp) Descriptor() ([]byte, []int) { + return file_user_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *UserLoadRsp) GetData() *Cache_UserData { + if x != nil { + return x.Data + } + return nil +} + var File_user_msg_proto protoreflect.FileDescriptor var file_user_msg_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, - 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, - 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, - 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, + 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, + 0x61, 0x6d, 0x65, 0x22, 0x48, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, + 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, + 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, + 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, + 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, + 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, + 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -237,19 +299,23 @@ func file_user_msg_proto_rawDescGZIP() []byte { return file_user_msg_proto_rawDescData } -var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_user_msg_proto_goTypes = []interface{}{ (*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginResp)(nil), // 1: UserLoginResp (*UserRegisterReq)(nil), // 2: UserRegisterReq (*UserRegisterRsp)(nil), // 3: UserRegisterRsp + (*UserLoadRsp)(nil), // 4: UserLoadRsp + (*Cache_UserData)(nil), // 5: Cache_UserData } var file_user_msg_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 5, // 0: UserLoginResp.data:type_name -> Cache_UserData + 5, // 1: UserLoadRsp.data:type_name -> Cache_UserData + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_user_msg_proto_init() } @@ -257,6 +323,7 @@ func file_user_msg_proto_init() { if File_user_msg_proto != nil { return } + file_user_db_proto_init() if !protoimpl.UnsafeEnabled { file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UserLoginReq); i { @@ -306,6 +373,18 @@ func file_user_msg_proto_init() { return nil } } + file_user_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserLoadRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -313,7 +392,7 @@ func file_user_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_user_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, From c25df3e3977c6cb86dbc6c8d055eef4522372504 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 6 Jun 2022 18:46:28 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/robot.go | 2 +- comm/errorcode.go | 36 ---- comm/usersession.go | 3 +- modules/gateway/agentmgr_comp.go | 17 +- modules/pack/api_comp.go | 38 +++- modules/pack/configure_comp.go | 4 + pb/comm.pb.go | 144 ++++++++------- pb/pack_msg.pb.go | 301 +++++++++++++++++++++++++++++-- pb/proto/comm.proto | 6 +- pb/proto/pack_msg.proto | 22 +++ pb/unitls.go | 22 +++ 11 files changed, 468 insertions(+), 127 deletions(-) delete mode 100644 comm/errorcode.go create mode 100644 pb/unitls.go diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 5ca3a97c9..7ab393c96 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -96,7 +96,7 @@ func (r *Robot) AccountRegister() { regRsp := &pb.UserRegisterRsp{} err = jsoniter.Unmarshal(body, regRsp) - if regRsp.Code == comm.ErrorCode_Success { //注册成功 + if regRsp.Code == int32(pb.ErrorCode_Success) { //注册成功 //登录 loginReg := &pb.UserLoginReq{ Name: regReq.Account, diff --git a/comm/errorcode.go b/comm/errorcode.go deleted file mode 100644 index e436aaec4..000000000 --- a/comm/errorcode.go +++ /dev/null @@ -1,36 +0,0 @@ -package comm - -///内置错误码 0-1000 请外部应用服务不要占用 -const ( - ErrorCode_Success int32 = 0 //成功 - ErrorCode_NoFindService int32 = 10 //没有找到远程服务器 - ErrorCode_RpcFuncExecutionError int32 = 11 //Rpc方法执行错误 - ErrorCode_CacheReadError int32 = 12 //缓存读取失败 - ErrorCode_SqlExecutionError int32 = 13 //数据库执行错误 - ErrorCode_ReqParameterError int32 = 14 //请求参数错误 - ErrorCode_SignError int32 = 15 //签名错误 - ErrorCode_InsufficientPermissions int32 = 16 //权限不足 - ErrorCode_NoLogin int32 = 17 //未登录 - ErrorCode_UserSessionNobeing int32 = 18 //用户不存在 -) - -var ErrorCodeMsg = map[int32]string{ - ErrorCode_Success: "成功", - ErrorCode_NoFindService: "没有找到远程服务器", - ErrorCode_RpcFuncExecutionError: "Rpc方法执行错误", - ErrorCode_CacheReadError: "缓存读取失败", - ErrorCode_SqlExecutionError: "数据库执行错误", - ErrorCode_ReqParameterError: "请求参数错误", - ErrorCode_SignError: "签名错误", - ErrorCode_InsufficientPermissions: "权限不足", - ErrorCode_NoLogin: "未登录", - ErrorCode_UserSessionNobeing: "用户不存在", -} - -func GetErrorCodeMsg(code int32) string { - if v, ok := ErrorCodeMsg[code]; ok { - return v - } else { - return "未描述" - } -} diff --git a/comm/usersession.go b/comm/usersession.go index 4fa7c2eff..ae0cbae24 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -63,12 +63,13 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e return } -func (this *UserSession) SendMsg(ServiceMethod string, msg proto.Message) (err error) { +func (this *UserSession) SendMsg(ServiceMethod string, code pb.ErrorCode, msg proto.Message) (err error) { reply := &pb.RPCMessageReply{} data, _ := proto.Marshal(msg) if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{ UserSessionId: this.SessionId, ServiceMethod: ServiceMethod, + Code: code, Data: data, }, reply); err != nil { log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, ServiceMethod, err) diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 2cf811d0e..3acedcd1f 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -2,7 +2,6 @@ package gateway import ( "context" - "go_dreamfactory/comm" "go_dreamfactory/pb" "sync" @@ -32,8 +31,8 @@ func (this *AgentMgr_Comp) Build(ctx context.Context, args *pb.AgentBuildReq, re if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).Build(args.UserId) } else { - reply.Code = int32(comm.ErrorCode_UserSessionNobeing) - reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) + reply.Code = pb.ErrorCode_UserSessionNobeing + reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } @@ -43,8 +42,8 @@ func (this *AgentMgr_Comp) UnBuild(ctx context.Context, args *pb.AgentUnBuildReq if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).UnBuild() } else { - reply.Code = int32(comm.ErrorCode_UserSessionNobeing) - reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) + reply.Code = pb.ErrorCode_UserSessionNobeing + reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } @@ -57,8 +56,8 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen Data: args.Data, }) } else { - reply.Code = int32(comm.ErrorCode_UserSessionNobeing) - reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) + reply.Code = pb.ErrorCode_UserSessionNobeing + reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } @@ -95,8 +94,8 @@ func (this *AgentMgr_Comp) CloseAgent(ctx context.Context, args *pb.AgentCloseeR if a, ok := this.agents.Load(args.UserSessionId); ok { a.(IAgent).Close() } else { - reply.Code = int32(comm.ErrorCode_UserSessionNobeing) - reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) + reply.Code = pb.ErrorCode_UserSessionNobeing + reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) } return nil } diff --git a/modules/pack/api_comp.go b/modules/pack/api_comp.go index 7de34f37a..5e3de0f7b 100644 --- a/modules/pack/api_comp.go +++ b/modules/pack/api_comp.go @@ -14,6 +14,10 @@ import ( const ( QueryUserPackReq = "pack.queryuserpackreq" QueryUserPackResp = "pack.queryuserpackresp" + UseItemReq = "pack.useitemreq" + UseItemResp = "pack.useitemresp" + SellItemReq = "pack.sellitemreq" + SellItemResp = "pack.sellitemresp" ) type Api_Comp struct { @@ -53,5 +57,37 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe } } } - return nil + return +} + +//使用道具 +func (this *Api_Comp) UseItemReq(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (err error) { + var ( + code pb.ErrorCode + ) + defer func() { + session.SendMsg(UseItemResp, &pb.UseItemResp{Code: code}) + }() + if session.GetUserId() == 0 { + code = pb.ErrorCode_NoLogin + return + } + + return +} + +//出售道具 +func (this *Api_Comp) SellItemReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserPackReq) (err error) { + var ( + code pb.ErrorCode + ) + defer func() { + session.SendMsg(SellItemResp, &pb.SellItemResp{Code: code}) + }() + if session.GetUserId() == 0 { + code = pb.ErrorCode_NoLogin + return + } + + return } diff --git a/modules/pack/configure_comp.go b/modules/pack/configure_comp.go index cbdc1ec87..8317bb466 100644 --- a/modules/pack/configure_comp.go +++ b/modules/pack/configure_comp.go @@ -14,3 +14,7 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com this.ModuleCompBase.Init(service, module, comp, options) return } + +func (this *Configure_Comp) GetItemConfigureData(id uint32) { + +} diff --git a/pb/comm.pb.go b/pb/comm.pb.go index 74f718a8a..3363e32ec 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -170,8 +170,8 @@ type RPCMessageReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` - Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` + Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` } func (x *RPCMessageReply) Reset() { @@ -206,11 +206,11 @@ func (*RPCMessageReply) Descriptor() ([]byte, []int) { return file_comm_proto_rawDescGZIP(), []int{2} } -func (x *RPCMessageReply) GetCode() int32 { +func (x *RPCMessageReply) GetCode() ErrorCode { if x != nil { return x.Code } - return 0 + return ErrorCode_Success } func (x *RPCMessageReply) GetMsg() string { @@ -330,9 +330,10 @@ type AgentSendMessageReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` - ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 - Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` + UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` + ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 + Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *AgentSendMessageReq) Reset() { @@ -381,6 +382,13 @@ func (x *AgentSendMessageReq) GetServiceMethod() string { return "" } +func (x *AgentSendMessageReq) GetCode() ErrorCode { + if x != nil { + return x.Code + } + return ErrorCode_Success +} + func (x *AgentSendMessageReq) GetData() []byte { if x != nil { return x.Data @@ -559,60 +567,64 @@ func (x *AgentCloseeReq) GetUserSessionId() string { var File_comm_proto protoreflect.FileDescriptor var file_comm_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, 0x0b, - 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, - 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, - 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, - 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, - 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, - 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, - 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, - 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, - 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x22, 0x75, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, + 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, + 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, + 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, + 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, + 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e, + 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, + 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, + 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74, + 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61, - 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, - 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, - 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, - 0x4f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, - 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, - 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, - 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x95, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, + 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x24, + 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, + 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, + 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x4f, 0x0a, + 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, + 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x36, + 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, 0x71, + 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -638,13 +650,16 @@ var file_comm_proto_goTypes = []interface{}{ (*BatchMessageReq)(nil), // 6: BatchMessageReq (*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq (*AgentCloseeReq)(nil), // 8: AgentCloseeReq + (ErrorCode)(0), // 9: ErrorCode } var file_comm_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 9, // 0: RPCMessageReply.Code:type_name -> ErrorCode + 9, // 1: AgentSendMessageReq.Code:type_name -> ErrorCode + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_comm_proto_init() } @@ -652,6 +667,7 @@ func file_comm_proto_init() { if File_comm_proto != nil { return } + file_errorcode_proto_init() if !protoimpl.UnsafeEnabled { file_comm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*UserMessage); i { diff --git a/pb/pack_msg.pb.go b/pb/pack_msg.pb.go index 08cb3964c..bff6f1463 100644 --- a/pb/pack_msg.pb.go +++ b/pb/pack_msg.pb.go @@ -188,6 +188,214 @@ func (x *QueryUserPackResp) GetItems() []*ItemAmount { return nil } +//使用物品请求 +type UseItemReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"` + Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"` +} + +func (x *UseItemReq) Reset() { + *x = UseItemReq{} + if protoimpl.UnsafeEnabled { + mi := &file_pack_msg_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UseItemReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UseItemReq) ProtoMessage() {} + +func (x *UseItemReq) ProtoReflect() protoreflect.Message { + mi := &file_pack_msg_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UseItemReq.ProtoReflect.Descriptor instead. +func (*UseItemReq) Descriptor() ([]byte, []int) { + return file_pack_msg_proto_rawDescGZIP(), []int{3} +} + +func (x *UseItemReq) GetItemId() uint32 { + if x != nil { + return x.ItemId + } + return 0 +} + +func (x *UseItemReq) GetAmount() uint32 { + if x != nil { + return x.Amount + } + return 0 +} + +//使用物品请求 回应 +type UseItemResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` +} + +func (x *UseItemResp) Reset() { + *x = UseItemResp{} + if protoimpl.UnsafeEnabled { + mi := &file_pack_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UseItemResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UseItemResp) ProtoMessage() {} + +func (x *UseItemResp) ProtoReflect() protoreflect.Message { + mi := &file_pack_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UseItemResp.ProtoReflect.Descriptor instead. +func (*UseItemResp) Descriptor() ([]byte, []int) { + return file_pack_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *UseItemResp) GetCode() ErrorCode { + if x != nil { + return x.Code + } + return ErrorCode_Success +} + +//出售道具请求 +type SellItemReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"` + Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"` +} + +func (x *SellItemReq) Reset() { + *x = SellItemReq{} + if protoimpl.UnsafeEnabled { + mi := &file_pack_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SellItemReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SellItemReq) ProtoMessage() {} + +func (x *SellItemReq) ProtoReflect() protoreflect.Message { + mi := &file_pack_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SellItemReq.ProtoReflect.Descriptor instead. +func (*SellItemReq) Descriptor() ([]byte, []int) { + return file_pack_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *SellItemReq) GetItemId() uint32 { + if x != nil { + return x.ItemId + } + return 0 +} + +func (x *SellItemReq) GetAmount() uint32 { + if x != nil { + return x.Amount + } + return 0 +} + +//出售道具请求 回应 +type SellItemResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` +} + +func (x *SellItemResp) Reset() { + *x = SellItemResp{} + if protoimpl.UnsafeEnabled { + mi := &file_pack_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SellItemResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SellItemResp) ProtoMessage() {} + +func (x *SellItemResp) ProtoReflect() protoreflect.Message { + mi := &file_pack_msg_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SellItemResp.ProtoReflect.Descriptor instead. +func (*SellItemResp) Descriptor() ([]byte, []int) { + return file_pack_msg_proto_rawDescGZIP(), []int{6} +} + +func (x *SellItemResp) GetCode() ErrorCode { + if x != nil { + return x.Code + } + return ErrorCode_Success +} + var File_pack_msg_proto protoreflect.FileDescriptor var file_pack_msg_proto_rawDesc = []byte{ @@ -208,8 +416,21 @@ var file_pack_msg_proto_rawDesc = []byte{ 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 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, + 0x73, 0x22, 0x3c, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, + 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x2d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, + 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x3d, + 0x0a, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, + 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, + 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2e, 0x0a, + 0x0c, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, + 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -224,23 +445,29 @@ func file_pack_msg_proto_rawDescGZIP() []byte { return file_pack_msg_proto_rawDescData } -var file_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_pack_msg_proto_goTypes = []interface{}{ (*ItemAmount)(nil), // 0: ItemAmount (*QueryUserPackReq)(nil), // 1: QueryUserPackReq (*QueryUserPackResp)(nil), // 2: QueryUserPackResp - (ItemType)(0), // 3: ItemType - (ErrorCode)(0), // 4: ErrorCode + (*UseItemReq)(nil), // 3: UseItemReq + (*UseItemResp)(nil), // 4: UseItemResp + (*SellItemReq)(nil), // 5: SellItemReq + (*SellItemResp)(nil), // 6: SellItemResp + (ItemType)(0), // 7: ItemType + (ErrorCode)(0), // 8: ErrorCode } var file_pack_msg_proto_depIdxs = []int32{ - 3, // 0: QueryUserPackReq.IType:type_name -> ItemType - 4, // 1: QueryUserPackResp.Code:type_name -> ErrorCode + 7, // 0: QueryUserPackReq.IType:type_name -> ItemType + 8, // 1: QueryUserPackResp.Code:type_name -> ErrorCode 0, // 2: QueryUserPackResp.Items:type_name -> ItemAmount - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 8, // 3: UseItemResp.Code:type_name -> ErrorCode + 8, // 4: SellItemResp.Code:type_name -> ErrorCode + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_pack_msg_proto_init() } @@ -287,6 +514,54 @@ func file_pack_msg_proto_init() { return nil } } + file_pack_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UseItemReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pack_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UseItemResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pack_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SellItemReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_pack_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SellItemResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -294,7 +569,7 @@ func file_pack_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_pack_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index 5c9efaa36..97acdf7a8 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -1,5 +1,6 @@ syntax = "proto3"; option go_package = ".;pb"; +import "errorcode.proto"; //用户消息流结构 message UserMessage { @@ -19,7 +20,7 @@ message AgentMessage { //RPC 服务固定回复结构 message RPCMessageReply { - int32 Code = 1; + ErrorCode Code = 1; string Msg = 2; } @@ -37,7 +38,8 @@ message AgentUnBuildReq { message AgentSendMessageReq { string UserSessionId = 1; string ServiceMethod = 2; //服务名 - bytes Data = 3; + ErrorCode Code = 3; + bytes Data = 4; } //发送批量消息 diff --git a/pb/proto/pack_msg.proto b/pb/proto/pack_msg.proto index 209b70606..a43bd94d1 100644 --- a/pb/proto/pack_msg.proto +++ b/pb/proto/pack_msg.proto @@ -20,3 +20,25 @@ message QueryUserPackResp { ErrorCode Code = 1; repeated ItemAmount Items = 2; } + +//使用物品请求 +message UseItemReq { + uint32 ItemId = 2; + uint32 Amount = 3; +} + +//使用物品请求 回应 +message UseItemResp { + ErrorCode Code = 1; +} + +//出售道具请求 +message SellItemReq { + uint32 ItemId = 2; + uint32 Amount = 3; +} + +//出售道具请求 回应 +message SellItemResp { + ErrorCode Code = 1; +} \ No newline at end of file diff --git a/pb/unitls.go b/pb/unitls.go new file mode 100644 index 000000000..a3b526dbc --- /dev/null +++ b/pb/unitls.go @@ -0,0 +1,22 @@ +package pb + +var ErrorCodeMsg = map[ErrorCode]string{ + ErrorCode_Success: "成功", + ErrorCode_NoFindService: "没有找到远程服务器", + ErrorCode_RpcFuncExecutionError: "Rpc方法执行错误", + ErrorCode_CacheReadError: "缓存读取失败", + ErrorCode_SqlExecutionError: "数据库执行错误", + ErrorCode_ReqParameterError: "请求参数错误", + ErrorCode_SignError: "签名错误", + ErrorCode_InsufficientPermissions: "权限不足", + ErrorCode_NoLogin: "未登录", + ErrorCode_UserSessionNobeing: "用户不存在", +} + +func GetErrorCodeMsg(code ErrorCode) string { + if v, ok := ErrorCodeMsg[code]; ok { + return v + } else { + return "未描述" + } +} From 81f1c47c05e521ef83d2009d9a046c4b3b701d59 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Mon, 6 Jun 2022 18:50:12 +0800 Subject: [PATCH 3/5] update sendmsg params --- modules/pack/api_comp.go | 2 +- services/worker/main.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/pack/api_comp.go b/modules/pack/api_comp.go index 7de34f37a..e57721f7d 100644 --- a/modules/pack/api_comp.go +++ b/modules/pack/api_comp.go @@ -35,7 +35,7 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe items []*pb.ItemAmount ) defer func() { - session.SendMsg(QueryUserPackResp, &pb.QueryUserPackResp{Code: code, Items: items}) + session.SendMsg("pack", "queryuserpackresp", &pb.QueryUserPackResp{Code: code, Items: items}) }() if session.GetUserId() == 0 { code = pb.ErrorCode_NoLogin diff --git a/services/worker/main.go b/services/worker/main.go index fda63a1c1..4e7bd9961 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -3,8 +3,8 @@ package main import ( "flag" "fmt" - "go_dreamfactory/modules/login" "go_dreamfactory/modules/pack" + "go_dreamfactory/modules/user" "go_dreamfactory/services" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/db" @@ -30,7 +30,7 @@ func main() { ) lego.Run(s, //运行模块 // web.NewModule(), - login.NewModule(), + user.NewModule(), pack.NewModule(), ) From 8e8efe12d26c2894eeffd133ffc82a628f6fc898 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 6 Jun 2022 19:33:51 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/robot.go | 4 +- comm/core.go | 2 +- comm/usersession.go | 3 +- modules/gateway/agentmgr_comp.go | 1 + modules/pack/api_comp.go | 6 +- modules/user/login_comp.go | 3 +- modules/web/api_comp.go | 7 +- pb/comm.pb.go | 168 +++++++++----------------- pb/pack_msg.pb.go | 100 +++++----------- pb/proto/comm.proto | 6 +- pb/proto/pack_msg.proto | 8 +- pb/proto/user_msg.proto | 6 +- pb/user_msg.pb.go | 199 +++++++++++++++++++++++++------ services/comp_gateroute.go | 4 +- services/worker/main.go | 4 +- 15 files changed, 281 insertions(+), 240 deletions(-) diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 0b117f89a..bc4ff8de3 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -74,7 +74,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) { } func (r *Robot) onUserLoaded() { - + } func (r *Robot) SendToClient(data []byte) error { @@ -102,7 +102,7 @@ func (r *Robot) AccountRegister() { regRsp := &pb.UserRegisterRsp{} err = jsoniter.Unmarshal(body, regRsp) - if regRsp.Code == int32(pb.ErrorCode_Success) { //注册成功 + if regRsp.Code == pb.ErrorCode_Success { //注册成功 //登录 loginReg := &pb.UserLoginReq{ Name: regReq.Account, diff --git a/comm/core.go b/comm/core.go index 9c1bc8ea6..cf2eab281 100644 --- a/comm/core.go +++ b/comm/core.go @@ -43,7 +43,7 @@ type IUserSession interface { GetGatewayServiceId() string Build(uid uint32) (err error) UnBuild(ServiceMethod string, msg proto.Message) (err error) - SendMsg(mainType, subType string, msg proto.Message) (err error) + SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) Close() (err error) ToString() string } diff --git a/comm/usersession.go b/comm/usersession.go index 13c07b350..7f27e04c7 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -63,7 +63,7 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e return } -func (this *UserSession) SendMsg(mainType, subType string, msg proto.Message) (err error) { +func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) { reply := &pb.RPCMessageReply{} data, _ := proto.Marshal(msg) log.Debugf("SendMsg Data: %v", msg) @@ -71,6 +71,7 @@ func (this *UserSession) SendMsg(mainType, subType string, msg proto.Message) (e UserSessionId: this.SessionId, MainType: mainType, SubType: subType, + Code: code, Data: data, }, reply); err != nil { log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err) diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index 53744e8fd..5c6043111 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -54,6 +54,7 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen a.(IAgent).WriteMsg(&pb.UserMessage{ MainType: args.MainType, SubType: args.SubType, + Code: args.Code, Data: args.Data, }) } else { diff --git a/modules/pack/api_comp.go b/modules/pack/api_comp.go index 5e3de0f7b..d1de91c90 100644 --- a/modules/pack/api_comp.go +++ b/modules/pack/api_comp.go @@ -39,7 +39,7 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe items []*pb.ItemAmount ) defer func() { - session.SendMsg(QueryUserPackResp, &pb.QueryUserPackResp{Code: code, Items: items}) + session.SendMsg(string(this.module.GetType()), QueryUserPackResp, code, &pb.QueryUserPackResp{Items: items}) }() if session.GetUserId() == 0 { code = pb.ErrorCode_NoLogin @@ -66,7 +66,7 @@ func (this *Api_Comp) UseItemReq(ctx context.Context, session comm.IUserSession, code pb.ErrorCode ) defer func() { - session.SendMsg(UseItemResp, &pb.UseItemResp{Code: code}) + session.SendMsg(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{}) }() if session.GetUserId() == 0 { code = pb.ErrorCode_NoLogin @@ -82,7 +82,7 @@ func (this *Api_Comp) SellItemReq(ctx context.Context, session comm.IUserSession code pb.ErrorCode ) defer func() { - session.SendMsg(SellItemResp, &pb.SellItemResp{Code: code}) + session.SendMsg(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{}) }() if session.GetUserId() == 0 { code = pb.ErrorCode_NoLogin diff --git a/modules/user/login_comp.go b/modules/user/login_comp.go index eca7fde70..7cad5c595 100644 --- a/modules/user/login_comp.go +++ b/modules/user/login_comp.go @@ -47,8 +47,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req return err } - session.SendMsg("login", "login", &pb.UserLoginResp{ - Code: comm.ErrorCode_Success, + session.SendMsg("login", "login", pb.ErrorCode_Success, &pb.UserLoginResp{ Data: &pb.Cache_UserData{ UserData: &pb.DB_UserData{ UserId: db_user.UserId, diff --git a/modules/web/api_comp.go b/modules/web/api_comp.go index 2f9fa9334..b41c68dc4 100644 --- a/modules/web/api_comp.go +++ b/modules/web/api_comp.go @@ -1,7 +1,6 @@ package web import ( - "go_dreamfactory/comm" "go_dreamfactory/pb" "go_dreamfactory/sys/db" "net/http" @@ -39,11 +38,11 @@ func (this *Api_Comp) Register(c *engine.Context) { }) if err != nil { log.Errorf("create user err: %v", err) - rsp.Code = comm.ErrorCode_SqlExecutionError + rsp.Code = pb.ErrorCode_SqlExecutionError } - rsp.Code = comm.ErrorCode_Success + rsp.Code = pb.ErrorCode_Success } else { - rsp.Code = comm.ErrorCode_ReqParameterError + rsp.Code = pb.ErrorCode_ReqParameterError } c.JSON(http.StatusOK, rsp) } diff --git a/pb/comm.pb.go b/pb/comm.pb.go index d5244c87f..d6ace1697 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -26,9 +26,10 @@ type UserMessage struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` - SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"` + MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` + SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"` + Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *UserMessage) Reset() { @@ -77,6 +78,13 @@ func (x *UserMessage) GetSubType() string { return "" } +func (x *UserMessage) GetCode() ErrorCode { + if x != nil { + return x.Code + } + return ErrorCode_Success +} + func (x *UserMessage) GetData() []byte { if x != nil { return x.Data @@ -338,17 +346,11 @@ type AgentSendMessageReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields -<<<<<<< HEAD UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` - ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 - Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` - Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` -======= - UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` - MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"` - SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"` - Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"` ->>>>>>> 13ef42edcc8224c366e5fe7b0451996de0e346d1 + MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"` + SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"` + Code ErrorCode `protobuf:"varint,4,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` + Data []byte `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data,omitempty"` } func (x *AgentSendMessageReq) Reset() { @@ -605,13 +607,15 @@ func (x *AgentCloseeReq) GetUserSessionId() string { var File_comm_proto protoreflect.FileDescriptor var file_comm_proto_rawDesc = []byte{ -<<<<<<< HEAD 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, - 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, + 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a, + 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, + 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, + 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, @@ -637,93 +641,36 @@ var file_comm_proto_rawDesc = []byte{ 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x22, 0x95, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, + 0x22, 0xa5, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x24, - 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, + 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, - 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61, 0x74, 0x63, - 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, 0x55, - 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x4f, 0x0a, - 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, - 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x36, - 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, 0x71, - 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -======= - 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0b, - 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x4d, - 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, - 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, - 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, - 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, - 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, - 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, - 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, - 0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, - 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, - 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, - 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x49, 0x64, 0x22, 0x85, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, - 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, - 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, - 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 0x0a, 0x0f, - 0x42, 0x61, 0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, - 0x26, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, - 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x22, 0x5f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, - 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, - 0x74, 0x61, 0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, - 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, - 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, ->>>>>>> 13ef42edcc8224c366e5fe7b0451996de0e346d1 + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x83, 0x01, 0x0a, 0x0f, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0e, + 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x49, 0x64, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, + 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x5f, + 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, + 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, + 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65, + 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -752,13 +699,14 @@ var file_comm_proto_goTypes = []interface{}{ (ErrorCode)(0), // 9: ErrorCode } var file_comm_proto_depIdxs = []int32{ - 9, // 0: RPCMessageReply.Code:type_name -> ErrorCode - 9, // 1: AgentSendMessageReq.Code:type_name -> ErrorCode - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 9, // 0: UserMessage.Code:type_name -> ErrorCode + 9, // 1: RPCMessageReply.Code:type_name -> ErrorCode + 9, // 2: AgentSendMessageReq.Code:type_name -> ErrorCode + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_comm_proto_init() } diff --git a/pb/pack_msg.pb.go b/pb/pack_msg.pb.go index bff6f1463..c84a69c20 100644 --- a/pb/pack_msg.pb.go +++ b/pb/pack_msg.pb.go @@ -138,8 +138,7 @@ type QueryUserPackResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` - Items []*ItemAmount `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items,omitempty"` + Items []*ItemAmount `protobuf:"bytes,1,rep,name=Items,proto3" json:"Items,omitempty"` } func (x *QueryUserPackResp) Reset() { @@ -174,13 +173,6 @@ func (*QueryUserPackResp) Descriptor() ([]byte, []int) { return file_pack_msg_proto_rawDescGZIP(), []int{2} } -func (x *QueryUserPackResp) GetCode() ErrorCode { - if x != nil { - return x.Code - } - return ErrorCode_Success -} - func (x *QueryUserPackResp) GetItems() []*ItemAmount { if x != nil { return x.Items @@ -249,8 +241,6 @@ type UseItemResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` } func (x *UseItemResp) Reset() { @@ -285,13 +275,6 @@ func (*UseItemResp) Descriptor() ([]byte, []int) { return file_pack_msg_proto_rawDescGZIP(), []int{4} } -func (x *UseItemResp) GetCode() ErrorCode { - if x != nil { - return x.Code - } - return ErrorCode_Success -} - //出售道具请求 type SellItemReq struct { state protoimpl.MessageState @@ -353,8 +336,6 @@ type SellItemResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` } func (x *SellItemResp) Reset() { @@ -389,48 +370,34 @@ func (*SellItemResp) Descriptor() ([]byte, []int) { return file_pack_msg_proto_rawDescGZIP(), []int{6} } -func (x *SellItemResp) GetCode() ErrorCode { - if x != nil { - return x.Code - } - return ErrorCode_Success -} - var File_pack_msg_proto protoreflect.FileDescriptor var file_pack_msg_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x52, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, - 0x73, 0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, - 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, - 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x56, 0x0a, 0x11, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, - 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x21, - 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, - 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, - 0x73, 0x22, 0x3c, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, - 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x2d, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, - 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x3d, - 0x0a, 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, - 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, - 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x2e, 0x0a, - 0x0c, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, - 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, - 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x52, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, + 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, 0x73, + 0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, + 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, + 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x36, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, + 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x49, + 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, + 0x22, 0x3c, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, + 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, + 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0d, + 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x3d, 0x0a, + 0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, + 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, + 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c, + 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -455,19 +422,15 @@ var file_pack_msg_proto_goTypes = []interface{}{ (*SellItemReq)(nil), // 5: SellItemReq (*SellItemResp)(nil), // 6: SellItemResp (ItemType)(0), // 7: ItemType - (ErrorCode)(0), // 8: ErrorCode } var file_pack_msg_proto_depIdxs = []int32{ 7, // 0: QueryUserPackReq.IType:type_name -> ItemType - 8, // 1: QueryUserPackResp.Code:type_name -> ErrorCode - 0, // 2: QueryUserPackResp.Items:type_name -> ItemAmount - 8, // 3: UseItemResp.Code:type_name -> ErrorCode - 8, // 4: SellItemResp.Code:type_name -> ErrorCode - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 0, // 1: QueryUserPackResp.Items:type_name -> ItemAmount + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_pack_msg_proto_init() } @@ -475,7 +438,6 @@ func file_pack_msg_proto_init() { if File_pack_msg_proto != nil { return } - file_errorcode_proto_init() file_pack_db_proto_init() if !protoimpl.UnsafeEnabled { file_pack_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index 3e08bce92..07aa9a060 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -6,7 +6,8 @@ import "errorcode.proto"; message UserMessage { string MainType =1; string SubType = 2; - bytes Data = 3; + ErrorCode Code = 3; + bytes Data = 4; } //代理用户转发消息结构 @@ -40,7 +41,8 @@ message AgentSendMessageReq { string UserSessionId = 1; string MainType = 2; string SubType = 3; - bytes Data = 4; + ErrorCode Code = 4; + bytes Data = 5; } //发送批量消息 diff --git a/pb/proto/pack_msg.proto b/pb/proto/pack_msg.proto index a43bd94d1..cf7b4661e 100644 --- a/pb/proto/pack_msg.proto +++ b/pb/proto/pack_msg.proto @@ -1,6 +1,5 @@ syntax = "proto3"; option go_package = ".;pb"; -import "errorcode.proto"; import "pack_db.proto"; //物品数量 @@ -17,8 +16,7 @@ message QueryUserPackReq { //查询用户背包请求 回应 message QueryUserPackResp { - ErrorCode Code = 1; - repeated ItemAmount Items = 2; + repeated ItemAmount Items = 1; } //使用物品请求 @@ -29,7 +27,7 @@ message UseItemReq { //使用物品请求 回应 message UseItemResp { - ErrorCode Code = 1; + } //出售道具请求 @@ -40,5 +38,5 @@ message SellItemReq { //出售道具请求 回应 message SellItemResp { - ErrorCode Code = 1; + } \ No newline at end of file diff --git a/pb/proto/user_msg.proto b/pb/proto/user_msg.proto index 76b03d3eb..5e21e3a72 100644 --- a/pb/proto/user_msg.proto +++ b/pb/proto/user_msg.proto @@ -1,6 +1,6 @@ syntax = "proto3"; option go_package = ".;pb"; - +import "errorcode.proto"; import "user_db.proto"; message UserLoginReq { @@ -8,7 +8,7 @@ message UserLoginReq { } message UserLoginResp { - int32 Code = 1; + ErrorCode Code = 1; Cache_UserData data = 2; } @@ -18,7 +18,7 @@ message UserRegisterReq{ } message UserRegisterRsp{ - int32 Code = 1; + ErrorCode Code = 1; } message UserLoadRsp { diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index ecf0e49fd..d2e7e851e 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -72,7 +72,7 @@ type UserLoginResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` Data *Cache_UserData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } @@ -108,11 +108,11 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) { return file_user_msg_proto_rawDescGZIP(), []int{1} } -func (x *UserLoginResp) GetCode() int32 { +func (x *UserLoginResp) GetCode() ErrorCode { if x != nil { return x.Code } - return 0 + return ErrorCode_Success } func (x *UserLoginResp) GetData() *Cache_UserData { @@ -174,7 +174,7 @@ type UserRegisterRsp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"` + Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` } func (x *UserRegisterRsp) Reset() { @@ -209,11 +209,11 @@ func (*UserRegisterRsp) Descriptor() ([]byte, []int) { return file_user_msg_proto_rawDescGZIP(), []int{3} } -func (x *UserRegisterRsp) GetCode() int32 { +func (x *UserRegisterRsp) GetCode() ErrorCode { if x != nil { return x.Code } - return 0 + return ErrorCode_Success } type UserLoadRsp struct { @@ -263,28 +263,129 @@ func (x *UserLoadRsp) GetData() *Cache_UserData { return nil } +type UserCreateReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + NickName string `protobuf:"bytes,1,opt,name=NickName,proto3" json:"NickName,omitempty"` //昵称 + Gender int32 `protobuf:"varint,2,opt,name=gender,proto3" json:"gender,omitempty"` //性别 +} + +func (x *UserCreateReq) Reset() { + *x = UserCreateReq{} + if protoimpl.UnsafeEnabled { + mi := &file_user_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserCreateReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserCreateReq) ProtoMessage() {} + +func (x *UserCreateReq) ProtoReflect() protoreflect.Message { + mi := &file_user_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserCreateReq.ProtoReflect.Descriptor instead. +func (*UserCreateReq) Descriptor() ([]byte, []int) { + return file_user_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *UserCreateReq) GetNickName() string { + if x != nil { + return x.NickName + } + return "" +} + +func (x *UserCreateReq) GetGender() int32 { + if x != nil { + return x.Gender + } + return 0 +} + +type UserCreateRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *UserCreateRsp) Reset() { + *x = UserCreateRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_user_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserCreateRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserCreateRsp) ProtoMessage() {} + +func (x *UserCreateRsp) ProtoReflect() protoreflect.Message { + mi := &file_user_msg_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserCreateRsp.ProtoReflect.Descriptor instead. +func (*UserCreateRsp) Descriptor() ([]byte, []int) { + return file_user_msg_proto_rawDescGZIP(), []int{6} +} + var File_user_msg_proto protoreflect.FileDescriptor var file_user_msg_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, - 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, - 0x61, 0x6d, 0x65, 0x22, 0x48, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, - 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, - 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, - 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, - 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, - 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, - 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, + 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x54, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, + 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, + 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, + 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, + 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, + 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, + 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, + 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, + 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -299,23 +400,28 @@ func file_user_msg_proto_rawDescGZIP() []byte { return file_user_msg_proto_rawDescData } -var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_user_msg_proto_goTypes = []interface{}{ (*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginResp)(nil), // 1: UserLoginResp (*UserRegisterReq)(nil), // 2: UserRegisterReq (*UserRegisterRsp)(nil), // 3: UserRegisterRsp (*UserLoadRsp)(nil), // 4: UserLoadRsp - (*Cache_UserData)(nil), // 5: Cache_UserData + (*UserCreateReq)(nil), // 5: UserCreateReq + (*UserCreateRsp)(nil), // 6: UserCreateRsp + (ErrorCode)(0), // 7: ErrorCode + (*Cache_UserData)(nil), // 8: Cache_UserData } var file_user_msg_proto_depIdxs = []int32{ - 5, // 0: UserLoginResp.data:type_name -> Cache_UserData - 5, // 1: UserLoadRsp.data:type_name -> Cache_UserData - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 7, // 0: UserLoginResp.Code:type_name -> ErrorCode + 8, // 1: UserLoginResp.data:type_name -> Cache_UserData + 7, // 2: UserRegisterRsp.Code:type_name -> ErrorCode + 8, // 3: UserLoadRsp.data:type_name -> Cache_UserData + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_user_msg_proto_init() } @@ -323,6 +429,7 @@ func file_user_msg_proto_init() { if File_user_msg_proto != nil { return } + file_errorcode_proto_init() file_user_db_proto_init() if !protoimpl.UnsafeEnabled { file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { @@ -385,6 +492,30 @@ func file_user_msg_proto_init() { return nil } } + file_user_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserCreateReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserCreateRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -392,7 +523,7 @@ func file_user_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_user_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index a8e51f9bb..a84783f8e 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -82,8 +82,8 @@ func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentM } msghandle.fn.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(ctx), reflect.ValueOf(session), reflect.ValueOf(msg)}) } else { - reply.Code = int32(core.ErrorCode_ReqParameterError) - reply.Msg = core.GetErrorCodeMsg(core.ErrorCode_ReqParameterError) + reply.Code = pb.ErrorCode_ReqParameterError + reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_ReqParameterError) } return nil } diff --git a/services/worker/main.go b/services/worker/main.go index fda63a1c1..4e7bd9961 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -3,8 +3,8 @@ package main import ( "flag" "fmt" - "go_dreamfactory/modules/login" "go_dreamfactory/modules/pack" + "go_dreamfactory/modules/user" "go_dreamfactory/services" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/db" @@ -30,7 +30,7 @@ func main() { ) lego.Run(s, //运行模块 // web.NewModule(), - login.NewModule(), + user.NewModule(), pack.NewModule(), ) From 7ada2ce4a4351c1043dc195072c1b10966a3370c Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 7 Jun 2022 09:59:48 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=B8=8A=E4=BC=A0uid=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/user.go | 4 +-- comm/core.go | 15 ++-------- comm/usersession.go | 8 ++--- modules/gateway/agent.go | 10 +++---- modules/gateway/core.go | 4 +-- modules/pack/api_comp.go | 16 +++++----- modules/user/login_comp.go | 2 +- pb/comm.pb.go | 16 +++++----- pb/pack_db.pb.go | 61 ++++++++++++++++---------------------- pb/proto/comm.proto | 4 +-- pb/proto/pack_db.proto | 5 ++-- pb/proto/user_db.proto | 2 +- pb/user_db.pb.go | 8 ++--- sys/cache/pack.go | 6 ++-- sys/cache/user.go | 2 +- sys/cache/user_test.go | 3 +- sys/db/db.go | 1 - sys/db/pack.go | 4 +-- sys/db/user.go | 61 +++++--------------------------------- sys/db/user_test.go | 5 ++-- 20 files changed, 85 insertions(+), 152 deletions(-) diff --git a/cmd/robot/user.go b/cmd/robot/user.go index ced98e66f..cc4dd1b75 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -23,7 +23,7 @@ func (r *Robot) handleUserMsg(msg *pb.UserMessage) { log.Fatal("load user err") } - if rsp.Data.UserData.UserId != 0 { + if rsp.Data.UserData.UserId != "" { r.onUserLoaded() } else { log.Debugf("%s不存在", r.Opts.Account) @@ -35,5 +35,5 @@ func (r *Robot) handleUserMsg(msg *pb.UserMessage) { } func (r *Robot) CreateUser() { - + } diff --git a/comm/core.go b/comm/core.go index cf2eab281..88a10e89e 100644 --- a/comm/core.go +++ b/comm/core.go @@ -38,27 +38,16 @@ type ISC_GateRouteComp interface { //用户会话 type IUserSession interface { GetSessionId() string - GetUserId() uint32 + GetUserId() string GetIP() string GetGatewayServiceId() string - Build(uid uint32) (err error) + Build(uid string) (err error) UnBuild(ServiceMethod string, msg proto.Message) (err error) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) Close() (err error) ToString() string } -//消息体 -type MessageHead struct { - ServiceMethod string //服务名 -} - -//处理JSON消息 -type Message struct { - Head *MessageHead - Data []byte -} - func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) { err := proto.Unmarshal(msg.Data, req) if err != nil { diff --git a/comm/usersession.go b/comm/usersession.go index 7f27e04c7..44a961e51 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -10,7 +10,7 @@ import ( "google.golang.org/protobuf/proto" ) -func NewUserSession(service base.IRPCXService, ip, sessionId, gatewayServiceId string, uid uint32) IUserSession { +func NewUserSession(service base.IRPCXService, ip, sessionId, gatewayServiceId string, uid string) IUserSession { return &UserSession{ IP: ip, SessionId: sessionId, @@ -24,7 +24,7 @@ type UserSession struct { IP string SessionId string GatewayServiceId string //用户所在网关服务 - UserId uint32 + UserId string service base.IRPCXService } @@ -32,7 +32,7 @@ func (this *UserSession) GetSessionId() string { return this.SessionId } -func (this *UserSession) GetUserId() uint32 { +func (this *UserSession) GetUserId() string { return this.UserId } func (this *UserSession) GetIP() string { @@ -42,7 +42,7 @@ func (this *UserSession) GetGatewayServiceId() string { return this.GatewayServiceId } -func (this *UserSession) Build(uid uint32) (err error) { +func (this *UserSession) Build(uid string) (err error) { reply := &pb.RPCMessageReply{} if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentBuild), context.Background(), &pb.AgentBuildReq{ UserSessionId: this.SessionId, diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index bc79f4c86..ac7ca93f2 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -19,7 +19,7 @@ func newAgent(gateway IGateway, conn *websocket.Conn) *Agent { gateway: gateway, wsConn: conn, sessionId: id.NewUUId(), - uId: 0, + uId: "", writeChan: make(chan *pb.UserMessage, 2), closeSignal: make(chan bool), state: 1, @@ -35,7 +35,7 @@ type Agent struct { gateway IGateway wsConn *websocket.Conn sessionId string - uId uint32 + uId string writeChan chan *pb.UserMessage closeSignal chan bool state int32 //状态 0 关闭 1 运行 2 关闭中 @@ -100,16 +100,16 @@ func (this *Agent) SessionId() string { func (this *Agent) IP() string { return this.wsConn.RemoteAddr().String() } -func (this *Agent) UserId() uint32 { +func (this *Agent) UserId() string { return this.uId } -func (this *Agent) Build(uId uint32) { +func (this *Agent) Build(uId string) { this.uId = uId } func (this *Agent) UnBuild() { - this.uId = 0 + this.uId = "" } func (this *Agent) WriteMsg(msg *pb.UserMessage) (err error) { diff --git a/modules/gateway/core.go b/modules/gateway/core.go index 566c19d29..c0313200c 100644 --- a/modules/gateway/core.go +++ b/modules/gateway/core.go @@ -11,8 +11,8 @@ type ( IAgent interface { SessionId() string IP() string - UserId() uint32 - Build(uId uint32) + UserId() string + Build(uId string) UnBuild() WriteMsg(msg *pb.UserMessage) (err error) Close() //主动关闭接口 diff --git a/modules/pack/api_comp.go b/modules/pack/api_comp.go index d1de91c90..434bf8518 100644 --- a/modules/pack/api_comp.go +++ b/modules/pack/api_comp.go @@ -41,7 +41,7 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe defer func() { session.SendMsg(string(this.module.GetType()), QueryUserPackResp, code, &pb.QueryUserPackResp{Items: items}) }() - if session.GetUserId() == 0 { + if session.GetUserId() == "" { code = pb.ErrorCode_NoLogin return } @@ -51,11 +51,11 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe return } else { items = make([]*pb.ItemAmount, 0, len(pack.Pack)) - for _, v := range pack.Pack { - if v.Itype == req.IType { - items = append(items, &pb.ItemAmount{IsNew: v.IsNew, ItemId: v.ItemId, Amount: v.Amount}) - } - } + // for _, v := range pack.Pack { + // if v.Itype == req.IType { + // items = append(items, &pb.ItemAmount{IsNew: v.IsNew, ItemId: v.ItemId, Amount: v.Amount}) + // } + // } } return } @@ -68,7 +68,7 @@ func (this *Api_Comp) UseItemReq(ctx context.Context, session comm.IUserSession, defer func() { session.SendMsg(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{}) }() - if session.GetUserId() == 0 { + if session.GetUserId() == "" { code = pb.ErrorCode_NoLogin return } @@ -84,7 +84,7 @@ func (this *Api_Comp) SellItemReq(ctx context.Context, session comm.IUserSession defer func() { session.SendMsg(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{}) }() - if session.GetUserId() == 0 { + if session.GetUserId() == "" { code = pb.ErrorCode_NoLogin return } diff --git a/modules/user/login_comp.go b/modules/user/login_comp.go index 7cad5c595..6257bf40d 100644 --- a/modules/user/login_comp.go +++ b/modules/user/login_comp.go @@ -27,7 +27,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req } } - if db_user.UserId == 0 { + if db_user.UserId == "" { db_user.Account = req.Name err = db.Defsys.User_CreateUser(db_user) if err != nil { diff --git a/pb/comm.pb.go b/pb/comm.pb.go index d6ace1697..d1ce2baff 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -100,7 +100,7 @@ type AgentMessage struct { Ip string `protobuf:"bytes,1,opt,name=Ip,proto3" json:"Ip,omitempty"` UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` - UserId uint32 `protobuf:"varint,3,opt,name=UserId,proto3" json:"UserId,omitempty"` + UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId,omitempty"` GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId,omitempty"` Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method,omitempty"` Message []byte `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message,omitempty"` @@ -152,11 +152,11 @@ func (x *AgentMessage) GetUserSessionId() string { return "" } -func (x *AgentMessage) GetUserId() uint32 { +func (x *AgentMessage) GetUserId() string { if x != nil { return x.UserId } - return 0 + return "" } func (x *AgentMessage) GetGatewayServiceId() string { @@ -243,7 +243,7 @@ type AgentBuildReq struct { unknownFields protoimpl.UnknownFields UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` - UserId uint32 `protobuf:"varint,2,opt,name=UserId,proto3" json:"UserId,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"` } func (x *AgentBuildReq) Reset() { @@ -285,11 +285,11 @@ func (x *AgentBuildReq) GetUserSessionId() string { return "" } -func (x *AgentBuildReq) GetUserId() uint32 { +func (x *AgentBuildReq) GetUserId() string { if x != nil { return x.UserId } - return 0 + return "" } //用户代理解绑请求 @@ -621,7 +621,7 @@ var file_comm_proto_rawDesc = []byte{ 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, - 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, + 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, @@ -636,7 +636,7 @@ var file_comm_proto_rawDesc = []byte{ 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, - 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, diff --git a/pb/pack_db.pb.go b/pb/pack_db.pb.go index b9aa2f991..6dd9577bf 100644 --- a/pb/pack_db.pb.go +++ b/pb/pack_db.pb.go @@ -75,10 +75,9 @@ type GridData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IsNew bool `protobuf:"varint,1,opt,name=IsNew,proto3" json:"IsNew,omitempty"` //是否是新的 - ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id - Itype ItemType `protobuf:"varint,3,opt,name=Itype,proto3,enum=ItemType" json:"Itype,omitempty"` //物品类型 - Amount uint32 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量 + IsNew bool `protobuf:"varint,1,opt,name=IsNew,proto3" json:"IsNew,omitempty"` //是否是新的 + ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id + Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量 } func (x *GridData) Reset() { @@ -127,13 +126,6 @@ func (x *GridData) GetItemId() uint32 { return 0 } -func (x *GridData) GetItype() ItemType { - if x != nil { - return x.Itype - } - return ItemType_Props -} - func (x *GridData) GetAmount() uint32 { if x != nil { return x.Amount @@ -147,8 +139,8 @@ type DB_UserPackData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId uint32 `protobuf:"varint,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id - Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表 + UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id + Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表 } func (x *DB_UserPackData) Reset() { @@ -183,11 +175,11 @@ func (*DB_UserPackData) Descriptor() ([]byte, []int) { return file_pack_db_proto_rawDescGZIP(), []int{1} } -func (x *DB_UserPackData) GetUserId() uint32 { +func (x *DB_UserPackData) GetUserId() string { if x != nil { return x.UserId } - return 0 + return "" } func (x *DB_UserPackData) GetPack() []*GridData { @@ -201,22 +193,20 @@ var File_pack_db_proto protoreflect.FileDescriptor var file_pack_db_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x71, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x49, + 0x50, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, - 0x79, 0x70, 0x65, 0x52, 0x05, 0x49, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, - 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, - 0x04, 0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x47, 0x72, - 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x2a, 0x2e, 0x0a, 0x08, - 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x70, - 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x71, 0x75, 0x69, 0x70, 0x10, 0x02, 0x12, 0x0c, - 0x0a, 0x08, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, + 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x04, + 0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x47, 0x72, 0x69, + 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x2a, 0x2e, 0x0a, 0x08, 0x49, + 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x70, 0x73, + 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x71, 0x75, 0x69, 0x70, 0x10, 0x02, 0x12, 0x0c, 0x0a, + 0x08, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -239,13 +229,12 @@ var file_pack_db_proto_goTypes = []interface{}{ (*DB_UserPackData)(nil), // 2: DB_UserPackData } var file_pack_db_proto_depIdxs = []int32{ - 0, // 0: GridData.Itype:type_name -> ItemType - 1, // 1: DB_UserPackData.Pack:type_name -> GridData - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 1, // 0: DB_UserPackData.Pack:type_name -> GridData + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_pack_db_proto_init() } diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index 07aa9a060..c32a58ad2 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -14,7 +14,7 @@ message UserMessage { message AgentMessage { string Ip = 1; string UserSessionId = 2; - uint32 UserId = 3; + string UserId = 3; string GatewayServiceId = 4; string Method = 5; bytes Message = 6; @@ -29,7 +29,7 @@ message RPCMessageReply { //用户代理绑定Uid请求 message AgentBuildReq { string UserSessionId = 1; - uint32 UserId = 2; + string UserId = 2; } //用户代理解绑请求 message AgentUnBuildReq { diff --git a/pb/proto/pack_db.proto b/pb/proto/pack_db.proto index 92d570ce7..1f144c70e 100644 --- a/pb/proto/pack_db.proto +++ b/pb/proto/pack_db.proto @@ -11,12 +11,11 @@ enum ItemType { message GridData { bool IsNew = 1; //是否是新的 uint32 ItemId = 2; //存放物品的Id - ItemType Itype = 3; //物品类型 - uint32 Amount = 4; //存放物品的数量 + uint32 Amount = 3; //存放物品的数量 } //用户背包 message DB_UserPackData { - uint32 UserId = 1; //tags:{bson:"_id"}用户Id + string UserId = 1; //tags:{bson:"_id"}用户Id repeated GridData Pack = 2; //背包列表 } \ No newline at end of file diff --git a/pb/proto/user_db.proto b/pb/proto/user_db.proto index 2276b00f7..7a239c802 100644 --- a/pb/proto/user_db.proto +++ b/pb/proto/user_db.proto @@ -8,7 +8,7 @@ message Cache_UserData { } message DB_UserData { - uint32 UserId = 1; //tags:{bson:"_id"}动态Id + string UserId = 1; //tags:{bson:"_id"}动态Id string account = 2; string NiceName = 3; string Email = 4; diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 136214325..2ce469232 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -88,7 +88,7 @@ type DB_UserData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId uint32 `protobuf:"varint,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id + UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"` @@ -127,11 +127,11 @@ func (*DB_UserData) Descriptor() ([]byte, []int) { return file_user_db_proto_rawDescGZIP(), []int{1} } -func (x *DB_UserData) GetUserId() uint32 { +func (x *DB_UserData) GetUserId() string { if x != nil { return x.UserId } - return 0 + return "" } func (x *DB_UserData) GetAccount() string { @@ -176,7 +176,7 @@ var file_user_db_proto_rawDesc = []byte{ 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, diff --git a/sys/cache/pack.go b/sys/cache/pack.go index f370d7492..8465fa099 100644 --- a/sys/cache/pack.go +++ b/sys/cache/pack.go @@ -10,17 +10,17 @@ import ( ) const ( //Redis - Redis_PackCache string = "pack:%d" + Redis_PackCache string = "pack:%s" ) const () type IPack interface { - QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error) + QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) } ///查询用户背包数据 -func (this *Cache) QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error) { +func (this *Cache) QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) { pack = &pb.DB_UserPackData{ UserId: uId, } diff --git a/sys/cache/user.go b/sys/cache/user.go index 709115789..f2bae78cd 100644 --- a/sys/cache/user.go +++ b/sys/cache/user.go @@ -6,7 +6,7 @@ import ( ) const ( //Redis - Redis_UserCache string = "user:%d" //会话列表 + Redis_UserCache string = "user:%s" //会话列表 ) type IUser interface { diff --git a/sys/cache/user_test.go b/sys/cache/user_test.go index 6f12ddac3..0f2a97533 100644 --- a/sys/cache/user_test.go +++ b/sys/cache/user_test.go @@ -7,6 +7,7 @@ import ( "github.com/liwei1dao/lego/sys/redis" "github.com/stretchr/testify/require" + "go.mongodb.org/mongo-driver/bson/primitive" ) var cache *Cache @@ -28,7 +29,7 @@ func TestUpdateUser(t *testing.T) { SessionId: "1", GatewayServiceId: "work", UserData: &pb.DB_UserData{ - UserId: 1, + UserId: primitive.NewObjectID().Hex(), Account: "aaa", }, } diff --git a/sys/db/db.go b/sys/db/db.go index ff084ef3f..bac81395f 100644 --- a/sys/db/db.go +++ b/sys/db/db.go @@ -22,6 +22,5 @@ func (this *DB) init() (err error) { ); err != nil { return } - err = this.checkUserIdInit() return } diff --git a/sys/db/pack.go b/sys/db/pack.go index 333dd4f34..b50b51f62 100644 --- a/sys/db/pack.go +++ b/sys/db/pack.go @@ -12,11 +12,11 @@ const ( //Redis ) type IPack interface { - QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error) + QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) } ///查询用户背包数据 -func (this *DB) QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error) { +func (this *DB) QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) { pack = &pb.DB_UserPackData{} err = this.mgo.FindOne(DB_PackTable, bson.M{"_id": uId}).Decode(pack) return diff --git a/sys/db/user.go b/sys/db/user.go index 97fbc850b..12b4688d5 100644 --- a/sys/db/user.go +++ b/sys/db/user.go @@ -1,34 +1,25 @@ package db import ( - "context" - "fmt" "go_dreamfactory/pb" - "math/rand" - "time" "github.com/liwei1dao/lego/core" - "github.com/liwei1dao/lego/sys/log" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo/options" ) const ( //Redis - DB_UserTable core.SqlTable = "user" //用户表 - DB_UserIdTable core.SqlTable = "userid" //用户id表 + DB_UserTable core.SqlTable = "user" //用户表 ) type IUser interface { User_FindUserByAccount(account string) (*pb.DB_UserData, error) - User_FindUserById(id uint32) (*pb.DB_UserData, error) + User_FindUserById(id string) (*pb.DB_UserData, error) User_CreateUser(user *pb.DB_UserData) error User_UpdateUser(data *pb.DB_UserData) (err error) } -type UserId struct { - UserId uint32 `bson:"_id"` -} - func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error) { filter := bson.D{ {"account", account}, @@ -39,7 +30,7 @@ func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error) return user, err } -func (this *DB) User_FindUserById(id uint32) (*pb.DB_UserData, error) { +func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) { filter := bson.D{ {"_id", id}, } @@ -49,21 +40,15 @@ func (this *DB) User_FindUserById(id uint32) (*pb.DB_UserData, error) { return user, err } -func (this *DB) User_CreateUser(user *pb.DB_UserData) error { - userId := &UserId{} - err := this.mgo.FindOneAndDelete(DB_UserIdTable, bson.M{}).Decode(userId) - if err != nil { - log.Errorf("find userId err :%v", err) - return err - } - user.UserId = userId.UserId +func (this *DB) User_CreateUser(user *pb.DB_UserData) (err error) { + user.UserId = primitive.NewObjectID().Hex() _, err = this.mgo.InsertOne(DB_UserTable, user) return err } //更新用户数据到DB -func (this *DB) User_UpdateUser(data *pb.DB_UserData) error { - err := this.mgo.FindOneAndUpdate( +func (this *DB) User_UpdateUser(data *pb.DB_UserData) (err error) { + err = this.mgo.FindOneAndUpdate( DB_UserTable, bson.M{"_id": data.UserId}, bson.M{"$set": bson.M{ @@ -74,33 +59,3 @@ func (this *DB) User_UpdateUser(data *pb.DB_UserData) error { ).Decode(data) return err } - -//校验数据库初始化工作是否完成 -func (this *DB) checkUserIdInit() (err error) { - ctx, _ := context.WithTimeout(context.Background(), time.Second*60) - count, err := this.mgo.CountDocuments(DB_UserIdTable, bson.M{}) - if err != nil || count == 0 { - //批量插入数据 - leng := 1000000 - cIds := make([]interface{}, leng) - for i, _ := range cIds { - cIds[i] = 1000000 + i - } - data := make([]interface{}, leng) - r := rand.New(rand.NewSource(time.Now().Unix())) - n := 0 - for _, i := range r.Perm(leng) { - data[n] = bson.M{"_id": i} - n++ - } - var ( - err error - ) - begin := time.Now() - if _, err = this.mgo.InsertManyByCtx(DB_UserIdTable, ctx, data); err != nil { - return fmt.Errorf("checkUserIdInit err=%s", err.Error()) - } - log.Debugf("checkUserIdInit succ time consuming:%v", time.Now().Sub(begin)) - } - return -} diff --git a/sys/db/user_test.go b/sys/db/user_test.go index 6b5134c9f..b0128ad23 100644 --- a/sys/db/user_test.go +++ b/sys/db/user_test.go @@ -9,6 +9,7 @@ import ( "github.com/liwei1dao/lego/sys/mgo" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mongodb.org/mongo-driver/bson/primitive" ) var db *DB @@ -37,7 +38,7 @@ func TestCreate(t *testing.T) { } func TestFindOne(t *testing.T) { - user, err := db.User_FindUserById(1) + user, err := db.User_FindUserById("") require.Nil(t, err) assert.Equal(t, "legu1", user.Account) @@ -49,7 +50,7 @@ func TestFindOne(t *testing.T) { func TestUpdate(t *testing.T) { user := &pb.DB_UserData{ - UserId: 10001, + UserId: primitive.NewObjectID().String(), Email: "new@qq.com", } err := db.User_UpdateUser(user)