Files
go-account-register/api/ads.go
2025-11-21 10:52:22 +08:00

39 lines
913 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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": "",
})
}