Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into meixiongfeng

This commit is contained in:
meixiongfeng 2022-06-07 10:18:15 +08:00
commit fa15d16231
40 changed files with 1036 additions and 445 deletions

View File

@ -44,9 +44,7 @@ var runCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
opts := robot.DefaultOpts() opts := robot.DefaultOpts()
opts.Create = *create opts.Create = *create
if *create {
opts.Account = *account opts.Account = *account
}
r := robot.NewRobot(opts) r := robot.NewRobot(opts)
r.Run() r.Run()

View File

@ -1,38 +1,49 @@
package robot package robot
import ( import (
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"log" "log"
"github.com/golang/protobuf/proto" "google.golang.org/protobuf/proto"
) )
func (r *Robot) handleLogin(methodName string) { func (r *Robot) handleLogin(msg *pb.UserMessage) {
switch methodName { switch msg.SubType {
case "login": case "login":
handleLogin(r) handleLogin(r, msg)
default: default:
log.Fatal("methodName no exist") log.Fatal("methodName no exist")
} }
} }
func handleLogin(r *Robot) { //处理接口响应数据
loginreq := &pb.UserLoginReq{ func handleLogin(r *Robot, msg *pb.UserMessage) {
Name: "aaa", rsp := &pb.UserLoginResp{}
if !comm.ProtoDecode(msg, rsp) {
return
} }
logindata, _ := proto.Marshal(loginreq) log.Printf("to client: %v", rsp.Data)
}
//处理登录请求
func (r *Robot) AccountLogin() {
//登录
loginReg := &pb.UserLoginReq{
Name: r.Opts.Account,
}
head := &pb.UserMessage{ head := &pb.UserMessage{
ServiceMethod: "login.login", MainType: "login",
Data: logindata, SubType: "login",
} }
if comm.ProtoEncode(loginReg, head) {
if comm.ProtoEncode(loginreq, head) { data, _ := proto.Marshal(head)
err := r.SendToClient(head.Data) err := r.SendToClient(data)
if err != nil { if err != nil {
fmt.Printf("err:%v\n", err) log.Fatal(err)
} }
} }
log.Printf("%s login ", r.Opts.Account)
} }

12
cmd/robot/readme.md Normal file
View File

@ -0,0 +1,12 @@
# Robot使用
## 命令行
```sh
#使用已存在的账号测试接口
go run cmd.go run --account yourAccount
```
```sh
#使用新账号测试接口
go run cmd.go run --account newAccount --create true
```

View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
@ -44,11 +43,13 @@ func (r *Robot) Run() {
r.AccountLogin() r.AccountLogin()
} }
//处理响应
go func() {
for { for {
var msg *pb.UserMessage = &pb.UserMessage{} var msg *pb.UserMessage = &pb.UserMessage{}
_, data, err := r.ws.ReadMessage() _, data, err := r.ws.ReadMessage()
if err != nil { if err != nil {
log.Fatal(err) log.Println(err)
} }
if err = proto.Unmarshal(data, msg); err != nil { if err = proto.Unmarshal(data, msg); err != nil {
@ -56,21 +57,26 @@ func (r *Robot) Run() {
} }
r.handleMsg(msg) r.handleMsg(msg)
} }
}()
select {}
} }
func (r *Robot) handleMsg(msg *pb.UserMessage) { func (r *Robot) handleMsg(msg *pb.UserMessage) {
m, f, ok := utils.ParseP(msg.ServiceMethod) switch msg.MainType {
if !ok {
log.Fatal("route error")
}
switch m {
case "login": case "login":
r.handleLogin(f) r.handleLogin(msg)
case "user":
r.handleUserMsg(msg)
default: default:
log.Fatal("module route no exist") log.Fatal("module route no exist")
} }
} }
func (r *Robot) onUserLoaded() {
}
func (r *Robot) SendToClient(data []byte) error { func (r *Robot) SendToClient(data []byte) error {
return r.ws.WriteMessage(websocket.BinaryMessage, data) return r.ws.WriteMessage(websocket.BinaryMessage, data)
} }
@ -96,14 +102,15 @@ func (r *Robot) AccountRegister() {
regRsp := &pb.UserRegisterRsp{} regRsp := &pb.UserRegisterRsp{}
err = jsoniter.Unmarshal(body, regRsp) err = jsoniter.Unmarshal(body, regRsp)
if regRsp.Code == comm.ErrorCode_Success { //注册成功 if regRsp.Code == pb.ErrorCode_Success { //注册成功
//登录 //登录
loginReg := &pb.UserLoginReq{ loginReg := &pb.UserLoginReq{
Name: regReq.Account, Name: regReq.Account,
} }
head := &pb.UserMessage{ head := &pb.UserMessage{
ServiceMethod: "login.login", MainType: "login",
SubType: "login",
} }
if comm.ProtoEncode(loginReg, head) { if comm.ProtoEncode(loginReg, head) {
err = r.SendToClient(head.Data) 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)
}
}
} }

View File

@ -1 +1,39 @@
package robot 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 != "" {
r.onUserLoaded()
} else {
log.Debugf("%s不存在", r.Opts.Account)
//创建
}
}
}
func (r *Robot) CreateUser() {
}

View File

