package com.base.orbit.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

@Slf4j
public class BizUtils {

    public static <T, E> List<T> copyEntityToDto(Class<T> tClass, List<E> list) {
        List<T> res = null;
        try {
            res = new ArrayList<>();
            for (E e : list) {
                T t = tClass.newInstance();
                BeanUtils.copyProperties(e, t);
                res.add(t);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        return res;
    }
}