更新获取接口
This commit is contained in:
parent
ccad4c05f7
commit
53decd0084
@ -34,13 +34,14 @@ var validModules = map[string]bool{
|
|||||||
|
|
||||||
func (c *ApiGetCardController) cardErr(httpStatus, code int, msg string) {
|
func (c *ApiGetCardController) cardErr(httpStatus, code int, msg string) {
|
||||||
c.Ctx.Output.SetStatus(httpStatus)
|
c.Ctx.Output.SetStatus(httpStatus)
|
||||||
c.Data["json"] = map[string]interface{}{"code": code, "msg": msg}
|
c.Ctx.Output.Header("Content-Type", "text/plain; charset=utf-8")
|
||||||
_ = c.ServeJSON()
|
_ = c.Ctx.Output.Body([]byte(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApiGetCardController) cardOK(data interface{}) {
|
func (c *ApiGetCardController) cardOK(text string) {
|
||||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "success", "data": data}
|
c.Ctx.Output.SetStatus(200)
|
||||||
_ = c.ServeJSON()
|
c.Ctx.Output.Header("Content-Type", "text/plain; charset=utf-8")
|
||||||
|
_ = c.Ctx.Output.Body([]byte(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCard 提取一张卡(不可重复提取)
|
// GetCard 提取一张卡(不可重复提取)
|
||||||
@ -179,11 +180,8 @@ func (c *ApiGetCardController) extractKrio(platform, dataType string, now time.T
|
|||||||
c.cardOK(buildCardResult(&row.Account, &row.Password, row.Token, row.DataType))
|
c.cardOK(buildCardResult(&row.Account, &row.Password, row.Token, row.DataType))
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildCardResult 根据账号类型组装返回数据
|
// buildCardResult 根据账号类型返回格式化字符串
|
||||||
func buildCardResult(account, password *string, token string, dataType string) map[string]interface{} {
|
func buildCardResult(account, password *string, token string, dataType string) string {
|
||||||
result := map[string]interface{}{
|
|
||||||
"type": dataType,
|
|
||||||
}
|
|
||||||
acc := ""
|
acc := ""
|
||||||
pwd := ""
|
pwd := ""
|
||||||
if account != nil {
|
if account != nil {
|
||||||
@ -194,14 +192,10 @@ func buildCardResult(account, password *string, token string, dataType string) m
|
|||||||
}
|
}
|
||||||
switch dataType {
|
switch dataType {
|
||||||
case "account":
|
case "account":
|
||||||
result["account"] = acc
|
return fmt.Sprintf("账号:%s / 密码:%s", acc, pwd)
|
||||||
result["password"] = pwd
|
|
||||||
case "tk":
|
|
||||||
result["token"] = token
|
|
||||||
case "account_tk":
|
case "account_tk":
|
||||||
result["account"] = acc
|
return fmt.Sprintf("账号:%s / 密码:%s / Token:%s", acc, pwd, token)
|
||||||
result["password"] = pwd
|
default: // tk
|
||||||
result["token"] = token
|
return token
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,50 +95,88 @@ func listPoolRows(c *beego.Controller, module string) {
|
|||||||
dataType := strings.TrimSpace(c.GetString("type"))
|
dataType := strings.TrimSpace(c.GetString("type"))
|
||||||
status := strings.TrimSpace(c.GetString("status"))
|
status := strings.TrimSpace(c.GetString("status"))
|
||||||
|
|
||||||
var table string
|
applyFilters := func(qs orm.QuerySeter) orm.QuerySeter {
|
||||||
|
if dataType != "" && isValidPoolType(dataType) {
|
||||||
|
qs = qs.Filter("data_type", dataType)
|
||||||
|
}
|
||||||
|
if status == "unused" {
|
||||||
|
qs = qs.Filter("is_extracted", 0)
|
||||||
|
}
|
||||||
|
if status == "extracted" {
|
||||||
|
qs = qs.Filter("is_extracted", 1)
|
||||||
|
}
|
||||||
|
if keyword != "" {
|
||||||
|
qs = qs.Filter("account__icontains", keyword)
|
||||||
|
}
|
||||||
|
return qs
|
||||||
|
}
|
||||||
|
|
||||||
|
var list interface{}
|
||||||
|
var total int64
|
||||||
|
var err error
|
||||||
|
|
||||||
switch module {
|
switch module {
|
||||||
case "cursor":
|
case "cursor":
|
||||||
table = new(models.PlatformAccountPoolCursor).TableName()
|
qs := applyFilters(models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)))
|
||||||
|
total, err = qs.Count()
|
||||||
|
if err != nil {
|
||||||
|
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var rows []models.PlatformAccountPoolCursor
|
||||||
|
_, err = qs.OrderBy("-id").Limit(pageSize, (page-1)*pageSize).All(&rows)
|
||||||
|
if err != nil && err != orm.ErrNoRows {
|
||||||
|
poolJSONErr(c, 500, 500, "cursor查询失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if rows == nil {
|
||||||
|
rows = []models.PlatformAccountPoolCursor{}
|
||||||
|
}
|
||||||
|
list = rows
|
||||||
case "windsurf":
|
case "windsurf":
|
||||||
table = new(models.PlatformAccountPoolWindsurf).TableName()
|
qs := applyFilters(models.Orm.QueryTable(new(models.PlatformAccountPoolWindsurf)))
|
||||||
|
total, err = qs.Count()
|
||||||
|
if err != nil {
|
||||||
|
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var rows []models.PlatformAccountPoolWindsurf
|
||||||
|
_, err = qs.OrderBy("-id").Limit(pageSize, (page-1)*pageSize).All(&rows)
|
||||||
|
if err != nil && err != orm.ErrNoRows {
|
||||||
|
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if rows == nil {
|
||||||
|
rows = []models.PlatformAccountPoolWindsurf{}
|
||||||
|
}
|
||||||
|
list = rows
|
||||||
case "krio":
|
case "krio":
|
||||||
table = new(models.PlatformAccountPoolKiro).TableName()
|
qs := applyFilters(models.Orm.QueryTable(new(models.PlatformAccountPoolKiro)))
|
||||||
|
total, err = qs.Count()
|
||||||
|
if err != nil {
|
||||||
|
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var rows []models.PlatformAccountPoolKiro
|
||||||
|
_, err = qs.OrderBy("-id").Limit(pageSize, (page-1)*pageSize).All(&rows)
|
||||||
|
if err != nil && err != orm.ErrNoRows {
|
||||||
|
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if rows == nil {
|
||||||
|
rows = []models.PlatformAccountPoolKiro{}
|
||||||
|
}
|
||||||
|
list = rows
|
||||||
default:
|
default:
|
||||||
poolJSONErr(c, 400, 400, "无效模块")
|
poolJSONErr(c, 400, 400, "无效模块")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
qs := models.Orm.QueryTable(table)
|
|
||||||
if dataType != "" && isValidPoolType(dataType) {
|
|
||||||
qs = qs.Filter("data_type", dataType)
|
|
||||||
}
|
|
||||||
if status == "unused" {
|
|
||||||
qs = qs.Filter("is_extracted", 0)
|
|
||||||
}
|
|
||||||
if status == "extracted" {
|
|
||||||
qs = qs.Filter("is_extracted", 1)
|
|
||||||
}
|
|
||||||
if keyword != "" {
|
|
||||||
qs = qs.Filter("account__icontains", keyword).Filter("remark__icontains", keyword)
|
|
||||||
}
|
|
||||||
total, err := qs.Count()
|
|
||||||
if err != nil {
|
|
||||||
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var rows []orm.Params
|
|
||||||
_, err = qs.OrderBy("-id").Limit(pageSize, (page-1)*pageSize).Values(&rows)
|
|
||||||
if err != nil {
|
|
||||||
poolJSONErr(c, 500, 500, "获取列表失败: "+err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Data["json"] = map[string]interface{}{
|
c.Data["json"] = map[string]interface{}{
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"msg": "success",
|
"msg": "success",
|
||||||
"data": map[string]interface{}{
|
"data": map[string]interface{}{
|
||||||
"list": rows,
|
"list": list,
|
||||||
"total": total,
|
"total": total,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user