diff --git a/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/base_device.cs b/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/base_device.cs index bf10cfc..02be855 100644 --- a/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/base_device.cs +++ b/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/base_device.cs @@ -4,19 +4,39 @@ */ using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using SqlSugar; using VolPro.Entity.SystemModels; namespace VolPro.Entity.DomainModels { - public partial class base_device { - //此处配置字段(字段配置见此model的另一个partial),如果表中没有此字段请加上[SugarColumn(IsIgnore = true)]属性,否则会异常 + /// 导航属性:关联视频通道扩展记录(一对一) + [Navigate(NavigateType.OneToOne, nameof(DeviceId), nameof(video_channel.DeviceId))] + public video_channel? VideoChannel { get; set; } + + /// 导航属性:关联告警记录(一对多) + [Navigate(NavigateType.OneToMany, nameof(DeviceId), nameof(iot_alarm.DeviceId))] + public List? Alarms { get; set; } + + /// 导航属性:关联数据归档(一对多) + [Navigate(NavigateType.OneToMany, nameof(DeviceId), nameof(iot_devicedata.DeviceId))] + public List? DeviceData { get; set; } + + /// + /// 网关字段白名单。网关同步时,只有此集合中的字段会被覆盖, + /// 其他字段(DeviceName/DeviceCategory/DeviceGroup/Location/MapModelId等) + /// 由管理员在管理端维护,同步不覆盖。 + /// + public static readonly HashSet GatewayFields = new() + { + nameof(IsOnline), + nameof(IsParent), + nameof(ParentDeviceId), + nameof(ExtraData), + nameof(IpAddress), + nameof(Port), + nameof(LastSyncTime) + }; } -} \ No newline at end of file +} diff --git a/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/gateway_nodes.cs b/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/gateway_nodes.cs index 32e8d35..24c71fc 100644 --- a/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/gateway_nodes.cs +++ b/api_sqlsugar/VolPro.Entity/DomainModels/device_manager/partial/gateway_nodes.cs @@ -4,19 +4,25 @@ */ using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; using System.Linq; -using System.Text; -using System.Threading.Tasks; using SqlSugar; using VolPro.Entity.SystemModels; namespace VolPro.Entity.DomainModels { - public partial class gateway_nodes { - //此处配置字段(字段配置见此model的另一个partial),如果表中没有此字段请加上[SugarColumn(IsIgnore = true)]属性,否则会异常 + /// + /// 适配器类型列表。从 AdapterTypes(逗号分隔字符串)解析。 + /// 示例:"Owl:main,MC4:31ku" → ["Owl:main","MC4:31ku"] + /// + [SugarColumn(IsIgnore = true)] + public List AdapterList + { + get => string.IsNullOrEmpty(AdapterTypes) + ? new List() + : AdapterTypes.Split(',').Select(x => x.Trim()).Where(x => !string.IsNullOrEmpty(x)).ToList(); + set => AdapterTypes = value != null ? string.Join(",", value) : ""; + } } -} \ No newline at end of file +}