50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package atlas
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) ActivateCheck(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode) {
|
|
|
|
return
|
|
}
|
|
|
|
// 一键激活所有激活图鉴信息
|
|
func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
bUpdate bool
|
|
)
|
|
if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
|
|
for k, v := range list.Collect {
|
|
if !v.Activate {
|
|
v.Activate = true // 找到图鉴积分 并更新积分
|
|
if atlasConf := this.module.configure.GetPandoAtlasConf(k); atlasConf != nil {
|
|
list.Score += atlasConf.AtlasScore
|
|
bUpdate = true
|
|
}
|
|
}
|
|
}
|
|
if bUpdate {
|
|
update := make(map[string]interface{})
|
|
update["collect"] = list.Collect
|
|
update["score"] = list.Score
|
|
|
|
this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update)
|
|
} else {
|
|
code = pb.ErrorCode_SmithyNoActivateAtlas
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{
|
|
Data: list,
|
|
})
|
|
return
|
|
}
|