60 lines
1.5 KiB
Go
60 lines
1.5 KiB
Go
package mainline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) SetPoltsCheck(session comm.IUserSession, req *pb.MainlineSetPoltsReq) (errdata *pb.ErrorData) {
|
|
return
|
|
}
|
|
|
|
// /挑战主线关卡
|
|
func (this *apiComp) SetPolts(session comm.IUserSession, req *pb.MainlineSetPoltsReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBMainline
|
|
err error
|
|
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
|
)
|
|
if errdata = this.SetPoltsCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
|
|
if info, err = this.module.modelMline.getMainlineData(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if !info.Plots[req.Pid] {
|
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype60, 1))
|
|
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype61, 1, int32(req.Pid)))
|
|
}
|
|
info.Plots[req.Pid] = req.State
|
|
|
|
if err = this.module.modelMline.Change(session.GetUserId(), map[string]interface{}{
|
|
"plots": info.Plots,
|
|
}); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
session.SendMsg(string(this.module.GetType()), "setpolts", &pb.MainlineSetPoltsResp{
|
|
Plots: info.Plots,
|
|
})
|
|
|
|
if len(tasks) > 0 {
|
|
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
|
|
this.module.ModuleBuried.TriggerBuried(session, tasks...)
|
|
})
|
|
}
|
|
return
|
|
}
|