新增将账号导入到adspower的方法

This commit is contained in:
zyj
2025-11-21 10:52:22 +08:00
parent ecc99977d2
commit 87a077d40c
7 changed files with 648 additions and 0 deletions

38
api/ads.go Normal file
View 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": "",
})
}