Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
e4ff953a13
@ -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
|
||||
}
|
||||
|
||||
|
@ -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,17 @@ 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{
|
||||
UserSessionId: this.SessionId,
|
||||
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)
|
||||
|
@ -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)
|
||||
//向多个用户发送消息
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -19,16 +19,21 @@ 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
|
||||
shopconf *cfg.Game_shopData
|
||||
shopData *pb.DBShop
|
||||
sdata *pb.UserShopData
|
||||
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 {
|
||||
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 +44,34 @@ 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
|
||||
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 +93,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, udata); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
items = append(items, randomGoods(_items))
|
||||
}
|
||||
goods = transGoods(items, ushoputem)
|
||||
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, udata); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
items = append(items, randomGoods(_items))
|
||||
}
|
||||
goods = transGoods(items, ushoputem)
|
||||
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, ushoputem)
|
||||
}
|
||||
} else {
|
||||
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
|
||||
return
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
@ -44,3 +45,72 @@ 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, user *pb.DBUser) (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 &&
|
||||
user.Lv >= v.Lvmin &&
|
||||
user.Lv <= v.Lvmax &&
|
||||
v.Vip >= v.Vip {
|
||||
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
|
||||
}
|
||||
|
64
modules/shop/core.go
Normal file
64
modules/shop/core.go
Normal file
@ -0,0 +1,64 @@
|
||||
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, 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.UserAssets, len(v.Iteminfo))
|
||||
for i1, v1 := range v.Iteminfo {
|
||||
result[i].Items[i1] = &pb.UserAssets{
|
||||
A: v1.A,
|
||||
T: v1.T,
|
||||
N: v1.N,
|
||||
}
|
||||
}
|
||||
result[i].Consume = make([]*pb.UserAssets, len(v.Need))
|
||||
for i1, v1 := range v.Need {
|
||||
result[i].Items[i1] = &pb.UserAssets{
|
||||
A: v1.A,
|
||||
T: v1.T,
|
||||
N: v1.N,
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
@ -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)}},
|
||||
|
72
modules/shop/model_shopitems.go
Normal file
72
modules/shop/model_shopitems.go
Normal file
@ -0,0 +1,72 @@
|
||||
package shop
|
||||
|
||||
import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/sys/mgo"
|
||||
"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) (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
|
||||
}
|
||||
|
||||
//查询用户装备数据
|
||||
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
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
207
pb/comm.pb.go
207
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
|
||||
}
|
||||
@ -742,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{
|
||||
@ -792,48 +840,48 @@ 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, 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 (
|
||||
@ -849,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
|
||||
@ -862,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
|
||||
11, // 5: AgentSendMessageReq.Data:type_name -> google.protobuf.Any
|
||||
11, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any
|
||||
11, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
|
||||
1, // 5: AgentSendMessageReq.Reply:type_name -> UserMessage
|
||||
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
|
||||
@ -1008,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{
|
||||
@ -1015,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,
|
||||
},
|
||||
|
@ -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,11 @@ enum HeroAttributesType{
|
||||
Def = 2; //防御
|
||||
Speed = 3; //速度
|
||||
Crit = 4; //暴击
|
||||
}
|
||||
|
||||
//用户资产数据 对标*cfg.Game_atn 数据结构
|
||||
message UserAssets{
|
||||
string A=1;
|
||||
string T=2;
|
||||
int32 N=3;
|
||||
}
|
@ -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; //最后一次购买的时间
|
||||
}
|
@ -1,6 +1,17 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
import "shop/shop_db.proto";
|
||||
import "comm.proto";
|
||||
|
||||
|
||||
//商品对象数据
|
||||
message ShopItem {
|
||||
int32 GoodsId = 1; //商品Id
|
||||
repeated UserAssets Items = 2; //货物
|
||||
repeated UserAssets Consume = 3; //消耗
|
||||
int32 Sale = 4; //打折
|
||||
int32 LeftBuyNum = 5; //还可购买次数
|
||||
}
|
||||
|
||||
//获取装备列表请求
|
||||
message ShopGetListReq {
|
||||
@ -10,15 +21,15 @@ message ShopGetListReq {
|
||||
|
||||
//获取装备列表请求
|
||||
message ShopGetListResp {
|
||||
|
||||
repeated ShopItem Goods = 1; //商品列表
|
||||
}
|
||||
|
||||
//购买商品 请求
|
||||
message ShopBuyReq {
|
||||
|
||||
int32 GoodsId = 1; //商品Id
|
||||
}
|
||||
|
||||
//购买商品 回应
|
||||
message ShopBuyResp {
|
||||
|
||||
bool IsSucc = 1; //是否成功
|
||||
}
|
||||
|
121
pb/shop_db.pb.go
121
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,
|
||||
},
|
||||
|
@ -20,6 +20,150 @@ 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 []*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() {
|
||||
*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() []*UserAssets {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ShopItem) GetConsume() []*UserAssets {
|
||||
if x != nil {
|
||||
return x.Consume
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *ShopItem) GetSale() int32 {
|
||||
if x != nil {
|
||||
return x.Sale
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ShopItem) GetLeftBuyNum() int32 {
|
||||
if x != nil {
|
||||
return x.LeftBuyNum
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
//获取装备列表请求
|
||||
type ShopGetListReq struct {
|
||||
state protoimpl.MessageState
|
||||
@ -33,7 +177,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 +190,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 +203,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 +225,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 +245,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 +258,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 +273,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 +293,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 +306,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 +321,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 +341,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 +354,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 +369,40 @@ 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, 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,
|
||||
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 (
|
||||
@ -223,21 +417,27 @@ 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
|
||||
(*UserAssets)(nil), // 6: UserAssets
|
||||
(ShopType)(0), // 7: 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
|
||||
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
|
||||
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() }
|
||||
@ -246,9 +446,10 @@ 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.(*ShopGetListReq); i {
|
||||
switch v := v.(*Resource); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
@ -260,7 +461,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 +473,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 +485,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 +527,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,
|
||||
},
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user