@ -16,7 +16,7 @@ const (
const ( const (
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块
SM_WebModule core.M_Modules = "web" //web模块 SM_WebModule core.M_Modules = "web" //web模块
SM_LoginModule core.M_Modules = "login" //web模块 SM_LoginModule core.M_Modules = "user" //用户模块
SM_PackModule core.M_Modules = "pack" //背包模块 SM_PackModule core.M_Modules = "pack" //背包模块
SM_MailModule core.M_Modules = "mail" //邮件模块 SM_MailModule core.M_Modules = "mail" //邮件模块
) )
@ -39,31 +39,20 @@ type ISC_GateRouteComp interface {
//用户会话 //用户会话
type IUserSession interface { type IUserSession interface {
GetSessionId() string GetSessionId() string
GetUserId() uint32 GetUserId() string
GetIP() string GetIP() string
GetGatewayServiceId() string GetGatewayServiceId() string
Build(uid uint32) (err error) Build(uid string) (err error)
UnBuild(ServiceMethod string, msg proto.Message) (err error) UnBuild(ServiceMethod string, msg proto.Message) (err error)
SendMsg(ServiceMethod string, msg proto.Message) (err error) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error)
Close() (err error) Close() (err error)
ToString() string 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) { func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
err := proto.Unmarshal(msg.Data, req) err := proto.Unmarshal(msg.Data, req)
if err != nil { if err != nil {
log.Errorf("%s %v", msg.ServiceMethod, err) log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
return return
} }
return true return true
@ -72,7 +61,7 @@ func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) { func ProtoEncode(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
data, err := proto.Marshal(rsp) data, err := proto.Marshal(rsp)
if err != nil { if err != nil {
log.Errorf("%s %v", msg.ServiceMethod, err) log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
return return
} }
msg.Data = data msg.Data = data

View File

@ -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 "未描述"
}
}

View File

@ -10,7 +10,7 @@ import (
"google.golang.org/protobuf/proto" "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{ return &UserSession{
IP: ip, IP: ip,
SessionId: sessionId, SessionId: sessionId,
@ -24,7 +24,7 @@ type UserSession struct {
IP string IP string
SessionId string SessionId string
GatewayServiceId string //用户所在网关服务 GatewayServiceId string //用户所在网关服务
UserId uint32 UserId string
service base.IRPCXService service base.IRPCXService
} }
@ -32,7 +32,7 @@ func (this *UserSession) GetSessionId() string {
return this.SessionId return this.SessionId
} }
func (this *UserSession) GetUserId() uint32 { func (this *UserSession) GetUserId() string {
return this.UserId return this.UserId
} }
func (this *UserSession) GetIP() string { func (this *UserSession) GetIP() string {
@ -42,7 +42,7 @@ func (this *UserSession) GetGatewayServiceId() string {
return this.GatewayServiceId return this.GatewayServiceId
} }
func (this *UserSession) Build(uid uint32) (err error) { func (this *UserSession) Build(uid string) (err error) {
reply := &pb.RPCMessageReply{} reply := &pb.RPCMessageReply{}
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentBuild), context.Background(), &pb.AgentBuildReq{ if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentBuild), context.Background(), &pb.AgentBuildReq{
UserSessionId: this.SessionId, UserSessionId: this.SessionId,
@ -63,15 +63,18 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e
return return
} }
func (this *UserSession) SendMsg(ServiceMethod string, msg proto.Message) (err error) { func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) {
reply := &pb.RPCMessageReply{} reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg) data, _ := proto.Marshal(msg)
log.Debugf("SendMsg Data: %v", msg)
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{ if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
UserSessionId: this.SessionId, UserSessionId: this.SessionId,
ServiceMethod: ServiceMethod, MainType: mainType,
SubType: subType,
Code: code,
Data: data, Data: data,
}, reply); err != nil { }, 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 return
} }

View File

