59 lines
1.3 KiB
Java
59 lines
1.3 KiB
Java
package com.ruoyi.media.service.convert;
|
|
|
|
import com.ruoyi.media.domain.model.MediaTemp;
|
|
import com.ruoyi.media.service.dto.MediaTempDTO;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* 媒体临时表Service层转换器
|
|
* Service DTO ↔ Domain Model
|
|
*
|
|
* @author ruoyi
|
|
* @date 2026-01-17
|
|
*/
|
|
public class MediaTempServiceConvert
|
|
{
|
|
/**
|
|
* Model 转 DTO
|
|
*/
|
|
public static MediaTempDTO toDTO(MediaTemp model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
MediaTempDTO dto = new MediaTempDTO();
|
|
BeanUtils.copyProperties(model, dto);
|
|
return dto;
|
|
}
|
|
|
|
/**
|
|
* DTO 转 Model
|
|
*/
|
|
public static MediaTemp toModel(MediaTempDTO dto)
|
|
{
|
|
if (dto == null)
|
|
{
|
|
return null;
|
|
}
|
|
MediaTemp model = new MediaTemp();
|
|
BeanUtils.copyProperties(dto, model);
|
|
return model;
|
|
}
|
|
|
|
/**
|
|
* Model List 转 DTO List
|
|
*/
|
|
public static List<MediaTempDTO> toDTOList(List<MediaTemp> modelList)
|
|
{
|
|
if (modelList == null)
|
|
{
|
|
return null;
|
|
}
|
|
return modelList.stream().map(MediaTempServiceConvert::toDTO).collect(Collectors.toList());
|
|
}
|
|
}
|