更新号池功能

This commit is contained in:
扫地僧 2026-04-15 23:20:40 +08:00
parent 53decd0084
commit d9df691298
2 changed files with 67 additions and 0 deletions

View File

@ -366,6 +366,7 @@ func extractPoolRow(c *beego.Controller, module string) {
ID uint64 `json:"id"`
Type string `json:"type"`
Platform string `json:"platform"` // local | xianyu
Remark string `json:"remark"`
}
if err := json.Unmarshal(raw, &payload); err != nil {
poolJSONErr(c, 400, 400, "参数错误")
@ -382,6 +383,7 @@ func extractPoolRow(c *beego.Controller, module string) {
now := time.Now()
platform := payload.Platform
remark := strings.TrimSpace(payload.Remark)
switch module {
case "cursor":
@ -400,6 +402,7 @@ func extractPoolRow(c *beego.Controller, module string) {
"is_extracted": 1,
"extracted_time": now,
"extracted_platform": platform,
"remark": remark,
})
if err != nil {
poolJSONErr(c, 500, 500, "提取失败: "+err.Error())
@ -422,6 +425,7 @@ func extractPoolRow(c *beego.Controller, module string) {
"is_extracted": 1,
"extracted_time": now,
"extracted_platform": platform,
"remark": remark,
})
if err != nil {
poolJSONErr(c, 500, 500, "提取失败: "+err.Error())
@ -444,6 +448,7 @@ func extractPoolRow(c *beego.Controller, module string) {
"is_extracted": 1,
"extracted_time": now,
"extracted_platform": platform,
"remark": remark,
})
if err != nil {
poolJSONErr(c, 500, 500, "提取失败: "+err.Error())
@ -457,20 +462,79 @@ func extractPoolRow(c *beego.Controller, module string) {
_ = c.ServeJSON()
}
func updatePoolRemark(c *beego.Controller, module string) {
if _, err := requirePlatformAuth(c); err != nil {
poolJSONErr(c, 401, 401, err.Error())
return
}
raw, err := io.ReadAll(c.Ctx.Request.Body)
if err != nil {
poolJSONErr(c, 400, 400, "参数错误")
return
}
var payload struct {
ID uint64 `json:"id"`
Remark string `json:"remark"`
}
if err := json.Unmarshal(raw, &payload); err != nil || payload.ID == 0 {
poolJSONErr(c, 400, 400, "参数错误")
return
}
remark := strings.TrimSpace(payload.Remark)
var updated int64
switch module {
case "cursor":
updated, err = models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)).Filter("id", payload.ID).Update(map[string]interface{}{
"remark": remark,
})
case "windsurf":
updated, err = models.Orm.QueryTable(new(models.PlatformAccountPoolWindsurf)).Filter("id", payload.ID).Update(map[string]interface{}{
"remark": remark,
})
case "krio":
updated, err = models.Orm.QueryTable(new(models.PlatformAccountPoolKiro)).Filter("id", payload.ID).Update(map[string]interface{}{
"remark": remark,
})
default:
poolJSONErr(c, 400, 400, "无效模块")
return
}
if err != nil {
poolJSONErr(c, 500, 500, "备注更新失败: "+err.Error())
return
}
if updated == 0 {
poolJSONErr(c, 404, 404, "记录不存在")
return
}
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "备注更新成功"}
_ = c.ServeJSON()
}
func (c *PlatformAccountPoolCursorController) List() { listPoolRows(&c.Controller, "cursor") }
func (c *PlatformAccountPoolCursorController) Add() { addPoolRow(&c.Controller, "cursor") }
func (c *PlatformAccountPoolCursorController) BatchAdd() { batchAddPoolRows(&c.Controller, "cursor") }
func (c *PlatformAccountPoolCursorController) Detail() { getPoolDetail(&c.Controller, "cursor") }
func (c *PlatformAccountPoolCursorController) Extract() { extractPoolRow(&c.Controller, "cursor") }
func (c *PlatformAccountPoolCursorController) UpdateRemark() {
updatePoolRemark(&c.Controller, "cursor")
}
func (c *PlatformAccountPoolWindsurfController) List() { listPoolRows(&c.Controller, "windsurf") }
func (c *PlatformAccountPoolWindsurfController) Add() { addPoolRow(&c.Controller, "windsurf") }
func (c *PlatformAccountPoolWindsurfController) BatchAdd() { batchAddPoolRows(&c.Controller, "windsurf") }
func (c *PlatformAccountPoolWindsurfController) Detail() { getPoolDetail(&c.Controller, "windsurf") }
func (c *PlatformAccountPoolWindsurfController) Extract() { extractPoolRow(&c.Controller, "windsurf") }
func (c *PlatformAccountPoolWindsurfController) UpdateRemark() {
updatePoolRemark(&c.Controller, "windsurf")
}
func (c *PlatformAccountPoolKrioController) List() { listPoolRows(&c.Controller, "krio") }
func (c *PlatformAccountPoolKrioController) Add() { addPoolRow(&c.Controller, "krio") }
func (c *PlatformAccountPoolKrioController) BatchAdd() { batchAddPoolRows(&c.Controller, "krio") }
func (c *PlatformAccountPoolKrioController) Detail() { getPoolDetail(&c.Controller, "krio") }
func (c *PlatformAccountPoolKrioController) Extract() { extractPoolRow(&c.Controller, "krio") }
func (c *PlatformAccountPoolKrioController) UpdateRemark() {
updatePoolRemark(&c.Controller, "krio")
}

