feat(设备管理): 添加设备在线记录查询功能并优化设备列表排序
Build docker and publish / build (20.15.1) (push) Successful in 7m28s
Build docker and publish / build (20.15.1) (push) Successful in 7m28s
添加FindLatestDeviceOnlineRecord接口用于查询设备最新在线记录 实现GetOnlineDeviceLoginTime方法获取设备登录时间 优化设备列表查询按最后活动时间排序 移除未使用的依赖项
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user