49 lines
1.3 KiB
Go
49 lines
1.3 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) {
|
|
if req.Id == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
// 激活图鉴信息
|
|
func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
atlasConf := this.module.configure.GetPandoAtlasConf(req.Id)
|
|
if atlasConf == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId())
|
|
if v, ok := list.Collect[req.Id]; ok {
|
|
if !v.Activate {
|
|
update := make(map[string]interface{})
|
|
v.Activate = true // 找到图鉴积分 并更新积分
|
|
list.Score += atlasConf.AtlasScore
|
|
update["collect"] = list.Collect
|
|
update["score"] = list.Score
|
|
this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update)
|
|
session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{
|
|
Data: list,
|
|
})
|
|
return
|
|
} else {
|
|
code = pb.ErrorCode_MartialhallAtlasError
|
|
}
|
|
}
|
|
code = pb.ErrorCode_SmithyNoFoundAtlas
|
|
return
|
|
}
|