feat(自定义对比): 功能开发

This commit is contained in:
yjz
2023-10-26 16:12:58 +08:00
parent 21a25ae474
commit b346065657
33 changed files with 1569 additions and 8 deletions
@@ -0,0 +1,33 @@
package com.jero.common.util;
import org.springframework.beans.BeanUtils;
import java.util.List;
import java.util.stream.Collectors;
public class BeanCopyUtils {
private BeanCopyUtils() {
}
/** 1、单个对象*/
public static <V> V copyBean(Object source, Class<V> clazz) {
/** 创建目标对象 实现属性拷贝*/
V result = null;
try {
result = clazz.newInstance();
/** 拷贝*/
BeanUtils.copyProperties(source, result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
/** 2、集合*/
public static <O, V> List<V> copyBeanList(List<O> list, Class<V> clazz) {
/** 创建目标对象 实现属性拷贝*/
return list.stream()
.map(o -> copyBean(o, clazz))
.collect(Collectors.toList());
}
}
@@ -0,0 +1,16 @@
package com.jero.common.util;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
public class SnowflakeUtils {
private SnowflakeUtils(){
}
public static long snowflake(){
Snowflake snowflake = IdUtil.getSnowflake(1, 1);
return snowflake.nextId();
}
}