go-wxhelper/service/adminuser/save.go

25 lines
617 B
Go
Raw Permalink Normal View History

2024-01-19 12:06:30 +08:00
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)
}
}