上传lua 集群处理
This commit is contained in:
parent
fc27cf0d09
commit
9f4e3edac8
@ -17,6 +17,9 @@ func TestMain(m *testing.M) {
|
||||
redis.SetRedis_Single_Addr("10.0.0.9:6986"),
|
||||
redis.SetRedis_Single_Password("li13451234"),
|
||||
redis.SetRedis_Single_DB(6),
|
||||
// redis.SetRedisType(redis.Redis_Cluster),
|
||||
// redis.SetRedis_Cluster_Addr([]string{"10.0.0.9:9001", "10.0.0.9:9002", "10.0.0.9:9003", "10.0.1.45:9004", "10.0.1.45:9005", "10.0.1.45:9006"}),
|
||||
// redis.SetRedis_Cluster_Password(""),
|
||||
); err != nil {
|
||||
fmt.Println("err:", err)
|
||||
return
|
||||
@ -124,15 +127,9 @@ func Test_Redis_Encoder_Hash(t *testing.T) {
|
||||
//测试redis lua 脚本
|
||||
func Test_Redis_Lua_HGETALL(t *testing.T) {
|
||||
script := redis.NewScript(`
|
||||
local key = tostring(KEYS[1])
|
||||
local keys = redis.call("HGETALL", key)
|
||||
local data = {}
|
||||
local n = 1
|
||||
for i, v in ipairs(keys) do
|
||||
if i%2 == 0 then
|
||||
data[n] = redis.call("HGETALL", v)
|
||||
n = n+1
|
||||
end
|
||||
for i, v in ipairs(KEYS) do
|
||||
data[i] = redis.call("HGETALL", v)
|
||||
end
|
||||
return data
|
||||
`)
|
||||
@ -140,7 +137,7 @@ func Test_Redis_Lua_HGETALL(t *testing.T) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
ret := redis.EvalSha(redis.Context(), sha, []string{"items:0_62c259916d8cf3e4e06311a8"})
|
||||
ret := redis.EvalSha(redis.Context(), sha, []string{"test_HMSet{test}", "test_HMSet_1{test}"})
|
||||
if result, err := ret.Result(); err != nil {
|
||||
fmt.Printf("Execute Redis err: %v", err.Error())
|
||||
} else {
|
||||
@ -181,7 +178,7 @@ func Test_Redis_Lua_HSETALL(t *testing.T) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
ret := redis.EvalSha(redis.Context(), sha, []string{"test_HMSet", "test_HMSet_1"}, "a", "1", "b", "2", "#end", "a1", "11", "b", "21", "#end")
|
||||
ret := redis.EvalSha(redis.Context(), sha, []string{"test_HMSet{test}", "test_HMSet_1{test}"}, "a", "1", "b", "2", "#end", "a1", "11", "b", "21", "#end")
|
||||
if result, err := ret.Result(); err != nil {
|
||||
fmt.Printf("Execute Redis err: %v", err.Error())
|
||||
} else {
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
)
|
||||
|
||||
//Redis 自定义脚本 批量读取列表数据
|
||||
var LusScriptgetList = `
|
||||
var LuaScriptgetList = `
|
||||
local key = tostring(KEYS[1])
|
||||
local keys = redis.call("HGETALL", key)
|
||||
local data = {}
|
||||
@ -40,7 +40,7 @@ return data
|
||||
`
|
||||
|
||||
//Redis 自定义脚本 批量写入列表数据
|
||||
var LusScriptsetList = `
|
||||
var LuaScriptsetList = `
|
||||
local n = 1
|
||||
for i, v in ipairs(KEYS) do
|
||||
local key = v
|
||||
@ -58,8 +58,21 @@ end
|
||||
return "OK"
|
||||
`
|
||||
|
||||
//Redis 自定义脚本 批量卸载列表数据
|
||||
var LuaScriptdelList = `
|
||||
local key = tostring(KEYS[1])
|
||||
local keys = redis.call("HGETALL", key)
|
||||
for i, v in ipairs(keys) do
|
||||
if i%2 == 0 then
|
||||
redis.call("DEL", v)
|
||||
end
|
||||
end
|
||||
redis.call("DEL", key)
|
||||
return "OK"
|
||||
`
|
||||
|
||||
//Redis 自定义脚本 批量读取队列数据
|
||||
var LusScriptgetQueue = `
|
||||
var LuaScriptgetQueue = `
|
||||
local key = tostring(KEYS[1])
|
||||
local keys = redis.call("LRANGE", key,0,-1)
|
||||
local data = {}
|
||||
@ -70,7 +83,7 @@ return data
|
||||
`
|
||||
|
||||
//Redis 自定义脚本 批量写入队列数据
|
||||
var LusScriptsetQueue = `
|
||||
var LuaScriptsetQueue = `
|
||||
local count = tonumber(ARGV[1])
|
||||
local k = tostring(ARGV[3])
|
||||
local keys = {}
|
||||
@ -130,6 +143,7 @@ type MCompModel struct {
|
||||
TableName string //redis key前缀
|
||||
getListSha1 string //getList LusScript 的shal值
|
||||
setListSha1 string //getList LusScript 的shal值
|
||||
dellListSha1 string //getList LusScript 的shal值
|
||||
getQueueSha1 string //getList LusScript 的shal值
|
||||
setQueueSha1 string //getList LusScript 的shal值
|
||||
}
|
||||
@ -147,30 +161,29 @@ func (this *MCompModel) Init(service core.IService, module core.IModule, comp co
|
||||
}
|
||||
func (this *MCompModel) Start() (err error) {
|
||||
err = this.ModuleCompBase.Start()
|
||||
if this.getListSha1, err = this.Redis.NewScript(LusScriptgetList).Result(); err != nil {
|
||||
if this.getListSha1, err = this.Redis.NewScript(LuaScriptgetList).Result(); err != nil {
|
||||
return
|
||||
}
|
||||
if this.setListSha1, err = this.Redis.NewScript(LusScriptsetList).Result(); err != nil {
|
||||
if this.setListSha1, err = this.Redis.NewScript(LuaScriptsetList).Result(); err != nil {
|
||||
return
|
||||
}
|
||||
if this.getQueueSha1, err = this.Redis.NewScript(LusScriptgetQueue).Result(); err != nil {
|
||||
if this.dellListSha1, err = this.Redis.NewScript(LuaScriptdelList).Result(); err != nil {
|
||||
return
|
||||
}
|
||||
if this.setQueueSha1, err = this.Redis.NewScript(LusScriptsetQueue).Result(); err != nil {
|
||||
if this.getQueueSha1, err = this.Redis.NewScript(LuaScriptgetQueue).Result(); err != nil {
|
||||
return
|
||||
}
|
||||
if this.setQueueSha1, err = this.Redis.NewScript(LuaScriptsetQueue).Result(); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *MCompModel) setTableName(suffix string) {
|
||||
this.TableName = fmt.Sprintf("%s_%s", this.TableName, suffix)
|
||||
}
|
||||
|
||||
func (this *MCompModel) ukey(uid string) string {
|
||||
return fmt.Sprintf("%s:%s", this.TableName, uid)
|
||||
return fmt.Sprintf("%s:%s{%s}", this.TableName, uid, this.TableName)
|
||||
}
|
||||
func (this *MCompModel) ukeylist(uid string, id string) string {
|
||||
return fmt.Sprintf("%s:%s-%s", this.TableName, uid, id)
|
||||
return fmt.Sprintf("%s:%s-%s{%s}", this.TableName, uid, id, this.TableName)
|
||||
}
|
||||
|
||||
func (this *MCompModel) InsertModelLogs(table string, uID string, target interface{}) (err error) {
|
||||
@ -230,21 +243,22 @@ func (this *MCompModel) UpdateModelLogs(table string, uID string, where bson.M,
|
||||
}
|
||||
|
||||
//添加新的数据
|
||||
func (this *MCompModel) Add(uid string, data interface{}, attrs ...*cache.OperationAttr) (err error) {
|
||||
func (this *MCompModel) Add(uid string, data interface{}, opt ...DBOption) (err error) {
|
||||
if err = this.Redis.HMSet(this.ukey(uid), data); err != nil {
|
||||
return
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
|
||||
err = this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
||||
option := newDBOption(opt...)
|
||||
if option.IsMgoLog {
|
||||
err = this.InsertModelLogs(this.TableName, uid, []interface{}{data})
|
||||
}
|
||||
if option.Expire > 0 {
|
||||
err = this.Redis.Expire(this.ukey(uid), option.Expire)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//添加新的数据到列表
|
||||
func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs ...*cache.OperationAttr) (err error) {
|
||||
func (this *MCompModel) AddList(uid string, id string, data interface{}, opt ...DBOption) (err error) {
|
||||
key := this.ukeylist(uid, id)
|
||||
if err = this.Redis.HMSet(key, data); err != nil {
|
||||
return
|
||||
@ -252,17 +266,18 @@ func (this *MCompModel) AddList(uid string, id string, data interface{}, attrs .
|
||||
if err = this.Redis.HSet(this.ukey(uid), id, key); err != nil {
|
||||
return
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
|
||||
err = this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
||||
option := newDBOption(opt...)
|
||||
if option.IsMgoLog {
|
||||
err = this.InsertModelLogs(this.TableName, uid, []interface{}{data})
|
||||
}
|
||||
if option.Expire > 0 {
|
||||
err = this.Redis.Expire(this.ukey(uid), option.Expire)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//添加新的多个数据到列表 data map[string]type
|
||||
func (this *MCompModel) AddLists(uid string, data interface{}, attrs ...*cache.OperationAttr) (err error) {
|
||||
func (this *MCompModel) AddLists(uid string, data interface{}, opt ...DBOption) (err error) {
|
||||
vof := reflect.ValueOf(data)
|
||||
if !vof.IsValid() {
|
||||
return fmt.Errorf("Model_Comp: AddLists(nil)")
|
||||
@ -288,44 +303,48 @@ func (this *MCompModel) AddLists(uid string, data interface{}, attrs ...*cache.O
|
||||
if err = this.Redis.HMSetForMap(this.ukey(uid), listskeys); err != nil {
|
||||
return
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
|
||||
this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||
for _, v := range listskeys {
|
||||
this.Redis.Expire(v, ret.(time.Duration))
|
||||
}
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
||||
|
||||
option := newDBOption(opt...)
|
||||
if option.IsMgoLog {
|
||||
err = this.InsertModelLogs(this.TableName, uid, lists)
|
||||
}
|
||||
|
||||
if option.Expire > 0 {
|
||||
this.Redis.Expire(this.ukey(uid), option.Expire)
|
||||
for _, v := range listskeys {
|
||||
this.Redis.Expire(v, option.Expire)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//修改数据多个字段 uid 作为主键
|
||||
func (this *MCompModel) Change(uid string, data map[string]interface{}, attrs ...*cache.OperationAttr) (err error) {
|
||||
func (this *MCompModel) Change(uid string, data map[string]interface{}, opt ...DBOption) (err error) {
|
||||
if err = this.Redis.HMSet(this.ukey(uid), data); err != nil {
|
||||
return
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
|
||||
this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
||||
option := newDBOption(opt...)
|
||||
if option.IsMgoLog {
|
||||
err = this.UpdateModelLogs(this.TableName, uid, bson.M{"uid": uid}, data)
|
||||
}
|
||||
if option.Expire > 0 {
|
||||
this.Redis.Expire(this.ukey(uid), option.Expire)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//修改数据多个字段 uid 作为主键
|
||||
func (this *MCompModel) ChangeList(uid string, _id string, data map[string]interface{}, attrs ...*cache.OperationAttr) (err error) {
|
||||
func (this *MCompModel) ChangeList(uid string, _id string, data map[string]interface{}, opt ...DBOption) (err error) {
|
||||
if err = this.Redis.HMSet(this.ukeylist(uid, _id), data); err != nil {
|
||||
return
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_EXPIRE).Unwrap_Or(nil); ret != nil {
|
||||
this.Redis.Expire(this.ukey(uid), ret.(time.Duration))
|
||||
}
|
||||
if ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil); ret == nil {
|
||||
|
||||
option := newDBOption(opt...)
|
||||
if option.IsMgoLog {
|
||||
err = this.UpdateModelLogs(this.TableName, uid, bson.M{"_id": _id, "uid": uid}, data)
|
||||
}
|
||||
if option.Expire > 0 {
|
||||
this.Redis.Expire(this.ukey(uid), option.Expire)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -464,12 +483,15 @@ func (this *MCompModel) GetListObj(uid string, id string, data interface{}) (err
|
||||
}
|
||||
|
||||
//删除用户数据
|
||||
func (this *MCompModel) Del(uid string) (err error) {
|
||||
func (this *MCompModel) Del(uid string, opt ...DBOption) (err error) {
|
||||
err = this.Redis.Delete(this.ukey(uid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = this.DeleteModelLogs(this.TableName, uid, bson.M{"uid": uid})
|
||||
option := newDBOption(opt...)
|
||||
if option.IsMgoLog {
|
||||
err = this.DeleteModelLogs(this.TableName, uid, bson.M{"uid": uid})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -624,6 +646,15 @@ func (this *MCompModel) Batchsetqueues(key string, count int32, ks []string, vs
|
||||
return
|
||||
}
|
||||
|
||||
//批量删除数据
|
||||
func (this *MCompModel) BatchDelLists(uid string) (err error) {
|
||||
ret := this.Redis.EvalSha(this.Redis.Context(), this.dellListSha1, []string{this.ukey(uid)})
|
||||
if _, err := ret.Result(); err != nil {
|
||||
fmt.Printf("Execute batchsetlists err: %v", err.Error())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//日志操作可选项
|
||||
func (this *MCompModel) logOpt(uid string, data interface{}, attrs ...*cache.OperationAttr) error {
|
||||
ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil)
|
||||
@ -649,7 +680,7 @@ func (this *MCompModel) logOpt(uid string, data interface{}, attrs ...*cache.Ope
|
||||
//获取用户通过扩展表
|
||||
func (this *MCompModel) GetUserRecord(uid string) (result *pb.DBUserRecord, err error) {
|
||||
result = &pb.DBUserRecord{}
|
||||
key := fmt.Sprintf("userrecord:%s", uid)
|
||||
key := fmt.Sprintf("userrecord:%s{userrecord}", uid)
|
||||
if err = this.Redis.HGetAll(key, result); err != nil && err != redis.RedisNil {
|
||||
return
|
||||
}
|
||||
@ -665,7 +696,7 @@ func (this *MCompModel) GetUserRecord(uid string) (result *pb.DBUserRecord, err
|
||||
//修改用户扩展数据
|
||||
func (this *MCompModel) ChangeUserRecord(uid string, value map[string]interface{}) (err error) {
|
||||
value["mtime"] = time.Now().Unix() // 更新时间
|
||||
key := fmt.Sprintf("userrecord:%s", uid)
|
||||
key := fmt.Sprintf("userrecord:%s{userrecord}", uid)
|
||||
if err = this.Redis.HMSet(key, value); err != nil && err != redis.RedisNil {
|
||||
return
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package equipment
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
@ -41,8 +42,10 @@ func (this *Equipment) Init(service core.IService, module core.IModule, options
|
||||
}
|
||||
|
||||
//模块启动接口
|
||||
//模块启动
|
||||
func (this *Equipment) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
event.RegisterGO(comm.EventUserOffline, this.EventUserOffline)
|
||||
return
|
||||
}
|
||||
|
||||
@ -54,6 +57,12 @@ func (this *Equipment) OnInstallComp() {
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
//Event------------------------------------------------------------------------------------------------------------
|
||||
func (this *Equipment) EventUserOffline(session comm.IUserSession) {
|
||||
err := this.modelEquipment.BatchDelLists(session.GetUserId())
|
||||
this.Debugf("EventUserOffline:%s err:%v", session, err)
|
||||
}
|
||||
|
||||
//IEquipment-------------------------------------------------------------------------------------------------------------------------------
|
||||
//查询武器信息
|
||||
func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) {
|
||||
|
26
modules/gm/api_cmd.go
Normal file
26
modules/gm/api_cmd.go
Normal file
@ -0,0 +1,26 @@
|
||||
package gm
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) CmdCheck(session comm.IUserSession, req *pb.GMCmdReq) (code pb.ErrorCode) {
|
||||
if len(req.Cmod) == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
///获取用户装备列表
|
||||
func (this *apiComp) Cmd(session comm.IUserSession, req *pb.GMCmdReq) (code pb.ErrorCode, data proto.Message) {
|
||||
if code = this.CmdCheck(session, req); code == pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.module.GetType()), "cmd", &pb.GMCmdResp{IsSucc: true})
|
||||
return
|
||||
}
|
@ -6,6 +6,7 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -36,6 +37,13 @@ func (this *Items) Init(service core.IService, module core.IModule, options core
|
||||
return
|
||||
}
|
||||
|
||||
//模块启动
|
||||
func (this *Items) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
event.RegisterGO(comm.EventUserOffline, this.EventUserOffline)
|
||||
return
|
||||
}
|
||||
|
||||
//装备组件
|
||||
func (this *Items) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
@ -44,6 +52,12 @@ func (this *Items) OnInstallComp() {
|
||||
this.configure = this.RegisterComp(new(ConfigureComp)).(*ConfigureComp)
|
||||
}
|
||||
|
||||
//Event------------------------------------------------------------------------------------------------------------
|
||||
func (this *Items) EventUserOffline(session comm.IUserSession) {
|
||||
err := this.modelItems.BatchDelLists(session.GetUserId())
|
||||
this.Debugf("EventUserOffline:%s err:%v", session, err)
|
||||
}
|
||||
|
||||
//IItems-------------------------------------------------------------------------------------------------------------------------------
|
||||
///查询用户背包物品数量
|
||||
func (this *Items) QueryItemAmount(source *comm.ModuleCallSource, uId string, itemid string) (amount uint32) {
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/lego/utils/mapstructure"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -40,3 +41,34 @@ func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type DBOption func(*DBOptions)
|
||||
type DBOptions struct {
|
||||
IsMgoLog bool //是否写mgolog
|
||||
Expire time.Duration //过期时间
|
||||
}
|
||||
|
||||
//设置是否写mgor日志
|
||||
func SetDBMgoLog(v bool) DBOption {
|
||||
return func(o *DBOptions) {
|
||||
o.IsMgoLog = v
|
||||
}
|
||||
}
|
||||
|
||||
//设置过期时间
|
||||
func SetDBExpire(v time.Duration) DBOption {
|
||||
return func(o *DBOptions) {
|
||||
o.Expire = v
|
||||
}
|
||||
}
|
||||
|
||||
//更具 Option 序列化 系统参数对象
|
||||
func newDBOption(opts ...DBOption) DBOptions {
|
||||
options := DBOptions{
|
||||
IsMgoLog: true,
|
||||
}
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ import (
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.ShopGetListReq) (code pb.ErrorCode) {
|
||||
|
||||
if req.SType == 0 {
|
||||
code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -32,7 +34,9 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
|
||||
ltime time.Duration
|
||||
leftrefnum int32
|
||||
)
|
||||
|
||||
if code = this.GetlistCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if shopconf, err = this.module.configure.GetShopConfigure(int32(req.SType)); err != nil && err != mgo.MongodbNil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
|
@ -43,3 +43,9 @@ func (this *Shop) OnInstallComp() {
|
||||
this.modelShopItems = this.RegisterComp(new(modelShopItemsComp)).(*modelShopItemsComp)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
//Event------------------------------------------------------------------------------------------------------------
|
||||
func (this *Shop) EventUserOffline(session comm.IUserSession) {
|
||||
this.modelShop.Del(session.GetUserId(), modules.SetDBMgoLog(false))
|
||||
this.modelShopItems.BatchDelLists(session.GetUserId())
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/lego/sys/event"
|
||||
"go_dreamfactory/lego/sys/log"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/cache"
|
||||
"go_dreamfactory/utils"
|
||||
"time"
|
||||
|
||||
@ -86,8 +86,8 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
|
||||
"gatewayServiceId": session.GetGatewayServiceId(),
|
||||
"ip": session.GetIP(),
|
||||
},
|
||||
cache.WithExpire(time.Hour*12),
|
||||
cache.WithDisabledMgoLog())
|
||||
modules.SetDBExpire(time.Hour*12),
|
||||
modules.SetDBMgoLog(false))
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
205
pb/gm_msg.pb.go
Normal file
205
pb/gm_msg.pb.go
Normal file
@ -0,0 +1,205 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v3.20.0
|
||||
// source: gm/gm_msg.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
///gm 命令请求
|
||||
type GMCmdReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Cmod string `protobuf:"bytes,1,opt,name=Cmod,proto3" json:"Cmod"`
|
||||
}
|
||||
|
||||
func (x *GMCmdReq) Reset() {
|
||||
*x = GMCmdReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_gm_gm_msg_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GMCmdReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GMCmdReq) ProtoMessage() {}
|
||||
|
||||
func (x *GMCmdReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_gm_gm_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 GMCmdReq.ProtoReflect.Descriptor instead.
|
||||
func (*GMCmdReq) Descriptor() ([]byte, []int) {
|
||||
return file_gm_gm_msg_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GMCmdReq) GetCmod() string {
|
||||
if x != nil {
|
||||
return x.Cmod
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
///gm 命令请求 回应
|
||||
type GMCmdResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
IsSucc bool `protobuf:"varint,1,opt,name=IsSucc,proto3" json:"IsSucc"`
|
||||
}
|
||||
|
||||
func (x *GMCmdResp) Reset() {
|
||||
*x = GMCmdResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_gm_gm_msg_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GMCmdResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GMCmdResp) ProtoMessage() {}
|
||||
|
||||
func (x *GMCmdResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_gm_gm_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 GMCmdResp.ProtoReflect.Descriptor instead.
|
||||
func (*GMCmdResp) Descriptor() ([]byte, []int) {
|
||||
return file_gm_gm_msg_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GMCmdResp) GetIsSucc() bool {
|
||||
if x != nil {
|
||||
return x.IsSucc
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_gm_gm_msg_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_gm_gm_msg_proto_rawDesc = []byte{
|
||||
0x0a, 0x0f, 0x67, 0x6d, 0x2f, 0x67, 0x6d, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x22, 0x1e, 0x0a, 0x08, 0x47, 0x4d, 0x43, 0x6d, 0x64, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x43, 0x6d, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x43, 0x6d, 0x6f,
|
||||
0x64, 0x22, 0x23, 0x0a, 0x09, 0x47, 0x4d, 0x43, 0x6d, 0x64, 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 (
|
||||
file_gm_gm_msg_proto_rawDescOnce sync.Once
|
||||
file_gm_gm_msg_proto_rawDescData = file_gm_gm_msg_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_gm_gm_msg_proto_rawDescGZIP() []byte {
|
||||
file_gm_gm_msg_proto_rawDescOnce.Do(func() {
|
||||
file_gm_gm_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_gm_gm_msg_proto_rawDescData)
|
||||
})
|
||||
return file_gm_gm_msg_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_gm_gm_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_gm_gm_msg_proto_goTypes = []interface{}{
|
||||
(*GMCmdReq)(nil), // 0: GMCmdReq
|
||||
(*GMCmdResp)(nil), // 1: GMCmdResp
|
||||
}
|
||||
var file_gm_gm_msg_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_gm_gm_msg_proto_init() }
|
||||
func file_gm_gm_msg_proto_init() {
|
||||
if File_gm_gm_msg_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_gm_gm_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GMCmdReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_gm_gm_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GMCmdResp); 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{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_gm_gm_msg_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_gm_gm_msg_proto_goTypes,
|
||||
DependencyIndexes: file_gm_gm_msg_proto_depIdxs,
|
||||
MessageInfos: file_gm_gm_msg_proto_msgTypes,
|
||||
}.Build()
|
||||
File_gm_gm_msg_proto = out.File
|
||||
file_gm_gm_msg_proto_rawDesc = nil
|
||||
file_gm_gm_msg_proto_goTypes = nil
|
||||
file_gm_gm_msg_proto_depIdxs = nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user