2026-01-16 19:13:33 +08:00
|
|
|
package com.ruoyi.device.domain.convert;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.device.domain.model.Device;
|
|
|
|
|
import com.ruoyi.device.mapper.entity.DeviceEntity;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设备Domain层转换器
|
|
|
|
|
* Domain Model ↔ Mapper Entity
|
|
|
|
|
*
|
|
|
|
|
* @author ruoyi
|
|
|
|
|
* @date 2026-01-16
|
|
|
|
|
*/
|
2026-01-20 17:05:25 +08:00
|
|
|
public class DeviceDomainEntityConvert
|
2026-01-16 19:13:33 +08:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Entity 转 Model
|
|
|
|
|
*/
|
|
|
|
|
public static Device toModel(DeviceEntity entity)
|
|
|
|
|
{
|
|
|
|
|
if (entity == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
Device model = new Device();
|
|
|
|
|
BeanUtils.copyProperties(entity, model);
|
|
|
|
|
return model;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Model 转 Entity
|
|
|
|
|
*/
|
|
|
|
|
public static DeviceEntity toEntity(Device model)
|
|
|
|
|
{
|
|
|
|
|
if (model == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
DeviceEntity entity = new DeviceEntity();
|
|
|
|
|
BeanUtils.copyProperties(model, entity);
|
|
|
|
|
return entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Entity List 转 Model List
|
|
|
|
|
*/
|
|
|
|
|
public static List<Device> toModelList(List<DeviceEntity> entityList)
|
|
|
|
|
{
|
|
|
|
|
if (entityList == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2026-01-20 17:05:25 +08:00
|
|
|
return entityList.stream().map(DeviceDomainEntityConvert::toModel).collect(Collectors.toList());
|
2026-01-16 19:13:33 +08:00
|
|
|
}
|
|
|
|
|
}
|