更新数据
This commit is contained in:
@@ -2,6 +2,8 @@ package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"server/models"
|
||||
@@ -23,7 +25,7 @@ var validPlatformTypes = map[string]bool{
|
||||
"jingdong": true,
|
||||
"douyin": true,
|
||||
"local": true,
|
||||
"xubei": true,
|
||||
"xubei": true,
|
||||
}
|
||||
|
||||
// validModules 支持的号池模块
|
||||
@@ -52,10 +54,16 @@ func (c *ApiGetCardController) cardOK(text string) {
|
||||
// - type (必填) 来源平台:xianyu / taobao / pinduoduo / jingdong / local / xubei
|
||||
// - module (必填) 号池模块:cursor / windsurf / krio
|
||||
// - data_type (可选) 账号类型:account / tk / account_tk,不传则取任意未提取的
|
||||
// - id/start_id/current_id (可选) 起始 ID:从该 ID 开始向后提取,避免传 896 却取到 892
|
||||
func (c *ApiGetCardController) GetCard() {
|
||||
platform := c.GetString("type")
|
||||
module := c.GetString("module")
|
||||
dataType := c.GetString("data_type")
|
||||
startID, err := c.readOptionalStartID()
|
||||
if err != nil {
|
||||
c.cardErr(400, 400, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// 参数校验
|
||||
if platform == "" {
|
||||
@@ -83,20 +91,42 @@ func (c *ApiGetCardController) GetCard() {
|
||||
|
||||
switch module {
|
||||
case "cursor":
|
||||
c.extractCursor(platform, dataType, now)
|
||||
c.extractCursor(platform, dataType, startID, now)
|
||||
case "windsurf":
|
||||
c.extractWindsurf(platform, dataType, now)
|
||||
c.extractWindsurf(platform, dataType, startID, now)
|
||||
case "krio":
|
||||
c.extractKrio(platform, dataType, now)
|
||||
c.extractKrio(platform, dataType, startID, now)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ApiGetCardController) extractCursor(platform, dataType string, now time.Time) {
|
||||
func (c *ApiGetCardController) readOptionalStartID() (uint64, error) {
|
||||
raw := strings.TrimSpace(c.GetString("id"))
|
||||
if raw == "" {
|
||||
raw = strings.TrimSpace(c.GetString("start_id"))
|
||||
}
|
||||
if raw == "" {
|
||||
raw = strings.TrimSpace(c.GetString("current_id"))
|
||||
}
|
||||
if raw == "" {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
id, err := strconv.ParseUint(raw, 10, 64)
|
||||
if err != nil || id == 0 {
|
||||
return 0, fmt.Errorf("id/start_id/current_id 必须是大于 0 的整数")
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (c *ApiGetCardController) extractCursor(platform, dataType string, startID uint64, now time.Time) {
|
||||
c.extractWithProbe("cursor", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
|
||||
var row models.PlatformAccountPoolCursor
|
||||
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)).
|
||||
Filter("is_extracted", 0).
|
||||
Filter("delete_time__isnull", true)
|
||||
if startID > 0 {
|
||||
qs = qs.Filter("id__gte", startID)
|
||||
}
|
||||
if dataType != "" {
|
||||
qs = qs.Filter("data_type", dataType)
|
||||
}
|
||||
@@ -107,12 +137,15 @@ func (c *ApiGetCardController) extractCursor(platform, dataType string, now time
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ApiGetCardController) extractWindsurf(platform, dataType string, now time.Time) {
|
||||
func (c *ApiGetCardController) extractWindsurf(platform, dataType string, startID uint64, now time.Time) {
|
||||
c.extractWithProbe("windsurf", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
|
||||
var row models.PlatformAccountPoolWindsurf
|
||||
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolWindsurf)).
|
||||
Filter("is_extracted", 0).
|
||||
Filter("delete_time__isnull", true)
|
||||
if startID > 0 {
|
||||
qs = qs.Filter("id__gte", startID)
|
||||
}
|
||||
if dataType != "" {
|
||||
qs = qs.Filter("data_type", dataType)
|
||||
}
|
||||
@@ -123,12 +156,15 @@ func (c *ApiGetCardController) extractWindsurf(platform, dataType string, now ti
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ApiGetCardController) extractKrio(platform, dataType string, now time.Time) {
|
||||
func (c *ApiGetCardController) extractKrio(platform, dataType string, startID uint64, now time.Time) {
|
||||
c.extractWithProbe("krio", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
|
||||
var row models.PlatformAccountPoolKiro
|
||||
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolKiro)).
|
||||
Filter("is_extracted", 0).
|
||||
Filter("delete_time__isnull", true)
|
||||
if startID > 0 {
|
||||
qs = qs.Filter("id__gte", startID)
|
||||
}
|
||||
if dataType != "" {
|
||||
qs = qs.Filter("data_type", dataType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user