Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into meixiongfeng
This commit is contained in:
commit
fa15d16231
@ -43,10 +43,8 @@ var runCmd = &cobra.Command{
|
||||
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
opts := robot.DefaultOpts()
|
||||
opts.Create = *create
|
||||
if *create {
|
||||
opts.Account = *account
|
||||
}
|
||||
opts.Create = *create
|
||||
opts.Account = *account
|
||||
|
||||
r := robot.NewRobot(opts)
|
||||
r.Run()
|
||||
|
@ -1,38 +1,49 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"log"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func (r *Robot) handleLogin(methodName string) {
|
||||
switch methodName {
|
||||
func (r *Robot) handleLogin(msg *pb.UserMessage) {
|
||||
switch msg.SubType {
|
||||
case "login":
|
||||
handleLogin(r)
|
||||
handleLogin(r, msg)
|
||||
default:
|
||||
log.Fatal("methodName no exist")
|
||||
}
|
||||
}
|
||||
|
||||
func handleLogin(r *Robot) {
|
||||
loginreq := &pb.UserLoginReq{
|
||||
Name: "aaa",
|
||||
//处理接口响应数据
|
||||
func handleLogin(r *Robot, msg *pb.UserMessage) {
|
||||
rsp := &pb.UserLoginResp{}
|
||||
if !comm.ProtoDecode(msg, rsp) {
|
||||
return
|
||||
}
|
||||
logindata, _ := proto.Marshal(loginreq)
|
||||
head := &pb.UserMessage{
|
||||
ServiceMethod: "login.login",
|
||||
Data: logindata,
|
||||
log.Printf("to client: %v", rsp.Data)
|
||||
}
|
||||
|
||||
//处理登录请求
|
||||
func (r *Robot) AccountLogin() {
|
||||
//登录
|
||||
loginReg := &pb.UserLoginReq{
|
||||
Name: r.Opts.Account,
|
||||
}
|
||||
|
||||
if comm.ProtoEncode(loginreq, head) {
|
||||
err := r.SendToClient(head.Data)
|
||||
head := &pb.UserMessage{
|
||||
MainType: "login",
|
||||
SubType: "login",
|
||||
}
|
||||
if comm.ProtoEncode(loginReg, head) {
|
||||
data, _ := proto.Marshal(head)
|
||||
err := r.SendToClient(data)
|
||||
if err != nil {
|
||||
fmt.Printf("err:%v\n", err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Printf("%s login ", r.Opts.Account)
|
||||
}
|
||||
|
12
cmd/robot/readme.md
Normal file
12
cmd/robot/readme.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Robot使用
|
||||
|
||||
## 命令行
|
||||
```sh
|
||||
#使用已存在的账号测试接口
|
||||
go run cmd.go run --account yourAccount
|
||||
```
|
||||
|
||||
```sh
|
||||
#使用新账号测试接口
|
||||
go run cmd.go run --account newAccount --create true
|
||||
```
|
@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -44,33 +43,40 @@ func (r *Robot) Run() {
|
||||
r.AccountLogin()
|
||||
}
|
||||
|
||||
for {
|
||||
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||
_, data, err := r.ws.ReadMessage()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
//处理响应
|
||||
go func() {
|
||||
for {
|
||||
var msg *pb.UserMessage = &pb.UserMessage{}
|
||||
_, data, err := r.ws.ReadMessage()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
log.Fatal(err)
|
||||
if err = proto.Unmarshal(data, msg); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
r.handleMsg(msg)
|
||||
}
|
||||
r.handleMsg(msg)
|
||||
}
|
||||
}()
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
func (r *Robot) handleMsg(msg *pb.UserMessage) {
|
||||
m, f, ok := utils.ParseP(msg.ServiceMethod)
|
||||
if !ok {
|
||||
log.Fatal("route error")
|
||||
}
|
||||
switch m {
|
||||
switch msg.MainType {
|
||||
case "login":
|
||||
r.handleLogin(f)
|
||||
r.handleLogin(msg)
|
||||
case "user":
|
||||
r.handleUserMsg(msg)
|
||||
default:
|
||||
log.Fatal("module route no exist")
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Robot) onUserLoaded() {
|
||||
|
||||
}
|
||||
|
||||
func (r *Robot) SendToClient(data []byte) error {
|
||||
return r.ws.WriteMessage(websocket.BinaryMessage, data)
|
||||
}
|
||||
@ -96,14 +102,15 @@ func (r *Robot) AccountRegister() {
|
||||
regRsp := &pb.UserRegisterRsp{}
|
||||
err = jsoniter.Unmarshal(body, regRsp)
|
||||
|
||||
if regRsp.Code == comm.ErrorCode_Success { //注册成功
|
||||
if regRsp.Code == pb.ErrorCode_Success { //注册成功
|
||||
//登录
|
||||
loginReg := &pb.UserLoginReq{
|
||||
Name: regReq.Account,
|
||||
}
|
||||
|
||||
head := &pb.UserMessage{
|
||||
ServiceMethod: "login.login",
|
||||
MainType: "login",
|
||||
SubType: "login",
|
||||
}
|
||||
if comm.ProtoEncode(loginReg, head) {
|
||||
err = r.SendToClient(head.Data)
|
||||
@ -113,23 +120,4 @@ func (r *Robot) AccountRegister() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//登录认证
|
||||
func (r *Robot) AccountLogin() {
|
||||
//登录
|
||||
loginReg := &pb.UserLoginReq{
|
||||
Name: r.Opts.Account,
|
||||
}
|
||||
|
||||
head := &pb.UserMessage{
|
||||
ServiceMethod: "login.login",
|
||||
}
|
||||
if comm.ProtoEncode(loginReg, head) {
|
||||
err := r.SendToClient(head.Data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,39 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"github.com/liwei1dao/lego/sys/log"
|
||||
)
|
||||
|
||||
func (r *Robot) handleUserMsg(msg *pb.UserMessage) {
|
||||
|
||||
switch msg.SubType {
|
||||
//创建账号
|
||||
case "create":
|
||||
case "load":
|
||||
|
||||
}
|
||||
|
||||
//加载玩家数据
|
||||
if msg.SubType == "load" {
|
||||
rsp := &pb.UserLoadRsp{}
|
||||
if !comm.ProtoDecode(msg, rsp) {
|
||||
log.Fatal("load user err")
|
||||
}
|
||||
|
||||
if rsp.Data.UserData.UserId != "" {
|
||||
r.onUserLoaded()
|
||||
} else {
|
||||
log.Debugf("%s不存在", r.Opts.Account)
|
||||
//创建
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Robot) CreateUser() {
|
||||
|
||||
}
|
||||
|
23
comm/core.go
23
comm/core.go
@ -16,7 +16,7 @@ const (
|
||||
const (
|
||||
SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块
|
||||
SM_WebModule core.M_Modules = "web" //web模块
|
||||
SM_LoginModule core.M_Modules = "login" //web模块
|
||||
SM_LoginModule core.M_Modules = "user" //用户模块
|
||||
SM_PackModule core.M_Modules = "pack" //背包模块
|
||||
SM_MailModule core.M_Modules = "mail" //邮件模块
|
||||
)
|
||||
@ -39,31 +39,20 @@ type ISC_GateRouteComp interface {
|
||||
//用户会话
|
||||
type IUserSession interface {
|
||||
GetSessionId() string
|
||||
GetUserId() uint32
|
||||
GetUserId() string
|
||||
GetIP() string
|
||||
GetGatewayServiceId() string
|
||||
Build(uid uint32) (err error)
|
||||
Build(uid string) (err error)
|
||||
UnBuild(ServiceMethod string, msg proto.Message) (err error)
|
||||
SendMsg(ServiceMethod string, msg proto.Message) (err error)
|
||||
SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error)
|
||||
Close() (err error)
|
||||
ToString() string
|
||||
}
|
||||
|
||||
//消息体
|
||||
type MessageHead struct {
|
||||
ServiceMethod string //服务名
|
||||
}
|
||||
|
||||
//处理JSON消息
|
||||
type Message struct {
|
||||
Head *MessageHead
|
||||
Data []byte
|
||||
}
|
||||
|
||||
func ProtoDecode(msg *pb.UserMessage, req proto.Message) (ok bool) {
|
||||
err := proto.Unmarshal(msg.Data, req)
|
||||
if err != nil {
|
||||
log.Errorf("%s %v", msg.ServiceMethod, err)
|
||||
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
||||
return
|
||||
}
|
||||
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) {
|
||||
data, err := proto.Marshal(rsp)
|
||||
if err != nil {
|
||||
log.Errorf("%s %v", msg.ServiceMethod, err)
|
||||
log.Errorf("%s.%s %v", msg.MainType, msg.SubType, err)
|
||||
return
|
||||
}
|
||||
msg.Data = data
|
||||
|
@ -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 "未描述"
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ import (
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
func NewUserSession(service base.IRPCXService, ip, sessionId, gatewayServiceId string, uid uint32) IUserSession {
|
||||
func NewUserSession(service base.IRPCXService, ip, sessionId, gatewayServiceId string, uid string) IUserSession {
|
||||
return &UserSession{
|
||||
IP: ip,
|
||||
SessionId: sessionId,
|
||||
@ -24,7 +24,7 @@ type UserSession struct {
|
||||
IP string
|
||||
SessionId string
|
||||
GatewayServiceId string //用户所在网关服务
|
||||
UserId uint32
|
||||
UserId string
|
||||
service base.IRPCXService
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ func (this *UserSession) GetSessionId() string {
|
||||
return this.SessionId
|
||||
}
|
||||
|
||||
func (this *UserSession) GetUserId() uint32 {
|
||||
func (this *UserSession) GetUserId() string {
|
||||
return this.UserId
|
||||
}
|
||||
func (this *UserSession) GetIP() string {
|
||||
@ -42,7 +42,7 @@ func (this *UserSession) GetGatewayServiceId() string {
|
||||
return this.GatewayServiceId
|
||||
}
|
||||
|
||||
func (this *UserSession) Build(uid uint32) (err error) {
|
||||
func (this *UserSession) Build(uid string) (err error) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentBuild), context.Background(), &pb.AgentBuildReq{
|
||||
UserSessionId: this.SessionId,
|
||||
@ -63,15 +63,18 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e
|
||||
return
|
||||
}
|
||||
|
||||
func (this *UserSession) SendMsg(ServiceMethod string, msg proto.Message) (err error) {
|
||||
func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
data, _ := proto.Marshal(msg)
|
||||
log.Debugf("SendMsg Data: %v", msg)
|
||||
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
|
||||
UserSessionId: this.SessionId,
|
||||
ServiceMethod: ServiceMethod,
|
||||
MainType: mainType,
|
||||
SubType: subType,
|
||||
Code: code,
|
||||
Data: data,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, ServiceMethod, err)
|
||||
log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
type (
|
||||
IModule interface {
|
||||
core.IModule
|
||||
SendMsgToUser(ServiceMethod string, msg proto.Message, user *pb.Cache_UserData) (err error)
|
||||
SendMsgToUsers(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
|
||||
SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error)
|
||||
SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error)
|
||||
}
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"sync"
|
||||
@ -18,7 +19,7 @@ func newAgent(gateway IGateway, conn *websocket.Conn) *Agent {
|
||||
gateway: gateway,
|
||||
wsConn: conn,
|
||||
sessionId: id.NewUUId(),
|
||||
uId: 0,
|
||||
uId: "",
|
||||
writeChan: make(chan *pb.UserMessage, 2),
|
||||
closeSignal: make(chan bool),
|
||||
state: 1,
|
||||
@ -34,7 +35,7 @@ type Agent struct {
|
||||
gateway IGateway
|
||||
wsConn *websocket.Conn
|
||||
sessionId string
|
||||
uId uint32
|
||||
uId string
|
||||
writeChan chan *pb.UserMessage
|
||||
closeSignal chan bool
|
||||
state int32 //状态 0 关闭 1 运行 2 关闭中
|
||||
@ -99,16 +100,16 @@ func (this *Agent) SessionId() string {
|
||||
func (this *Agent) IP() string {
|
||||
return this.wsConn.RemoteAddr().String()
|
||||
}
|
||||
func (this *Agent) UserId() uint32 {
|
||||
func (this *Agent) UserId() string {
|
||||
return this.uId
|
||||
}
|
||||
|
||||
func (this *Agent) Build(uId uint32) {
|
||||
func (this *Agent) Build(uId string) {
|
||||
this.uId = uId
|
||||
}
|
||||
|
||||
func (this *Agent) UnBuild() {
|
||||
this.uId = 0
|
||||
this.uId = ""
|
||||
}
|
||||
|
||||
func (this *Agent) WriteMsg(msg *pb.UserMessage) (err error) {
|
||||
@ -134,13 +135,13 @@ func (this *Agent) Close() {
|
||||
//分发用户消息
|
||||
func (this *Agent) messageDistribution(msg *pb.UserMessage) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
log.Debugf("agent:%s uId:%d MessageDistribution msg:%s", this.sessionId, this.uId, msg.ServiceMethod)
|
||||
log.Debugf("agent:%s uId:%d MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType)
|
||||
if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{
|
||||
Ip: this.IP(),
|
||||
UserSessionId: this.sessionId,
|
||||
UserId: this.uId,
|
||||
GatewayServiceId: this.gateway.Service().GetId(),
|
||||
Method: msg.ServiceMethod,
|
||||
Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType),
|
||||
Message: msg.Data,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err)
|
||||
|
@ -2,7 +2,6 @@ package gateway
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"sync"
|
||||
|
||||
@ -32,8 +31,8 @@ func (this *AgentMgr_Comp) Build(ctx context.Context, args *pb.AgentBuildReq, re
|
||||
if a, ok := this.agents.Load(args.UserSessionId); ok {
|
||||
a.(IAgent).Build(args.UserId)
|
||||
} else {
|
||||
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -43,8 +42,8 @@ func (this *AgentMgr_Comp) UnBuild(ctx context.Context, args *pb.AgentUnBuildReq
|
||||
if a, ok := this.agents.Load(args.UserSessionId); ok {
|
||||
a.(IAgent).UnBuild()
|
||||
} else {
|
||||
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -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 {
|
||||
if a, ok := this.agents.Load(args.UserSessionId); ok {
|
||||
a.(IAgent).WriteMsg(&pb.UserMessage{
|
||||
ServiceMethod: args.ServiceMethod,
|
||||
Data: args.Data,
|
||||
MainType: args.MainType,
|
||||
SubType: args.SubType,
|
||||
Code: args.Code,
|
||||
Data: args.Data,
|
||||
})
|
||||
} else {
|
||||
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -66,8 +67,9 @@ func (this *AgentMgr_Comp) SendMsgToAgent(ctx context.Context, args *pb.AgentSen
|
||||
//向多个户发送消息
|
||||
func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMessageReq, reply *pb.RPCMessageReply) error {
|
||||
msg := &pb.UserMessage{
|
||||
ServiceMethod: args.ServiceMethod,
|
||||
Data: args.Data,
|
||||
MainType: args.MainType,
|
||||
SubType: args.SubType,
|
||||
Data: args.Data,
|
||||
}
|
||||
for _, v := range args.UserSessionIds {
|
||||
if a, ok := this.agents.Load(v); ok {
|
||||
@ -80,8 +82,9 @@ func (this *AgentMgr_Comp) SendMsgToAgents(ctx context.Context, args *pb.BatchMe
|
||||
//向所有户发送消息
|
||||
func (this *AgentMgr_Comp) SendMsgToAllAgent(ctx context.Context, args *pb.BroadCastMessageReq, reply *pb.RPCMessageReply) error {
|
||||
msg := &pb.UserMessage{
|
||||
ServiceMethod: args.ServiceMethod,
|
||||
Data: args.Data,
|
||||
MainType: args.MainType,
|
||||
SubType: args.SubType,
|
||||
Data: args.Data,
|
||||
}
|
||||
this.agents.Range(func(key, value any) bool {
|
||||
value.(IAgent).WriteMsg(msg)
|
||||
@ -95,8 +98,8 @@ func (this *AgentMgr_Comp) CloseAgent(ctx context.Context, args *pb.AgentCloseeR
|
||||
if a, ok := this.agents.Load(args.UserSessionId); ok {
|
||||
a.(IAgent).Close()
|
||||
} else {
|
||||
reply.Code = int32(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Msg = comm.GetErrorCodeMsg(comm.ErrorCode_UserSessionNobeing)
|
||||
reply.Code = pb.ErrorCode_UserSessionNobeing
|
||||
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -40,8 +40,9 @@ func Test_WebSocket(t *testing.T) {
|
||||
}
|
||||
logindata, _ := proto.Marshal(loginreq)
|
||||
message := &pb.UserMessage{
|
||||
ServiceMethod: "login.login",
|
||||
Data: logindata,
|
||||
MainType: "login",
|
||||
SubType: "login",
|
||||
Data: logindata,
|
||||
}
|
||||
data, _ := proto.Marshal(message)
|
||||
err = ws.WriteMessage(websocket.BinaryMessage, data)
|
||||
|
@ -11,8 +11,8 @@ type (
|
||||
IAgent interface {
|
||||
SessionId() string
|
||||
IP() string
|
||||
UserId() uint32
|
||||
Build(uId uint32)
|
||||
UserId() string
|
||||
Build(uId string)
|
||||
UnBuild()
|
||||
WriteMsg(msg *pb.UserMessage) (err error)
|
||||
Close() //主动关闭接口
|
||||
|
@ -23,20 +23,21 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModuleBase) SendMsgToUser(ServiceMethod string, msg proto.Message, user *pb.Cache_UserData) (err error) {
|
||||
func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
data, _ := proto.Marshal(msg)
|
||||
if _, err = this.service.RpcGoById(user.GatewayServiceId, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.AgentSendMessageReq{
|
||||
UserSessionId: user.SessionId,
|
||||
ServiceMethod: ServiceMethod,
|
||||
MainType: mainType,
|
||||
SubType: subType,
|
||||
Data: data,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("SendMsgToUser%d:%s [%s] err:%v", user.UserData.UserId, user.SessionId, ServiceMethod, err)
|
||||
log.Errorf("SendMsgToUser%d:%s [%s.%s] err:%v", user.UserData.UserId, user.SessionId, mainType, subType, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message, user ...*pb.Cache_UserData) (err error) {
|
||||
func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Message, user ...*pb.Cache_UserData) (err error) {
|
||||
var (
|
||||
gateways map[string][]string = make(map[string][]string)
|
||||
gateway []string
|
||||
@ -54,10 +55,11 @@ func (this *ModuleBase) SendMsgToUsers(ServiceMethod string, msg proto.Message,
|
||||
for k, v := range gateways {
|
||||
if _, err = this.service.RpcGoById(k, string(comm.Rpc_GatewayAgentSendMsg), context.Background(), &pb.BatchMessageReq{
|
||||
UserSessionIds: v,
|
||||
ServiceMethod: ServiceMethod,
|
||||
MainType: mainType,
|
||||
SubType: subType,
|
||||
Data: data,
|
||||
}, reply); err != nil {
|
||||
log.Errorf("SendMsgToUsers:%s->%s err:%v", k, ServiceMethod, err)
|
||||
log.Errorf("SendMsgToUsers:%s->%s.%s err:%v", k, mainType, subType, err)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
@ -14,6 +14,10 @@ import (
|
||||
const (
|
||||
QueryUserPackReq = "pack.queryuserpackreq"
|
||||
QueryUserPackResp = "pack.queryuserpackresp"
|
||||
UseItemReq = "pack.useitemreq"
|
||||
UseItemResp = "pack.useitemresp"
|
||||
SellItemReq = "pack.sellitemreq"
|
||||
SellItemResp = "pack.sellitemresp"
|
||||
)
|
||||
|
||||
type Api_Comp struct {
|
||||
@ -35,9 +39,9 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe
|
||||
items []*pb.ItemAmount
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(QueryUserPackResp, &pb.QueryUserPackResp{Code: code, Items: items})
|
||||
session.SendMsg("pack", "queryuserpackresp", code, &pb.QueryUserPackResp{Items: items})
|
||||
}()
|
||||
if session.GetUserId() == 0 {
|
||||
if session.GetUserId() == "" {
|
||||
code = pb.ErrorCode_NoLogin
|
||||
return
|
||||
}
|
||||
@ -47,11 +51,43 @@ func (this *Api_Comp) QueryUserPackReq(ctx context.Context, session comm.IUserSe
|
||||
return
|
||||
} else {
|
||||
items = make([]*pb.ItemAmount, 0, len(pack.Pack))
|
||||
for _, v := range pack.Pack {
|
||||
if v.Itype == req.IType {
|
||||
items = append(items, &pb.ItemAmount{IsNew: v.IsNew, ItemId: v.ItemId, Amount: v.Amount})
|
||||
}
|
||||
}
|
||||
// for _, v := range pack.Pack {
|
||||
// if v.Itype == req.IType {
|
||||
// items = append(items, &pb.ItemAmount{IsNew: v.IsNew, ItemId: v.ItemId, Amount: v.Amount})
|
||||
// }
|
||||
// }
|
||||
}
|
||||
return nil
|
||||
return
|
||||
}
|
||||
|
||||
//使用道具
|
||||
func (this *Api_Comp) UseItemReq(ctx context.Context, session comm.IUserSession, req *pb.UseItemReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{})
|
||||
}()
|
||||
if session.GetUserId() == "" {
|
||||
code = pb.ErrorCode_NoLogin
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//出售道具
|
||||
func (this *Api_Comp) SellItemReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserPackReq) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{})
|
||||
}()
|
||||
if session.GetUserId() == "" {
|
||||
code = pb.ErrorCode_NoLogin
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -14,3 +14,7 @@ func (this *Configure_Comp) Init(service core.IService, module core.IModule, com
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Configure_Comp) GetItemConfigureData(id uint32) {
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package login
|
||||
package user
|
||||
|
||||
import (
|
||||
"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
|
||||
err = db.Defsys.User_CreateUser(db_user)
|
||||
if err != nil {
|
||||
@ -57,13 +57,18 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
||||
return err
|
||||
}
|
||||
|
||||
session.SendMsg("loginRsp", &pb.UserLoginResp{
|
||||
Code: comm.ErrorCode_Success,
|
||||
session.SendMsg("login", "login", pb.ErrorCode_Success, &pb.UserLoginResp{
|
||||
Data: &pb.Cache_UserData{
|
||||
UserData: &pb.DB_UserData{
|
||||
UserId: db_user.UserId,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
//注销
|
||||
func (this *LoginComp) Logout(ctx context.Context, session comm.IUserSession, rsp *pb.UserLoginReq) error {
|
||||
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)
|
||||
|
@ -1,4 +1,4 @@
|
||||
package login
|
||||
package user
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
@ -11,22 +11,22 @@ import (
|
||||
)
|
||||
|
||||
func NewModule() core.IModule {
|
||||
m := new(Login)
|
||||
m := new(User)
|
||||
return m
|
||||
}
|
||||
|
||||
type Login struct {
|
||||
type User struct {
|
||||
modules.ModuleBase
|
||||
user_comp *LoginComp
|
||||
login_comp *LoginComp
|
||||
}
|
||||
|
||||
func (this *Login) GetType() core.M_Modules {
|
||||
func (this *User) GetType() core.M_Modules {
|
||||
return comm.SM_LoginModule
|
||||
}
|
||||
|
||||
func (this *Login) OnInstallComp() {
|
||||
func (this *User) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.user_comp = this.RegisterComp(new(LoginComp)).(*LoginComp)
|
||||
this.login_comp = this.RegisterComp(new(LoginComp)).(*LoginComp)
|
||||
}
|
||||
|
||||
func (this *Login) Start() (err error) {
|
17
modules/user/user_comp.go
Normal file
17
modules/user/user_comp.go
Normal 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
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
"net/http"
|
||||
@ -16,6 +15,7 @@ import (
|
||||
type Api_Comp struct {
|
||||
cbase.ModuleCompBase
|
||||
options *Options
|
||||
module *Web
|
||||
gin gin.ISys
|
||||
}
|
||||
|
||||
@ -38,11 +38,11 @@ func (this *Api_Comp) Register(c *engine.Context) {
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("create user err: %v", err)
|
||||
rsp.Code = comm.ErrorCode_SqlExecutionError
|
||||
rsp.Code = pb.ErrorCode_SqlExecutionError
|
||||
}
|
||||
rsp.Code = comm.ErrorCode_Success
|
||||
rsp.Code = pb.ErrorCode_Success
|
||||
} else {
|
||||
rsp.Code = comm.ErrorCode_ReqParameterError
|
||||
rsp.Code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
c.JSON(http.StatusOK, rsp)
|
||||
}
|
||||
|
229
pb/comm.pb.go
229
pb/comm.pb.go
@ -26,8 +26,10 @@ type UserMessage struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
|
||||
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
|
||||
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() {
|
||||
@ -62,13 +64,27 @@ func (*UserMessage) Descriptor() ([]byte, []int) {
|
||||
return file_comm_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *UserMessage) GetServiceMethod() string {
|
||||
func (x *UserMessage) GetMainType() string {
|
||||
if x != nil {
|
||||
return x.ServiceMethod
|
||||
return x.MainType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserMessage) GetSubType() string {
|
||||
if x != nil {
|
||||
return x.SubType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UserMessage) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *UserMessage) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
@ -84,7 +100,7 @@ type AgentMessage struct {
|
||||
|
||||
Ip string `protobuf:"bytes,1,opt,name=Ip,proto3" json:"Ip,omitempty"`
|
||||
UserSessionId string `protobuf:"bytes,2,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
|
||||
UserId uint32 `protobuf:"varint,3,opt,name=UserId,proto3" json:"UserId,omitempty"`
|
||||
UserId string `protobuf:"bytes,3,opt,name=UserId,proto3" json:"UserId,omitempty"`
|
||||
GatewayServiceId string `protobuf:"bytes,4,opt,name=GatewayServiceId,proto3" json:"GatewayServiceId,omitempty"`
|
||||
Method string `protobuf:"bytes,5,opt,name=Method,proto3" json:"Method,omitempty"`
|
||||
Message []byte `protobuf:"bytes,6,opt,name=Message,proto3" json:"Message,omitempty"`
|
||||
@ -136,11 +152,11 @@ func (x *AgentMessage) GetUserSessionId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentMessage) GetUserId() uint32 {
|
||||
func (x *AgentMessage) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentMessage) GetGatewayServiceId() string {
|
||||
@ -170,8 +186,8 @@ type RPCMessageReply struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RPCMessageReply) Reset() {
|
||||
@ -206,11 +222,11 @@ func (*RPCMessageReply) Descriptor() ([]byte, []int) {
|
||||
return file_comm_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *RPCMessageReply) GetCode() int32 {
|
||||
func (x *RPCMessageReply) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *RPCMessageReply) GetMsg() string {
|
||||
@ -227,7 +243,7 @@ type AgentBuildReq struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
|
||||
UserId uint32 `protobuf:"varint,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
|
||||
UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AgentBuildReq) Reset() {
|
||||
@ -269,11 +285,11 @@ func (x *AgentBuildReq) GetUserSessionId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentBuildReq) GetUserId() uint32 {
|
||||
func (x *AgentBuildReq) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
//用户代理解绑请求
|
||||
@ -330,9 +346,11 @@ type AgentSendMessageReq struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
|
||||
ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
|
||||
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId,omitempty"`
|
||||
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
|
||||
Code ErrorCode `protobuf:"varint,4,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
|
||||
Data []byte `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AgentSendMessageReq) Reset() {
|
||||
@ -374,13 +392,27 @@ func (x *AgentSendMessageReq) GetUserSessionId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentSendMessageReq) GetServiceMethod() string {
|
||||
func (x *AgentSendMessageReq) GetMainType() string {
|
||||
if x != nil {
|
||||
return x.ServiceMethod
|
||||
return x.MainType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentSendMessageReq) GetSubType() string {
|
||||
if x != nil {
|
||||
return x.SubType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AgentSendMessageReq) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *AgentSendMessageReq) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
@ -395,8 +427,9 @@ type BatchMessageReq struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserSessionIds []string `protobuf:"bytes,1,rep,name=UserSessionIds,proto3" json:"UserSessionIds,omitempty"`
|
||||
ServiceMethod string `protobuf:"bytes,2,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"`
|
||||
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType,omitempty"`
|
||||
SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType,omitempty"`
|
||||
Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BatchMessageReq) Reset() {
|
||||
@ -438,9 +471,16 @@ func (x *BatchMessageReq) GetUserSessionIds() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *BatchMessageReq) GetServiceMethod() string {
|
||||
func (x *BatchMessageReq) GetMainType() string {
|
||||
if x != nil {
|
||||
return x.ServiceMethod
|
||||
return x.MainType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BatchMessageReq) GetSubType() string {
|
||||
if x != nil {
|
||||
return x.SubType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -458,8 +498,9 @@ type BroadCastMessageReq struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ServiceMethod string `protobuf:"bytes,1,opt,name=ServiceMethod,proto3" json:"ServiceMethod,omitempty"` //服务名
|
||||
Data []byte `protobuf:"bytes,2,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
MainType string `protobuf:"bytes,1,opt,name=MainType,proto3" json:"MainType,omitempty"` //服务名
|
||||
SubType string `protobuf:"bytes,2,opt,name=SubType,proto3" json:"SubType,omitempty"`
|
||||
Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BroadCastMessageReq) Reset() {
|
||||
@ -494,9 +535,16 @@ func (*BroadCastMessageReq) Descriptor() ([]byte, []int) {
|
||||
return file_comm_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *BroadCastMessageReq) GetServiceMethod() string {
|
||||
func (x *BroadCastMessageReq) GetMainType() string {
|
||||
if x != nil {
|
||||
return x.ServiceMethod
|
||||
return x.MainType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BroadCastMessageReq) GetSubType() string {
|
||||
if x != nil {
|
||||
return x.SubType
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -559,60 +607,70 @@ func (x *AgentCloseeReq) GetUserSessionId() string {
|
||||
var File_comm_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_comm_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x47, 0x0a, 0x0b,
|
||||
0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x53,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f,
|
||||
0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||
0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x4d,
|
||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55,
|
||||
0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73,
|
||||
0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10,
|
||||
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64,
|
||||
0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||
0x67, 0x65, 0x22, 0x37, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
||||
0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41,
|
||||
0x67, 0x65, 0x6e, 0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d,
|
||||
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67,
|
||||
0x65, 0x6e, 0x74, 0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a,
|
||||
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x49, 0x64, 0x22, 0x75, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64,
|
||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
|
||||
0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72,
|
||||
0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a,
|
||||
0x0b, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75, 0x62, 0x54,
|
||||
0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62, 0x54, 0x79,
|
||||
0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e,
|
||||
0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f,
|
||||
0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c,
|
||||
0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0xba, 0x01, 0x0a, 0x0c, 0x41, 0x67, 0x65, 0x6e, 0x74,
|
||||
0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x70, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x70, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
|
||||
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d,
|
||||
0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55,
|
||||
0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79,
|
||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49,
|
||||
0x64, 0x12, 0x16, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x06, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73,
|
||||
0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x52, 0x50, 0x43, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
|
||||
0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65,
|
||||
0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x03, 0x4d, 0x73, 0x67, 0x22, 0x4d, 0x0a, 0x0d, 0x41, 0x67, 0x65, 0x6e,
|
||||
0x74, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65,
|
||||
0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,
|
||||
0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x37, 0x0a, 0x0f, 0x41, 0x67, 0x65, 0x6e, 0x74,
|
||||
0x55, 0x6e, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73,
|
||||
0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
|
||||
0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f,
|
||||
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x73, 0x0a, 0x0f, 0x42, 0x61,
|
||||
0x74, 0x63, 0x68, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x26, 0x0a,
|
||||
0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x73, 0x18,
|
||||
0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x49, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53, 0x65,
|
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x44,
|
||||
0x22, 0xa5, 0x01, 0x0a, 0x13, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x65,
|
||||
0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72,
|
||||
0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x53, 0x75,
|
||||
0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x53, 0x75, 0x62,
|
||||
0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01,
|
||||
0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04,
|
||||
0x43, 0x6f, 0x64, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 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,
|
||||
0x4f, 0x0a, 0x13, 0x42, 0x72, 0x6f, 0x61, 0x64, 0x43, 0x61, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x53,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x44, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61,
|
||||
0x22, 0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52,
|
||||
0x65, 0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
|
||||
0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53,
|
||||
0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x36, 0x0a, 0x0e, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x65, 0x52, 0x65,
|
||||
0x71, 0x12, 0x24, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -638,13 +696,17 @@ var file_comm_proto_goTypes = []interface{}{
|
||||
(*BatchMessageReq)(nil), // 6: BatchMessageReq
|
||||
(*BroadCastMessageReq)(nil), // 7: BroadCastMessageReq
|
||||
(*AgentCloseeReq)(nil), // 8: AgentCloseeReq
|
||||
(ErrorCode)(0), // 9: ErrorCode
|
||||
}
|
||||
var file_comm_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
9, // 0: UserMessage.Code:type_name -> ErrorCode
|
||||
9, // 1: RPCMessageReply.Code:type_name -> ErrorCode
|
||||
9, // 2: AgentSendMessageReq.Code:type_name -> ErrorCode
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_comm_proto_init() }
|
||||
@ -652,6 +714,7 @@ func file_comm_proto_init() {
|
||||
if File_comm_proto != nil {
|
||||
return
|
||||
}
|
||||
file_errorcode_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_comm_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserMessage); i {
|
||||
|
@ -75,10 +75,9 @@ type GridData struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
IsNew bool `protobuf:"varint,1,opt,name=IsNew,proto3" json:"IsNew,omitempty"` //是否是新的
|
||||
ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id
|
||||
Itype ItemType `protobuf:"varint,3,opt,name=Itype,proto3,enum=ItemType" json:"Itype,omitempty"` //物品类型
|
||||
Amount uint32 `protobuf:"varint,4,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量
|
||||
IsNew bool `protobuf:"varint,1,opt,name=IsNew,proto3" json:"IsNew,omitempty"` //是否是新的
|
||||
ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //存放物品的Id
|
||||
Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"` //存放物品的数量
|
||||
}
|
||||
|
||||
func (x *GridData) Reset() {
|
||||
@ -127,13 +126,6 @@ func (x *GridData) GetItemId() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GridData) GetItype() ItemType {
|
||||
if x != nil {
|
||||
return x.Itype
|
||||
}
|
||||
return ItemType_Props
|
||||
}
|
||||
|
||||
func (x *GridData) GetAmount() uint32 {
|
||||
if x != nil {
|
||||
return x.Amount
|
||||
@ -147,8 +139,8 @@ type DB_UserPackData struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId uint32 `bson:"_id" json:"UserId,omitempty" protobuf:"varint,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id
|
||||
Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id
|
||||
Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||
}
|
||||
|
||||
func (x *DB_UserPackData) Reset() {
|
||||
@ -183,11 +175,11 @@ func (*DB_UserPackData) Descriptor() ([]byte, []int) {
|
||||
return file_pack_db_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *DB_UserPackData) GetUserId() uint32 {
|
||||
func (x *DB_UserPackData) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserPackData) GetPack() []*GridData {
|
||||
@ -201,22 +193,20 @@ var File_pack_db_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_pack_db_proto_rawDesc = []byte{
|
||||
0x0a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x71, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x49,
|
||||
0x50, 0x0a, 0x08, 0x47, 0x72, 0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x49,
|
||||
0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, 0x73, 0x4e, 0x65,
|
||||
0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x74, 0x79,
|
||||
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54,
|
||||
0x79, 0x70, 0x65, 0x52, 0x05, 0x49, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75,
|
||||
0x6e, 0x74, 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63,
|
||||
0x6b, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a,
|
||||
0x04, 0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x47, 0x72,
|
||||
0x69, 0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x2a, 0x2e, 0x0a, 0x08,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x70,
|
||||
0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x71, 0x75, 0x69, 0x70, 0x10, 0x02, 0x12, 0x0c,
|
||||
0x0a, 0x08, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04,
|
||||
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x22, 0x48, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b,
|
||||
0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x04,
|
||||
0x50, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x47, 0x72, 0x69,
|
||||
0x64, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x50, 0x61, 0x63, 0x6b, 0x2a, 0x2e, 0x0a, 0x08, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x72, 0x6f, 0x70, 0x73,
|
||||
0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x71, 0x75, 0x69, 0x70, 0x10, 0x02, 0x12, 0x0c, 0x0a,
|
||||
0x08, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x10, 0x0c, 0x42, 0x06, 0x5a, 0x04, 0x2e,
|
||||
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -239,13 +229,12 @@ var file_pack_db_proto_goTypes = []interface{}{
|
||||
(*DB_UserPackData)(nil), // 2: DB_UserPackData
|
||||
}
|
||||
var file_pack_db_proto_depIdxs = []int32{
|
||||
0, // 0: GridData.Itype:type_name -> ItemType
|
||||
1, // 1: DB_UserPackData.Pack:type_name -> GridData
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
1, // 0: DB_UserPackData.Pack:type_name -> GridData
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_pack_db_proto_init() }
|
||||
|
@ -138,8 +138,7 @@ type QueryUserPackResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
|
||||
Items []*ItemAmount `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items,omitempty"`
|
||||
Items []*ItemAmount `protobuf:"bytes,1,rep,name=Items,proto3" json:"Items,omitempty"`
|
||||
}
|
||||
|
||||
func (x *QueryUserPackResp) Reset() {
|
||||
@ -174,13 +173,6 @@ func (*QueryUserPackResp) Descriptor() ([]byte, []int) {
|
||||
return file_pack_msg_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *QueryUserPackResp) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *QueryUserPackResp) GetItems() []*ItemAmount {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
@ -188,28 +180,224 @@ func (x *QueryUserPackResp) GetItems() []*ItemAmount {
|
||||
return nil
|
||||
}
|
||||
|
||||
//使用物品请求
|
||||
type UseItemReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
ItemId uint32 `protobuf:"varint,2,opt,name=ItemId,proto3" json:"ItemId,omitempty"`
|
||||
Amount uint32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UseItemReq) Reset() {
|
||||
*x = UseItemReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_pack_msg_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UseItemReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UseItemReq) ProtoMessage() {}
|
||||
|
||||
func (x *UseItemReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_pack_msg_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UseItemReq.ProtoReflect.Descriptor instead.
|
||||
func (*UseItemReq) Descriptor() ([]byte, []int) {
|
||||
return file_pack_msg_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *UseItemReq) GetItemId() uint32 {
|
||||
if x != nil {
|
||||
return x.ItemId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UseItemReq) GetAmount() uint32 {
|
||||
if x != nil {
|
||||
return x.Amount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
//使用物品请求 回应
|
||||
type UseItemResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
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_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x22, 0x52, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49,
|
||||
0x73, 0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65,
|
||||
0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79,
|
||||
0x70, 0x65, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x56, 0x0a, 0x11, 0x51, 0x75, 0x65,
|
||||
0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e,
|
||||
0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x21,
|
||||
0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x33,
|
||||
0x1a, 0x0d, 0x70, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
|
||||
0x52, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x49, 0x73, 0x4e, 0x65, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x49, 0x73,
|
||||
0x4e, 0x65, 0x77, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41,
|
||||
0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x22, 0x33, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72,
|
||||
0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70,
|
||||
0x65, 0x52, 0x05, 0x49, 0x54, 0x79, 0x70, 0x65, 0x22, 0x36, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72,
|
||||
0x79, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a,
|
||||
0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73,
|
||||
0x22, 0x3c, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16,
|
||||
0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0d,
|
||||
0x0a, 0x0b, 0x55, 0x73, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x22, 0x3d, 0x0a,
|
||||
0x0b, 0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74,
|
||||
0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x0e, 0x0a, 0x0c,
|
||||
0x53, 0x65, 0x6c, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04,
|
||||
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -224,23 +412,25 @@ func file_pack_msg_proto_rawDescGZIP() []byte {
|
||||
return file_pack_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_pack_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_pack_msg_proto_goTypes = []interface{}{
|
||||
(*ItemAmount)(nil), // 0: ItemAmount
|
||||
(*QueryUserPackReq)(nil), // 1: QueryUserPackReq
|
||||
(*QueryUserPackResp)(nil), // 2: QueryUserPackResp
|
||||
(ItemType)(0), // 3: ItemType
|
||||
(ErrorCode)(0), // 4: ErrorCode
|
||||
(*UseItemReq)(nil), // 3: UseItemReq
|
||||
(*UseItemResp)(nil), // 4: UseItemResp
|
||||
(*SellItemReq)(nil), // 5: SellItemReq
|
||||
(*SellItemResp)(nil), // 6: SellItemResp
|
||||
(ItemType)(0), // 7: ItemType
|
||||
}
|
||||
var file_pack_msg_proto_depIdxs = []int32{
|
||||
3, // 0: QueryUserPackReq.IType:type_name -> ItemType
|
||||
4, // 1: QueryUserPackResp.Code:type_name -> ErrorCode
|
||||
0, // 2: QueryUserPackResp.Items:type_name -> ItemAmount
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
7, // 0: QueryUserPackReq.IType:type_name -> ItemType
|
||||
0, // 1: QueryUserPackResp.Items:type_name -> ItemAmount
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_pack_msg_proto_init() }
|
||||
@ -248,7 +438,6 @@ func file_pack_msg_proto_init() {
|
||||
if File_pack_msg_proto != nil {
|
||||
return
|
||||
}
|
||||
file_errorcode_proto_init()
|
||||
file_pack_db_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pack_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
@ -287,6 +476,54 @@ func file_pack_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pack_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UseItemReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pack_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UseItemResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pack_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SellItemReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_pack_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SellItemResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -294,7 +531,7 @@ func file_pack_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_pack_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -1,17 +1,20 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "errorcode.proto";
|
||||
|
||||
//用户消息流结构
|
||||
message UserMessage {
|
||||
string ServiceMethod =1; //服务名
|
||||
bytes Data = 2;
|
||||
string MainType =1;
|
||||
string SubType = 2;
|
||||
ErrorCode Code = 3;
|
||||
bytes Data = 4;
|
||||
}
|
||||
|
||||
//代理用户转发消息结构
|
||||
message AgentMessage {
|
||||
string Ip = 1;
|
||||
string UserSessionId = 2;
|
||||
uint32 UserId = 3;
|
||||
string UserId = 3;
|
||||
string GatewayServiceId = 4;
|
||||
string Method = 5;
|
||||
bytes Message = 6;
|
||||
@ -19,14 +22,14 @@ message AgentMessage {
|
||||
|
||||
//RPC 服务固定回复结构
|
||||
message RPCMessageReply {
|
||||
int32 Code = 1;
|
||||
ErrorCode Code = 1;
|
||||
string Msg = 2;
|
||||
}
|
||||
|
||||
//用户代理绑定Uid请求
|
||||
message AgentBuildReq {
|
||||
string UserSessionId = 1;
|
||||
uint32 UserId = 2;
|
||||
string UserId = 2;
|
||||
}
|
||||
//用户代理解绑请求
|
||||
message AgentUnBuildReq {
|
||||
@ -36,21 +39,25 @@ message AgentUnBuildReq {
|
||||
//向用户代理发送消息请求
|
||||
message AgentSendMessageReq {
|
||||
string UserSessionId = 1;
|
||||
string ServiceMethod = 2; //服务名
|
||||
bytes Data = 3;
|
||||
string MainType = 2;
|
||||
string SubType = 3;
|
||||
ErrorCode Code = 4;
|
||||
bytes Data = 5;
|
||||
}
|
||||
|
||||
//发送批量消息
|
||||
message BatchMessageReq {
|
||||
repeated string UserSessionIds = 1;
|
||||
string ServiceMethod = 2;
|
||||
bytes Data = 3;
|
||||
string MainType = 2;
|
||||
string SubType = 3;
|
||||
bytes Data = 4;
|
||||
}
|
||||
|
||||
//发送广播消息
|
||||
message BroadCastMessageReq {
|
||||
string ServiceMethod = 1; //服务名
|
||||
bytes Data = 2;
|
||||
string MainType = 1; //服务名
|
||||
string SubType = 2;
|
||||
bytes Data = 3;
|
||||
}
|
||||
|
||||
//关闭用户代理
|
||||
|
@ -11,12 +11,11 @@ enum ItemType {
|
||||
message GridData {
|
||||
bool IsNew = 1; //是否是新的
|
||||
uint32 ItemId = 2; //存放物品的Id
|
||||
ItemType Itype = 3; //物品类型
|
||||
uint32 Amount = 4; //存放物品的数量
|
||||
uint32 Amount = 3; //存放物品的数量
|
||||
}
|
||||
|
||||
//用户背包
|
||||
message DB_UserPackData {
|
||||
uint32 UserId = 1; //tags:{bson:"_id"}用户Id
|
||||
string UserId = 1; //tags:{bson:"_id"}用户Id
|
||||
repeated GridData Pack = 2; //背包列表
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "errorcode.proto";
|
||||
import "pack_db.proto";
|
||||
|
||||
//物品数量
|
||||
@ -17,6 +16,27 @@ message QueryUserPackReq {
|
||||
|
||||
//查询用户背包请求 回应
|
||||
message QueryUserPackResp {
|
||||
ErrorCode Code = 1;
|
||||
repeated ItemAmount Items = 2;
|
||||
repeated ItemAmount Items = 1;
|
||||
}
|
||||
|
||||
//使用物品请求
|
||||
message UseItemReq {
|
||||
uint32 ItemId = 2;
|
||||
uint32 Amount = 3;
|
||||
}
|
||||
|
||||
//使用物品请求 回应
|
||||
message UseItemResp {
|
||||
|
||||
}
|
||||
|
||||
//出售道具请求
|
||||
message SellItemReq {
|
||||
uint32 ItemId = 2;
|
||||
uint32 Amount = 3;
|
||||
}
|
||||
|
||||
//出售道具请求 回应
|
||||
message SellItemResp {
|
||||
|
||||
}
|
@ -8,7 +8,7 @@ message Cache_UserData {
|
||||
}
|
||||
|
||||
message DB_UserData {
|
||||
uint32 UserId = 1; //tags:{bson:"_id"}动态Id
|
||||
string UserId = 1; //tags:{bson:"_id"}动态Id
|
||||
string account = 2;
|
||||
string NiceName = 3;
|
||||
string Email = 4;
|
||||
|
@ -1,12 +1,15 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "errorcode.proto";
|
||||
import "user_db.proto";
|
||||
|
||||
message UserLoginReq {
|
||||
string Name = 1;
|
||||
}
|
||||
|
||||
message UserLoginResp {
|
||||
int32 Code = 1;
|
||||
ErrorCode Code = 1;
|
||||
Cache_UserData data = 2;
|
||||
}
|
||||
|
||||
|
||||
@ -15,5 +18,18 @@ message UserRegisterReq{
|
||||
}
|
||||
|
||||
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
22
pb/unitls.go
Normal 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 "未描述"
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ type DB_UserData struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
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"`
|
||||
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
|
||||
Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"`
|
||||
@ -127,11 +127,11 @@ func (*DB_UserData) Descriptor() ([]byte, []int) {
|
||||
return file_user_db_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetUserId() uint32 {
|
||||
func (x *DB_UserData) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetAccount() string {
|
||||
@ -176,7 +176,7 @@ var file_user_db_proto_rawDesc = []byte{
|
||||
0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73,
|
||||
0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18,
|
||||
0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65,
|
||||
|
@ -72,7 +72,8 @@ type UserLoginResp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
|
||||
Code 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() {
|
||||
@ -107,11 +108,18 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) {
|
||||
return file_user_msg_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *UserLoginResp) GetCode() int32 {
|
||||
func (x *UserLoginResp) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
return ErrorCode_Success
|
||||
}
|
||||
|
||||
func (x *UserLoginResp) GetData() *Cache_UserData {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UserRegisterReq struct {
|
||||
@ -166,7 +174,7 @@ type UserRegisterRsp struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
|
||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UserRegisterRsp) Reset() {
|
||||
@ -201,28 +209,183 @@ func (*UserRegisterRsp) Descriptor() ([]byte, []int) {
|
||||
return file_user_msg_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *UserRegisterRsp) GetCode() int32 {
|
||||
func (x *UserRegisterRsp) GetCode() ErrorCode {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 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
|
||||
}
|
||||
|
||||
type UserCreateRsp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *UserCreateRsp) Reset() {
|
||||
*x = UserCreateRsp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_user_msg_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UserCreateRsp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UserCreateRsp) ProtoMessage() {}
|
||||
|
||||
func (x *UserCreateRsp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_user_msg_proto_msgTypes[6]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UserCreateRsp.ProtoReflect.Descriptor instead.
|
||||
func (*UserCreateRsp) Descriptor() ([]byte, []int) {
|
||||
return file_user_msg_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
var File_user_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_user_msg_proto_rawDesc = []byte{
|
||||
0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x22, 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x23, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65,
|
||||
0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07,
|
||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x25, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
|
||||
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x43, 0x6f, 0x64,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x4e, 0x61, 0x6d, 0x65, 0x22, 0x54, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52,
|
||||
0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72,
|
||||
0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73,
|
||||
0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a,
|
||||
0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
||||
0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52,
|
||||
0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f,
|
||||
0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73,
|
||||
0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74,
|
||||
0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f,
|
||||
0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43,
|
||||
0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67,
|
||||
0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e,
|
||||
0x64, 0x65, 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74,
|
||||
0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@ -237,19 +400,28 @@ func file_user_msg_proto_rawDescGZIP() []byte {
|
||||
return file_user_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_user_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_user_msg_proto_goTypes = []interface{}{
|
||||
(*UserLoginReq)(nil), // 0: UserLoginReq
|
||||
(*UserLoginResp)(nil), // 1: UserLoginResp
|
||||
(*UserRegisterReq)(nil), // 2: UserRegisterReq
|
||||
(*UserRegisterRsp)(nil), // 3: UserRegisterRsp
|
||||
(*UserLoadRsp)(nil), // 4: UserLoadRsp
|
||||
(*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{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
7, // 0: UserLoginResp.Code:type_name -> ErrorCode
|
||||
8, // 1: UserLoginResp.data:type_name -> Cache_UserData
|
||||
7, // 2: UserRegisterRsp.Code:type_name -> ErrorCode
|
||||
8, // 3: UserLoadRsp.data:type_name -> Cache_UserData
|
||||
4, // [4:4] is the sub-list for method output_type
|
||||
4, // [4:4] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_user_msg_proto_init() }
|
||||
@ -257,6 +429,8 @@ func file_user_msg_proto_init() {
|
||||
if File_user_msg_proto != nil {
|
||||
return
|
||||
}
|
||||
file_errorcode_proto_init()
|
||||
file_user_db_proto_init()
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_user_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserLoginReq); i {
|
||||
@ -306,6 +480,42 @@ func file_user_msg_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserLoadRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserCreateReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_user_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UserCreateRsp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@ -313,7 +523,7 @@ func file_user_msg_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_user_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
@ -82,8 +82,8 @@ func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentM
|
||||
}
|
||||
msghandle.fn.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(ctx), reflect.ValueOf(session), reflect.ValueOf(msg)})
|
||||
} else {
|
||||
reply.Code = int32(core.ErrorCode_ReqParameterError)
|
||||
reply.Msg = core.GetErrorCodeMsg(core.ErrorCode_ReqParameterError)
|
||||
reply.Code = pb.ErrorCode_ReqParameterError
|
||||
reply.Msg = pb.GetErrorCodeMsg(pb.ErrorCode_ReqParameterError)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"go_dreamfactory/modules/login"
|
||||
"go_dreamfactory/modules/mail"
|
||||
"go_dreamfactory/modules/pack"
|
||||
"go_dreamfactory/modules/user"
|
||||
"go_dreamfactory/services"
|
||||
"go_dreamfactory/sys/cache"
|
||||
"go_dreamfactory/sys/db"
|
||||
@ -31,7 +31,7 @@ func main() {
|
||||
)
|
||||
lego.Run(s, //运行模块
|
||||
// web.NewModule(),
|
||||
login.NewModule(),
|
||||
user.NewModule(),
|
||||
pack.NewModule(),
|
||||
mail.NewModule(),
|
||||
)
|
||||
|
6
sys/cache/pack.go
vendored
6
sys/cache/pack.go
vendored
@ -10,17 +10,17 @@ import (
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
Redis_PackCache string = "pack:%d"
|
||||
Redis_PackCache string = "pack:%s"
|
||||
)
|
||||
|
||||
const ()
|
||||
|
||||
type IPack interface {
|
||||
QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error)
|
||||
QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error)
|
||||
}
|
||||
|
||||
///查询用户背包数据
|
||||
func (this *Cache) QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error) {
|
||||
func (this *Cache) QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) {
|
||||
pack = &pb.DB_UserPackData{
|
||||
UserId: uId,
|
||||
}
|
||||
|
2
sys/cache/user.go
vendored
2
sys/cache/user.go
vendored
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
Redis_UserCache string = "user:%d" //会话列表
|
||||
Redis_UserCache string = "user:%s" //会话列表
|
||||
)
|
||||
|
||||
type IUser interface {
|
||||
|
3
sys/cache/user_test.go
vendored
3
sys/cache/user_test.go
vendored
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/liwei1dao/lego/sys/redis"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
var cache *Cache
|
||||
@ -28,7 +29,7 @@ func TestUpdateUser(t *testing.T) {
|
||||
SessionId: "1",
|
||||
GatewayServiceId: "work",
|
||||
UserData: &pb.DB_UserData{
|
||||
UserId: 1,
|
||||
UserId: primitive.NewObjectID().Hex(),
|
||||
Account: "aaa",
|
||||
},
|
||||
}
|
||||
|
@ -22,6 +22,5 @@ func (this *DB) init() (err error) {
|
||||
); err != nil {
|
||||
return
|
||||
}
|
||||
err = this.checkUserIdInit()
|
||||
return
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ const ( //Redis
|
||||
)
|
||||
|
||||
type IPack interface {
|
||||
QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error)
|
||||
QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error)
|
||||
}
|
||||
|
||||
///查询用户背包数据
|
||||
func (this *DB) QueryUserPack(uId uint32) (pack *pb.DB_UserPackData, err error) {
|
||||
func (this *DB) QueryUserPack(uId string) (pack *pb.DB_UserPackData, err error) {
|
||||
pack = &pb.DB_UserPackData{}
|
||||
err = this.mgo.FindOne(DB_PackTable, bson.M{"_id": uId}).Decode(pack)
|
||||
return
|
||||
|
@ -1,34 +1,25 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/liwei1dao/lego/core"
|
||||
"github.com/liwei1dao/lego/sys/log"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
DB_UserTable core.SqlTable = "user" //用户表
|
||||
DB_UserIdTable core.SqlTable = "userid" //用户id表
|
||||
DB_UserTable core.SqlTable = "user" //用户表
|
||||
)
|
||||
|
||||
type IUser interface {
|
||||
User_FindUserByAccount(account string) (*pb.DB_UserData, error)
|
||||
User_FindUserById(id uint32) (*pb.DB_UserData, error)
|
||||
User_FindUserById(id string) (*pb.DB_UserData, error)
|
||||
User_CreateUser(user *pb.DB_UserData) error
|
||||
User_UpdateUser(data *pb.DB_UserData) (err error)
|
||||
}
|
||||
|
||||
type UserId struct {
|
||||
UserId uint32 `bson:"_id"`
|
||||
}
|
||||
|
||||
func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error) {
|
||||
filter := bson.D{
|
||||
{"account", account},
|
||||
@ -39,7 +30,7 @@ func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error)
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (this *DB) User_FindUserById(id uint32) (*pb.DB_UserData, error) {
|
||||
func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) {
|
||||
filter := bson.D{
|
||||
{"_id", id},
|
||||
}
|
||||
@ -49,21 +40,15 @@ func (this *DB) User_FindUserById(id uint32) (*pb.DB_UserData, error) {
|
||||
return user, err
|
||||
}
|
||||
|
||||
func (this *DB) User_CreateUser(user *pb.DB_UserData) error {
|
||||
userId := &UserId{}
|
||||
err := this.mgo.FindOneAndDelete(DB_UserIdTable, bson.M{}).Decode(userId)
|
||||
if err != nil {
|
||||
log.Errorf("find userId err :%v", err)
|
||||
return err
|
||||
}
|
||||
user.UserId = userId.UserId
|
||||
func (this *DB) User_CreateUser(user *pb.DB_UserData) (err error) {
|
||||
user.UserId = primitive.NewObjectID().Hex()
|
||||
_, err = this.mgo.InsertOne(DB_UserTable, user)
|
||||
return err
|
||||
}
|
||||
|
||||
//更新用户数据到DB
|
||||
func (this *DB) User_UpdateUser(data *pb.DB_UserData) error {
|
||||
err := this.mgo.FindOneAndUpdate(
|
||||
func (this *DB) User_UpdateUser(data *pb.DB_UserData) (err error) {
|
||||
err = this.mgo.FindOneAndUpdate(
|
||||
DB_UserTable,
|
||||
bson.M{"_id": data.UserId},
|
||||
bson.M{"$set": bson.M{
|
||||
@ -74,33 +59,3 @@ func (this *DB) User_UpdateUser(data *pb.DB_UserData) error {
|
||||
).Decode(data)
|
||||
return err
|
||||
}
|
||||
|
||||
//校验数据库初始化工作是否完成
|
||||
func (this *DB) checkUserIdInit() (err error) {
|
||||
ctx, _ := context.WithTimeout(context.Background(), time.Second*60)
|
||||
count, err := this.mgo.CountDocuments(DB_UserIdTable, bson.M{})
|
||||
if err != nil || count == 0 {
|
||||
//批量插入数据
|
||||
leng := 1000000
|
||||
cIds := make([]interface{}, leng)
|
||||
for i, _ := range cIds {
|
||||
cIds[i] = 1000000 + i
|
||||
}
|
||||
data := make([]interface{}, leng)
|
||||
r := rand.New(rand.NewSource(time.Now().Unix()))
|
||||
n := 0
|
||||
for _, i := range r.Perm(leng) {
|
||||
data[n] = bson.M{"_id": i}
|
||||
n++
|
||||
}
|
||||
var (
|
||||
err error
|
||||
)
|
||||
begin := time.Now()
|
||||
if _, err = this.mgo.InsertManyByCtx(DB_UserIdTable, ctx, data); err != nil {
|
||||
return fmt.Errorf("checkUserIdInit err=%s", err.Error())
|
||||
}
|
||||
log.Debugf("checkUserIdInit succ time consuming:%v", time.Now().Sub(begin))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/liwei1dao/lego/sys/mgo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
)
|
||||
|
||||
var db *DB
|
||||
@ -37,7 +38,7 @@ func TestCreate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFindOne(t *testing.T) {
|
||||
user, err := db.User_FindUserById(1)
|
||||
user, err := db.User_FindUserById("")
|
||||
require.Nil(t, err)
|
||||
assert.Equal(t, "legu1", user.Account)
|
||||
|
||||
@ -49,7 +50,7 @@ func TestFindOne(t *testing.T) {
|
||||
|
||||
func TestUpdate(t *testing.T) {
|
||||
user := &pb.DB_UserData{
|
||||
UserId: 10001,
|
||||
UserId: primitive.NewObjectID().String(),
|
||||
Email: "new@qq.com",
|
||||
}
|
||||
err := db.User_UpdateUser(user)
|
||||
|
Loading…
Reference in New Issue
Block a user