From ceeefec4706e961438da3a6b0e6653b41d17df35 Mon Sep 17 00:00:00 2001 From: ShenQiLun <97694732@qq.com> Date: Tue, 30 Jun 2026 15:30:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20token/add=E6=8E=A5=E5=8F=A3=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0password=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/handler/token_handler.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/handler/token_handler.go b/internal/handler/token_handler.go index 5663cdf..704aa8b 100644 --- a/internal/handler/token_handler.go +++ b/internal/handler/token_handler.go @@ -32,6 +32,7 @@ type TokenResponse struct { type TokenInput struct { LoginName string `json:"login_name"` Username string `json:"username"` + Password string `json:"password"` Token string `json:"token"` } @@ -72,7 +73,7 @@ func (h *TokenHandler) BatchAddTokens(w http.ResponseWriter, r *http.Request) { continue } - id, err := h.tokenRepo.Insert(input.LoginName, input.Username, "", input.Token, true) + id, err := h.tokenRepo.Insert(input.LoginName, input.Username, input.Password, input.Token, true) if err != nil { log.Printf("[Token/BatchAdd] 第%d条插入失败: username=%s, 错误=%v", i+1, input.Username, err) failed = append(failed, input) @@ -182,6 +183,7 @@ func (h *TokenHandler) UpdateToken(w http.ResponseWriter, r *http.Request) { idStr := r.PostForm.Get("id") loginName := r.PostForm.Get("login_name") username := r.PostForm.Get("username") + password := r.PostForm.Get("password") token := r.PostForm.Get("token") isEnableStr := r.PostForm.Get("is_enable") @@ -198,7 +200,7 @@ func (h *TokenHandler) UpdateToken(w http.ResponseWriter, r *http.Request) { } log.Printf("[Token/Update] 更新: id=%d, login_name=%s, username=%s, is_enable=%v, 来源IP: %s", id, loginName, username, isEnable, clientIP) - err = h.tokenRepo.Update(id, loginName, username, "", token, isEnable) + err = h.tokenRepo.Update(id, loginName, username, password, token, isEnable) if err != nil { log.Printf("[Token/Update] 更新失败: id=%d, 错误=%v, 来源IP: %s", id, err, clientIP) w.Header().Set("Content-Type", "application/json")