新增将账号导入到adspower的方法
This commit is contained in:
38
api/ads.go
Normal file
38
api/ads.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"go-account-register/models"
|
||||
"go-account-register/services"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type AdsPower struct {
|
||||
}
|
||||
|
||||
// 导入账号
|
||||
func (a *AdsPower) ImportAccount(ctx *gin.Context) {
|
||||
// 查询当前的账号列表
|
||||
var twitterAccountService = services.InitTwitterAccountService()
|
||||
accountList := twitterAccountService.GetAvailableImportAccount(&models.TwitterAccount{
|
||||
Type: "raise",
|
||||
})
|
||||
// 循环创建AdsPower实例
|
||||
var AdsPowerService services.AdsPowerService
|
||||
log.Println("导入广告账号数量:", len(accountList))
|
||||
ticker := time.NewTicker(700 * time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for _, account := range accountList {
|
||||
<-ticker.C
|
||||
AdsPowerService.CreateBrowser(account.ID)
|
||||
// 如果只需要每秒10次,可以限制最多处理10个
|
||||
}
|
||||
ctx.JSON(http.StatusBadRequest, gin.H{
|
||||
"code": 200,
|
||||
"msg": "成功",
|
||||
"data": "",
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user