55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package rtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
func (this *apiComp) RtestCheck(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode) {
|
|
if len(req.Params) < 1 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Rtest(session comm.IUserSession, req *pb.RtaskTestReq) (code pb.ErrorCode, data *pb.ErrorData) {
|
|
if code = this.RtestCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
rsp := &pb.RtaskTestResp{Flag: true, RtaskType: req.RtaskType}
|
|
// 校验
|
|
if req.CondiId != 0 {
|
|
condIds, _, err := this.module.ModuleBuried.CheckCondition(session.GetUserId(), req.CondiId)
|
|
if err == nil && len(condIds) > 0 {
|
|
rsp.Flag = false
|
|
}
|
|
// 触发
|
|
} else if req.RtaskType != 0 && len(req.Params) > 0 {
|
|
conds := []int32{}
|
|
switch len(req.Params) {
|
|
case 2:
|
|
conds[0] = req.Params[1]
|
|
case 3:
|
|
conds[0] = req.Params[1]
|
|
conds[1] = req.Params[2]
|
|
case 4:
|
|
conds[0] = req.Params[1]
|
|
conds[1] = req.Params[2]
|
|
conds[2] = req.Params[3]
|
|
case 5:
|
|
conds[0] = req.Params[1]
|
|
conds[1] = req.Params[2]
|
|
conds[2] = req.Params[3]
|
|
conds[3] = req.Params[4]
|
|
}
|
|
this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.TaskType(req.RtaskType), req.Params[0], conds...))
|
|
|
|
rsp.Flag = true
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), "rtest", rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|