修复检测
This commit is contained in:
@@ -878,6 +878,54 @@ func setPoolUnavailable(c *beego.Controller, module string) {
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func updatePoolUsable(c *beego.Controller, module string) {
|
||||
if _, err := requirePlatformAuth(c); err != nil {
|
||||
poolJSONErr(c, 401, 401, err.Error())
|
||||
return
|
||||
}
|
||||
if module != "cursor" {
|
||||
poolJSONErr(c, 400, 400, "该模块不支持可用状态修改")
|
||||
return
|
||||
}
|
||||
raw, err := io.ReadAll(c.Ctx.Request.Body)
|
||||
if err != nil {
|
||||
poolJSONErr(c, 400, 400, "参数错误")
|
||||
return
|
||||
}
|
||||
var payload struct {
|
||||
ID uint64 `json:"id"`
|
||||
Usable int `json:"usable"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &payload); err != nil || payload.ID == 0 {
|
||||
poolJSONErr(c, 400, 400, "参数错误")
|
||||
return
|
||||
}
|
||||
if payload.Usable != 0 && payload.Usable != 1 {
|
||||
poolJSONErr(c, 400, 400, "可用状态参数错误")
|
||||
return
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
updated, err := models.Orm.QueryTable(new(models.PlatformAccountPoolCursor)).Filter("id", payload.ID).Update(orm.Params{
|
||||
"is_used": int8(payload.Usable),
|
||||
"update_time": now,
|
||||
})
|
||||
if err != nil {
|
||||
poolJSONErr(c, 500, 500, "可用状态更新失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
if updated == 0 {
|
||||
poolJSONErr(c, 404, 404, "记录不存在")
|
||||
return
|
||||
}
|
||||
msg := "已标记不可用"
|
||||
if payload.Usable == 1 {
|
||||
msg = "已标记可用"
|
||||
}
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": msg}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func updatePoolPlatform(c *beego.Controller, module string) {
|
||||
if _, err := requirePlatformAuth(c); err != nil {
|
||||
poolJSONErr(c, 401, 401, err.Error())
|
||||
@@ -1088,6 +1136,9 @@ func (c *PlatformAccountPoolCursorController) UpdateRemark() {
|
||||
func (c *PlatformAccountPoolCursorController) SetUnavailable() {
|
||||
setPoolUnavailable(&c.Controller, "cursor")
|
||||
}
|
||||
func (c *PlatformAccountPoolCursorController) UpdateUsable() {
|
||||
updatePoolUsable(&c.Controller, "cursor")
|
||||
}
|
||||
func (c *PlatformAccountPoolCursorController) UpdatePlatform() {
|
||||
updatePoolPlatform(&c.Controller, "cursor")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user