diff --git a/person.go b/person.go index 6265b8e..3416720 100644 --- a/person.go +++ b/person.go @@ -6,6 +6,8 @@ import ( "reflect" "time" + "474420502.top/eson/crontabex" + "474420502.top/eson/structure/circular_linked" "474420502.top/eson/curl2info" @@ -17,7 +19,7 @@ type ITask interface { Init() SetCrontab(cron string) - SetLastStatus(status bool) + GetCrontab() *crontab.Crontab SetName(name string) GetName() string @@ -172,6 +174,7 @@ func ExecuteOnPlan(task ITask, result chan string) { taskname := task.GetName() urlname := task.GetCurl().Name + task.NextTime() // 必须调用NextTime 才能触发TimeUp for { interval := time.Second * 2 if task.TimeUp() { diff --git a/structure.go b/structure.go deleted file mode 100644 index 47efed7..0000000 --- a/structure.go +++ /dev/null @@ -1 +0,0 @@ -package imitater diff --git a/structure_test.go b/structure_test.go deleted file mode 100644 index 47efed7..0000000 --- a/structure_test.go +++ /dev/null @@ -1 +0,0 @@ -package imitater diff --git a/task.go b/task.go index b0d5114..592cb89 100644 --- a/task.go +++ b/task.go @@ -1,9 +1,14 @@ package imitater import ( + "encoding/json" + "log" "time" + "474420502.top/test/logdb" + "474420502.top/eson/structure/circular_linked" + uuid "github.com/satori/go.uuid" "474420502.top/eson/crontabex" "474420502.top/eson/curl2info" @@ -73,9 +78,9 @@ func (task *Task) SetCrontab(cron string) { task.crontab = crontab.NewCrontab(cron) } -// SetLastStatus 设置上次执行的状态 成功true 失败false -func (task *Task) SetLastStatus(status bool) { - task.crontab.SetStatus(status) +// GetCrontab 设置上次执行的状态 成功true 失败false +func (task *Task) GetCrontab() *crontab.Crontab { + return task.crontab } // TimeUp 判断是否到了下次执行的时间点 @@ -125,3 +130,24 @@ func (task *Task) Session() *requests.Session { return task.session } + +// ADDataSave 公众存储数据的接口 +func ADDataSave(task ITask, db *logdb.LogDB, adDataList []string) { + if len(adDataList) != 0 { + adDataStore, err := json.Marshal(adDataList) + if err != nil { + panic(err) + } + // log.Println(string(adDataStore)) + uid, err := uuid.NewV4() + if err != nil { + panic(err) + } + + log.Println(uid.String()) + + adinfo := task.GetADInfo() + db.ADInsert(uid.String(), adinfo.Device, adinfo.Platform, adinfo.AreaCC, "", + string(adDataStore), adinfo.SpiderID, adinfo.Channel, adinfo.Media, adinfo.CatchAccountID, 0, adinfo.Priority, time.Now()) + } +}