package adminuser import ( "gitee.ltd/lxh/logger/log" "time" "wechat-robot/internal/database" "wechat-robot/model/entity" ) // UpdateLastLoginInfo // @description: 更新最后登录时间和IP // @param username string 登录账号 // @param ip string IP地址 func UpdateLastLoginInfo(username, ip string) { err := database.Client.Model(&entity.AdminUser{}). Where("username = ? OR email = ?", username, username). Updates(map[string]any{ "last_login_at": time.Now(), "last_login_ip": ip, }).Error if err != nil { log.Errorf("更新管理员用户最后登录时间和IP失败: %v", err) } }