diff --git a/Model/DeviceEntity.cs b/Model/DeviceEntity.cs index 7e8f76b..76de119 100644 --- a/Model/DeviceEntity.cs +++ b/Model/DeviceEntity.cs @@ -1,4 +1,5 @@ -using LY.App.Device; +using GraphQL; +using LY.App.Device; using Newtonsoft.Json; using SqlSugar; @@ -75,6 +76,8 @@ namespace LY.App.Model [SugarColumn(ColumnName = "is_move", ColumnDescription = "是否移动设备", IsNullable = true)] public bool isMove { get; set; } + [SugarColumn(IsIgnore = true)] + public bool online { get; set; } } diff --git a/Service/DeviceService.cs b/Service/DeviceService.cs index 01b9879..6f074de 100644 --- a/Service/DeviceService.cs +++ b/Service/DeviceService.cs @@ -47,6 +47,10 @@ namespace LY.App.Service .WhereIF(!string.IsNullOrEmpty(key), s => s.Name.Contains(key) || s.DeviceSN.Contains(key)) .OrderByDescending(s => s.Id) .ToPageListAsync(pageNum, pageSize, total); + items.ForEach(async s => + { + s.online = await _redisService.ExistsAsync(RedisKeyList.DeviceStatus(s.DeviceSN)); + }); return new ApiResult() { data = new