|
@@ -6,6 +6,7 @@ import (
|
|
|
"github.com/robfig/cron/v3"
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
"time"
|
|
|
+ "youngee_b_api/app/service"
|
|
|
"youngee_b_api/db"
|
|
|
"youngee_b_api/model/gorm_model"
|
|
|
)
|
|
@@ -69,6 +70,36 @@ func AutoTask() error {
|
|
|
log.Println("service [UpdateProjectTaskWeiBoLinkData] error:", err10)
|
|
|
return err10
|
|
|
}
|
|
|
+ _, err11 := c.AddFunc(spec, UpdateProjectTaskDouyinLinkData)
|
|
|
+ if err11 != nil {
|
|
|
+ log.Println("service [UpdateProjectTaskDouyinLinkData] error:", err11)
|
|
|
+ return err11
|
|
|
+ }
|
|
|
+ _, err12 := c.AddFunc(spec, UpdateLocalTaskDouyinLinkData)
|
|
|
+ if err12 != nil {
|
|
|
+ log.Println("service [UpdateLocalTaskDouyinLinkData] error:", err12)
|
|
|
+ return err12
|
|
|
+ }
|
|
|
+ _, err13 := c.AddFunc(spec, UpdateProjectTaskKuaishouLinkData)
|
|
|
+ if err13 != nil {
|
|
|
+ log.Println("service [UpdateProjectTaskKuaishouLinkData] error:", err13)
|
|
|
+ return err13
|
|
|
+ }
|
|
|
+ _, err14 := c.AddFunc(spec, UpdateLocalTaskKuaishouLinkData)
|
|
|
+ if err14 != nil {
|
|
|
+ log.Println("service [UpdateLocalTaskKuaishouLinkData] error:", err14)
|
|
|
+ return err14
|
|
|
+ }
|
|
|
+ _, err15 := c.AddFunc(spec, UpdateProjectTaskBilibiliLinkData)
|
|
|
+ if err15 != nil {
|
|
|
+ log.Println("service [UpdateProjectTaskBilibiliLinkData] error:", err15)
|
|
|
+ return err15
|
|
|
+ }
|
|
|
+ _, err16 := c.AddFunc(spec, UpdateLocalTaskBilibiliLinkData)
|
|
|
+ if err16 != nil {
|
|
|
+ log.Println("service [UpdateLocalTaskBilibiliLinkData] error:", err16)
|
|
|
+ return err16
|
|
|
+ }
|
|
|
fmt.Println(spec)
|
|
|
c.Start()
|
|
|
return nil
|
|
@@ -344,3 +375,333 @@ func UpdateLocalTaskWeiBoLinkData() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// UpdateProjectTaskDouyinLinkData 定时拉取抖音平台,种草子任务链接数据
|
|
|
+func UpdateProjectTaskDouyinLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateProjectTaskDouyinLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的project
|
|
|
+ ctx := context.Background()
|
|
|
+ projectIdList, projectIdListTotal, projectIdListErr := db.GetProjectIdList(ctx, 8, 2)
|
|
|
+ if projectIdListErr != nil {
|
|
|
+ log.Println("GetProjectIdList error : ", projectIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if projectIdList != nil && projectIdListTotal != 0 {
|
|
|
+ for _, projectId := range projectIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetProjectTaskIdList(ctx, projectId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetProjectTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := service.MoreapiService{}.GetDouyinStatistic(linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetDouyinStatistic error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.ProjectTaskLinkStatistic{
|
|
|
+ ProjectId: projectId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 2,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateProjectTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateProjectTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateLocalTaskDouyinLinkData 定时拉取抖音平台,本地生活子任务链接数据
|
|
|
+func UpdateLocalTaskDouyinLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateLocalTaskDouyinLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的local
|
|
|
+ ctx := context.Background()
|
|
|
+ localIdList, localIdListTotal, localIdListErr := db.GetLocalIdList(ctx, 8, 2)
|
|
|
+ if localIdListErr != nil {
|
|
|
+ log.Println("GetLocalIdList error : ", localIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if localIdList != nil && localIdListTotal != 0 {
|
|
|
+ for _, localId := range localIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetLocalTaskIdList(ctx, localId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetLocalTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := service.MoreapiService{}.GetDouyinStatistic(linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetWeiBoLinkDetail error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.LocalTaskLinkStatistic{
|
|
|
+ LocalId: localId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 2,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateLocalTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateLocalTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateProjectTaskKuaishouLinkData 定时拉取快手平台,种草子任务链接数据
|
|
|
+func UpdateProjectTaskKuaishouLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateProjectTaskKuaishouLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的project
|
|
|
+ ctx := context.Background()
|
|
|
+ projectIdList, projectIdListTotal, projectIdListErr := db.GetProjectIdList(ctx, 8, 4)
|
|
|
+ if projectIdListErr != nil {
|
|
|
+ log.Println("GetProjectIdList error : ", projectIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if projectIdList != nil && projectIdListTotal != 0 {
|
|
|
+ for _, projectId := range projectIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetProjectTaskIdList(ctx, projectId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetProjectTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := service.MoreapiService{}.GetKuaishouStatistic(linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetKuaishouStatistic error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.ProjectTaskLinkStatistic{
|
|
|
+ ProjectId: projectId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 4,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateProjectTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateProjectTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateLocalTaskKuaishouLinkData 定时拉取快手平台,本地生活子任务链接数据
|
|
|
+func UpdateLocalTaskKuaishouLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateLocalTaskKuaishouLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的local
|
|
|
+ ctx := context.Background()
|
|
|
+ localIdList, localIdListTotal, localIdListErr := db.GetLocalIdList(ctx, 8, 4)
|
|
|
+ if localIdListErr != nil {
|
|
|
+ log.Println("GetLocalIdList error : ", localIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if localIdList != nil && localIdListTotal != 0 {
|
|
|
+ for _, localId := range localIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetLocalTaskIdList(ctx, localId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetLocalTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := service.MoreapiService{}.GetKuaishouStatistic(linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetKuaishouStatistic error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.LocalTaskLinkStatistic{
|
|
|
+ LocalId: localId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 4,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateLocalTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateLocalTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateProjectTaskBilibiliLinkData 定时拉取b站平台,种草子任务链接数据
|
|
|
+func UpdateProjectTaskBilibiliLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateProjectTaskBilibiliLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的project
|
|
|
+ ctx := context.Background()
|
|
|
+ projectIdList, projectIdListTotal, projectIdListErr := db.GetProjectIdList(ctx, 8, 5)
|
|
|
+ if projectIdListErr != nil {
|
|
|
+ log.Println("GetProjectIdList error : ", projectIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if projectIdList != nil && projectIdListTotal != 0 {
|
|
|
+ for _, projectId := range projectIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetProjectTaskIdList(ctx, projectId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetProjectTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := service.MoreapiService{}.GetBilibiliStatistic(linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetBilibiliStatistic error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.ProjectTaskLinkStatistic{
|
|
|
+ ProjectId: projectId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 5,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateProjectTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateProjectTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// UpdateLocalTaskBilibiliLinkData 定时拉取b站平台,本地生活子任务链接数据
|
|
|
+func UpdateLocalTaskBilibiliLinkData() {
|
|
|
+
|
|
|
+ log.Println("UpdateLocalTaskBilibiliLinkData is running ,Time :", time.Now())
|
|
|
+
|
|
|
+ // 1. 符合条件的local
|
|
|
+ ctx := context.Background()
|
|
|
+ localIdList, localIdListTotal, localIdListErr := db.GetLocalIdList(ctx, 8, 5)
|
|
|
+ if localIdListErr != nil {
|
|
|
+ log.Println("GetLocalIdList error : ", localIdListErr)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 符合条件的task
|
|
|
+ if localIdList != nil && localIdListTotal != 0 {
|
|
|
+ for _, localId := range localIdList {
|
|
|
+ taskIdList, taskIdTotal, taskIdErr := db.GetLocalTaskIdList(ctx, localId)
|
|
|
+ if taskIdErr != nil {
|
|
|
+ log.Println("GetLocalTaskIdList error : ", taskIdErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if taskIdList != nil && taskIdTotal != 0 {
|
|
|
+ for _, taskId := range taskIdList {
|
|
|
+ linkInfo, linkErr := db.GetProjectTaskLinkInfo(ctx, taskId, 1)
|
|
|
+ if linkErr != nil {
|
|
|
+ log.Println("GetProjectTaskLinkInfo error : ", linkErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if linkInfo != "" {
|
|
|
+ like, comment, collect, share, moreApiErr := service.MoreapiService{}.GetBilibiliStatistic(linkInfo)
|
|
|
+ if moreApiErr != nil {
|
|
|
+ log.Println("GetKuaishouStatistic error : ", moreApiErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ createData := gorm_model.LocalTaskLinkStatistic{
|
|
|
+ LocalId: localId,
|
|
|
+ TaskId: taskId,
|
|
|
+ PlatformId: 5,
|
|
|
+ VoteCount: like,
|
|
|
+ CommitCount: comment,
|
|
|
+ CollectionCount: collect,
|
|
|
+ ViewCount: share,
|
|
|
+ }
|
|
|
+ createErr := db.CreateLocalTaskLinkStatistic(ctx, &createData)
|
|
|
+ if createErr != nil {
|
|
|
+ log.Println("CreateLocalTaskLinkStatistic error : ", createErr)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|