Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d7d4c11a0 | |||
| e4d07874eb | |||
| ae9984460f | |||
| e38a1a4480 |
+6
-1
@@ -37,4 +37,9 @@ fromName = "今日校园系统"
|
||||
accessKey = "dzckoE1UlZe8XFItWQDI"
|
||||
secretKey = "f8UZdnDohtwZk5HInT1Cw1QCztSGnFuPPqfSSjzu"
|
||||
baseUrl = "http://s3.out"
|
||||
bucket = "likedream"
|
||||
bucket = "likedream"
|
||||
|
||||
[cpdaily]
|
||||
appVersion = "5.7.0"
|
||||
systemVersion = "iOS 17"
|
||||
calVersion = "3.0.0"
|
||||
@@ -237,6 +237,7 @@ func (c *CpdailyCasLogin) Login(ctx context.Context, schoolDetail *school.School
|
||||
if isCasNeedKickOut(doc) {
|
||||
kickoutResponse := submitCasKickOut(ctx, loginResponseUrl.String(), doc, c.client)
|
||||
handleCasLoginSuccess(ctx, kickoutResponse, schoolDetail, username, password, c.client)
|
||||
return
|
||||
}
|
||||
|
||||
message := getCasErrorMessage(doc)
|
||||
|
||||
@@ -605,9 +605,9 @@ func (c *CpdailySleepCheckTask) FillCustomForm(ctx context.Context, form map[str
|
||||
} else {
|
||||
// 否则,填充查寝其他参数
|
||||
if signInstanceWidVar := rows["signInstanceWid"]; signInstanceWidVar != nil {
|
||||
resultForm["signInstanceWid"] = gvar.New(signInstanceWidVar.String())
|
||||
resultForm["SignInstanceWid"] = gvar.New(signInstanceWidVar.String())
|
||||
} else {
|
||||
resultForm["signInstanceWid"] = gvar.New("")
|
||||
resultForm["SignInstanceWid"] = gvar.New("")
|
||||
}
|
||||
|
||||
// 查找 isMalposition 参数
|
||||
@@ -676,7 +676,6 @@ func (c *CpdailySleepCheckTask) Submit(ctx context.Context, form map[string]*gva
|
||||
sign := taskhelper.GetSubmitSign(submitData)
|
||||
|
||||
submitData["sign"] = gvar.New(sign)
|
||||
utils.OkOrPanic(errors.NewBusinessError(503, "临时拦截"), oops.WithContext(ctx).Wrap)
|
||||
response, e := c.client.R().
|
||||
SetBody(submitData).
|
||||
WithContext(ctx).
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBusinessError(t *testing.T) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
of, b := Of[*BusinessError](err.(error))
|
||||
t.Log(of, b)
|
||||
t.Log("ok")
|
||||
}
|
||||
}()
|
||||
err := NewBusinessError(503, "调试错误")
|
||||
panic(err)
|
||||
}
|
||||
func Of[T error](input error) (T, bool) {
|
||||
var ret T
|
||||
if errors.As(input, &ret) {
|
||||
return ret, true
|
||||
}
|
||||
|
||||
return ret, false
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"likedream-goframe/internal/application/cpdaily/school"
|
||||
task2 "likedream-goframe/internal/application/cpdaily/task"
|
||||
"likedream-goframe/internal/application/cpdaily/task/formtype"
|
||||
errors2 "likedream-goframe/internal/common/errors"
|
||||
"likedream-goframe/internal/db"
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/ent/cptask"
|
||||
@@ -57,6 +58,8 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
|
||||
if e1, ok := utils.Of[*errors.BusinessError](err); ok {
|
||||
errorMessage = e1.Message()
|
||||
} else if e1, ok := utils.Of[*errors2.BusinessError](err); ok {
|
||||
errorMessage = e1.Message
|
||||
} else {
|
||||
errorMessage = "未知的错误导致任务执行失败"
|
||||
}
|
||||
@@ -68,7 +71,7 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
SetIsSuccess(false).
|
||||
SetRealName("").
|
||||
SetErrorMessage(errorMessage).
|
||||
Exec(ctx)
|
||||
Exec(context.Background())
|
||||
|
||||
utils.LogError(ctx, "创建任务日志失败", oops.With("task_id", taskPayload.CpTaskID).Wrap(e))
|
||||
|
||||
@@ -127,7 +130,6 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
}
|
||||
|
||||
submitForm := taskExecutor.FillCustomForm(ctx, cpdailyRealTask, customFormItems, deviceID, targetTask.Edges.CpUser.Username)
|
||||
utils.OkOrPanic(errors.NewBusinessError(400, "临时错误"))
|
||||
taskExecutor.Submit(ctx, submitForm, targetTask.Edges.CpUser.Username, deviceID)
|
||||
|
||||
db.Global.CpTask.UpdateOneID(taskPayload.CpTaskID).SetTaskStatus(cptask.TaskStatusDone).AddSuccessCount(1).ExecX(ctx)
|
||||
|
||||
@@ -118,7 +118,7 @@ func (ts *TaskScanner) scanCpdailyTask() {
|
||||
queue.AddTask(ts.ctx, asynq.NewTask(cst.TaskCpdaily, payloadWriter.Bytes()),
|
||||
asynq.TaskID(fmt.Sprintf("cpdaily:task:%d", task.ID)),
|
||||
asynq.MaxRetry(3),
|
||||
asynq.Unique(10*time.Minute),
|
||||
asynq.Unique(1*time.Minute),
|
||||
asynq.ProcessAt(execTime),
|
||||
asynq.Deadline(execTime.Add(12*time.Minute)),
|
||||
asynq.Queue(cst.TaskQueueCpdaily),
|
||||
|
||||
Reference in New Issue
Block a user