58 lines
1.3 KiB
Java
58 lines
1.3 KiB
Java
|
|
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
|
||
|
|
*/
|
||
|
|
public class DeviceDomainConvert
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 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;
|
||
|
|
}
|
||
|
|
return entityList.stream().map(DeviceDomainConvert::toModel).collect(Collectors.toList());
|
||
|
|
}
|
||
|
|
}
|