53 lines
1.4 KiB
Go
53 lines
1.4 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) (code pb.ErrorCode) {
|
|
if req.Cid == "" {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) ActivateAtlas(session comm.IUserSession, req *pb.GourmetActivateAtlasReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
|
|
code = this.ActivateAtlasCheck(session, req)
|
|
if code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
conf := this.configure.GetGrormetCookBookConf(req.Cid)
|
|
if conf == nil { // 配置校验
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
_gourmet, err := this.module.modelAtlas.getGourmetAtlasList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
if v, ok := _gourmet.Atlas[req.Cid]; !ok || v != -1 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
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,
|
|
})
|
|
|
|
return
|
|
}
|