add ip字段返回

This commit is contained in:
2025-05-08 14:15:55 +08:00
parent 2ba0776345
commit 9f953767a3
2 changed files with 27 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ public class DevicesController : ControllerBase
HeartbeatInterval = x.HeartbeatInterval,
DirectionType = x.DeployDirection,
LastHeartbeatTime = xr.LastHeartbeatTime,
ConnectionInfo = x.ConnectionInfo
})
.ToListAsync();
}

View File

@@ -1,4 +1,7 @@
using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Dlhis.External.OpenApi.Response;
@@ -49,4 +52,27 @@ public class DeviceResponse
return LastHeartbeatTime.Value.AddSeconds(HeartbeatInterval) >= DateTime.Now;
}
}
[JsonIgnore]
public string ConnectionInfo { get; set; }
/// <summary>
/// 设备列表
/// </summary>
public string Ip
{
get
{
if (!ConnectionInfo.IsPresent())
{
return string.Empty;
}
var jObj = JObject.Parse(ConnectionInfo);
return jObj.TryGetValue("ip", out var ip)
? ip.Value<string>()
: string.Empty;
}
}
}