cursor从大到小获取

This commit is contained in:
2026-07-08 09:56:50 +08:00
parent 0f961789dc
commit 3da6718729
8 changed files with 141 additions and 24 deletions
+6 -6
View File
@@ -55,7 +55,7 @@ func (c *ApiGetCardController) cardOK(text string) {
// - type (必填) 来源平台:xianyu / taobao / pinduoduo / jingdong / local / xubei
// - module (必填) 号池模块:cursor / windsurf / krio / codex
// - data_type (可选) 账号类型:account / tk / account_tk,不传则取任意未提取的
// - id/start_id/current_id (可选) 起始 ID从该 ID 开始向后提取,避免传 896 却取到 892
// - id/start_id/current_id (可选) 起始 ID仅取 id >= 起始值 的记录,按 id 从大到小提取
func (c *ApiGetCardController) GetCard() {
platform := c.GetString("type")
module := c.GetString("module")
@@ -159,7 +159,7 @@ func (c *ApiGetCardController) extractCursor(platform, dataType string, startID
if dataType != "" {
qs = qs.Filter("data_type", dataType)
}
if err := qs.OrderBy("id").One(&row); err != nil {
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, row.IsUsed, nil
@@ -178,7 +178,7 @@ func (c *ApiGetCardController) extractWindsurf(platform, dataType string, startI
if dataType != "" {
qs = qs.Filter("data_type", dataType)
}
if err := qs.OrderBy("id").One(&row); err != nil {
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
@@ -197,7 +197,7 @@ func (c *ApiGetCardController) extractKrio(platform, dataType string, startID ui
if dataType != "" {
qs = qs.Filter("data_type", dataType)
}
if err := qs.OrderBy("id").One(&row); err != nil {
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
@@ -216,7 +216,7 @@ func (c *ApiGetCardController) extractCodex(platform, dataType string, startID u
if dataType != "" {
qs = qs.Filter("data_type", dataType)
}
if err := qs.OrderBy("id").One(&row); err != nil {
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
@@ -225,7 +225,7 @@ func (c *ApiGetCardController) extractCodex(platform, dataType string, startID u
type poolRowFetcher func() (id uint64, account, password *string, token, rowDataType string, isUsed *int8, err error)
// extractWithProbe 按 id 顺序提取并探测 Token 可用性;不可用则标记已提取并继续下一条。
// extractWithProbe 按 id 从大到小提取并探测 Token 可用性;不可用则标记已提取并继续下一条。
func (c *ApiGetCardController) extractWithProbe(
module, platform, dataType string,
now time.Time,