feat: Implement the ChatGPT Owner Demotion Console with new frontend and backend components.
This commit is contained in:
36
backend/internal/api/demote.go
Normal file
36
backend/internal/api/demote.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user