using Model.Dto.Asset; using Model.Dto.Config; using Model.Dto.Inspection; using Model.Entity.Asset; using Model.Entity.Config; using Model.Entity.Inspection; namespace Model.Mapper { /// /// Entity → DTO 映射器(统一在此处做实体到传输对象的转换) /// 核心转换:雪花 Id 由 long 转 string,避免前端 JavaScript 大数精度丢失 /// 使用方法 给查询的数据后面加上.ToDtoList()或者.ToDto() /// public static class EntityMapper { #region 设备台账 /// /// EquipmentEntity → EquipmentDto /// public static EquipmentDto ToDto(this EquipmentEntity entity) { if (entity == null) return null; return new EquipmentDto { Id = entity.Id.ToString(), IsDel = entity.IsDel, CreateTime = entity.CreateTime, Code = entity.Code, Name = entity.Name, CategoryId = entity.CategoryId.ToString(), Type = entity.Type, Brand = entity.Brand, Model = entity.Model, Specifications = entity.Specifications, Manufacturer = entity.Manufacturer, Supplier = entity.Supplier, ImageUrl = entity.ImageUrl, QrCode = entity.QrCode, Description = entity.Description, Department = entity.Department, Location = entity.Location, ResponsiblePerson = entity.ResponsiblePerson, ContactPhone = entity.ContactPhone, Custodian = entity.Custodian, PurchaseDate = entity.PurchaseDate, PurchasePrice = entity.PurchasePrice, WarrantyExpireDate = entity.WarrantyExpireDate, AcceptanceDate = entity.AcceptanceDate, EnableDate = entity.EnableDate, ServiceLifeYears = entity.ServiceLifeYears, ScrapDate = entity.ScrapDate, Status = entity.Status, CalibrationStatus = entity.CalibrationStatus, LastCalibrationDate = entity.LastCalibrationDate, NextCalibrationDate = entity.NextCalibrationDate, InspectionDate = entity.InspectionDate, NextInspectionDate = entity.NextInspectionDate, MaintenanceStatus = entity.MaintenanceStatus, LastMaintenanceDate = entity.LastMaintenanceDate, NextMaintenanceDate = entity.NextMaintenanceDate, Remark = entity.Remark, CreateBy = entity.CreateBy, UpdateBy = entity.UpdateBy, UpdateTime = entity.UpdateTime }; } /// /// List<EquipmentEntity> → List<EquipmentDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// EquipmentDto → EquipmentEntity(入参映射,用于新增/修改) /// 安全约定:IsDel/CreateTime/UpdateTime 等服务端管控字段刻意不映射,防止过度绑定(over-binding); /// Id 解析失败时为 0(新增时由雪花算法自动生成) /// public static EquipmentEntity ToEntity(this EquipmentDto dto) { if (dto == null) return null; return new EquipmentEntity { Id = long.TryParse(dto.Id, out var id) ? id : 0, Code = dto.Code, Name = dto.Name, CategoryId = long.TryParse(dto.CategoryId, out var categoryId) ? categoryId : 0, Type = dto.Type, Brand = dto.Brand, Model = dto.Model, Specifications = dto.Specifications, Manufacturer = dto.Manufacturer, Supplier = dto.Supplier, ImageUrl = dto.ImageUrl, QrCode = dto.QrCode, Description = dto.Description, Department = dto.Department, Location = dto.Location, ResponsiblePerson = dto.ResponsiblePerson, ContactPhone = dto.ContactPhone, Custodian = dto.Custodian, PurchaseDate = dto.PurchaseDate, PurchasePrice = dto.PurchasePrice, WarrantyExpireDate = dto.WarrantyExpireDate, AcceptanceDate = dto.AcceptanceDate, EnableDate = dto.EnableDate, ServiceLifeYears = dto.ServiceLifeYears, ScrapDate = dto.ScrapDate, Status = dto.Status, CalibrationStatus = dto.CalibrationStatus, LastCalibrationDate = dto.LastCalibrationDate, NextCalibrationDate = dto.NextCalibrationDate, InspectionDate = dto.InspectionDate, NextInspectionDate = dto.NextInspectionDate, MaintenanceStatus = dto.MaintenanceStatus, LastMaintenanceDate = dto.LastMaintenanceDate, NextMaintenanceDate = dto.NextMaintenanceDate, Remark = dto.Remark }; } #endregion #region 设备附件 /// /// EquipmentAttachmentEntity → EquipmentAttachmentDto /// public static EquipmentAttachmentDto ToDto(this EquipmentAttachmentEntity entity) { if (entity == null) return null; return new EquipmentAttachmentDto { Id = entity.Id.ToString(), IsDel = entity.IsDel, CreateTime = entity.CreateTime, EquipmentId = entity.EquipmentId.ToString(), FileName = entity.FileName, FileType = entity.FileType, FileExt = entity.FileExt, FileUrl = entity.FileUrl, FileSize = entity.FileSize, Uploader = entity.Uploader, Remark = entity.Remark }; } /// /// List<EquipmentAttachmentEntity> → List<EquipmentAttachmentDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 设备分类 /// /// EquipmentCategoryEntity → EquipmentCategoryDto /// public static EquipmentCategoryDto ToDto(this EquipmentCategoryEntity entity) { if (entity == null) return null; return new EquipmentCategoryDto { Id = entity.Id.ToString(), IsDel = entity.IsDel, CreateTime = entity.CreateTime, ParentId = entity.ParentId.ToString(), Name = entity.Name, Code = entity.Code, Level = entity.Level, Sort = entity.Sort, Remark = entity.Remark }; } /// /// List<EquipmentCategoryEntity> → List<EquipmentCategoryDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 设备状态记录 /// /// EquipmentStatusRecordEntity → EquipmentStatusRecordDto /// public static EquipmentStatusRecordDto ToDto(this EquipmentStatusRecordEntity entity) { if (entity == null) return null; return new EquipmentStatusRecordDto { Id = entity.Id.ToString(), IsDel = entity.IsDel, CreateTime = entity.CreateTime, EquipmentId = entity.EquipmentId.ToString(), FromStatus = entity.FromStatus, ToStatus = entity.ToStatus, ChangeTime = entity.ChangeTime, Operator = entity.Operator, Remark = entity.Remark }; } /// /// List<EquipmentStatusRecordEntity> → List<EquipmentStatusRecordDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 温度箱看板数据 /// /// TemperatureBoxDataEntity → TemperatureBoxDataDto /// public static TemperatureBoxDataDto ToDto(this TemperatureBoxDataEntity entity) { if (entity == null) return null; return new TemperatureBoxDataDto { Id = entity.Id.ToString(), IsDel = entity.IsDel, CreateTime = entity.CreateTime, DeviceCode = entity.DeviceCode, DeviceType = entity.DeviceType, DeviceTemperature = entity.DeviceTemperature, DeviceHumidity = entity.DeviceHumidity, Status = entity.Status, AlarmInfo = entity.AlarmInfo }; } /// /// List<TemperatureBoxDataEntity> → List<TemperatureBoxDataDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 告警规则 /// /// AlertRuleEntity → AlertRuleDto /// public static AlertRuleDto ToDto(this AlertRuleEntity entity) { if (entity == null) return null; return new AlertRuleDto { Id = entity.Id.ToString(), OwnerType = entity.OwnerType, OwnerId = entity.OwnerId, PointCode = entity.PointCode, IsDel = entity.IsDel, CreateTime = entity.CreateTime, RuleName = entity.RuleName, DeviceType = entity.DeviceType, Metric = entity.Metric, Operator = entity.Operator, Threshold = entity.Threshold, AlarmLevel = entity.AlarmLevel, Enabled = entity.Enabled, TriggerCount = entity.TriggerCount, LastAlarmTime = entity.LastAlarmTime, Remark = entity.Remark }; } /// /// List<AlertRuleEntity> → List<AlertRuleDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 数据转发规则 /// /// DataForwardRuleEntity → DataForwardRuleDto /// public static DataForwardRuleDto ToDto(this DataForwardRuleEntity entity) { if (entity == null) return null; return new DataForwardRuleDto { Id = entity.Id.ToString(), IsDel = entity.IsDel, CreateTime = entity.CreateTime, ForwardName = entity.ForwardName, SourceDeviceType = entity.SourceDeviceType, ForwardInterval = entity.ForwardInterval, NotifyType = entity.NotifyType, TargetAddress = entity.TargetAddress, Enabled = entity.Enabled, LastForwardTime = entity.LastForwardTime, Remark = entity.Remark }; } /// /// List<DataForwardRuleEntity> → List<DataForwardRuleDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 反向转换 DTO → Entity(前端入参转实体入库用,Id 由 string 转回 long) /// /// string Id 安全转 long(空/非法返回 0,新增时由雪花算法自动赋值) /// private static long ParseId(string id) { return long.TryParse(id, out var value) ? value : 0; } /// /// EquipmentDto → EquipmentEntity /// /// /// TemperatureBoxDataDto → TemperatureBoxDataEntity /// public static TemperatureBoxDataEntity ToEntity(this TemperatureBoxDataDto dto) { if (dto == null) return null; return new TemperatureBoxDataEntity { Id = ParseId(dto.Id), IsDel = dto.IsDel, CreateTime = dto.CreateTime, DeviceCode = dto.DeviceCode, DeviceType = dto.DeviceType, DeviceTemperature = dto.DeviceTemperature, DeviceHumidity = dto.DeviceHumidity, Status = dto.Status, AlarmInfo = dto.AlarmInfo }; } /// /// AlertRuleDto → AlertRuleEntity /// public static AlertRuleEntity ToEntity(this AlertRuleDto dto) { if (dto == null) return null; return new AlertRuleEntity { Id = ParseId(dto.Id), OwnerType = dto.OwnerType, OwnerId = dto.OwnerId, PointCode = dto.PointCode, IsDel = dto.IsDel, CreateTime = dto.CreateTime, RuleName = dto.RuleName, DeviceType = dto.DeviceType, Metric = dto.Metric, Operator = dto.Operator, Threshold = dto.Threshold, AlarmLevel = dto.AlarmLevel, Enabled = dto.Enabled, TriggerCount = dto.TriggerCount, LastAlarmTime = dto.LastAlarmTime, Remark = dto.Remark }; } /// /// DataForwardRuleDto → DataForwardRuleEntity /// public static DataForwardRuleEntity ToEntity(this DataForwardRuleDto dto) { if (dto == null) return null; return new DataForwardRuleEntity { Id = ParseId(dto.Id), IsDel = dto.IsDel, CreateTime = dto.CreateTime, ForwardName = dto.ForwardName, SourceDeviceType = dto.SourceDeviceType, ForwardInterval = dto.ForwardInterval, NotifyType = dto.NotifyType, TargetAddress = dto.TargetAddress, Enabled = dto.Enabled, LastForwardTime = dto.LastForwardTime, Remark = dto.Remark }; } #endregion #region IOT设备 /// /// IotDeviceEntity → IotDeviceDto /// public static IotDeviceDto ToDto(this IotDeviceEntity entity) { if (entity == null) return null; return new IotDeviceDto { Id = entity.Id.ToString(), Code = entity.Code, Name = entity.Name, DeviceType = entity.DeviceType, ProductId = entity.ProductId.ToString(), GatewayCode = entity.GatewayCode, SlaveId = entity.SlaveId, Manufacturer = entity.Manufacturer, Description = entity.Description, ProtocolType = entity.ProtocolType, IsEnabled = entity.IsEnabled, OnlineStatus = entity.OnlineStatus, LastCollectTime = entity.LastCollectTime, LastError = entity.LastError, Remark = entity.Remark, CreateTime = entity.CreateTime }; } /// /// List<IotDeviceEntity> → List<IotDeviceDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// IotDeviceDto → IotDeviceEntity(入参映射,IsDel/CreateTime/OnlineStatus 等服务端管控字段不映射) /// public static IotDeviceEntity ToEntity(this IotDeviceDto dto) { if (dto == null) return null; return new IotDeviceEntity { Id = ParseId(dto.Id), Code = dto.Code, Name = dto.Name, DeviceType = dto.DeviceType, ProductId = ParseId(dto.ProductId), GatewayCode = dto.GatewayCode, SlaveId = dto.SlaveId, Manufacturer = dto.Manufacturer, Description = dto.Description, ProtocolType = dto.ProtocolType, IsEnabled = dto.IsEnabled, Remark = dto.Remark }; } #endregion #region 设备日志 /// /// DeviceLogEntity → DeviceLogDto /// public static DeviceLogDto ToDto(this DeviceLogEntity entity) { if (entity == null) return null; return new DeviceLogDto { Id = entity.Id.ToString(), DeviceId = entity.DeviceId.ToString(), DeviceCode = entity.DeviceCode, Level = entity.Level, LogType = entity.LogType, Message = entity.Message, LogTime = entity.LogTime, CreateTime = entity.CreateTime }; } /// /// List<DeviceLogEntity> → List<DeviceLogDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 产品分类 /// /// ProductCategoryEntity → ProductCategoryDto /// public static ProductCategoryDto ToDto(this ProductCategoryEntity entity) { if (entity == null) return null; return new ProductCategoryDto { Id = entity.Id.ToString(), Code = entity.Code, Name = entity.Name, Sort = entity.Sort, Remark = entity.Remark, CreateTime = entity.CreateTime }; } /// /// List<ProductCategoryEntity> → List<ProductCategoryDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// ProductCategoryDto → ProductCategoryEntity(入参映射) /// public static ProductCategoryEntity ToEntity(this ProductCategoryDto dto) { if (dto == null) return null; return new ProductCategoryEntity { Id = ParseId(dto.Id), Code = dto.Code, Name = dto.Name, Sort = dto.Sort, Remark = dto.Remark }; } #endregion #region 产品 /// /// ProductEntity → ProductDto /// public static ProductDto ToDto(this ProductEntity entity) { if (entity == null) return null; return new ProductDto { Id = entity.Id.ToString(), Model = entity.Model, Name = entity.Name, CategoryId = entity.CategoryId.ToString(), Manufacturer = entity.Manufacturer, Description = entity.Description, ProtocolType = entity.ProtocolType, MessageModel = entity.MessageModel, IsEnabled = entity.IsEnabled, Remark = entity.Remark, CreateTime = entity.CreateTime }; } /// /// List<ProductEntity> → List<ProductDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// ProductDto → ProductEntity(入参映射,IsDel/CreateTime 等服务端管控字段不映射) /// public static ProductEntity ToEntity(this ProductDto dto) { if (dto == null) return null; return new ProductEntity { Id = ParseId(dto.Id), Model = dto.Model, Name = dto.Name, CategoryId = ParseId(dto.CategoryId), Manufacturer = dto.Manufacturer, Description = dto.Description, ProtocolType = dto.ProtocolType, MessageModel = dto.MessageModel, IsEnabled = dto.IsEnabled, Remark = dto.Remark }; } /// /// ProductEntity → ProductOptionDto(下拉选项) /// public static ProductOptionDto ToOptionDto(this ProductEntity entity) { if (entity == null) return null; return new ProductOptionDto { Id = entity.Id.ToString(), Model = entity.Model, Name = entity.Name }; } /// /// List<ProductEntity> → List<ProductOptionDto> /// public static List ToOptionDtoList(this List entities) { return entities?.Select(e => e.ToOptionDto()).ToList() ?? new List(); } #endregion #region 物模型点 /// /// ThingModelPointEntity → ThingModelPointDto /// public static ThingModelPointDto ToDto(this ThingModelPointEntity entity) { if (entity == null) return null; return new ThingModelPointDto { Id = entity.Id.ToString(), OwnerType = entity.OwnerType, OwnerId = entity.OwnerId.ToString(), Code = entity.Code, Name = entity.Name, RegisterType = entity.RegisterType, Rw = entity.Rw, DataType = entity.DataType, Address = entity.Address, Scale = entity.Scale, Offset = entity.Offset, Unit = entity.Unit, Enabled = entity.Enabled, Sort = entity.Sort, Remark = entity.Remark, CreateTime = entity.CreateTime }; } /// /// List<ThingModelPointEntity> → List<ThingModelPointDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// ThingModelPointDto → ThingModelPointEntity(入参映射) /// public static ThingModelPointEntity ToEntity(this ThingModelPointDto dto) { if (dto == null) return null; return new ThingModelPointEntity { Id = ParseId(dto.Id), OwnerType = dto.OwnerType, OwnerId = ParseId(dto.OwnerId), Code = dto.Code, Name = dto.Name, RegisterType = dto.RegisterType, Rw = dto.Rw, DataType = dto.DataType, Address = dto.Address, Scale = dto.Scale, Offset = dto.Offset, Unit = dto.Unit, Enabled = dto.Enabled, Sort = dto.Sort, Remark = dto.Remark }; } #endregion #region 告警消息 /// /// AlertMessageEntity → AlertMessageDto /// public static AlertMessageDto ToDto(this AlertMessageEntity entity) { if (entity == null) return null; return new AlertMessageDto { Id = entity.Id.ToString(), CreateTime = entity.CreateTime, Source = entity.Source, RuleId = entity.RuleId.ToString(), DeviceCode = entity.DeviceCode, DeviceName = entity.DeviceName, DeviceType = entity.DeviceType, Metric = entity.Metric, AlertType = entity.AlertType, AlertLevel = entity.AlertLevel, CurrentValue = entity.CurrentValue, ThresholdValue = entity.ThresholdValue, Content = entity.Content, TemplateCode = entity.TemplateCode, TriggerCount = entity.TriggerCount, FirstAlertTime = entity.FirstAlertTime, LastAlertTime = entity.LastAlertTime, AlertStatus = entity.AlertStatus, AckBy = entity.AckBy, AckTime = entity.AckTime, HandleBy = entity.HandleBy, HandleTime = entity.HandleTime, HandleRemark = entity.HandleRemark, WorkOrderId = entity.WorkOrderId.ToString() }; } /// /// List<AlertMessageEntity> → List<AlertMessageDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// AlertRaiseDto → AlertMessageEntity(告警中心上报入参映射; /// 状态/闭环/聚合字段由服务端初始化,不接受调用方指定) /// public static AlertMessageEntity ToEntity(this AlertRaiseDto dto) { if (dto == null) return null; return new AlertMessageEntity { Source = dto.Source, RuleId = dto.RuleId, DeviceCode = dto.DeviceCode, DeviceName = dto.DeviceName, DeviceType = dto.DeviceType, Metric = dto.Metric, AlertType = dto.AlertType, AlertLevel = dto.AlertLevel, CurrentValue = dto.CurrentValue, ThresholdValue = dto.ThresholdValue, Content = dto.Content, TemplateCode = dto.TemplateCode }; } #endregion #region 告警通知渠道 /// /// AlertNotifyChannelEntity → AlertNotifyChannelDto(Secret 脱敏:不回传明文,仅标记 HasSecret) /// public static AlertNotifyChannelDto ToDto(this AlertNotifyChannelEntity entity) { if (entity == null) return null; return new AlertNotifyChannelDto { Id = entity.Id.ToString(), CreateTime = entity.CreateTime, ChannelType = entity.ChannelType, Name = entity.Name, WebhookUrl = entity.WebhookUrl, Secret = null, HasSecret = !string.IsNullOrWhiteSpace(entity.Secret), PushMode = entity.PushMode, IsEnabled = entity.IsEnabled, Remark = entity.Remark }; } /// /// List<AlertNotifyChannelEntity> → List<AlertNotifyChannelDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// AlertNotifyChannelDto → AlertNotifyChannelEntity(IsDel/CreateTime 不映射) /// public static AlertNotifyChannelEntity ToEntity(this AlertNotifyChannelDto dto) { if (dto == null) return null; return new AlertNotifyChannelEntity { Id = ParseId(dto.Id), ChannelType = dto.ChannelType, Name = dto.Name, WebhookUrl = dto.WebhookUrl, Secret = dto.Secret, PushMode = dto.PushMode, IsEnabled = dto.IsEnabled, Remark = dto.Remark }; } #endregion #region 告警通知规则 /// /// AlertNotifyRuleEntity → AlertNotifyRuleDto /// public static AlertNotifyRuleDto ToDto(this AlertNotifyRuleEntity entity) { if (entity == null) return null; return new AlertNotifyRuleDto { Id = entity.Id.ToString(), CreateTime = entity.CreateTime, RuleName = entity.RuleName, AlertLevel = entity.AlertLevel, ChannelId = entity.ChannelId.ToString(), Receivers = entity.Receivers, NotifyDutyPerson = entity.NotifyDutyPerson, SilenceMinutes = entity.SilenceMinutes, IsEnabled = entity.IsEnabled, Remark = entity.Remark }; } /// /// List<AlertNotifyRuleEntity> → List<AlertNotifyRuleDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// AlertNotifyRuleDto → AlertNotifyRuleEntity(IsDel/CreateTime 不映射) /// public static AlertNotifyRuleEntity ToEntity(this AlertNotifyRuleDto dto) { if (dto == null) return null; return new AlertNotifyRuleEntity { Id = ParseId(dto.Id), RuleName = dto.RuleName, AlertLevel = dto.AlertLevel, ChannelId = ParseId(dto.ChannelId), Receivers = dto.Receivers, NotifyDutyPerson = dto.NotifyDutyPerson, SilenceMinutes = dto.SilenceMinutes, IsEnabled = dto.IsEnabled, Remark = dto.Remark }; } #endregion #region 告警通知日志 /// /// AlertNotifyLogEntity → AlertNotifyLogDto /// public static AlertNotifyLogDto ToDto(this AlertNotifyLogEntity entity) { if (entity == null) return null; return new AlertNotifyLogDto { Id = entity.Id.ToString(), AlertId = entity.AlertId.ToString(), ChannelType = entity.ChannelType, ChannelId = entity.ChannelId.ToString(), Target = entity.Target, Content = entity.Content, Success = entity.Success, ErrorMsg = entity.ErrorMsg, RetryCount = entity.RetryCount, NotifyTime = entity.NotifyTime }; } /// /// List<AlertNotifyLogEntity> → List<AlertNotifyLogDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 跨网发件箱 /// /// AlertOutboxEntity → AlertOutboxItemDto /// public static AlertOutboxItemDto ToDto(this AlertOutboxEntity entity) { if (entity == null) return null; return new AlertOutboxItemDto { Id = entity.Id.ToString(), AlertId = entity.AlertId.ToString(), ChannelId = entity.ChannelId.ToString(), Payload = entity.Payload, RetryCount = entity.RetryCount }; } /// /// List<AlertOutboxEntity> → List<AlertOutboxItemDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } #endregion #region 值班排班 /// /// DutyRosterEntity → DutyRosterDto /// public static DutyRosterDto ToDto(this DutyRosterEntity entity) { if (entity == null) return null; return new DutyRosterDto { Id = entity.Id.ToString(), CreateTime = entity.CreateTime, DutyDate = entity.DutyDate, PersonName = entity.PersonName, Phone = entity.Phone, Remark = entity.Remark }; } /// /// List<DutyRosterEntity> → List<DutyRosterDto> /// public static List ToDtoList(this List entities) { return entities?.Select(e => e.ToDto()).ToList() ?? new List(); } /// /// DutyRosterDto → DutyRosterEntity(IsDel/CreateTime 不映射) /// public static DutyRosterEntity ToEntity(this DutyRosterDto dto) { if (dto == null) return null; return new DutyRosterEntity { Id = ParseId(dto.Id), DutyDate = dto.DutyDate.Date, PersonName = dto.PersonName, Phone = dto.Phone, Remark = dto.Remark }; } #endregion } }