58 lines
1.2 KiB
Java
58 lines
1.2 KiB
Java
package com.ruoyi.device.domain.convert;
|
|
|
|
import com.ruoyi.device.domain.model.Group;
|
|
import com.ruoyi.device.mapper.entity.GroupEntity;
|
|
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 GroupDomainConvert
|
|
{
|
|
/**
|
|
* Entity 转 Model
|
|
*/
|
|
public static Group toModel(GroupEntity entity)
|
|
{
|
|
if (entity == null)
|
|
{
|
|
return null;
|
|
}
|
|
Group model = new Group();
|
|
BeanUtils.copyProperties(entity, model);
|
|
return model;
|
|
}
|
|
|
|
/**
|
|
* Model 转 Entity
|
|
*/
|
|
public static GroupEntity toEntity(Group model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return null;
|
|
}
|
|
GroupEntity entity = new GroupEntity();
|
|
BeanUtils.copyProperties(model, entity);
|
|
return entity;
|
|
}
|
|
|
|
/**
|
|
* Entity List 转 Model List
|
|
*/
|
|
public static List<Group> toModelList(List<GroupEntity> entityList)
|
|
{
|
|
if (entityList == null)
|
|
{
|
|
return null;
|
|
}
|
|
return entityList.stream().map(GroupDomainConvert::toModel).collect(Collectors.toList());
|
|
}
|
|
} |