51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package treasuremap
|
|
|
|
import (
|
|
"fmt"
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.TreasuremapAwardReq) (errdata *pb.ErrorData) {
|
|
|
|
return
|
|
}
|
|
|
|
// /获取系统公告
|
|
func (this *apiComp) Award(session comm.IUserSession, req *pb.TreasuremapAwardReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBTreasuremap
|
|
ok bool
|
|
err error
|
|
)
|
|
if errdata = this.AwardCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
|
|
if info, err = this.module.model.getModel(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if _, ok = info.Treasuremap[req.Id]; ok {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: fmt.Sprintf("Treasuremap Claimed! id:%d", req.Id),
|
|
}
|
|
}
|
|
|
|
info.Treasuremap[req.Id] = true
|
|
|
|
this.module.model.Change(session.GetUserId(), map[string]interface{}{
|
|
"treasuremap": info.Treasuremap,
|
|
})
|
|
session.SendMsg(string(this.module.GetType()), "award", &pb.TreasuremapAwardResp{Id: req.Id})
|
|
return
|
|
}
|