From e0d825b2ae1bea37e4f9d89714da16fac0c4ff57 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 4 Jul 2022 18:21:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BD=91=E5=85=B3?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E7=AE=A1=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 5 + comm/usersession.go | 35 ++++ modules/core.go | 5 + modules/gateway/agentmgr_comp.go | 8 +- modules/modulebase.go | 44 +++-- modules/shop/api_buy.go | 43 ++++- modules/shop/api_getlist.go | 57 +++++- modules/shop/configure.go | 66 +++++++ modules/shop/core.go | 58 +++++++ modules/shop/model_shop.go | 2 +- modules/shop/model_shopitems.go | 64 +++++++ modules/shop/module.go | 8 +- pb/comm.pb.go | 107 +++++------- pb/proto/comm.proto | 7 +- pb/proto/shop/shop_db.proto | 7 + pb/proto/shop/shop_msg.proto | 22 ++- pb/shop_db.pb.go | 121 +++++++++++-- pb/shop_msg.pb.go | 290 ++++++++++++++++++++++++++----- services/comp_gateroute.go | 52 +++--- 19 files changed, 834 insertions(+), 167 deletions(-) create mode 100644 modules/shop/core.go create mode 100644 modules/shop/model_shopitems.go diff --git a/comm/core.go b/comm/core.go index e2dc21b4d..a17361a21 100644 --- a/comm/core.go +++ b/comm/core.go @@ -17,6 +17,8 @@ type ISC_GateRouteComp interface { core.IServiceComp ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, handle reflect.Method) + GetUserSession(udata *pb.CacheUser) (session IUserSession) + PutUserSession(session IUserSession) } //游戏类资源类型 @@ -46,6 +48,7 @@ type ErrorCode struct { //用户会话 type IUserSession interface { + SetSession(ip, sessionId, gatewayServiceId, uid string) GetSessionId() string GetUserId() string GetIP() string @@ -55,7 +58,9 @@ type IUserSession interface { UnBind() (err error) SendMsg(mainType, subType string, msg proto.Message) (err error) Polls() []*pb.UserMessage + Push() (err error) //警告 api传递过来的会话禁用此接口 Close() (err error) + Reset() ToString() string } diff --git a/comm/usersession.go b/comm/usersession.go index eeab688e2..47afe21bc 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -27,6 +27,13 @@ func NewUserSession(service base.IRPCXService, ip, sessionId, gatewayServiceId s } } +func NewUserSessionByPools(service base.IRPCXService) IUserSession { + return &UserSession{ + msgqueue: make([]*pb.UserMessage, 0), + service: service, + } +} + type UserSession struct { IP string SessionId string @@ -36,6 +43,24 @@ type UserSession struct { msgqueue []*pb.UserMessage } +//重置 +func (this *UserSession) SetSession(ip, sessionId, gatewayServiceId, uid string) { + this.IP = ip + this.SessionId = sessionId + this.GatewayServiceId = gatewayServiceId + this.UserId = uid + this.msgqueue = this.msgqueue[:0] +} + +//重置 +func (this *UserSession) Reset() { + this.IP = "" + this.SessionId = "" + this.GatewayServiceId = "" + this.UserId = "" + this.msgqueue = this.msgqueue[:0] +} + //获取用户的会话id func (this *UserSession) GetSessionId() string { return this.SessionId @@ -121,6 +146,16 @@ func (this *UserSession) Polls() []*pb.UserMessage { return msgs } +func (this *UserSession) Push() (err error) { + reply := &pb.RPCMessageReply{} + if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ + Reply: this.msgqueue, + }, reply); err != nil { + log.Errorf("SendMsgToUsers:%v err:%v", this, err) + } + return +} + //打印日志需要 func (this *UserSession) ToString() string { return fmt.Sprintf("SessionId:%s UserId:%s GatewayServiceId:%s", this.SessionId, this.UserId, this.GatewayServiceId) diff --git a/modules/core.go b/modules/core.go index 4f1e11612..e1f15c701 100644 --- a/modules/core.go +++ b/modules/core.go @@ -1,6 +1,7 @@ package modules import ( + "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" @@ -12,6 +13,10 @@ type ( //业务模块基类接口 定义所有业务模块都可以使用的接口 IModule interface { core.IModule + //获取用户对象 + GetUserSession(uid string) (session comm.IUserSession, ok bool) + //归还会话对象 + PutUserSession(session comm.IUserSession) //向指定用户发送消息 SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.CacheUser) (err error) //向多个用户发送消息 diff --git a/modules/gateway/agentmgr_comp.go b/modules/gateway/agentmgr_comp.go index d9a487132..3c85854b9 100644 --- a/modules/gateway/agentmgr_comp.go +++ b/modules/gateway/agentmgr_comp.go @@ -74,11 +74,9 @@ func (this *AgentMgrComp) UnBind(ctx context.Context, args *pb.AgentUnBuildReq, // SendMsgToAgent 向用户发送消息 func (this *AgentMgrComp) 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{ - MainType: args.MainType, - SubType: args.SubType, - Data: args.Data, - }) + for _, v := range args.Reply { + a.(IAgent).WriteMsg(v) + } } else { reply.Code = pb.ErrorCode_UserSessionNobeing reply.ErrorMessage = pb.GetErrorCodeMsg(pb.ErrorCode_UserSessionNobeing) diff --git a/modules/modulebase.go b/modules/modulebase.go index 79043cf34..0504579fc 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -12,8 +12,8 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "strconv" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" ) /* @@ -23,6 +23,7 @@ type ModuleBase struct { cbase.ModuleBase module core.IModule service base.IRPCXService + scomp comm.ISC_GateRouteComp //网关服务组件 //常用的一些通用模块 在底层注册好 ModuleUser comm.IUser //用户模块 ModuleItems comm.IItems //道具背包模块 @@ -41,6 +42,12 @@ func (this *ModuleBase) Init(service core.IService, module core.IModule, options //模块启动接口 func (this *ModuleBase) Start() (err error) { err = this.ModuleBase.Start() + var comp core.IServiceComp + //注册远程路由 + if comp, err = this.service.GetComp(comm.SC_ServiceGateRouteComp); err != nil { + return + } + this.scomp = comp.(comm.ISC_GateRouteComp) var module core.IModule if module, err = this.service.GetModule(comm.ModuleUser); err != nil { return @@ -61,18 +68,29 @@ func (this *ModuleBase) Start() (err error) { return } +func (this *ModuleBase) GetUserSession(uid string) (session comm.IUserSession, ok bool) { + var udata *pb.CacheUser + if udata = this.ModuleUser.GetUserSession(uid); udata == nil { + ok = false + return + } + session = this.scomp.GetUserSession(udata) + ok = true + return +} + +func (this *ModuleBase) PutUserSession(session comm.IUserSession) { + session.Reset() + this.scomp.PutUserSession(session) + return +} + //向指定用户发送消息 func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.CacheUser) (err error) { - reply := &pb.RPCMessageReply{} - data, _ := ptypes.MarshalAny(msg) - if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Gateway, user.GatewayServiceId), string(comm.Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ - UserSessionId: user.SessionId, - MainType: mainType, - SubType: subType, - Data: data, - }, reply); err != nil { - log.Errorf("SendMsgToUser%d:%s [%s.%s] err:%v", user.Uid, user.SessionId, mainType, subType, err) - } + session := this.scomp.GetUserSession(user) + session.SendMsg(mainType, subType, msg) + err = session.Push() + this.scomp.PutUserSession(session) return } @@ -91,7 +109,7 @@ func (this *ModuleBase) SendMsgToUsers(mainType, subType string, msg proto.Messa gateway = append(gateway, v.SessionId) } reply := &pb.RPCMessageReply{} - data, _ := ptypes.MarshalAny(msg) + data, _ := anypb.New(msg) for k, v := range gateways { if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", comm.Service_Gateway, k), string(comm.Rpc_GatewayAgentSendMsg), &pb.BatchMessageReq{ UserSessionIds: v, diff --git a/modules/shop/api_buy.go b/modules/shop/api_buy.go index 9d8a0fcb6..af6b271ec 100644 --- a/modules/shop/api_buy.go +++ b/modules/shop/api_buy.go @@ -3,7 +3,10 @@ package shop import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + "time" + "go.mongodb.org/mongo-driver/bson/primitive" "google.golang.org/protobuf/proto" ) @@ -15,12 +18,48 @@ func (this *apiComp) BuyCheck(session comm.IUserSession, req *pb.ShopBuyReq) (co ///获取用户商品列表 func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb.ErrorCode, data proto.Message) { - var () + var ( + err error + ok bool + conf *cfg.Game_shopitemData + shopitem *pb.DBShopItem + ) defer func() { if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{}) + session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{IsSucc: true}) + } else { + session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{IsSucc: false}) } }() + if conf, err = this.module.configure.GetShopItemsConfigure(req.GoodsId); err != nil { + code = pb.ErrorCode_SystemError + return + } + if shopitem, ok = this.module.modelShopItems.QueryUserShopDataByGoodId(session.GetUserId(), req.GoodsId); !ok { //没有购买记录 + shopitem = &pb.DBShopItem{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + GoodsId: req.GoodsId, + BuyNum: 0, + LastBuyTime: 0, + } + } + if code = this.module.CheckConsumeRes(session.GetUserId(), conf.Need); code != pb.ErrorCode_Success { + return + } + if code = this.module.DispenseRes(session.GetUserId(), conf.Iteminfo); code != pb.ErrorCode_Success { + return + } + shopitem.BuyNum++ + shopitem.LastBuyTime = time.Now().Unix() + if !ok { + this.module.modelShopItems.AddList(session.GetUserId(), shopitem.Id, shopitem) + } else { + this.module.modelShopItems.ChangeList(session.GetUserId(), shopitem.Id, map[string]interface{}{ + "buynum": shopitem.BuyNum, + "lastbuytime": shopitem.LastBuyTime, + }) + } return } diff --git a/modules/shop/api_getlist.go b/modules/shop/api_getlist.go index 890f5c0a8..cdea7c212 100644 --- a/modules/shop/api_getlist.go +++ b/modules/shop/api_getlist.go @@ -20,15 +20,18 @@ func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.ShopGetList func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) (code pb.ErrorCode, data proto.Message) { var ( err error + filed string shopconf *cfg.Game_shopData shopData *pb.DBShop sdata *pb.UserShopData + items []*cfg.Game_shopitemData + goods []*pb.ShopItem tdata time.Duration ltime time.Duration ) defer func() { if code == pb.ErrorCode_Success { - session.SendMsg(string(this.module.GetType()), "getlist", &pb.ShopGetListResp{}) + session.SendMsg(string(this.module.GetType()), "getlist", &pb.ShopGetListResp{Goods: goods}) } }() if shopconf, err = this.module.configure.GetShopConfigure(int32(req.SType)); err != nil && err != mgo.MongodbNil { @@ -39,21 +42,27 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) code = pb.ErrorCode_SystemError return } + switch req.SType { case pb.ShopType_GoldShop: sdata = shopData.GoldShop + filed = "goldshop" break case pb.ShopType_DiamondShop: sdata = shopData.DiamondShop + filed = "diamondshop" break case pb.ShopType_PVPShop: sdata = shopData.PVPShop + filed = "pvpshop" break case pb.ShopType_PVEShop: sdata = shopData.PVEShop + filed = "pveshop" break case pb.ShopType_AllianceShop: sdata = shopData.AllianceShop + filed = "allianceshop" break } if sdata == nil { @@ -75,10 +84,52 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) break } - if tdata > ltime { //达到刷新时间 可以刷新商品列表 + if req.IsManualRefresh && shopconf.Rtype == 1 { //可以手动刷新 + if code = this.module.CheckConsumeRes(session.GetUserId(), shopconf.Rneed); code != pb.ErrorCode_Success { + return + } + var _items []*cfg.Game_shopitemData + for _, v := range shopconf.Shopitem { + if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v); err != nil { + code = pb.ErrorCode_SystemError + return + } + items = append(items, randomGoods(_items)) + } + goods = transGoods(items) + sdata.LastRefreshTime = time.Now().Unix() + sdata.Items = make([]int32, len(items)) + for i, v := range items { + sdata.Items[i] = v.Key + } + this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: sdata}) + } else if !req.IsManualRefresh { + if tdata > ltime { //达到刷新时间 可以刷新商品列表 + var _items []*cfg.Game_shopitemData + for _, v := range shopconf.Shopitem { + if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v); err != nil { + code = pb.ErrorCode_SystemError + return + } + items = append(items, randomGoods(_items)) + } + goods = transGoods(items) + sdata.LastRefreshTime = time.Now().Unix() + sdata.Items = make([]int32, len(items)) + for i, v := range items { + sdata.Items[i] = v.Key + } + this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: sdata}) + } else { //返回以前的商品列表 + if items, err = this.module.configure.GetShopItemsConfigureByIds(sdata.Items...); err != nil { + code = pb.ErrorCode_SystemError + return + } + goods = transGoods(items) + } } else { - + code = pb.ErrorCode_ReqParameterError } return diff --git a/modules/shop/configure.go b/modules/shop/configure.go index 58a144357..dcb0e3136 100644 --- a/modules/shop/configure.go +++ b/modules/shop/configure.go @@ -44,3 +44,69 @@ func (this *configureComp) GetShopConfigure(id int32) (configure *cfg.Game_shopD } return } + +//读取商品 +func (this *configureComp) GetShopItemsConfigure(key int32) (result *cfg.Game_shopitemData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_shop); err != nil { + log.Errorf("err:%v", err) + return + } else { + if result, ok = v.(*cfg.Game_shopitem).GetDataMap()[key]; !ok { + err = fmt.Errorf("ShopConfigure not found:%d ", key) + log.Errorf("err:%v", err) + return + } + } + return +} + +//读取商品组 +func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32) (result []*cfg.Game_shopitemData, err error) { + result = make([]*cfg.Game_shopitemData, 0, 10) + var ( + v interface{} + table *cfg.Game_shopitem + item *cfg.Game_shopitemData + ) + if v, err = this.GetConfigure(game_shop); err != nil { + log.Errorf("err:%v", err) + return + } else { + table = v.(*cfg.Game_shopitem) + for _, v := range table.GetDataMap() { + if v.Id == groupid { + result = append(result, item) + } + } + } + return +} + +//读取商品 +func (this *configureComp) GetShopItemsConfigureByIds(keys ...int32) (result []*cfg.Game_shopitemData, err error) { + result = make([]*cfg.Game_shopitemData, 0, len(keys)) + var ( + v interface{} + table *cfg.Game_shopitem + item *cfg.Game_shopitemData + ok bool + ) + if v, err = this.GetConfigure(game_shop); err != nil { + log.Errorf("err:%v", err) + return + } else { + table = v.(*cfg.Game_shopitem) + for _, v := range keys { + if item, ok = table.GetDataMap()[v]; ok { + result = append(result, item) + } else { + log.Errorf("no found GetShopItemsConfigureByIds:%d", v) + } + } + } + return +} diff --git a/modules/shop/core.go b/modules/shop/core.go new file mode 100644 index 000000000..3f279b52f --- /dev/null +++ b/modules/shop/core.go @@ -0,0 +1,58 @@ +package shop + +import ( + "crypto/rand" + "go_dreamfactory/pb" + cfg "go_dreamfactory/sys/configure/structs" + "math/big" +) + +//随机商品列表 +func randomGoods(goods []*cfg.Game_shopitemData) (result *cfg.Game_shopitemData) { + var ( + totle int64 + curr int64 + temp int64 + ) + for _, v := range goods { + totle += int64(v.Probability) + } + n, _ := rand.Int(rand.Reader, big.NewInt(totle)) + curr = n.Int64() + for _, v := range goods { + temp += int64(v.Probability) + if curr <= temp { + result = v + return + } + } + return +} + +//转换商品对象 +func transGoods(goods []*cfg.Game_shopitemData) (result []*pb.ShopItem) { + result = make([]*pb.ShopItem, len(goods)) + for i, v := range goods { + result[i] = &pb.ShopItem{ + GoodsId: v.Key, + Sale: int32(v.Sale), + } + result[i].Items = make([]*pb.Resource, len(v.Iteminfo)) + for i1, v1 := range v.Iteminfo { + result[i].Items[i1] = &pb.Resource{ + ResourceType: v1.A, + ResourceId: v1.T, + Amount: v1.N, + } + } + result[i].Consume = make([]*pb.Resource, len(v.Need)) + for i1, v1 := range v.Need { + result[i].Items[i1] = &pb.Resource{ + ResourceType: v1.A, + ResourceId: v1.T, + Amount: v1.N, + } + } + } + return +} diff --git a/modules/shop/model_shop.go b/modules/shop/model_shop.go index 82f0cdb56..1194f53a8 100644 --- a/modules/shop/model_shop.go +++ b/modules/shop/model_shop.go @@ -19,7 +19,7 @@ type modelShopComp struct { func (this *modelShopComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { this.MCompModel.Init(service, module, comp, opt) this.module = module.(*Shop) - this.TableName = "forum" + this.TableName = "shop" //创建uid索引 this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, diff --git a/modules/shop/model_shopitems.go b/modules/shop/model_shopitems.go new file mode 100644 index 000000000..2ec8d6044 --- /dev/null +++ b/modules/shop/model_shopitems.go @@ -0,0 +1,64 @@ +package shop + +import ( + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" +) + +///商店物品记录 数据组件 +type modelShopItemsComp struct { + modules.MCompModel + module *Shop +} + +//组件初始化接口 +func (this *modelShopItemsComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { + this.MCompModel.Init(service, module, comp, opt) + this.module = module.(*Shop) + this.TableName = "shopitems" + + //创建uid索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}, {Key: "goodsid", Value: bsonx.Int32(1)}}, + }) + return +} + +//查询用户装备数据 +func (this *modelShopItemsComp) QueryUserShopData(uId string) (data []*pb.DBShopItem, err error) { + data = make([]*pb.DBShopItem, 0) + err = this.GetList(uId, &data) + return +} + +//查询用户装备数据 +func (this *modelShopItemsComp) QueryUserShopDataByGoodId(uId string, goodId int32) (result *pb.DBShopItem, ok bool) { + var ( + err error + data []*pb.DBShopItem + ) + data = make([]*pb.DBShopItem, 0) + if err = this.GetList(uId, &data); err != nil { + log.Errorf("err%v", err) + return + } + for _, v := range data { + if v.GoodsId == goodId { + result = v + ok = true + return + } + } + return +} + +//添加用户的商品购买记录 +func (this *modelShopItemsComp) AddUserShopItemData(data *pb.DBShopItem) (err error) { + err = this.AddList(data.Uid, data.Id, data) + return +} diff --git a/modules/shop/module.go b/modules/shop/module.go index 9a9a331b2..5e3a0026c 100644 --- a/modules/shop/module.go +++ b/modules/shop/module.go @@ -18,9 +18,10 @@ func NewModule() core.IModule { type Shop struct { modules.ModuleBase - api_comp *apiComp - configure *configureComp - modelShop *modelShopComp + api_comp *apiComp + configure *configureComp + modelShop *modelShopComp + modelShopItems *modelShopItemsComp } //模块名 @@ -39,5 +40,6 @@ func (this *Shop) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) this.modelShop = this.RegisterComp(new(modelShopComp)).(*modelShopComp) + this.modelShopItems = this.RegisterComp(new(modelShopItemsComp)).(*modelShopItemsComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } diff --git a/pb/comm.pb.go b/pb/comm.pb.go index 390bbaaf8..e2ea9ec41 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -436,10 +436,8 @@ type AgentSendMessageReq struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId"` - MainType string `protobuf:"bytes,2,opt,name=MainType,proto3" json:"MainType"` - SubType string `protobuf:"bytes,3,opt,name=SubType,proto3" json:"SubType"` - Data *anypb.Any `protobuf:"bytes,4,opt,name=Data,proto3" json:"Data"` + UserSessionId string `protobuf:"bytes,1,opt,name=UserSessionId,proto3" json:"UserSessionId"` + Reply []*UserMessage `protobuf:"bytes,2,rep,name=Reply,proto3" json:"Reply"` } func (x *AgentSendMessageReq) Reset() { @@ -481,23 +479,9 @@ func (x *AgentSendMessageReq) GetUserSessionId() string { return "" } -func (x *AgentSendMessageReq) GetMainType() string { +func (x *AgentSendMessageReq) GetReply() []*UserMessage { if x != nil { - return x.MainType - } - return "" -} - -func (x *AgentSendMessageReq) GetSubType() string { - if x != nil { - return x.SubType - } - return "" -} - -func (x *AgentSendMessageReq) GetData() *anypb.Any { - if x != nil { - return x.Data + return x.Reply } return nil } @@ -792,48 +776,45 @@ var file_comm_proto_rawDesc = []byte{ 0x6b, 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, 0x9b, - 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, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 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, 0x28, - 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, - 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x75, 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, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 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, 0x22, 0x52, 0x0a, 0x12, 0x4e, 0x6f, 0x74, 0x69, 0x63, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6c, 0x6f, 0x73, 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, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x2a, 0x43, 0x0a, 0x12, 0x48, - 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, - 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, - 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, - 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, - 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0d, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x5f, + 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, 0x22, 0x0a, 0x05, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, + 0x99, 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, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x75, 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, 0x28, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 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, 0x22, 0x52, 0x0a, 0x12, 0x4e, 0x6f, + 0x74, 0x69, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6c, 0x6f, 0x73, 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, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x2a, 0x43, + 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, + 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, + 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, + 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -871,7 +852,7 @@ var file_comm_proto_depIdxs = []int32{ 12, // 2: RPCMessageReply.Code:type_name -> ErrorCode 11, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any 1, // 4: RPCMessageReply.Reply:type_name -> UserMessage - 11, // 5: AgentSendMessageReq.Data:type_name -> google.protobuf.Any + 1, // 5: AgentSendMessageReq.Reply:type_name -> UserMessage 11, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any 11, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any 8, // [8:8] is the sub-list for method output_type diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index bbd896913..ae3ef83bc 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -43,9 +43,7 @@ message AgentUnBuildReq { string UserSessionId = 1; } //向用户代理发送消息请求 message AgentSendMessageReq { string UserSessionId = 1; - string MainType = 2; - string SubType = 3; - google.protobuf.Any Data = 4; + repeated UserMessage Reply = 2; } //发送批量消息 @@ -76,4 +74,5 @@ enum HeroAttributesType{ Def = 2; //防御 Speed = 3; //速度 Crit = 4; //暴击 -} \ No newline at end of file +} + diff --git a/pb/proto/shop/shop_db.proto b/pb/proto/shop/shop_db.proto index 0fcda975f..27e86e467 100644 --- a/pb/proto/shop/shop_db.proto +++ b/pb/proto/shop/shop_db.proto @@ -24,5 +24,12 @@ message DBShop { UserShopData PVPShop = 5; //金币商店数据 UserShopData PVEShop = 6; //金币商店数据 UserShopData AllianceShop = 7; //金币商店数据 +} +message DBShopItem { + string id = 1; //@go_tags(`bson:"_id"`) 装备id + string uid = 2; //@go_tags(`bson:"uid"`) 装备id + int32 GoodsId = 3; //商品Id + int32 BuyNum = 4; //购买数量 + int64 LastBuyTime = 5; //最后一次购买的时间 } \ No newline at end of file diff --git a/pb/proto/shop/shop_msg.proto b/pb/proto/shop/shop_msg.proto index e0e312ce6..a310ff540 100644 --- a/pb/proto/shop/shop_msg.proto +++ b/pb/proto/shop/shop_msg.proto @@ -2,6 +2,22 @@ syntax = "proto3"; option go_package = ".;pb"; import "shop/shop_db.proto"; + +//资源对象 +message Resource { + string ResourceType = 1; //资源类型 + string ResourceId = 2; //资源Id + int32 Amount = 3; //数量 +} + +//商品对象数据 +message ShopItem { + int32 GoodsId = 1; //商品Id + repeated Resource Items = 2; //货物 + repeated Resource Consume = 3; //消耗 + int32 Sale = 4; //打折 +} + //获取装备列表请求 message ShopGetListReq { ShopType sType = 1; //商城类型 @@ -10,15 +26,15 @@ message ShopGetListReq { //获取装备列表请求 message ShopGetListResp { - + repeated ShopItem Goods = 1; //商品列表 } //购买商品 请求 message ShopBuyReq { - + int32 GoodsId = 1; //商品Id } //购买商品 回应 message ShopBuyResp { - + bool IsSucc = 1; //是否成功 } diff --git a/pb/shop_db.pb.go b/pb/shop_db.pb.go index bf255244b..a1c91a9b3 100644 --- a/pb/shop_db.pb.go +++ b/pb/shop_db.pb.go @@ -236,6 +236,85 @@ func (x *DBShop) GetAllianceShop() *UserShopData { return nil } +type DBShopItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //装备id + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //装备id + GoodsId int32 `protobuf:"varint,3,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id + BuyNum int32 `protobuf:"varint,4,opt,name=BuyNum,proto3" json:"BuyNum"` //购买数量 + LastBuyTime int64 `protobuf:"varint,5,opt,name=LastBuyTime,proto3" json:"LastBuyTime"` //最后一次购买的时间 +} + +func (x *DBShopItem) Reset() { + *x = DBShopItem{} + if protoimpl.UnsafeEnabled { + mi := &file_shop_shop_db_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBShopItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBShopItem) ProtoMessage() {} + +func (x *DBShopItem) ProtoReflect() protoreflect.Message { + mi := &file_shop_shop_db_proto_msgTypes[2] + 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 DBShopItem.ProtoReflect.Descriptor instead. +func (*DBShopItem) Descriptor() ([]byte, []int) { + return file_shop_shop_db_proto_rawDescGZIP(), []int{2} +} + +func (x *DBShopItem) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBShopItem) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBShopItem) GetGoodsId() int32 { + if x != nil { + return x.GoodsId + } + return 0 +} + +func (x *DBShopItem) GetBuyNum() int32 { + if x != nil { + return x.BuyNum + } + return 0 +} + +func (x *DBShopItem) GetLastBuyTime() int64 { + if x != nil { + return x.LastBuyTime + } + return 0 +} + var File_shop_shop_db_proto protoreflect.FileDescriptor var file_shop_shop_db_proto_rawDesc = []byte{ @@ -264,14 +343,23 @@ var file_shop_shop_db_proto_rawDesc = []byte{ 0x74, 0x61, 0x52, 0x07, 0x50, 0x56, 0x45, 0x53, 0x68, 0x6f, 0x70, 0x12, 0x31, 0x0a, 0x0c, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x53, 0x68, 0x6f, 0x70, 0x44, 0x61, 0x74, 0x61, - 0x52, 0x0c, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x2a, 0x5f, - 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x75, - 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x47, 0x6f, 0x6c, 0x64, 0x53, 0x68, 0x6f, 0x70, - 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x44, 0x69, 0x61, 0x6d, 0x6f, 0x6e, 0x64, 0x53, 0x68, 0x6f, - 0x70, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x56, 0x50, 0x53, 0x68, 0x6f, 0x70, 0x10, 0x03, - 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x56, 0x45, 0x53, 0x68, 0x6f, 0x70, 0x10, 0x04, 0x12, 0x10, 0x0a, - 0x0c, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x10, 0x05, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x0c, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x68, 0x6f, 0x70, 0x22, 0x82, + 0x01, 0x0a, 0x0a, 0x44, 0x42, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a, + 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, + 0x18, 0x0a, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x42, 0x75, 0x79, + 0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x42, 0x75, 0x79, 0x4e, 0x75, + 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x61, 0x73, 0x74, 0x42, 0x75, 0x79, 0x54, 0x69, 0x6d, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x4c, 0x61, 0x73, 0x74, 0x42, 0x75, 0x79, 0x54, + 0x69, 0x6d, 0x65, 0x2a, 0x5f, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x08, 0x0a, 0x04, 0x4e, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x47, 0x6f, 0x6c, + 0x64, 0x53, 0x68, 0x6f, 0x70, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x44, 0x69, 0x61, 0x6d, 0x6f, + 0x6e, 0x64, 0x53, 0x68, 0x6f, 0x70, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x56, 0x50, 0x53, + 0x68, 0x6f, 0x70, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x56, 0x45, 0x53, 0x68, 0x6f, 0x70, + 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x41, 0x6c, 0x6c, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x53, 0x68, + 0x6f, 0x70, 0x10, 0x05, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -287,11 +375,12 @@ func file_shop_shop_db_proto_rawDescGZIP() []byte { } var file_shop_shop_db_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_shop_shop_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_shop_shop_db_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_shop_shop_db_proto_goTypes = []interface{}{ (ShopType)(0), // 0: ShopType (*UserShopData)(nil), // 1: UserShopData (*DBShop)(nil), // 2: DBShop + (*DBShopItem)(nil), // 3: DBShopItem } var file_shop_shop_db_proto_depIdxs = []int32{ 1, // 0: DBShop.GoldShop:type_name -> UserShopData @@ -336,6 +425,18 @@ func file_shop_shop_db_proto_init() { return nil } } + file_shop_shop_db_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBShopItem); 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{ @@ -343,7 +444,7 @@ func file_shop_shop_db_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_shop_shop_db_proto_rawDesc, NumEnums: 1, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/shop_msg.pb.go b/pb/shop_msg.pb.go index 78b133e33..9954f0524 100644 --- a/pb/shop_msg.pb.go +++ b/pb/shop_msg.pb.go @@ -20,6 +20,142 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +//资源对象 +type Resource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ResourceType string `protobuf:"bytes,1,opt,name=ResourceType,proto3" json:"ResourceType"` //资源类型 + ResourceId string `protobuf:"bytes,2,opt,name=ResourceId,proto3" json:"ResourceId"` //资源Id + Amount int32 `protobuf:"varint,3,opt,name=Amount,proto3" json:"Amount"` //数量 +} + +func (x *Resource) Reset() { + *x = Resource{} + if protoimpl.UnsafeEnabled { + mi := &file_shop_shop_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_shop_shop_msg_proto_msgTypes[0] + 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 Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_shop_shop_msg_proto_rawDescGZIP(), []int{0} +} + +func (x *Resource) GetResourceType() string { + if x != nil { + return x.ResourceType + } + return "" +} + +func (x *Resource) GetResourceId() string { + if x != nil { + return x.ResourceId + } + return "" +} + +func (x *Resource) GetAmount() int32 { + if x != nil { + return x.Amount + } + return 0 +} + +//商品对象数据 +type ShopItem struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + GoodsId int32 `protobuf:"varint,1,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id + Items []*Resource `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items"` //货物 + Consume []*Resource `protobuf:"bytes,3,rep,name=Consume,proto3" json:"Consume"` //消耗 + Sale int32 `protobuf:"varint,4,opt,name=Sale,proto3" json:"Sale"` //打折 +} + +func (x *ShopItem) Reset() { + *x = ShopItem{} + if protoimpl.UnsafeEnabled { + mi := &file_shop_shop_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ShopItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ShopItem) ProtoMessage() {} + +func (x *ShopItem) ProtoReflect() protoreflect.Message { + mi := &file_shop_shop_msg_proto_msgTypes[1] + 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 ShopItem.ProtoReflect.Descriptor instead. +func (*ShopItem) Descriptor() ([]byte, []int) { + return file_shop_shop_msg_proto_rawDescGZIP(), []int{1} +} + +func (x *ShopItem) GetGoodsId() int32 { + if x != nil { + return x.GoodsId + } + return 0 +} + +func (x *ShopItem) GetItems() []*Resource { + if x != nil { + return x.Items + } + return nil +} + +func (x *ShopItem) GetConsume() []*Resource { + if x != nil { + return x.Consume + } + return nil +} + +func (x *ShopItem) GetSale() int32 { + if x != nil { + return x.Sale + } + return 0 +} + //获取装备列表请求 type ShopGetListReq struct { state protoimpl.MessageState @@ -33,7 +169,7 @@ type ShopGetListReq struct { func (x *ShopGetListReq) Reset() { *x = ShopGetListReq{} if protoimpl.UnsafeEnabled { - mi := &file_shop_shop_msg_proto_msgTypes[0] + mi := &file_shop_shop_msg_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -46,7 +182,7 @@ func (x *ShopGetListReq) String() string { func (*ShopGetListReq) ProtoMessage() {} func (x *ShopGetListReq) ProtoReflect() protoreflect.Message { - mi := &file_shop_shop_msg_proto_msgTypes[0] + mi := &file_shop_shop_msg_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -59,7 +195,7 @@ func (x *ShopGetListReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ShopGetListReq.ProtoReflect.Descriptor instead. func (*ShopGetListReq) Descriptor() ([]byte, []int) { - return file_shop_shop_msg_proto_rawDescGZIP(), []int{0} + return file_shop_shop_msg_proto_rawDescGZIP(), []int{2} } func (x *ShopGetListReq) GetSType() ShopType { @@ -81,12 +217,14 @@ type ShopGetListResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Goods []*ShopItem `protobuf:"bytes,1,rep,name=Goods,proto3" json:"Goods"` //商品列表 } func (x *ShopGetListResp) Reset() { *x = ShopGetListResp{} if protoimpl.UnsafeEnabled { - mi := &file_shop_shop_msg_proto_msgTypes[1] + mi := &file_shop_shop_msg_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -99,7 +237,7 @@ func (x *ShopGetListResp) String() string { func (*ShopGetListResp) ProtoMessage() {} func (x *ShopGetListResp) ProtoReflect() protoreflect.Message { - mi := &file_shop_shop_msg_proto_msgTypes[1] + mi := &file_shop_shop_msg_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -112,7 +250,14 @@ func (x *ShopGetListResp) ProtoReflect() protoreflect.Message { // Deprecated: Use ShopGetListResp.ProtoReflect.Descriptor instead. func (*ShopGetListResp) Descriptor() ([]byte, []int) { - return file_shop_shop_msg_proto_rawDescGZIP(), []int{1} + return file_shop_shop_msg_proto_rawDescGZIP(), []int{3} +} + +func (x *ShopGetListResp) GetGoods() []*ShopItem { + if x != nil { + return x.Goods + } + return nil } //购买商品 请求 @@ -120,12 +265,14 @@ type ShopBuyReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + GoodsId int32 `protobuf:"varint,1,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id } func (x *ShopBuyReq) Reset() { *x = ShopBuyReq{} if protoimpl.UnsafeEnabled { - mi := &file_shop_shop_msg_proto_msgTypes[2] + mi := &file_shop_shop_msg_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -138,7 +285,7 @@ func (x *ShopBuyReq) String() string { func (*ShopBuyReq) ProtoMessage() {} func (x *ShopBuyReq) ProtoReflect() protoreflect.Message { - mi := &file_shop_shop_msg_proto_msgTypes[2] + mi := &file_shop_shop_msg_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -151,7 +298,14 @@ func (x *ShopBuyReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ShopBuyReq.ProtoReflect.Descriptor instead. func (*ShopBuyReq) Descriptor() ([]byte, []int) { - return file_shop_shop_msg_proto_rawDescGZIP(), []int{2} + return file_shop_shop_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *ShopBuyReq) GetGoodsId() int32 { + if x != nil { + return x.GoodsId + } + return 0 } //购买商品 回应 @@ -159,12 +313,14 @@ type ShopBuyResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + IsSucc bool `protobuf:"varint,1,opt,name=IsSucc,proto3" json:"IsSucc"` //是否成功 } func (x *ShopBuyResp) Reset() { *x = ShopBuyResp{} if protoimpl.UnsafeEnabled { - mi := &file_shop_shop_msg_proto_msgTypes[3] + mi := &file_shop_shop_msg_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -177,7 +333,7 @@ func (x *ShopBuyResp) String() string { func (*ShopBuyResp) ProtoMessage() {} func (x *ShopBuyResp) ProtoReflect() protoreflect.Message { - mi := &file_shop_shop_msg_proto_msgTypes[3] + mi := &file_shop_shop_msg_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -190,7 +346,14 @@ func (x *ShopBuyResp) ProtoReflect() protoreflect.Message { // Deprecated: Use ShopBuyResp.ProtoReflect.Descriptor instead. func (*ShopBuyResp) Descriptor() ([]byte, []int) { - return file_shop_shop_msg_proto_rawDescGZIP(), []int{3} + return file_shop_shop_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *ShopBuyResp) GetIsSucc() bool { + if x != nil { + return x.IsSucc + } + return false } var File_shop_shop_msg_proto protoreflect.FileDescriptor @@ -198,17 +361,37 @@ var File_shop_shop_msg_proto protoreflect.FileDescriptor var file_shop_shop_msg_proto_rawDesc = []byte{ 0x0a, 0x13, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x73, 0x68, 0x6f, 0x70, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x73, 0x68, 0x6f, 0x70, - 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, 0x0e, 0x53, 0x68, 0x6f, - 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x73, - 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, - 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x0f, - 0x49, 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x49, 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x52, - 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x22, 0x11, 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, - 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x0c, 0x0a, 0x0a, 0x53, 0x68, 0x6f, - 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, 0x22, 0x0d, 0x0a, 0x0b, 0x53, 0x68, 0x6f, 0x70, 0x42, - 0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x66, 0x0a, 0x08, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, + 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x7e, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x18, 0x0a, + 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, + 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x23, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x73, + 0x75, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x61, 0x6c, + 0x65, 0x22, 0x5b, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x73, + 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x49, 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, + 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x49, + 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x22, 0x32, + 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x12, 0x1f, 0x0a, 0x05, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x47, 0x6f, 0x6f, + 0x64, 0x73, 0x22, 0x26, 0x0a, 0x0a, 0x53, 0x68, 0x6f, 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, + 0x12, 0x18, 0x0a, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x22, 0x25, 0x0a, 0x0b, 0x53, 0x68, + 0x6f, 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, + 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x53, 0x75, 0x63, + 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -223,21 +406,26 @@ func file_shop_shop_msg_proto_rawDescGZIP() []byte { return file_shop_shop_msg_proto_rawDescData } -var file_shop_shop_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_shop_shop_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_shop_shop_msg_proto_goTypes = []interface{}{ - (*ShopGetListReq)(nil), // 0: ShopGetListReq - (*ShopGetListResp)(nil), // 1: ShopGetListResp - (*ShopBuyReq)(nil), // 2: ShopBuyReq - (*ShopBuyResp)(nil), // 3: ShopBuyResp - (ShopType)(0), // 4: ShopType + (*Resource)(nil), // 0: Resource + (*ShopItem)(nil), // 1: ShopItem + (*ShopGetListReq)(nil), // 2: ShopGetListReq + (*ShopGetListResp)(nil), // 3: ShopGetListResp + (*ShopBuyReq)(nil), // 4: ShopBuyReq + (*ShopBuyResp)(nil), // 5: ShopBuyResp + (ShopType)(0), // 6: ShopType } var file_shop_shop_msg_proto_depIdxs = []int32{ - 4, // 0: ShopGetListReq.sType:type_name -> ShopType - 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 + 0, // 0: ShopItem.Items:type_name -> Resource + 0, // 1: ShopItem.Consume:type_name -> Resource + 6, // 2: ShopGetListReq.sType:type_name -> ShopType + 1, // 3: ShopGetListResp.Goods:type_name -> ShopItem + 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_shop_shop_msg_proto_init() } @@ -248,7 +436,7 @@ func file_shop_shop_msg_proto_init() { file_shop_shop_db_proto_init() if !protoimpl.UnsafeEnabled { file_shop_shop_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShopGetListReq); i { + switch v := v.(*Resource); i { case 0: return &v.state case 1: @@ -260,7 +448,7 @@ func file_shop_shop_msg_proto_init() { } } file_shop_shop_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShopGetListResp); i { + switch v := v.(*ShopItem); i { case 0: return &v.state case 1: @@ -272,7 +460,7 @@ func file_shop_shop_msg_proto_init() { } } file_shop_shop_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ShopBuyReq); i { + switch v := v.(*ShopGetListReq); i { case 0: return &v.state case 1: @@ -284,6 +472,30 @@ func file_shop_shop_msg_proto_init() { } } file_shop_shop_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShopGetListResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shop_shop_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ShopBuyReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_shop_shop_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ShopBuyResp); i { case 0: return &v.state @@ -302,7 +514,7 @@ func file_shop_shop_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_shop_shop_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 5f7665087..0529b7e9e 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -39,11 +39,10 @@ type msghandle struct { //服务网关组件 type SCompGateRoute struct { cbase.ServiceCompBase - service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 - mrlock sync.RWMutex //msghandles 对象的锁 - msghandles map[string]*msghandle //处理函数的管理对象 - sessionslock sync.RWMutex //msghandles 对象的锁 - sessions map[string]comm.IUserSession //用户会话管理 避免频繁创建 + service base.IRPCXService //rpc服务对象 通过这个对象可以发布服务和调用其他服务的接口 + mrlock sync.RWMutex //msghandles 对象的锁 + msghandles map[string]*msghandle //处理函数的管理对象 + pools sync.Pool } //设置服务组件名称 方便业务模块中获取此组件对象 @@ -56,7 +55,12 @@ func (this *SCompGateRoute) Init(service core.IService, comp core.IServiceComp, err = this.ServiceCompBase.Init(service, comp, options) this.service = service.(base.IRPCXService) this.msghandles = make(map[string]*msghandle) - this.sessions = make(map[string]comm.IUserSession) + this.pools = sync.Pool{ + New: func() interface{} { + s := comm.NewUserSessionByPools(this.service) + return s + }, + } return err } // @@ -104,17 +108,14 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag msghandle, ok := this.msghandles[method] this.mrlock.RUnlock() if ok { - //读取会话对象 - this.sessionslock.RLock() - session, ok := this.sessions[args.UserSessionId] - this.sessionslock.RUnlock() - if !ok { //没有 创建会话 - //封装用户会话 - session = comm.NewUserSession(this.service, args.Ip, args.UserSessionId, args.GatewayServiceId, args.UserId) - this.sessionslock.Lock() - this.sessions[args.UserSessionId] = session - this.sessionslock.Unlock() - } + session := this.pools.Get().(comm.IUserSession) + session.SetSession(args.Ip, args.UserSessionId, args.GatewayServiceId, args.UserId) + + defer func() { //回收 + session.Reset() + this.pools.Put(session) + }() + //序列化用户消息对象 var msg proto.Message if msg, err = args.Message.UnmarshalNew(); err != nil { @@ -136,7 +137,6 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag data, _ := anypb.New(errdata.(proto.Message)) reply.ErrorData = data } - return nil } else { reply.Reply = session.Polls() } @@ -150,8 +150,18 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag //RPC_NoticeUserClose 接收用户离线通知 func (this *SCompGateRoute) NoticeUserClose(ctx context.Context, args *pb.NoticeUserCloseReq, reply *pb.RPCMessageReply) error { event.TriggerEvent(comm.EventUserOffline, args.UserId) - this.sessionslock.Lock() - delete(this.sessions, args.UserSessionId) - this.sessionslock.Unlock() return nil } + +//获取用户的会话对象 +func (this *SCompGateRoute) GetUserSession(udata *pb.CacheUser) (session comm.IUserSession) { + session = this.pools.Get().(comm.IUserSession) + session.SetSession("", udata.SessionId, udata.GatewayServiceId, udata.Uid) + return +} + +//获取用户的会话对象 +func (this *SCompGateRoute) PutUserSession(session comm.IUserSession) { + this.pools.Put(session) + return +} From ccfe0dfc02a02a420dd3b4cb5a81e115cb327e4b Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 4 Jul 2022 19:09:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=95=86=E5=9F=8Eapi?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/shop/api_getlist.go | 39 +++++++++++-------- modules/shop/configure.go | 8 +++- modules/shop/core.go | 8 +++- modules/shop/model_shopitems.go | 14 +++++-- pb/proto/shop/shop_msg.proto | 3 +- pb/shop_msg.pb.go | 66 +++++++++++++++++++-------------- 6 files changed, 88 insertions(+), 50 deletions(-) diff --git a/modules/shop/api_getlist.go b/modules/shop/api_getlist.go index cdea7c212..ab1ddf736 100644 --- a/modules/shop/api_getlist.go +++ b/modules/shop/api_getlist.go @@ -19,15 +19,17 @@ func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.ShopGetList ///获取用户商品列表 func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) (code pb.ErrorCode, data proto.Message) { var ( - err error - filed string - shopconf *cfg.Game_shopData - shopData *pb.DBShop - sdata *pb.UserShopData - items []*cfg.Game_shopitemData - goods []*pb.ShopItem - tdata time.Duration - ltime time.Duration + err error + filed string + shopconf *cfg.Game_shopData + shopData *pb.DBShop + udata *pb.DBUser + sdata *pb.UserShopData + items []*cfg.Game_shopitemData + ushoputem map[int32]*pb.DBShopItem + goods []*pb.ShopItem + tdata time.Duration + ltime time.Duration ) defer func() { if code == pb.ErrorCode_Success { @@ -42,7 +44,14 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) code = pb.ErrorCode_SystemError return } - + if udata = this.module.ModuleUser.GetUser(session.GetUserId()); udata == nil { + code = pb.ErrorCode_SystemError + return + } + if ushoputem, err = this.module.modelShopItems.QueryUserShopData(session.GetUserId()); err != nil { + code = pb.ErrorCode_SystemError + return + } switch req.SType { case pb.ShopType_GoldShop: sdata = shopData.GoldShop @@ -91,13 +100,13 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) var _items []*cfg.Game_shopitemData for _, v := range shopconf.Shopitem { - if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v); err != nil { + if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil { code = pb.ErrorCode_SystemError return } items = append(items, randomGoods(_items)) } - goods = transGoods(items) + goods = transGoods(items, ushoputem) sdata.LastRefreshTime = time.Now().Unix() sdata.Items = make([]int32, len(items)) for i, v := range items { @@ -108,13 +117,13 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) if tdata > ltime { //达到刷新时间 可以刷新商品列表 var _items []*cfg.Game_shopitemData for _, v := range shopconf.Shopitem { - if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v); err != nil { + if _items, err = this.module.configure.GetShopItemsConfigureByGroups(v, udata); err != nil { code = pb.ErrorCode_SystemError return } items = append(items, randomGoods(_items)) } - goods = transGoods(items) + goods = transGoods(items, ushoputem) sdata.LastRefreshTime = time.Now().Unix() sdata.Items = make([]int32, len(items)) for i, v := range items { @@ -126,7 +135,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) code = pb.ErrorCode_SystemError return } - goods = transGoods(items) + goods = transGoods(items, ushoputem) } } else { code = pb.ErrorCode_ReqParameterError diff --git a/modules/shop/configure.go b/modules/shop/configure.go index dcb0e3136..06ea89de8 100644 --- a/modules/shop/configure.go +++ b/modules/shop/configure.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" "go_dreamfactory/modules" + "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) @@ -65,7 +66,7 @@ func (this *configureComp) GetShopItemsConfigure(key int32) (result *cfg.Game_sh } //读取商品组 -func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32) (result []*cfg.Game_shopitemData, err error) { +func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb.DBUser) (result []*cfg.Game_shopitemData, err error) { result = make([]*cfg.Game_shopitemData, 0, 10) var ( v interface{} @@ -78,7 +79,10 @@ func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32) (result } else { table = v.(*cfg.Game_shopitem) for _, v := range table.GetDataMap() { - if v.Id == groupid { + if v.Id == groupid && + user.Lv >= v.Lvmin && + user.Lv <= v.Lvmax && + v.Vip >= v.Vip { result = append(result, item) } } diff --git a/modules/shop/core.go b/modules/shop/core.go index 3f279b52f..250ce0b33 100644 --- a/modules/shop/core.go +++ b/modules/shop/core.go @@ -30,13 +30,19 @@ func randomGoods(goods []*cfg.Game_shopitemData) (result *cfg.Game_shopitemData) } //转换商品对象 -func transGoods(goods []*cfg.Game_shopitemData) (result []*pb.ShopItem) { +func transGoods(goods []*cfg.Game_shopitemData, ushoputem map[int32]*pb.DBShopItem) (result []*pb.ShopItem) { result = make([]*pb.ShopItem, len(goods)) + ok := false + uitem := &pb.DBShopItem{} for i, v := range goods { + if uitem, ok = ushoputem[v.Key]; !ok { + uitem = &pb.DBShopItem{} + } result[i] = &pb.ShopItem{ GoodsId: v.Key, Sale: int32(v.Sale), } + result[i].LeftBuyNum = v.Buyminnum - uitem.BuyNum result[i].Items = make([]*pb.Resource, len(v.Iteminfo)) for i1, v1 := range v.Iteminfo { result[i].Items[i1] = &pb.Resource{ diff --git a/modules/shop/model_shopitems.go b/modules/shop/model_shopitems.go index 2ec8d6044..363067ebb 100644 --- a/modules/shop/model_shopitems.go +++ b/modules/shop/model_shopitems.go @@ -3,6 +3,7 @@ package shop import ( "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" + "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -30,9 +31,16 @@ func (this *modelShopItemsComp) Init(service core.IService, module core.IModule, } //查询用户装备数据 -func (this *modelShopItemsComp) QueryUserShopData(uId string) (data []*pb.DBShopItem, err error) { - data = make([]*pb.DBShopItem, 0) - err = this.GetList(uId, &data) +func (this *modelShopItemsComp) QueryUserShopData(uId string) (result map[int32]*pb.DBShopItem, err error) { + result = make(map[int32]*pb.DBShopItem) + data := make([]*pb.DBShopItem, 0) + if err = this.GetList(uId, &data); err != nil && err != mgo.MongodbNil { + return + } + err = nil + for _, v := range data { + result[v.GoodsId] = v + } return } diff --git a/pb/proto/shop/shop_msg.proto b/pb/proto/shop/shop_msg.proto index a310ff540..1bacece72 100644 --- a/pb/proto/shop/shop_msg.proto +++ b/pb/proto/shop/shop_msg.proto @@ -15,7 +15,8 @@ message ShopItem { int32 GoodsId = 1; //商品Id repeated Resource Items = 2; //货物 repeated Resource Consume = 3; //消耗 - int32 Sale = 4; //打折 + int32 Sale = 4; //打折 + int32 LeftBuyNum = 5; //还可购买次数 } //获取装备列表请求 diff --git a/pb/shop_msg.pb.go b/pb/shop_msg.pb.go index 9954f0524..9fd96cdf1 100644 --- a/pb/shop_msg.pb.go +++ b/pb/shop_msg.pb.go @@ -90,10 +90,11 @@ type ShopItem struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GoodsId int32 `protobuf:"varint,1,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id - Items []*Resource `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items"` //货物 - Consume []*Resource `protobuf:"bytes,3,rep,name=Consume,proto3" json:"Consume"` //消耗 - Sale int32 `protobuf:"varint,4,opt,name=Sale,proto3" json:"Sale"` //打折 + GoodsId int32 `protobuf:"varint,1,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id + Items []*Resource `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items"` //货物 + Consume []*Resource `protobuf:"bytes,3,rep,name=Consume,proto3" json:"Consume"` //消耗 + Sale int32 `protobuf:"varint,4,opt,name=Sale,proto3" json:"Sale"` //打折 + LeftBuyNum int32 `protobuf:"varint,5,opt,name=LeftBuyNum,proto3" json:"LeftBuyNum"` //还可购买次数 } func (x *ShopItem) Reset() { @@ -156,6 +157,13 @@ func (x *ShopItem) GetSale() int32 { return 0 } +func (x *ShopItem) GetLeftBuyNum() int32 { + if x != nil { + return x.LeftBuyNum + } + return 0 +} + //获取装备列表请求 type ShopGetListReq struct { state protoimpl.MessageState @@ -368,30 +376,32 @@ var file_shop_shop_msg_proto_rawDesc = []byte{ 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x22, 0x7e, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x18, 0x0a, - 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, - 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x23, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x73, - 0x75, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x61, 0x6c, - 0x65, 0x22, 0x5b, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, 0x73, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x49, 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, - 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x49, - 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x22, 0x32, - 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x12, 0x1f, 0x0a, 0x05, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x47, 0x6f, 0x6f, - 0x64, 0x73, 0x22, 0x26, 0x0a, 0x0a, 0x53, 0x68, 0x6f, 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, 0x71, - 0x12, 0x18, 0x0a, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x22, 0x25, 0x0a, 0x0b, 0x53, 0x68, - 0x6f, 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, - 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x53, 0x75, 0x63, - 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x18, + 0x0a, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x23, 0x0a, 0x07, 0x43, 0x6f, 0x6e, + 0x73, 0x75, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x61, + 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x4c, 0x65, 0x66, 0x74, 0x42, 0x75, 0x79, 0x4e, 0x75, 0x6d, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x4c, 0x65, 0x66, 0x74, 0x42, 0x75, 0x79, 0x4e, + 0x75, 0x6d, 0x22, 0x5b, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x12, 0x1f, 0x0a, 0x05, 0x73, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x52, 0x05, + 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x49, 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, + 0x6c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, + 0x49, 0x73, 0x4d, 0x61, 0x6e, 0x75, 0x61, 0x6c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x22, + 0x32, 0x0a, 0x0f, 0x53, 0x68, 0x6f, 0x70, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x05, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x09, 0x2e, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x47, 0x6f, + 0x6f, 0x64, 0x73, 0x22, 0x26, 0x0a, 0x0a, 0x53, 0x68, 0x6f, 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, + 0x71, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x22, 0x25, 0x0a, 0x0b, 0x53, + 0x68, 0x6f, 0x70, 0x42, 0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, + 0x53, 0x75, 0x63, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x53, 0x75, + 0x63, 0x63, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( From 4a367661e71f2ea00a0f0d50e506424fd54870d1 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 4 Jul 2022 19:22:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=B1=BB=E4=BC=BC=E6=95=B0=E6=8D=AE=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/shop/core.go | 20 +++--- pb/comm.pb.go | 114 +++++++++++++++++++++++++++++------ pb/proto/comm.proto | 6 ++ pb/proto/shop/shop_msg.proto | 12 +--- pb/shop_msg.pb.go | 53 ++++++++-------- 5 files changed, 144 insertions(+), 61 deletions(-) diff --git a/modules/shop/core.go b/modules/shop/core.go index 250ce0b33..872ea8e09 100644 --- a/modules/shop/core.go +++ b/modules/shop/core.go @@ -43,20 +43,20 @@ func transGoods(goods []*cfg.Game_shopitemData, ushoputem map[int32]*pb.DBShopIt Sale: int32(v.Sale), } result[i].LeftBuyNum = v.Buyminnum - uitem.BuyNum - result[i].Items = make([]*pb.Resource, len(v.Iteminfo)) + result[i].Items = make([]*pb.UserAssets, len(v.Iteminfo)) for i1, v1 := range v.Iteminfo { - result[i].Items[i1] = &pb.Resource{ - ResourceType: v1.A, - ResourceId: v1.T, - Amount: v1.N, + result[i].Items[i1] = &pb.UserAssets{ + A: v1.A, + T: v1.T, + N: v1.N, } } - result[i].Consume = make([]*pb.Resource, len(v.Need)) + result[i].Consume = make([]*pb.UserAssets, len(v.Need)) for i1, v1 := range v.Need { - result[i].Items[i1] = &pb.Resource{ - ResourceType: v1.A, - ResourceId: v1.T, - Amount: v1.N, + result[i].Items[i1] = &pb.UserAssets{ + A: v1.A, + T: v1.T, + N: v1.N, } } } diff --git a/pb/comm.pb.go b/pb/comm.pb.go index e2ea9ec41..dcac48fc8 100644 --- a/pb/comm.pb.go +++ b/pb/comm.pb.go @@ -726,6 +726,70 @@ func (x *NoticeUserCloseReq) GetUserId() string { return "" } +//用户资产数据 对标*cfg.Game_atn 数据结构 +type UserAssets struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + A string `protobuf:"bytes,1,opt,name=A,proto3" json:"A"` + T string `protobuf:"bytes,2,opt,name=T,proto3" json:"T"` + N int32 `protobuf:"varint,3,opt,name=N,proto3" json:"N"` +} + +func (x *UserAssets) Reset() { + *x = UserAssets{} + if protoimpl.UnsafeEnabled { + mi := &file_comm_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserAssets) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserAssets) ProtoMessage() {} + +func (x *UserAssets) ProtoReflect() protoreflect.Message { + mi := &file_comm_proto_msgTypes[10] + 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 UserAssets.ProtoReflect.Descriptor instead. +func (*UserAssets) Descriptor() ([]byte, []int) { + return file_comm_proto_rawDescGZIP(), []int{10} +} + +func (x *UserAssets) GetA() string { + if x != nil { + return x.A + } + return "" +} + +func (x *UserAssets) GetT() string { + if x != nil { + return x.T + } + return "" +} + +func (x *UserAssets) GetN() int32 { + if x != nil { + return x.N + } + return 0 +} + var File_comm_proto protoreflect.FileDescriptor var file_comm_proto_rawDesc = []byte{ @@ -808,13 +872,16 @@ var file_comm_proto_rawDesc = []byte{ 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, 0x2a, 0x43, - 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, - 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, - 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, - 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x36, + 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x12, 0x0c, 0x0a, 0x01, + 0x41, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x41, 0x12, 0x0c, 0x0a, 0x01, 0x54, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x54, 0x12, 0x0c, 0x0a, 0x01, 0x4e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x01, 0x4e, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, + 0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, + 0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, + 0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -830,7 +897,7 @@ func file_comm_proto_rawDescGZIP() []byte { } var file_comm_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_comm_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_comm_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_comm_proto_goTypes = []interface{}{ (HeroAttributesType)(0), // 0: HeroAttributesType (*UserMessage)(nil), // 1: UserMessage @@ -843,18 +910,19 @@ var file_comm_proto_goTypes = []interface{}{ (*BroadCastMessageReq)(nil), // 8: BroadCastMessageReq (*AgentCloseeReq)(nil), // 9: AgentCloseeReq (*NoticeUserCloseReq)(nil), // 10: NoticeUserCloseReq - (*anypb.Any)(nil), // 11: google.protobuf.Any - (ErrorCode)(0), // 12: ErrorCode + (*UserAssets)(nil), // 11: UserAssets + (*anypb.Any)(nil), // 12: google.protobuf.Any + (ErrorCode)(0), // 13: ErrorCode } var file_comm_proto_depIdxs = []int32{ - 11, // 0: UserMessage.data:type_name -> google.protobuf.Any - 11, // 1: AgentMessage.Message:type_name -> google.protobuf.Any - 12, // 2: RPCMessageReply.Code:type_name -> ErrorCode - 11, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any + 12, // 0: UserMessage.data:type_name -> google.protobuf.Any + 12, // 1: AgentMessage.Message:type_name -> google.protobuf.Any + 13, // 2: RPCMessageReply.Code:type_name -> ErrorCode + 12, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any 1, // 4: RPCMessageReply.Reply:type_name -> UserMessage 1, // 5: AgentSendMessageReq.Reply:type_name -> UserMessage - 11, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any - 11, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any + 12, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any + 12, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any 8, // [8:8] is the sub-list for method output_type 8, // [8:8] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name @@ -989,6 +1057,18 @@ func file_comm_proto_init() { return nil } } + file_comm_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserAssets); 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{ @@ -996,7 +1076,7 @@ func file_comm_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_comm_proto_rawDesc, NumEnums: 1, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/comm.proto b/pb/proto/comm.proto index ae3ef83bc..e33218916 100644 --- a/pb/proto/comm.proto +++ b/pb/proto/comm.proto @@ -76,3 +76,9 @@ enum HeroAttributesType{ Crit = 4; //暴击 } +//用户资产数据 对标*cfg.Game_atn 数据结构 +message UserAssets{ + string A=1; + string T=2; + int32 N=3; +} \ No newline at end of file diff --git a/pb/proto/shop/shop_msg.proto b/pb/proto/shop/shop_msg.proto index 1bacece72..96c3dc9d2 100644 --- a/pb/proto/shop/shop_msg.proto +++ b/pb/proto/shop/shop_msg.proto @@ -1,20 +1,14 @@ syntax = "proto3"; option go_package = ".;pb"; import "shop/shop_db.proto"; +import "comm.proto"; -//资源对象 -message Resource { - string ResourceType = 1; //资源类型 - string ResourceId = 2; //资源Id - int32 Amount = 3; //数量 -} - //商品对象数据 message ShopItem { int32 GoodsId = 1; //商品Id - repeated Resource Items = 2; //货物 - repeated Resource Consume = 3; //消耗 + repeated UserAssets Items = 2; //货物 + repeated UserAssets Consume = 3; //消耗 int32 Sale = 4; //打折 int32 LeftBuyNum = 5; //还可购买次数 } diff --git a/pb/shop_msg.pb.go b/pb/shop_msg.pb.go index 9fd96cdf1..bbc2da864 100644 --- a/pb/shop_msg.pb.go +++ b/pb/shop_msg.pb.go @@ -90,11 +90,11 @@ type ShopItem struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - GoodsId int32 `protobuf:"varint,1,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id - Items []*Resource `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items"` //货物 - Consume []*Resource `protobuf:"bytes,3,rep,name=Consume,proto3" json:"Consume"` //消耗 - Sale int32 `protobuf:"varint,4,opt,name=Sale,proto3" json:"Sale"` //打折 - LeftBuyNum int32 `protobuf:"varint,5,opt,name=LeftBuyNum,proto3" json:"LeftBuyNum"` //还可购买次数 + GoodsId int32 `protobuf:"varint,1,opt,name=GoodsId,proto3" json:"GoodsId"` //商品Id + Items []*UserAssets `protobuf:"bytes,2,rep,name=Items,proto3" json:"Items"` //货物 + Consume []*UserAssets `protobuf:"bytes,3,rep,name=Consume,proto3" json:"Consume"` //消耗 + Sale int32 `protobuf:"varint,4,opt,name=Sale,proto3" json:"Sale"` //打折 + LeftBuyNum int32 `protobuf:"varint,5,opt,name=LeftBuyNum,proto3" json:"LeftBuyNum"` //还可购买次数 } func (x *ShopItem) Reset() { @@ -136,14 +136,14 @@ func (x *ShopItem) GetGoodsId() int32 { return 0 } -func (x *ShopItem) GetItems() []*Resource { +func (x *ShopItem) GetItems() []*UserAssets { if x != nil { return x.Items } return nil } -func (x *ShopItem) GetConsume() []*Resource { +func (x *ShopItem) GetConsume() []*UserAssets { if x != nil { return x.Consume } @@ -369,20 +369,21 @@ var File_shop_shop_msg_proto protoreflect.FileDescriptor var file_shop_shop_msg_proto_rawDesc = []byte{ 0x0a, 0x13, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x73, 0x68, 0x6f, 0x70, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x68, 0x6f, 0x70, 0x2f, 0x73, 0x68, 0x6f, 0x70, - 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x66, 0x0a, 0x08, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x22, 0x9e, 0x01, 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x18, - 0x0a, 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x07, 0x47, 0x6f, 0x6f, 0x64, 0x73, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x23, 0x0a, 0x07, 0x43, 0x6f, 0x6e, - 0x73, 0x75, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x12, + 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x66, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x54, 0x79, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa2, 0x01, + 0x0a, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x6f, + 0x6f, 0x64, 0x73, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x47, 0x6f, 0x6f, + 0x64, 0x73, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, + 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x25, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x75, + 0x6d, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, + 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x61, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x61, 0x6c, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x4c, 0x65, 0x66, 0x74, 0x42, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x4c, 0x65, 0x66, 0x74, 0x42, 0x75, 0x79, 0x4e, @@ -424,12 +425,13 @@ var file_shop_shop_msg_proto_goTypes = []interface{}{ (*ShopGetListResp)(nil), // 3: ShopGetListResp (*ShopBuyReq)(nil), // 4: ShopBuyReq (*ShopBuyResp)(nil), // 5: ShopBuyResp - (ShopType)(0), // 6: ShopType + (*UserAssets)(nil), // 6: UserAssets + (ShopType)(0), // 7: ShopType } var file_shop_shop_msg_proto_depIdxs = []int32{ - 0, // 0: ShopItem.Items:type_name -> Resource - 0, // 1: ShopItem.Consume:type_name -> Resource - 6, // 2: ShopGetListReq.sType:type_name -> ShopType + 6, // 0: ShopItem.Items:type_name -> UserAssets + 6, // 1: ShopItem.Consume:type_name -> UserAssets + 7, // 2: ShopGetListReq.sType:type_name -> ShopType 1, // 3: ShopGetListResp.Goods:type_name -> ShopItem 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type @@ -444,6 +446,7 @@ func file_shop_shop_msg_proto_init() { return } file_shop_shop_db_proto_init() + file_comm_proto_init() if !protoimpl.UnsafeEnabled { file_shop_shop_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Resource); i { From 96daa17ae6f0d1759fb33afbee7e31fb9926954d Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 4 Jul 2022 19:23:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E6=B6=88=E6=81=AF=E8=B0=81=E9=80=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/usersession.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/comm/usersession.go b/comm/usersession.go index 47afe21bc..75087048b 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -149,7 +149,8 @@ func (this *UserSession) Polls() []*pb.UserMessage { func (this *UserSession) Push() (err error) { reply := &pb.RPCMessageReply{} if _, err = this.service.RpcGo(context.Background(), fmt.Sprintf("%s/%s", Service_Gateway, this.GatewayServiceId), string(Rpc_GatewayAgentSendMsg), &pb.AgentSendMessageReq{ - Reply: this.msgqueue, + UserSessionId: this.SessionId, + Reply: this.msgqueue, }, reply); err != nil { log.Errorf("SendMsgToUsers:%v err:%v", this, err) }