调整基础模块基础组件接口
This commit is contained in:
parent
91bc6c65a6
commit
3f3721abb2
@ -14,6 +14,7 @@ type (
|
||||
API() IAPI_Comp
|
||||
Cache() ICache_Comp
|
||||
DB() IDB_Comp
|
||||
Configure() IConfigure_Comp
|
||||
///向指定用户发送消息
|
||||
SendMsgToUser(mainType, subType string, msg proto.Message, user *pb.Cache_UserData) (err error)
|
||||
///向多个用户发送消息
|
||||
|
@ -20,10 +20,11 @@ import (
|
||||
*/
|
||||
type ModuleBase struct {
|
||||
cbase.ModuleBase
|
||||
service base.IRPCXService
|
||||
Api_Comp IAPI_Comp
|
||||
Cache_Comp ICache_Comp
|
||||
Db_Comp IDB_Comp
|
||||
service base.IRPCXService
|
||||
Api_Comp IAPI_Comp
|
||||
Cache_Comp ICache_Comp
|
||||
Db_Comp IDB_Comp
|
||||
Configure_Comp IConfigure_Comp
|
||||
}
|
||||
|
||||
func (this *ModuleBase) API() IAPI_Comp {
|
||||
@ -36,6 +37,10 @@ func (this *ModuleBase) DB() IDB_Comp {
|
||||
return this.Db_Comp
|
||||
}
|
||||
|
||||
func (this *ModuleBase) Configure() IConfigure_Comp {
|
||||
return this.Configure_Comp
|
||||
}
|
||||
|
||||
//模块初始化接口
|
||||
func (this *ModuleBase) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
||||
err = this.ModuleBase.Init(service, module, options)
|
||||
|
@ -17,14 +17,10 @@ const ( //消息回复的头名称
|
||||
*/
|
||||
type Api_Comp struct {
|
||||
modules.MComp_GateComp
|
||||
service core.IService
|
||||
module *Pack
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MComp_GateComp.Init(service, module, comp, options)
|
||||
this.service = service
|
||||
this.module = module.(*Pack)
|
||||
return
|
||||
}
|
||||
|
@ -29,23 +29,23 @@ func (this *Api_Comp) Getlist(ctx context.Context, session comm.IUserSession, re
|
||||
dels []string
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), GetlistResp, code, &pb.GetlistResp{Grids: grids})
|
||||
session.SendMsg(string(this.M.GetType()), GetlistResp, code, &pb.GetlistResp{Grids: grids})
|
||||
if code == pb.ErrorCode_Success {
|
||||
go func() { //异步处理修改数据
|
||||
this.module.Cache_Comp.(*Cache_Comp).Pack_UpdateUserPack(session.GetUserId(), modifys...)
|
||||
this.module.Cache_Comp.(*Cache_Comp).Pack_DeleteUserPack(session.GetUserId(), dels...)
|
||||
this.M.Cache().(*Cache_Comp).Pack_UpdateUserPack(session.GetUserId(), modifys...)
|
||||
this.M.Cache().(*Cache_Comp).Pack_DeleteUserPack(session.GetUserId(), dels...)
|
||||
}()
|
||||
}
|
||||
}()
|
||||
if code = this.Getlist_Check(ctx, session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if items, err = this.module.Cache_Comp.(*Cache_Comp).Pack_QueryUserPack(session.GetUserId()); err != nil {
|
||||
if items, err = this.M.Cache().(*Cache_Comp).Pack_QueryUserPack(session.GetUserId()); err != nil {
|
||||
log.Errorf("QueryUserPackReq err:%v", err)
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
} else {
|
||||
tempgrids = this.module.configure_comp.GetPackItemByType(items, req.IType)
|
||||
tempgrids = this.M.Configure().(*Configure_Comp).GetPackItemByType(items, req.IType)
|
||||
modifys = make([]*pb.DB_UserItemData, 0, len(tempgrids))
|
||||
dels = make([]string, 0, len(tempgrids))
|
||||
grids = make([]*pb.DB_UserItemData, 0, len(grids))
|
||||
|
@ -21,7 +21,7 @@ func (this *Api_Comp) SellItem(ctx context.Context, session comm.IUserSession, r
|
||||
code pb.ErrorCode
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), SellItemResp, code, &pb.SellItemResp{})
|
||||
session.SendMsg(string(this.M.GetType()), SellItemResp, code, &pb.SellItemResp{})
|
||||
}()
|
||||
if code = this.SellItem_Check(ctx, session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
|
@ -21,7 +21,7 @@ func (this *Api_Comp) Useitem(ctx context.Context, session comm.IUserSession, re
|
||||
code pb.ErrorCode
|
||||
)
|
||||
defer func() {
|
||||
session.SendMsg(string(this.module.GetType()), UseItemResp, code, &pb.UseItemResp{})
|
||||
session.SendMsg(string(this.M.GetType()), UseItemResp, code, &pb.UseItemResp{})
|
||||
}()
|
||||
if code = this.Useitem_Check(ctx, session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
|
@ -20,7 +20,6 @@ func NewModule() core.IModule {
|
||||
|
||||
type Pack struct {
|
||||
modules.ModuleBase
|
||||
configure_comp *Configure_Comp //背包模块 配置相关接口封装组件
|
||||
}
|
||||
|
||||
//模块名称
|
||||
@ -40,7 +39,7 @@ func (this *Pack) OnInstallComp() {
|
||||
this.Api_Comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||
this.Cache_Comp = this.RegisterComp(new(Cache_Comp)).(*Cache_Comp)
|
||||
this.Db_Comp = this.RegisterComp(new(DB_Comp)).(*DB_Comp)
|
||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||
this.Configure_Comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||
}
|
||||
|
||||
//IPack-------------------------------------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user