package com.webchat.domain.convert;

import com.webchat.domain.vo.response.MomentResponseBaseVO;
import com.webchat.repository.entity.MomentEntity;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: 程序员王七七 https://www.coderutil.com 网站作者
 * @Date: 2021-7-11 0011 14:52
 * @Description: 无描述信息
 */

public class MomentEntityConvert {

    public static MomentResponseBaseVO convertVo(MomentEntity entity) {
        if (entity == null) {
            return null;
        }
        MomentResponseBaseVO vo = new MomentResponseBaseVO();
        BeanUtils.copyProperties(entity, vo);
        return vo;
    }

    public static List<MomentResponseBaseVO> convertVoList(List<MomentEntity> entityList) {
        if (CollectionUtils.isEmpty(entityList)) {
            return new ArrayList<>();
        }
        return entityList.stream().map(MomentEntityConvert::convertVo).collect(Collectors.toList());
    }
}
