增加便捷工具
This commit is contained in:
@@ -33,6 +33,7 @@ var validModules = map[string]bool{
|
||||
"cursor": true,
|
||||
"windsurf": true,
|
||||
"krio": true,
|
||||
"codex": true,
|
||||
}
|
||||
|
||||
func (c *ApiGetCardController) cardErr(_ int, _ int, msg string) {
|
||||
@@ -52,7 +53,7 @@ func (c *ApiGetCardController) cardOK(text string) {
|
||||
//
|
||||
// 参数:
|
||||
// - type (必填) 来源平台:xianyu / taobao / pinduoduo / jingdong / local / xubei
|
||||
// - module (必填) 号池模块:cursor / windsurf / krio
|
||||
// - module (必填) 号池模块:cursor / windsurf / krio / codex
|
||||
// - data_type (可选) 账号类型:account / tk / account_tk,不传则取任意未提取的
|
||||
// - id/start_id/current_id (可选) 起始 ID:从该 ID 开始向后提取,避免传 896 却取到 892
|
||||
func (c *ApiGetCardController) GetCard() {
|
||||
@@ -79,7 +80,7 @@ func (c *ApiGetCardController) GetCard() {
|
||||
return
|
||||
}
|
||||
if !validModules[module] {
|
||||
c.cardErr(400, 400, fmt.Sprintf("不支持的模块: %s,支持: cursor/windsurf/krio", module))
|
||||
c.cardErr(400, 400, fmt.Sprintf("不支持的模块: %s,支持: cursor/windsurf/krio/codex", module))
|
||||
return
|
||||
}
|
||||
if dataType != "" && !isValidPoolType(dataType) {
|
||||
@@ -96,6 +97,8 @@ func (c *ApiGetCardController) GetCard() {
|
||||
c.extractWindsurf(platform, dataType, startID, now)
|
||||
case "krio":
|
||||
c.extractKrio(platform, dataType, startID, now)
|
||||
case "codex":
|
||||
c.extractCodex(platform, dataType, startID, now)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +178,25 @@ func (c *ApiGetCardController) extractKrio(platform, dataType string, startID ui
|
||||
})
|
||||
}
|
||||
|
||||
func (c *ApiGetCardController) extractCodex(platform, dataType string, startID uint64, now time.Time) {
|
||||
c.extractWithProbe("codex", platform, dataType, now, func() (uint64, *string, *string, string, string, *int8, error) {
|
||||
var row models.PlatformAccountPoolCodex
|
||||
qs := models.Orm.QueryTable(new(models.PlatformAccountPoolCodex)).
|
||||
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)
|
||||
}
|
||||
if err := qs.OrderBy("id").One(&row); err != nil {
|
||||
return 0, nil, nil, "", "", nil, err
|
||||
}
|
||||
return row.ID, &row.Account, &row.Password, row.Token, row.DataType, nil, nil
|
||||
})
|
||||
}
|
||||
|
||||
type poolRowFetcher func() (id uint64, account, password *string, token, rowDataType string, isUsed *int8, err error)
|
||||
|
||||
// extractWithProbe 按 id 顺序提取并探测 Token 可用性;不可用则标记已提取并继续下一条。
|
||||
|
||||
Reference in New Issue
Block a user