58 lines
1.2 KiB
Java
58 lines
1.2 KiB
Java
|
|
package com.ruoyi.device.service.convert;
|
||
|
|
|
||
|
|
import com.ruoyi.device.domain.model.Dock;
|
||
|
|
import com.ruoyi.device.service.dto.DockDTO;
|
||
|
|
import org.springframework.beans.BeanUtils;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.stream.Collectors;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 机场Service层转换器
|
||
|
|
* Service DTO ↔ Domain Model
|
||
|
|
*
|
||
|
|
* @author ruoyi
|
||
|
|
* @date 2026-01-16
|
||
|
|
*/
|
||
|
|
public class DockServiceConvert
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Model 转 DTO
|
||
|
|
*/
|
||
|
|
public static DockDTO toDTO(Dock model)
|
||
|
|
{
|
||
|
|
if (model == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
DockDTO dto = new DockDTO();
|
||
|
|
BeanUtils.copyProperties(model, dto);
|
||
|
|
return dto;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* DTO 转 Model
|
||
|
|
*/
|
||
|
|
public static Dock toModel(DockDTO dto)
|
||
|
|
{
|
||
|
|
if (dto == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
Dock model = new Dock();
|
||
|
|
BeanUtils.copyProperties(dto, model);
|
||
|
|
return model;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Model List 转 DTO List
|
||
|
|
*/
|
||
|
|
public static List<DockDTO> toDTOList(List<Dock> modelList)
|
||
|
|
{
|
||
|
|
if (modelList == null)
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
return modelList.stream().map(DockServiceConvert::toDTO).collect(Collectors.toList());
|
||
|
|
}
|
||
|
|
}
|