From fb7db0081704008da2c7b5349723d07ebb1eefa2 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Sun, 16 Aug 2026 09:04:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=86=E9=92=A5:=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E7=A1=AC=E5=88=A0(=E7=AB=8B=E5=8D=B3?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E4=B8=8D=E5=8F=AF=E6=81=A2=E5=A4=8D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - DELETE /api/v1/keys/:id 由软吊销(置 revoked)改为物理删除 Co-Authored-By: Claude --- server/internal/api/keys.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 {