上传武器背包api接口

This commit is contained in:
liwei1dao 2022-06-24 09:58:44 +08:00
parent 12bcbc72c2
commit c48ceefa17
3 changed files with 47 additions and 1 deletions

View File

@ -2,22 +2,48 @@ package equipment
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb" "go_dreamfactory/pb"
) )
//参数校验 //参数校验
func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) { func (this *Api_Comp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) {
var (
err error
errorCode pb.ErrorCode
equipment *pb.DB_Equipment
hero *pb.DB_HeroData
)
if equipment, err = this.module.model_equipment_comp.Equipment_QueryUserEquipmentsPackById(session.GetUserId(), req.EquipmentId); err != nil {
log.Errorf("Equip_Check err:%v", err)
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
return
}
if hero, errorCode = this.module.hero.GetHero(req.HeroCardId); errorCode != pb.ErrorCode_Success {
code.Code = errorCode
return
}
result = map[string]interface{}{
"equipment": equipment,
"hero": hero,
}
return return
} }
///英雄挂在装备 ///英雄挂在装备
func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) { func (this *Api_Comp) Equip(session comm.IUserSession, agrs map[string]interface{}, req *pb.Equipment_Equip_Req) (code pb.ErrorCode) {
var (
equipment *pb.DB_Equipment
hero *pb.DB_HeroData
)
defer func() { defer func() {
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_Equip_Resp{}) session.SendMsg(string(this.module.GetType()), "", &pb.Equipment_Equip_Resp{})
} }
}() }()
equipment = agrs["equipment"].(*pb.DB_Equipment)
hero = agrs["hero"].(*pb.DB_HeroData)
return return
} }

View File

@ -4,6 +4,8 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"github.com/smallnest/rpcx/log"
) )
/* /*
@ -18,9 +20,11 @@ func NewModule() core.IModule {
type Equipment struct { type Equipment struct {
modules.ModuleBase modules.ModuleBase
service core.IService
api_comp *Api_Comp api_comp *Api_Comp
configure_comp *Configure_Comp configure_comp *Configure_Comp
model_equipment_comp *Model_Equipment_Comp model_equipment_comp *Model_Equipment_Comp
hero comm.IHero
} }
//模块名 //模块名
@ -31,6 +35,19 @@ func (this *Equipment) GetType() core.M_Modules {
//模块初始化接口 注册用户创建角色事件 //模块初始化接口 注册用户创建角色事件
func (this *Equipment) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *Equipment) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service
return
}
//模块启动接口
func (this *Equipment) Start() (err error) {
err = this.ModuleBase.Start()
var module interface{}
if module, err = this.service.GetModule(comm.SM_HeroModule); err != nil {
log.Errorf("Equipment Start err:%v", err)
return
}
this.hero = module.(comm.IHero)
return return
} }

View File

@ -43,4 +43,7 @@ enum ErrorCode {
PackNoFoundGird = 1201; // PackNoFoundGird = 1201; //
PackGridNumUpper = 1202; // PackGridNumUpper = 1202; //
PackGirdAmountUpper = 1203; // PackGirdAmountUpper = 1203; //
//equipment
EquipmentOnFoundEquipment = 1300; //
} }