View File

@ -164,16 +164,19 @@ func Register() {
beego.Router("/platform/accountPool/cursor/batchAdd", &controllers.PlatformAccountPoolCursorController{}, "post:BatchAdd")
beego.Router("/platform/accountPool/cursor/detail/:id", &controllers.PlatformAccountPoolCursorController{}, "get:Detail")
beego.Router("/platform/accountPool/cursor/extract", &controllers.PlatformAccountPoolCursorController{}, "post:Extract")
beego.Router("/platform/accountPool/cursor/updateRemark", &controllers.PlatformAccountPoolCursorController{}, "post:UpdateRemark")
beego.Router("/platform/accountPool/windsurf/list", &controllers.PlatformAccountPoolWindsurfController{}, "get:List")
beego.Router("/platform/accountPool/windsurf/add", &controllers.PlatformAccountPoolWindsurfController{}, "post:Add")
beego.Router("/platform/accountPool/windsurf/batchAdd", &controllers.PlatformAccountPoolWindsurfController{}, "post:BatchAdd")
beego.Router("/platform/accountPool/windsurf/detail/:id", &controllers.PlatformAccountPoolWindsurfController{}, "get:Detail")
beego.Router("/platform/accountPool/windsurf/extract", &controllers.PlatformAccountPoolWindsurfController{}, "post:Extract")
beego.Router("/platform/accountPool/windsurf/updateRemark", &controllers.PlatformAccountPoolWindsurfController{}, "post:UpdateRemark")
beego.Router("/platform/accountPool/krio/list", &controllers.PlatformAccountPoolKrioController{}, "get:List")
beego.Router("/platform/accountPool/krio/add", &controllers.PlatformAccountPoolKrioController{}, "post:Add")
beego.Router("/platform/accountPool/krio/batchAdd", &controllers.PlatformAccountPoolKrioController{}, "post:BatchAdd")
beego.Router("/platform/accountPool/krio/detail/:id", &controllers.PlatformAccountPoolKrioController{}, "get:Detail")
beego.Router("/platform/accountPool/krio/extract", &controllers.PlatformAccountPoolKrioController{}, "post:Extract")
beego.Router("/platform/accountPool/krio/updateRemark", &controllers.PlatformAccountPoolKrioController{}, "post:UpdateRemark")
}