From 3351dcadf876a2b91d5c1245569c2c5514f046ff Mon Sep 17 00:00:00 2001 From: g82tt Date: Sun, 17 May 2026 05:27:38 +0800 Subject: [PATCH] =?UTF-8?q?V1.1=20Entity=20Partial:=20=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E5=B1=9E=E6=80=A7+=E7=BD=91=E5=85=B3=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95+AdapterList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device_manager/partial/base_device.cs | 36 ++++++++++++++----- .../device_manager/partial/gateway_nodes.cs | 20 +++++++---- 2 files changed, 41 insertions(+), 15 deletions(-) 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 +}