feat(设备管理): 添加设备在线记录查询功能并优化设备列表排序
Build docker and publish / build (20.15.1) (push) Successful in 7m28s

添加FindLatestDeviceOnlineRecord接口用于查询设备最新在线记录
实现GetOnlineDeviceLoginTime方法获取设备登录时间
优化设备列表查询按最后活动时间排序
移除未使用的依赖项
This commit is contained in:
2025-11-27 23:24:48 -08:00
parent 236fa6c4e6
commit 2442831cd7
12 changed files with 210 additions and 130 deletions
+15
View File
@@ -357,3 +357,18 @@ func (dm *DeviceManager) Shutdown(ctx context.Context) {
return true
})
}
func (dm *DeviceManager) GetOnlineDeviceLoginTime(userID int64, deviceID string) (time.Time, bool) {
mu := dm.getUserMutex(userID)
mu.Lock()
defer mu.Unlock()
if val, ok := dm.userDevices.Load(userID); ok {
devices := val.([]*Device)
for _, d := range devices {
if d.DeviceID == deviceID {
return d.CreatedAt, true
}
}
}
return time.Time{}, false
}