50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package mainline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) LevelSetPolts(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
|
|
)
|
|
if errdata = this.LevelSetPolts(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
|
|
}
|
|
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,
|
|
}) // 数据推送
|
|
|
|
return
|
|
}
|