diff --git a/server/internal/api/keys.go b/server/internal/api/keys.go index eb3b259..9a1703c 100644 --- a/server/internal/api/keys.go +++ b/server/internal/api/keys.go @@ -160,7 +160,7 @@ func (h *Handler) PatchKey(c *gin.Context) { resp.OK(c, gin.H{"ok": true}) } -// DeleteKey DELETE /api/v1/keys/:id — 吊销。 +// DeleteKey DELETE /api/v1/keys/:id — 删除(硬删,立即失效不可恢复)。 func (h *Handler) DeleteKey(c *gin.Context) { u, ok := userFromContext(c) if !ok { @@ -172,11 +172,9 @@ func (h *Handler) DeleteKey(c *gin.Context) { resp.Fail(c, http.StatusBadRequest, "invalid key id") return } - res := h.a.DB.Model(&store.APIKey{}). - Where("id = ? AND user_id = ?", id, u.ID). - Update("status", store.KeyStatusRevoked) + res := h.a.DB.Where("id = ? AND user_id = ?", id, u.ID).Delete(&store.APIKey{}) if res.Error != nil { - resp.Fail(c, http.StatusInternalServerError, "failed to revoke key") + resp.Fail(c, http.StatusInternalServerError, "failed to delete key") return } if res.RowsAffected == 0 {