修复check校验函数格式优化
This commit is contained in:
parent
09ecaa3207
commit
9089ab2344
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) EquipCheck(session comm.IUserSession, req *pb.Equipment_Equip_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
var (
|
||||
err error
|
||||
errorCode pb.ErrorCode
|
||||
@ -20,7 +20,7 @@ func (this *apiComp) Equip_Check(session comm.IUserSession, req *pb.Equipment_Eq
|
||||
equipments = make([]*pb.DB_Equipment, len(req.EquipmentId))
|
||||
for i, v := range req.EquipmentId {
|
||||
if v != "" {
|
||||
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
log.Errorf("Equip_Check err:%v", err)
|
||||
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
return
|
||||
@ -64,7 +64,7 @@ func (this *apiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
||||
for i, v := range hero.EquipID {
|
||||
if v != "" {
|
||||
if equipments[i] != nil && v != equipments[i].Id {
|
||||
if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
@ -73,7 +73,7 @@ func (this *apiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
||||
equipments[i].HeroId = hero.Id
|
||||
updatequipment = append(updatequipment, equipment, equipments[i])
|
||||
} else if equipments[i] == nil {
|
||||
if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
log.Errorf("Equip reader uid:%s equipment:%s err:%v", session.GetUserId(), v, err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
@ -96,7 +96,7 @@ func (this *apiComp) Equip(session comm.IUserSession, agrs map[string]interface{
|
||||
}
|
||||
}
|
||||
if code = this.module.hero.UpdateEquipment(hero, equipments); code == pb.ErrorCode_Success {
|
||||
if err = this.module.modelEquipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
|
||||
if err = this.module.modelequipment.UpdateByHeroId(session.GetUserId(), updatequipment...); err != nil {
|
||||
log.Errorf("Equip err%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) Getlist_Check(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.Equipment_GetList_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) UpgradeCheck(session comm.IUserSession, req *pb.Equipment_Upgrade_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
var (
|
||||
err error
|
||||
conf *cfg.Game_equipData
|
||||
@ -24,7 +24,7 @@ func (this *apiComp) Upgrade_Check(session comm.IUserSession, req *pb.Equipment_
|
||||
code.Code = pb.ErrorCode_ReqParameterError
|
||||
return
|
||||
}
|
||||
if equipment, err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil {
|
||||
if equipment, err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), req.EquipmentId); err != nil {
|
||||
log.Errorf("Equip_Check err:%v", err)
|
||||
code.Code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
return
|
||||
@ -85,7 +85,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
||||
//叠加装备 拆分处理
|
||||
if equipment.IsInitialState && equipment.OverlayNum > 1 {
|
||||
equipment.OverlayNum--
|
||||
if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
||||
if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
||||
"overlayNum": equipment.OverlayNum,
|
||||
"heroId": "",
|
||||
}); err != nil {
|
||||
@ -97,24 +97,24 @@ func (this *apiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
||||
equipment.Id = primitive.NewObjectID().Hex()
|
||||
equipment.IsInitialState = false
|
||||
equipment.OverlayNum = 1
|
||||
if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
||||
if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
return
|
||||
}
|
||||
if err = this.module.modelEquipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil {
|
||||
if err = this.module.modelequipment.AddList(session.GetUserId(), equipment.Id, equipment); err != nil {
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
} else {
|
||||
equipment.IsInitialState = false
|
||||
if err = this.module.modelEquipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
||||
if err = this.module.modelequipment.upgradeEquipment(equipment, conf, intensify); err != nil {
|
||||
code = pb.ErrorCode_SystemError
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
return
|
||||
}
|
||||
if err = this.module.modelEquipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
||||
if err = this.module.modelequipment.ChangeList(session.GetUserId(), equipment.Id, map[string]interface{}{
|
||||
"lv": equipment.Lv,
|
||||
"mainEntry": equipment.MainEntry,
|
||||
"adverbEntry": equipment.AdverbEntry,
|
||||
@ -136,7 +136,7 @@ func (this *apiComp) Upgrade(session comm.IUserSession, agrs map[string]interfac
|
||||
for i, v := range hero.EquipID {
|
||||
if v != "" {
|
||||
if v != equipment.Id {
|
||||
if equipments[i], err = this.module.modelEquipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
if equipments[i], err = this.module.modelequipment.QueryUserEquipmentsById(session.GetUserId(), v); err != nil {
|
||||
log.Errorf("Upgrade err:%v", err)
|
||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
return
|
||||
|
@ -25,7 +25,7 @@ type Equipment struct {
|
||||
service core.IService
|
||||
api *apiComp
|
||||
configure *configureComp
|
||||
modelEquipment *modelEquipmentComp
|
||||
modelequipment *modelEquipmentComp
|
||||
hero comm.IHero
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ func (this *Equipment) Start() (err error) {
|
||||
func (this *Equipment) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelEquipment = this.RegisterComp(new(modelEquipmentComp)).(*modelEquipmentComp)
|
||||
this.modelequipment = this.RegisterComp(new(modelEquipmentComp)).(*modelEquipmentComp)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ func (this *Equipment) OnInstallComp() {
|
||||
//查询武器信息
|
||||
func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string, Id string) (equipment *pb.DB_Equipment, code pb.ErrorCode) {
|
||||
var err error
|
||||
if equipment, err = this.modelEquipment.QueryUserEquipmentsById(uid, Id); err != nil {
|
||||
if equipment, err = this.modelequipment.QueryUserEquipmentsById(uid, Id); err != nil {
|
||||
if err == redis.Nil {
|
||||
code = pb.ErrorCode_EquipmentOnFoundEquipment
|
||||
} else {
|
||||
@ -77,14 +77,14 @@ func (this *Equipment) QueryEquipment(source *comm.ModuleCallSource, uid string,
|
||||
|
||||
//查询卡片数量
|
||||
func (this *Equipment) QueryEquipmentAmount(source *comm.ModuleCallSource, uid string, equipmentId int32) (amount uint32) {
|
||||
amount = this.modelEquipment.QueryEquipmentAmount(uid, equipmentId)
|
||||
amount = this.modelequipment.QueryEquipmentAmount(uid, equipmentId)
|
||||
return
|
||||
}
|
||||
|
||||
//添加武器
|
||||
func (this *Equipment) AddNewEquipments(source *comm.ModuleCallSource, uid string, cIds map[int32]uint32) (code pb.ErrorCode) {
|
||||
var err error
|
||||
if err = this.modelEquipment.AddEquipments(uid, cIds); err != nil {
|
||||
if err = this.modelequipment.AddEquipments(uid, cIds); err != nil {
|
||||
log.Errorf("err%v", err)
|
||||
code = pb.ErrorCode_SystemError
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ type ModelFriend struct {
|
||||
}
|
||||
|
||||
func (this *ModelFriend) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.Model_Comp.Init(service, module, comp, options)
|
||||
err = this.MCompModel.Init(service, module, comp, options)
|
||||
this.TableName = string(TableFriend)
|
||||
return
|
||||
}
|
||||
|
@ -9,21 +9,21 @@ import (
|
||||
/*
|
||||
API
|
||||
*/
|
||||
type Api_Comp struct {
|
||||
modules.MComp_GateComp
|
||||
type ApiComp struct {
|
||||
modules.MCompGate
|
||||
service core.IService
|
||||
module *Game
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
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)
|
||||
func (this *ApiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MCompGate.Init(service, module, comp, options)
|
||||
this.module = module.(*Game)
|
||||
this.service = service
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Api_Comp) Start() (err error) {
|
||||
err = this.MComp_GateComp.Start()
|
||||
func (this *ApiComp) Start() (err error) {
|
||||
err = this.MCompGate.Start()
|
||||
return
|
||||
}
|
||||
|
@ -11,12 +11,12 @@ const (
|
||||
)
|
||||
|
||||
///配置管理组件
|
||||
type Configure_Comp struct {
|
||||
modules.MComp_Configure
|
||||
type ConfigureComp struct {
|
||||
modules.MCompConfigure
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
|
||||
return
|
||||
|
@ -12,19 +12,19 @@ const (
|
||||
)
|
||||
|
||||
///背包配置管理组件
|
||||
type Configure_Comp struct {
|
||||
modules.MComp_Configure
|
||||
type ConfigureComp struct {
|
||||
modules.MCompConfigure
|
||||
}
|
||||
|
||||
//组件初始化接口
|
||||
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
this.LoadConfigure(game_msgdistrib, cfg.NewGame_msgDistrib)
|
||||
return
|
||||
}
|
||||
|
||||
//获取消息分发规则读取配置表
|
||||
func (this *Configure_Comp) GetMsgDistribRule(mtype, stype string) (rule string, ok bool) {
|
||||
func (this *ConfigureComp) GetMsgDistribRule(mtype, stype string) (rule string, ok bool) {
|
||||
var (
|
||||
err error
|
||||
v interface{}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
//参数校验
|
||||
func (this *apiComp) Useitem_Check(session comm.IUserSession, req *pb.Items_UseItem_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
func (this *apiComp) UseitemCheck(session comm.IUserSession, req *pb.Items_UseItem_Req) (result map[string]interface{}, code comm.ErrorCode) {
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ const (
|
||||
)
|
||||
|
||||
type ModelMail struct {
|
||||
modules.Model_Comp
|
||||
modules.MCompModel
|
||||
}
|
||||
|
||||
func (this *ModelMail) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.Model_Comp.Init(service, module, comp, options)
|
||||
this.MCompModel.Init(service, module, comp, options)
|
||||
this.TableName = "mail"
|
||||
//创建uid索引
|
||||
this.DB.CreateIndex(core.SqlTable(DB_MailTable), mongo.IndexModel{
|
||||
|
Loading…
Reference in New Issue
Block a user