31 lines
1015 B
Go
31 lines
1015 B
Go
package task
|
|
|
|
import (
|
|
"context"
|
|
"likedream-goframe/internal/application/cookiejar"
|
|
"likedream-goframe/internal/application/cpdaily/school"
|
|
"likedream-goframe/internal/application/httpclient"
|
|
errors2 "likedream-goframe/internal/common/errors"
|
|
"likedream-goframe/internal/ent/cptask"
|
|
"likedream-goframe/internal/utils"
|
|
)
|
|
|
|
func GetCpdailyTaskService(ctx context.Context, Type cptask.TaskType, cookie string, schoolId string) CpdailyTask {
|
|
detail := school.GetSchoolDetail(ctx, schoolId)
|
|
cookieJar := cookiejar.NewPersistCookieJar()
|
|
cookieJar.Deserialize(cookie)
|
|
client := httpclient.Cpdaily.Clone(ctx)
|
|
client.SetCookieJar(cookieJar)
|
|
switch Type {
|
|
case cptask.TaskTypeCollection:
|
|
return NewCollectionTask(client, detail.WecloudUrl)
|
|
case cptask.TaskTypeSign:
|
|
return NewAutoSignTask(client, detail.WecloudUrl)
|
|
case cptask.TaskTypeSleepCheck:
|
|
return NewSleepCheckTask(client, detail.WecloudUrl)
|
|
default:
|
|
utils.OkOrPanic(errors2.NewBusinessError(400, "不支持的任务类型"))
|
|
}
|
|
return nil
|
|
}
|