@ -10,7 +10,7 @@ import (
type ( type (
IModule interface { IModule interface {
core.IModule core.IModule
SendMsgToUser(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(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
} }
) )

View File

@ -2,6 +2,7 @@ package gateway
import ( import (
"context" "context"
"fmt"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"sync" "sync"
@ -18,7 +19,7 @@ func newAgent(gateway IGateway, conn *websocket.Conn) *Agent {
gateway: gateway, gateway: gateway,
wsConn: conn, wsConn: conn,
sessionId: id.NewUUId(), sessionId: id.NewUUId(),
uId: 0, uId: "",
writeChan: make(chan *pb.UserMessage, 2), writeChan: make(chan *pb.UserMessage, 2),
closeSignal: make(chan bool), closeSignal: make(chan bool),
state: 1, state: 1,
@ -34,7 +35,7 @@ type Agent struct {
gateway IGateway gateway IGateway
wsConn *websocket.Conn wsConn *websocket.Conn
sessionId string sessionId string
uId uint32 uId string
writeChan chan *pb.UserMessage writeChan chan *pb.UserMessage
closeSignal chan bool closeSignal chan bool
state int32 //状态 0 关闭 1 运行 2 关闭中 state int32 //状态 0 关闭 1 运行 2 关闭中
@ -99,16 +100,16 @@ func (this *Agent) SessionId() string {
func (this *Agent) IP() string { func (this *Agent) IP() string {
return this.wsConn.RemoteAddr().String() return this.wsConn.RemoteAddr().String()
} }
func (this *Agent) UserId() uint32 { func (this *Agent) UserId() string {
return this.uId return this.uId
} }
func (this *Agent) Build(uId uint32) { func (this *Agent) Build(uId string) {
this.uId = uId this.uId = uId
} }
func (this *Agent) UnBuild() { func (this *Agent) UnBuild() {
this.uId = 0 this.uId = ""
} }
func (this *Agent) WriteMsg(msg *pb.UserMessage) (err error) { func (this *Agent) WriteMsg(msg *pb.UserMessage) (err error) {
@ -134,13 +135,13 @@ func (this *Agent) Close() {
//分发用户消息 //分发用户消息
func (this *Agent) messageDistribution(msg *pb.UserMessage) { func (this *Agent) messageDistribution(msg *pb.UserMessage) {
reply := &pb.RPCMessageReply{} 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{ if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{
Ip: this.IP(), Ip: this.IP(),
UserSessionId: this.sessionId, UserSessionId: this.sessionId,
UserId: this.uId, UserId: this.uId,
GatewayServiceId: this.gateway.Service().GetId(), GatewayServiceId: this.gateway.Service().GetId(),
Method: msg.ServiceMethod, Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
Message: msg.Data, Message: msg.Data,
}, reply); err != nil { }, reply); err != nil {
log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err) log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err)

View File

@ -2,7 +2,6 @@ package gateway
import ( import (
"context" "context"
"go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"sync" "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 { if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).Build(args.UserId) a.(IAgent).Build(args.UserId)
} else { } else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing) reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
} }
return nil 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 { if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).UnBuild() a.(IAgent).UnBuild()
} else { } else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing) reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
} }
return nil return nil
} }
@ -53,12 +52,14 @@ 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 { func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSendMessageReq, reply *pb.RPCMessageReply) error {
if a, ok := this.agents.Load(args.UserSessionId); ok { if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).WriteMsg(&pb.UserMessage{ a.(IAgent).WriteMsg(&pb.UserMessage{
ServiceMethod: args.ServiceMethod, MainType: args.MainType,
SubType: args.SubType,
Code: args.Code,
Data: args.Data, Data: args.Data,
}) })
} else { } else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing) reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
} }
return nil return nil
} }
@ -66,7 +67,8 @@ 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 { func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error {
msg := &pb.UserMessage{ msg := &pb.UserMessage{
ServiceMethod: args.ServiceMethod, MainType: args.MainType,
SubType: args.SubType,
Data: args.Data, Data: args.Data,
} }
for _, v := range args.UserSessionIds { for _, v := range args.UserSessionIds {
@ -80,7 +82,8 @@ 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 { func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error {
msg := &pb.UserMessage{ msg := &pb.UserMessage{
ServiceMethod: args.ServiceMethod, MainType: args.MainType,
SubType: args.SubType,
Data: args.Data, Data: args.Data,
} }
this.agents.Range(func(key, value any) bool { this.agents.Range(func(key, value any) bool {
@ -95,8 +98,8 @@ func (this *AgentMgr_Comp) CloseAgent(ctx context.Context, args *pb.AgentCloseeR
if a, ok := this.agents.Load(args.UserSessionId); ok { if a, ok := this.agents.Load(args.UserSessionId); ok {
a.(IAgent).Close() a.(IAgent).Close()
} else { } else {
reply.Code = int32(comm.ErrorCode_UserSessionNobeing) reply.Code = pb.ErrorCode_UserSessionNobeing
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing) reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
} }
return nil return nil
} }

View File

@ -40,7 +40,8 @@ func Test_WebSocket(t *testing.T) {
} }
logindata, _ := proto.Marshal(loginreq) logindata, _ := proto.Marshal(loginreq)
message := &pb.UserMessage{ message := &pb.UserMessage{
ServiceMethod: "login.login", MainType: "login",
SubType: "login",
Data: logindata, Data: logindata,
} }
data, _ := proto.Marshal(message) data, _ := proto.Marshal(message)

View File

@ -11,8 +11,8 @@ type (
IAgent interface { IAgent interface {
SessionId() string SessionId() string
IP() string IP() string
UserId() uint32 UserId() string
Build(uId uint32) Build(uId string)
UnBuild() UnBuild()
WriteMsg(msg *pb.UserMessage) (err error) WriteMsg(msg *pb.UserMessage) (err error)
Close() //主动关闭接口 Close() //主动关闭接口

View File

@ -23,20 +23,21 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options
return 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{} reply := &pb.RPCMessageReply{}
data, _ := proto.Marshal(msg) data, _ := proto.Marshal(msg)
if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{ if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
UserSessionId: user.SessionId, UserSessionId: user.SessionId,
ServiceMethod: ServiceMethod, MainType: mainType,
SubType: subType,
Data: data, Data: data,
}, reply); err != nil { }, 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 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 ( var (
gateways map[string][]string = make(map[string][]string) gateways map[string][]string = make(map[string][]string)
gateway []string gateway []string
@ -54,10 +55,11 @@ func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message,
for k, v := range gateways { for k, v := range gateways {
if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{ if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{
UserSessionIds: v, UserSessionIds: v,
ServiceMethod: ServiceMethod, MainType: mainType,
SubType: subType,
Data: data, Data: data,
}, reply); err != nil { }, 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 return

View File

@ -14,6 +14,10 @@ import (
const ( const (
QueryUserPackReq = "pack.queryuserpackreq" QueryUserPackReq = "pack.queryuserpackreq"
QueryUserPackResp = "pack.queryuserpackresp" QueryUserPackResp = "pack.queryuserpackresp"
UseItemReq = "pack.useitemreq"
UseItemResp = "pack.useitemresp"
SellItemReq = "pack.sellitemreq"
SellItemResp = "pack.sellitemresp"
) )
type Api_Comp struct { type Api_Comp struct {
@ -35,9 +39,9 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe
items []*pb.ItemAmount items []*pb.ItemAmount
) )
defer func() { defer func() {
session.SendMsg(QueryUserPackResp, &pb.QueryUserPackResp{Code: code, Items: items}) session.SendMsg("pack", "queryuserpackresp", code, &pb.QueryUserPackResp{Items: items})
}() }()
if session.GetUserId() == 0 { if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin code = pb.ErrorCode_NoLogin
return return
} }
@ -47,11 +51,43 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe
return return
} else { } else {
items = make([]*pb.ItemAmount, 0, len(pack.Pack)) items = make([]*pb.ItemAmount, 0, len(pack.Pack))
for _, v := range pack.Pack { // for _, v := range pack.Pack {
if v.Itype == req.IType { // if v.Itype == req.IType {
items = append(items, &pb.ItemAmount{IsNew: v.IsNew, ItemId: v.ItemId, Amount: v.Amount}) // items = append(items, &pb.ItemAmount{IsNew: v.IsNew, ItemId: v.ItemId, Amount: v.Amount})
// }
// }
} }
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(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
} }
return nil
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(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
return
} }

View File

@ -14,3 +14,7 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com
this.ModuleCompBase.Init(service, module, comp, options) this.ModuleCompBase.Init(service, module, comp, options)
return return
} }
func (this *Configure_Comp) GetItemConfigureData(id uint32) {
}

View File

@ -1,4 +1,4 @@
package login package user
import ( import (
"context" "context"
@ -29,7 +29,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 db_user.Account = req.Name
err = db.Defsys.User_CreateUser(db_user) err = db.Defsys.User_CreateUser(db_user)
if err != nil { if err != nil {
@ -57,13 +57,18 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
return err return err
} }
session.SendMsg("loginRsp", &pb.UserLoginResp{ session.SendMsg("login", "login", pb.ErrorCode_Success, &pb.UserLoginResp{
Code: comm.ErrorCode_Success, Data: &pb.Cache_UserData{
UserData: &pb.DB_UserData{
UserId: db_user.UserId,
},
},
}) })
return nil return nil
} }
//注销
func (this *LoginComp) Logout(ctx context.Context, session comm.IUserSession, rsp *pb.UserLoginReq) error { 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) log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)

View File

@ -1,4 +1,4 @@
package login package user
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
@ -11,22 +11,22 @@ import (
) )
func NewModule() core.IModule { func NewModule() core.IModule {
m := new(Login) m := new(User)
return m return m
} }
type Login struct { type User struct {
modules.ModuleBase 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 return comm.SM_LoginModule
} }
func (this *Login) OnInstallComp() { func (this *User) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
this.user_comp = this.RegisterComp(new(LoginComp)).(*LoginComp) this.login_comp = this.RegisterComp(new(LoginComp)).(*LoginComp)
} }
func (this *Login) Start() (err error) { func (this *Login) Start() (err error) {

17
modules/user/user_comp.go Normal file
View File

@ -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
}

View File

@ -1,7 +1,6 @@
package web package web
import ( import (
"go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"net/http" "net/http"
@ -16,6 +15,7 @@ import (
type Api_Comp struct { type Api_Comp struct {
cbase.ModuleCompBase cbase.ModuleCompBase
options *Options options *Options
module *Web
gin gin.ISys gin gin.ISys
} }
@ -38,11 +38,11 @@ func (this *Api_Comp) Register(c *engine.Context) {
}) })
if err != nil { if err != nil {
log.Errorf("create user err: %v", err) 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 { } else {
rsp.Code = comm.ErrorCode_ReqParameterError rsp.Code = pb.ErrorCode_ReqParameterError
} }
c.JSON(http.StatusOK, rsp) c.JSON(http.StatusOK, rsp)
} }

View File

@ -26,8 +26,10 @@ type UserMessage struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,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() { func (x *UserMessage) Reset() {
@ -62,13 +64,27 @@ func (*UserMessage) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{0} return file_comm_proto_rawDescGZIP(), []int{0}
} }
func (x *UserMessage) GetServiceMethod() string { func (x *UserMessage) GetMainType() string {
if x != nil { if x != nil {
return x.ServiceMethod return x.MainType
} }
return "" return ""
} }
func (x *UserMessage) GetSubType() string {
if x != nil {
return x.SubType
}
return ""
}
func (x *UserMessage) GetCode() ErrorCode {
if x != nil {
return x.Code
}
return ErrorCode_Success
}
func (x *UserMessage) GetData() []byte { func (x *UserMessage) GetData() []byte {
if x != nil { if x != nil {
return x.Data return x.Data
@ -84,7 +100,7 @@ type AgentMessage struct {
Ip string `protobuf:"bytes,1,opt,name=Ip,proto3" json:"Ip,omitempty"` Ip string `protobuf:"bytes,1,opt,name=Ip,proto3" json:"Ip,omitempty"`
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId,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"` GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId,omitempty"`
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method,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"` Message []byte `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message,omitempty"`
@ -136,11 +152,11 @@ func (x *AgentMessage) GetUserSessionId() string {
return "" return ""
} }
func (x *AgentMessage) GetUserId() uint32 { func (x *AgentMessage) GetUserId() string {
if x != nil { if x != nil {
return x.UserId return x.UserId
} }
return 0 return ""
} }
func (x *AgentMessage) GetGatewayServiceId() string { func (x *AgentMessage) GetGatewayServiceId() string {
@ -170,7 +186,7 @@ type RPCMessageReply struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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"`
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
} }
@ -206,11 +222,11 @@ func (*RPCMessageReply) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{2} return file_comm_proto_rawDescGZIP(), []int{2}
} }
func (x *RPCMessageReply) GetCode() int32 { func (x *RPCMessageReply) GetCode() ErrorCode {
if x != nil { if x != nil {
return x.Code return x.Code
} }
return 0 return ErrorCode_Success
} }
func (x *RPCMessageReply) GetMsg() string { func (x *RPCMessageReply) GetMsg() string {
@ -227,7 +243,7 @@ type AgentBuildReq struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"` 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() { func (x *AgentBuildReq) Reset() {
@ -269,11 +285,11 @@ func (x *AgentBuildReq) GetUserSessionId() string {
return "" return ""
} }
func (x *AgentBuildReq) GetUserId() uint32 { func (x *AgentBuildReq) GetUserId() string {
if x != nil { if x != nil {
return x.UserId return x.UserId
} }
return 0 return ""
} }
//用户代理解绑请求 //用户代理解绑请求
@ -331,8 +347,10 @@ type AgentSendMessageReq struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,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"` //服务名 MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,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() { func (x *AgentSendMessageReq) Reset() {
@ -374,13 +392,27 @@ func (x *AgentSendMessageReq) GetUserSessionId() string {
return "" return ""
} }
func (x *AgentSendMessageReq) GetServiceMethod() string { func (x *AgentSendMessageReq) GetMainType() string {
if x != nil { if x != nil {
return x.ServiceMethod return x.MainType
} }
return "" return ""
} }
func (x *AgentSendMessageReq) GetSubType() string {
if x != nil {
return x.SubType
}
return ""
}
func (x *AgentSendMessageReq) GetCode() ErrorCode {
if x != nil {
return x.Code
}
return ErrorCode_Success
}
func (x *AgentSendMessageReq) GetData() []byte { func (x *AgentSendMessageReq) GetData() []byte {
if x != nil { if x != nil {
return x.Data return x.Data
@ -395,8 +427,9 @@ type BatchMessageReq struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"` UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"`
ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,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() { func (x *BatchMessageReq) Reset() {
@ -438,9 +471,16 @@ func (x *BatchMessageReq) GetUserSessionIds() []string {
return nil return nil
} }
func (x *BatchMessageReq) GetServiceMethod() string { func (x *BatchMessageReq) GetMainType() string {
if x != nil { if x != nil {
return x.ServiceMethod return x.MainType
}
return ""
}
func (x *BatchMessageReq) GetSubType() string {
if x != nil {
return x.SubType
} }
return "" return ""
} }
@ -458,8 +498,9 @@ type BroadCastMessageReq struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名 MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,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() { func (x *BroadCastMessageReq) Reset() {
@ -494,9 +535,16 @@ func (*BroadCastMessageReq) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{7} return file_comm_proto_rawDescGZIP(), []int{7}
} }
func (x *BroadCastMessageReq) GetServiceMethod() string { func (x *BroadCastMessageReq) GetMainType() string {
if x != nil { if x != nil {
return x.ServiceMethod return x.MainType
}
return ""
}
func (x *BroadCastMessageReq) GetSubType() string {
if x != nil {
return x.SubType
} }
return "" return ""
} }
@ -559,60 +607,70 @@ func (x *AgentCloseeReq) GetUserSessionId() string {
var File_comm_proto protoreflect.FileDescriptor var File_comm_proto protoreflect.FileDescriptor
var file_comm_proto_rawDesc = []byte{ var file_comm_proto_rawDesc = []byte{
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, 0x0b, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72,
0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08,
0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54,
0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e,
0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c,
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74,
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20,
0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a,
0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55,
0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79,
0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x67, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49,
0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28,
0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73,
0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20,
0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e,
0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
0x6e, 0x49, 0x64, 0x22, 0x75, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 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, 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, 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, 0x22, 0xa5, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65,
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72,
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a,
0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18, 0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75,
0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62,
0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01,
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 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, 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, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65,
0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
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 ( var (
@ -638,13 +696,17 @@ var file_comm_proto_goTypes = []interface{}{
(*BatchMessageReq)(nil), // 6: BatchMessageReq (*BatchMessageReq)(nil), // 6: BatchMessageReq
(*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq (*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq
(*AgentCloseeReq)(nil), // 8: AgentCloseeReq (*AgentCloseeReq)(nil), // 8: AgentCloseeReq
(ErrorCode)(0), // 9: ErrorCode
} }
var file_comm_proto_depIdxs = []int32{ var file_comm_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type 9, // 0: UserMessage.Code:type_name -> ErrorCode
0, // [0:0] is the sub-list for method input_type 9, // 1: RPCMessageReply.Code:type_name -> ErrorCode
0, // [0:0] is the sub-list for extension type_name 9, // 2: AgentSendMessageReq.Code:type_name -> ErrorCode
0, // [0:0] is the sub-list for extension extendee 3, // [3:3] is the sub-list for method output_type
0, // [0:0] is the sub-list for field type_name 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() } func init() { file_comm_proto_init() }
@ -652,6 +714,7 @@ func file_comm_proto_init() {
if File_comm_proto != nil { if File_comm_proto != nil {
return return
} }
file_errorcode_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_comm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_comm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserMessage); i { switch v := v.(*UserMessage); i {

View File

@ -77,8 +77,7 @@ type GridData struct {
IsNew bool `protobuf:"varint,1,opt,name=IsNew,proto3" json:"IsNew,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 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,3,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量
Amount uint32 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量
} }
func (x *GridData) Reset() { func (x *GridData) Reset() {
@ -127,13 +126,6 @@ func (x *GridData) GetItemId() uint32 {
return 0 return 0
} }
func (x *GridData) GetItype() ItemType {
if x != nil {
return x.Itype
}
return ItemType_Props
}
func (x *GridData) GetAmount() uint32 { func (x *GridData) GetAmount() uint32 {
if x != nil { if x != nil {
return x.Amount return x.Amount
@ -147,7 +139,7 @@ type DB_UserPackData struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
UserId uint32 `bson:"_id" json:"UserId,omitempty" protobuf:"varint,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id 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"` //背包列表 Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
} }
@ -183,11 +175,11 @@ func (*DB_UserPackData) Descriptor() ([]byte, []int) {
return file_pack_db_proto_rawDescGZIP(), []int{1} return file_pack_db_proto_rawDescGZIP(), []int{1}
} }
func (x *DB_UserPackData) GetUserId() uint32 { func (x *DB_UserPackData) GetUserId() string {
if x != nil { if x != nil {
return x.UserId return x.UserId
} }
return 0 return ""
} }
func (x *DB_UserPackData) GetPack() []*GridData { func (x *DB_UserPackData) GetPack() []*GridData {
@ -201,22 +193,20 @@ var File_pack_db_proto protoreflect.FileDescriptor
var file_pack_db_proto_rawDesc = []byte{ var file_pack_db_proto_rawDesc = []byte{
0x0a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 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, 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, 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, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f,
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
0x79, 0x70, 0x65, 0x52, 0x05, 0x49, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x74, 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b,
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01,
0x6e, 0x74, 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x04,
0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x47, 0x72, 0x69,
0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x2a, 0x2e, 0x0a, 0x08, 0x49,
0x04, 0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x47, 0x72, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x70, 0x73,
0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x2a, 0x2e, 0x0a, 0x08, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x71, 0x75, 0x69, 0x70, 0x10, 0x02, 0x12, 0x0c, 0x0a,
0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x70, 0x08, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e,
0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x71, 0x75, 0x69, 0x70, 0x10, 0x02, 0x12, 0x0c, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
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 ( var (
@ -239,13 +229,12 @@ var file_pack_db_proto_goTypes = []interface{}{
(*DB_UserPackData)(nil), // 2: DB_UserPackData (*DB_UserPackData)(nil), // 2: DB_UserPackData
} }
var file_pack_db_proto_depIdxs = []int32{ var file_pack_db_proto_depIdxs = []int32{
0, // 0: GridData.Itype:type_name -> ItemType 1, // 0: DB_UserPackData.Pack:type_name -> GridData
1, // 1: DB_UserPackData.Pack:type_name -> GridData 1, // [1:1] is the sub-list for method output_type
2, // [2:2] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type
2, // [2:2] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee
2, // [2:2] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name
0, // [0:2] is the sub-list for field type_name
} }
func init() { file_pack_db_proto_init() } func init() { file_pack_db_proto_init() }

View File

@ -138,8 +138,7 @@ type QueryUserPackResp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` Items []*ItemAmount `protobuf:"bytes,1,rep,name=Items,proto3" json:"Items,omitempty"`
Items []*ItemAmount `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items,omitempty"`
} }
func (x *QueryUserPackResp) Reset() { func (x *QueryUserPackResp) Reset() {
@ -174,13 +173,6 @@ func (*QueryUserPackResp) Descriptor() ([]byte, []int) {
return file_pack_msg_proto_rawDescGZIP(), []int{2} 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 { func (x *QueryUserPackResp) GetItems() []*ItemAmount {
if x != nil { if x != nil {
return x.Items return x.Items
@ -188,28 +180,224 @@ func (x *QueryUserPackResp) GetItems() []*ItemAmount {
return nil 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
}
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}
}
//出售道具请求
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
}
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}
}
var File_pack_msg_proto protoreflect.FileDescriptor var File_pack_msg_proto protoreflect.FileDescriptor
var file_pack_msg_proto_rawDesc = []byte{ var file_pack_msg_proto_rawDesc = []byte{
0x0a, 0x0e, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 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, 0x1a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x6f, 0x1a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x52, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a,
0x22, 0x52, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, 0x73,
0x0a, 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, 0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20,
0x73, 0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41,
0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f,
0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x75, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72,
0x6f, 0x75, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65,
0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x65, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x36, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72,
0x70, 0x65, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x56, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x79, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a,
0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x49,
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73,
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x22, 0x3c, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16,
0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06,
0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0d,
0x33, 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 ( var (
@ -224,23 +412,25 @@ func file_pack_msg_proto_rawDescGZIP() []byte {
return file_pack_msg_proto_rawDescData 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{}{ var file_pack_msg_proto_goTypes = []interface{}{
(*ItemAmount)(nil), // 0: ItemAmount (*ItemAmount)(nil), // 0: ItemAmount
(*QueryUserPackReq)(nil), // 1: QueryUserPackReq (*QueryUserPackReq)(nil), // 1: QueryUserPackReq
(*QueryUserPackResp)(nil), // 2: QueryUserPackResp (*QueryUserPackResp)(nil), // 2: QueryUserPackResp
(ItemType)(0), // 3: ItemType (*UseItemReq)(nil), // 3: UseItemReq
(ErrorCode)(0), // 4: ErrorCode (*UseItemResp)(nil), // 4: UseItemResp
(*SellItemReq)(nil), // 5: SellItemReq
(*SellItemResp)(nil), // 6: SellItemResp
(ItemType)(0), // 7: ItemType
} }
var file_pack_msg_proto_depIdxs = []int32{ var file_pack_msg_proto_depIdxs = []int32{
3, // 0: QueryUserPackReq.IType:type_name -> ItemType 7, // 0: QueryUserPackReq.IType:type_name -> ItemType
4, // 1: QueryUserPackResp.Code:type_name -> ErrorCode 0, // 1: QueryUserPackResp.Items:type_name -> ItemAmount
0, // 2: QueryUserPackResp.Items:type_name -> ItemAmount 2, // [2:2] is the sub-list for method output_type
3, // [3:3] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type
3, // [3:3] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension extendee
3, // [3:3] is the sub-list for extension extendee 0, // [0:2] is the sub-list for field type_name
0, // [0:3] is the sub-list for field type_name
} }
func init() { file_pack_msg_proto_init() } func init() { file_pack_msg_proto_init() }
@ -248,7 +438,6 @@ func file_pack_msg_proto_init() {
if File_pack_msg_proto != nil { if File_pack_msg_proto != nil {
return return
} }
file_errorcode_proto_init()
file_pack_db_proto_init() file_pack_db_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_pack_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_pack_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
@ -287,6 +476,54 @@ func file_pack_msg_proto_init() {
return nil 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{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -294,7 +531,7 @@ func file_pack_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_pack_msg_proto_rawDesc, RawDescriptor: file_pack_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 3, NumMessages: 7,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -1,17 +1,20 @@
syntax = "proto3"; syntax = "proto3";
option go_package = ".;pb"; option go_package = ".;pb";
import "errorcode.proto";
// //
message UserMessage { message UserMessage {
string ServiceMethod =1; // string MainType =1;
bytes Data = 2; string SubType = 2;
ErrorCode Code = 3;
bytes Data = 4;
} }
// //
message AgentMessage { message AgentMessage {
string Ip = 1; string Ip = 1;
string UserSessionId = 2; string UserSessionId = 2;
uint32 UserId = 3; string UserId = 3;
string GatewayServiceId = 4; string GatewayServiceId = 4;
string Method = 5; string Method = 5;
bytes Message = 6; bytes Message = 6;
@ -19,14 +22,14 @@ message AgentMessage {
//RPC //RPC
message RPCMessageReply { message RPCMessageReply {
int32 Code = 1; ErrorCode Code = 1;
string Msg = 2; string Msg = 2;
} }
//Uid请求 //Uid请求
message AgentBuildReq { message AgentBuildReq {
string UserSessionId = 1; string UserSessionId = 1;
uint32 UserId = 2; string UserId = 2;
} }
// //
message AgentUnBuildReq { message AgentUnBuildReq {
@ -36,21 +39,25 @@ message AgentUnBuildReq {
// //
message AgentSendMessageReq { message AgentSendMessageReq {
string UserSessionId = 1; string UserSessionId = 1;
string ServiceMethod = 2; // string MainType = 2;
bytes Data = 3; string SubType = 3;
ErrorCode Code = 4;
bytes Data = 5;
} }
// //
message BatchMessageReq { message BatchMessageReq {
repeated string UserSessionIds = 1; repeated string UserSessionIds = 1;
string ServiceMethod = 2; string MainType = 2;
bytes Data = 3; string SubType = 3;
bytes Data = 4;
} }
//广 //广
message BroadCastMessageReq { message BroadCastMessageReq {
string ServiceMethod = 1; // string MainType = 1; //
bytes Data = 2; string SubType = 2;
bytes Data = 3;
} }
// //

View File

@ -11,12 +11,11 @@ enum ItemType {
message GridData { message GridData {
bool IsNew = 1; // bool IsNew = 1; //
uint32 ItemId = 2; //Id uint32 ItemId = 2; //Id
ItemType Itype = 3; // uint32 Amount = 3; //
uint32 Amount = 4; //
} }
// //
message DB_UserPackData { message DB_UserPackData {
uint32 UserId = 1; //tags:{bson:"_id"}Id string UserId = 1; //tags:{bson:"_id"}Id
repeated GridData Pack = 2; // repeated GridData Pack = 2; //
} }

View File

@ -1,6 +1,5 @@
syntax = "proto3"; syntax = "proto3";
option go_package = ".;pb"; option go_package = ".;pb";
import "errorcode.proto";
import "pack_db.proto"; import "pack_db.proto";
// //
@ -17,6 +16,27 @@ message QueryUserPackReq {
// //
message QueryUserPackResp { message QueryUserPackResp {
ErrorCode Code = 1; repeated ItemAmount Items = 1;
repeated ItemAmount Items = 2; }
//使
message UseItemReq {
uint32 ItemId = 2;
uint32 Amount = 3;
}
//使
message UseItemResp {
}
//
message SellItemReq {
uint32 ItemId = 2;
uint32 Amount = 3;
}
//
message SellItemResp {
} }

View File

@ -8,7 +8,7 @@ message Cache_UserData {
} }
message DB_UserData { message DB_UserData {
uint32 UserId = 1; //tags:{bson:"_id"}Id string UserId = 1; //tags:{bson:"_id"}Id
string account = 2; string account = 2;
string NiceName = 3; string NiceName = 3;
string Email = 4; string Email = 4;

View File

@ -1,12 +1,15 @@
syntax = "proto3"; syntax = "proto3";
option go_package = ".;pb"; option go_package = ".;pb";
import "errorcode.proto";
import "user_db.proto";
message UserLoginReq { message UserLoginReq {
string Name = 1; string Name = 1;
} }
message UserLoginResp { message UserLoginResp {
int32 Code = 1; ErrorCode Code = 1;
Cache_UserData data = 2;
} }
@ -15,5 +18,18 @@ message UserRegisterReq{
} }
message UserRegisterRsp{ message UserRegisterRsp{
int32 Code = 1; ErrorCode Code = 1;
}
message UserLoadRsp {
Cache_UserData data = 1;
}
message UserCreateReq{
string NickName = 1;//
int32 gender = 2; //
}
message UserCreateRsp{
} }

22
pb/unitls.go Normal file
View File

@ -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 "未描述"
}
}

View File

@ -88,7 +88,7 @@ type DB_UserData struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
UserId uint32 `bson:"_id" json:"UserId,omitempty" protobuf:"varint,1,opt,name=UserId,proto3"` //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"` Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"`
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,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"` 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} return file_user_db_proto_rawDescGZIP(), []int{1}
} }
func (x *DB_UserData) GetUserId() uint32 { func (x *DB_UserData) GetUserId() string {
if x != nil { if x != nil {
return x.UserId return x.UserId
} }
return 0 return ""
} }
func (x *DB_UserData) GetAccount() string { 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, 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, 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, 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, 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, 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, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65,

View File

@ -72,7 +72,8 @@ type UserLoginResp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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"`
} }
func (x *UserLoginResp) Reset() { func (x *UserLoginResp) Reset() {
@ -107,11 +108,18 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) {
return file_user_msg_proto_rawDescGZIP(), []int{1} return file_user_msg_proto_rawDescGZIP(), []int{1}
} }
func (x *UserLoginResp) GetCode() int32 { func (x *UserLoginResp) GetCode() ErrorCode {
if x != nil { if x != nil {
return x.Code return x.Code
} }
return 0 return ErrorCode_Success
}
func (x *UserLoginResp) GetData() *Cache_UserData {
if x != nil {
return x.Data
}
return nil
} }
type UserRegisterReq struct { type UserRegisterReq struct {
@ -166,7 +174,7 @@ type UserRegisterRsp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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() { func (x *UserRegisterRsp) Reset() {
@ -201,28 +209,183 @@ func (*UserRegisterRsp) Descriptor() ([]byte, []int) {
return file_user_msg_proto_rawDescGZIP(), []int{3} return file_user_msg_proto_rawDescGZIP(), []int{3}
} }
func (x *UserRegisterRsp) GetCode() int32 { func (x *UserRegisterRsp) GetCode() ErrorCode {
if x != nil { if x != nil {
return x.Code return x.Code
} }
return ErrorCode_Success
}
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
}
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 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 protoreflect.FileDescriptor
var file_user_msg_proto_rawDesc = []byte{ var file_user_msg_proto_rawDesc = []byte{
0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 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, 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, 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, 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, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x54, 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, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 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, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52,
0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20,
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72,
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73,
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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 ( var (
@ -237,19 +400,28 @@ func file_user_msg_proto_rawDescGZIP() []byte {
return file_user_msg_proto_rawDescData 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, 7)
var file_user_msg_proto_goTypes = []interface{}{ var file_user_msg_proto_goTypes = []interface{}{
(*UserLoginReq)(nil), // 0: UserLoginReq (*UserLoginReq)(nil), // 0: UserLoginReq
(*UserLoginResp)(nil), // 1: UserLoginResp (*UserLoginResp)(nil), // 1: UserLoginResp
(*UserRegisterReq)(nil), // 2: UserRegisterReq (*UserRegisterReq)(nil), // 2: UserRegisterReq
(*UserRegisterRsp)(nil), // 3: UserRegisterRsp (*UserRegisterRsp)(nil), // 3: UserRegisterRsp
(*UserLoadRsp)(nil), // 4: UserLoadRsp
(*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{ var file_user_msg_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type 7, // 0: UserLoginResp.Code:type_name -> ErrorCode
0, // [0:0] is the sub-list for method input_type 8, // 1: UserLoginResp.data:type_name -> Cache_UserData
0, // [0:0] is the sub-list for extension type_name 7, // 2: UserRegisterRsp.Code:type_name -> ErrorCode
0, // [0:0] is the sub-list for extension extendee 8, // 3: UserLoadRsp.data:type_name -> Cache_UserData
0, // [0:0] is the sub-list for field type_name 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() } func init() { file_user_msg_proto_init() }
@ -257,6 +429,8 @@ func file_user_msg_proto_init() {
if File_user_msg_proto != nil { if File_user_msg_proto != nil {
return return
} }
file_errorcode_proto_init()
file_user_db_proto_init()
if !protoimpl.UnsafeEnabled { if !protoimpl.UnsafeEnabled {
file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserLoginReq); i { switch v := v.(*UserLoginReq); i {
@ -306,6 +480,42 @@ func file_user_msg_proto_init() {
return nil 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
}
}
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{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -313,7 +523,7 @@ func file_user_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_user_msg_proto_rawDesc, RawDescriptor: file_user_msg_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 4, NumMessages: 7,
NumExtensions: 0, NumExtensions: 0,
NumServices: 0, NumServices: 0,
}, },

View File

@ -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)}) msghandle.fn.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(ctx), reflect.ValueOf(session), reflect.ValueOf(msg)})
} else { } else {
reply.Code = int32(core.ErrorCode_ReqParameterError) reply.Code = pb.ErrorCode_ReqParameterError
reply.Msg = core.GetErrorCodeMsg(core.ErrorCode_ReqParameterError) reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_ReqParameterError)
} }
return nil return nil
} }

View File

@ -3,9 +3,9 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"go_dreamfactory/modules/login"
"go_dreamfactory/modules/mail" "go_dreamfactory/modules/mail"
"go_dreamfactory/modules/pack" "go_dreamfactory/modules/pack"
"go_dreamfactory/modules/user"
"go_dreamfactory/services" "go_dreamfactory/services"
"go_dreamfactory/sys/cache" "go_dreamfactory/sys/cache"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
@ -31,7 +31,7 @@ func main() {
) )
lego.Run(s, //运行模块 lego.Run(s, //运行模块
// web.NewModule(), // web.NewModule(),
login.NewModule(), user.NewModule(),
pack.NewModule(), pack.NewModule(),
mail.NewModule(), mail.NewModule(),
) )

6
sys/cache/pack.go vendored
View File

@ -10,17 +10,17 @@ import (
) )
const ( //Redis const ( //Redis
Redis_PackCache string = "pack:%d" Redis_PackCache string = "pack:%s"
) )
const () const ()
type IPack interface { 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{ pack = &pb.DB_UserPackData{
UserId: uId, UserId: uId,
} }

2
sys/cache/user.go vendored
View File

@ -6,7 +6,7 @@ import (
) )
const ( //Redis const ( //Redis
Redis_UserCache string = "user:%d" //会话列表 Redis_UserCache string = "user:%s" //会话列表
) )
type IUser interface { type IUser interface {

View File

@ -7,6 +7,7 @@ import (
"github.com/liwei1dao/lego/sys/redis" "github.com/liwei1dao/lego/sys/redis"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson/primitive"
) )
var cache *Cache var cache *Cache
@ -28,7 +29,7 @@ func TestUpdateUser(t *testing.T) {
SessionId: "1", SessionId: "1",
GatewayServiceId: "work", GatewayServiceId: "work",
UserData: &pb.DB_UserData{ UserData: &pb.DB_UserData{
UserId: 1, UserId: primitive.NewObjectID().Hex(),
Account: "aaa", Account: "aaa",
}, },
} }

View File

@ -22,6 +22,5 @@ func (this *DB) init() (err error) {
); err != nil { ); err != nil {
return return
} }
err = this.checkUserIdInit()
return return
} }

View File

@ -12,11 +12,11 @@ const ( //Redis
) )
type IPack interface { 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{} pack = &pb.DB_UserPackData{}
err = this.mgo.FindOne(DB_PackTable, bson.M{"_id": uId}).Decode(pack) err = this.mgo.FindOne(DB_PackTable, bson.M{"_id": uId}).Decode(pack)
return return

View File

@ -1,34 +1,25 @@
package db package db
import ( import (
"context"
"fmt"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"math/rand"
"time"
"github.com/liwei1dao/lego/core" "github.com/liwei1dao/lego/core"
"github.com/liwei1dao/lego/sys/log"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/options"
) )
const ( //Redis const ( //Redis
DB_UserTable core.SqlTable = "user" //用户表 DB_UserTable core.SqlTable = "user" //用户表
DB_UserIdTable core.SqlTable = "userid" //用户id表
) )
type IUser interface { type IUser interface {
User_FindUserByAccount(account string) (*pb.DB_UserData, error) 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_CreateUser(user *pb.DB_UserData) error
User_UpdateUser(data *pb.DB_UserData) (err 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) { func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error) {
filter := bson.D{ filter := bson.D{
{"account", account}, {"account", account},
@ -39,7 +30,7 @@ func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error)
return user, err 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{ filter := bson.D{
{"_id", id}, {"_id", id},
} }
@ -49,21 +40,15 @@ func (this *DB) User_FindUserById(id uint32) (*pb.DB_UserData, error) {
return user, err return user, err
} }
func (this *DB) User_CreateUser(user *pb.DB_UserData) error { func (this *DB) User_CreateUser(user *pb.DB_UserData) (err error) {
userId := &UserId{} user.UserId = primitive.NewObjectID().Hex()
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
_, err = this.mgo.InsertOne(DB_UserTable, user) _, err = this.mgo.InsertOne(DB_UserTable, user)
return err return err
} }
//更新用户数据到DB //更新用户数据到DB
func (this *DB) User_UpdateUser(data *pb.DB_UserData) error { func (this *DB) User_UpdateUser(data *pb.DB_UserData) (err error) {
err := this.mgo.FindOneAndUpdate( err = this.mgo.FindOneAndUpdate(
DB_UserTable, DB_UserTable,
bson.M{"_id": data.UserId}, bson.M{"_id": data.UserId},
bson.M{"$set": bson.M{ bson.M{"$set": bson.M{
@ -74,33 +59,3 @@ func (this *DB) User_UpdateUser(data *pb.DB_UserData) error {
).Decode(data) ).Decode(data)
return err 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
}

View File

@ -9,6 +9,7 @@ import (
"github.com/liwei1dao/lego/sys/mgo" "github.com/liwei1dao/lego/sys/mgo"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson/primitive"
) )
var db *DB var db *DB
@ -37,7 +38,7 @@ func TestCreate(t *testing.T) {
} }
func TestFindOne(t *testing.T) { func TestFindOne(t *testing.T) {
user, err := db.User_FindUserById(1) user, err := db.User_FindUserById("")
require.Nil(t, err) require.Nil(t, err)
assert.Equal(t, "legu1", user.Account) assert.Equal(t, "legu1", user.Account)
@ -49,7 +50,7 @@ func TestFindOne(t *testing.T) {
func TestUpdate(t *testing.T) { func TestUpdate(t *testing.T) {
user := &pb.DB_UserData{ user := &pb.DB_UserData{
UserId: 10001, UserId: primitive.NewObjectID().String(),
Email: "new@qq.com", Email: "new@qq.com",
} }
err := db.User_UpdateUser(user) err := db.User_UpdateUser(user)