feat: Implement the ChatGPT Owner Demotion Console with new frontend and backend components.

This commit is contained in:
2026-02-05 03:13:30 +08:00
parent 61712cf4fb
commit 2bccb06359
6 changed files with 454 additions and 13 deletions

View File

@@ -0,0 +1,36 @@
package api
import (
"encoding/json"
"net/http"
"codex-pool/internal/demote"
)
// HandleDemoteOwner POST /api/demote/owner - Owner 降级
func HandleDemoteOwner(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
Error(w, http.StatusMethodNotAllowed, "仅支持 POST")
return
}
var req demote.DemoteRequest
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
Error(w, http.StatusBadRequest, "无效的请求: "+err.Error())
return
}
if req.AccessToken == "" {
Error(w, http.StatusBadRequest, "access_token 不能为空")
return
}
// 默认角色
if req.Role == "" {
req.Role = "standard-user"
}
result := demote.DemoteOwner(req)
Success(w, result)
}