feat: token/add接口增加password参数

This commit is contained in:
ShenQiLun 2026-06-30 15:30:11 +08:00
parent 0f029b9ba6
commit ceeefec470

View File

@ -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")