添加设备类、设备日志类、设备服务类、设备控制器
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
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
|
||||
@@ -387,5 +389,92 @@ namespace Model.Mapper
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IOT设备
|
||||
/// <summary>
|
||||
/// IotDeviceEntity → IotDeviceDto
|
||||
/// </summary>
|
||||
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,
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List<IotDeviceEntity> → List<IotDeviceDto>
|
||||
/// </summary>
|
||||
public static List<IotDeviceDto> ToDtoList(this List<IotDeviceEntity> entities)
|
||||
{
|
||||
return entities?.Select(e => e.ToDto()).ToList() ?? new List<IotDeviceDto>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IotDeviceDto → IotDeviceEntity(入参映射,IsDel/CreateTime/OnlineStatus 等服务端管控字段不映射)
|
||||
/// </summary>
|
||||
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,
|
||||
GatewayCode = dto.GatewayCode,
|
||||
SlaveId = dto.SlaveId,
|
||||
Manufacturer = dto.Manufacturer,
|
||||
Description = dto.Description,
|
||||
ProtocolType = dto.ProtocolType,
|
||||
IsEnabled = dto.IsEnabled,
|
||||
Remark = dto.Remark
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 设备日志
|
||||
/// <summary>
|
||||
/// DeviceLogEntity → DeviceLogDto
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// List<DeviceLogEntity> → List<DeviceLogDto>
|
||||
/// </summary>
|
||||
public static List<DeviceLogDto> ToDtoList(this List<DeviceLogEntity> entities)
|
||||
{
|
||||
return entities?.Select(e => e.ToDto()).ToList() ?? new List<DeviceLogDto>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user