69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package gourmet
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) ActivateAtlasCheck(session comm.IUserSession, req *pb.GourmetActivateAtlasReq) (errdata *pb.ErrorData) {
|
|
if req.Cid == "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) ActivateAtlas(session comm.IUserSession, req *pb.GourmetActivateAtlasReq) (errdata *pb.ErrorData) {
|
|
|
|
errdata = this.ActivateAtlasCheck(session, req)
|
|
if errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
conf, err := this.configure.GetGrormetCookBookConf(req.Cid)
|
|
if err != nil { // 配置校验
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
_gourmet, err := this.module.modelAtlas.getGourmetAtlasList(session.GetUserId())
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if v, ok := _gourmet.Atlas[req.Cid]; !ok || v != -1 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
return
|
|
}
|
|
_gourmet.Atlas[req.Cid] = 1
|
|
if err := this.module.modelAtlas.Change(session.GetUserId(), map[string]interface{}{
|
|
"atlas": _gourmet.Atlas,
|
|
}); err != nil {
|
|
this.module.Errorf("change modelAtlas failed: %v", err)
|
|
}
|
|
|
|
// 发送首次获得奖励
|
|
this.module.DispenseRes(session, []*cfg.Gameatn{conf.Unlockreward}, true)
|
|
session.SendMsg(string(this.module.GetType()), "activateatlas", &pb.GourmetActivateAtlasResp{
|
|
Atlas: _gourmet.Atlas,
|
|
})
|
|
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.WriteUserLog(session.GetUserId(), "GourmetActivateAtlasReq", conf.Unlockreward)
|
|
})
|
|
return
|
|
}
|