66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package exclusive
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) WearCheck(session comm.IUserSession, req *pb.ExclusiveWearReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
///获取用户装备列表
|
|
func (this *apiComp) Wear(session comm.IUserSession, req *pb.ExclusiveWearReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DB_Exclusive
|
|
hero *pb.DBHero
|
|
change []*pb.DB_Exclusive
|
|
err error
|
|
)
|
|
|
|
if hero, errdata = this.module.ModuleHero.GetHeroByObjID(session.GetUserId(), req.Heroid); err != nil {
|
|
return
|
|
}
|
|
if hero.Exclusiveid != "" {
|
|
if info, err = this.module.model.getExclusivesById(session.GetUserId(), hero.Exclusiveid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
info.Hero = ""
|
|
change = append(change, info)
|
|
}
|
|
if req.Oid != "" {
|
|
if info, err = this.module.model.getExclusivesById(session.GetUserId(), req.Oid); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
info.Hero = hero.Id
|
|
change = append(change, info)
|
|
if err = this.module.model.updateExclusive(session.GetUserId(), change...); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if errdata = this.module.ModuleHero.UpdateExclusive(session, hero, info); errdata != nil {
|
|
return
|
|
}
|
|
} else {
|
|
if errdata = this.module.ModuleHero.UpdateExclusive(session, hero, nil); errdata != nil {
|
|
return
|
|
}
|
|
}
|
|
this.module.equipmentsChangePush(session, change)
|
|
session.SendMsg(string(this.module.GetType()), "wear", &pb.ExclusiveWearResp{Exclusives: info})
|
|
return
|
|
}
|