文件上传https
This commit is contained in:
parent
65208da054
commit
7d8dbac52e
|
@ -113,5 +113,16 @@ public interface CommonService {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* 复制属性并返回新的目标对象
|
||||
*
|
||||
* @param source 源对象
|
||||
* @param targetClass 目标对象的类型
|
||||
* @param <S> 源对象类型
|
||||
* @param <T> 目标对象类型
|
||||
* @return 目标对象
|
||||
*/
|
||||
<S, T> T copyProperties(S source, Class<T> targetClass);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -235,4 +235,33 @@ public class CommonServiceImpl implements CommonService {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 复制属性并返回新的目标对象
|
||||
*
|
||||
* @param source 源对象
|
||||
* @param targetClass 目标对象的类型
|
||||
* @param <S> 源对象类型
|
||||
* @param <T> 目标对象类型
|
||||
* @return 目标对象
|
||||
*/
|
||||
public <S, T> T copyProperties(S source, Class<T> targetClass) {
|
||||
try {
|
||||
if (source == null || targetClass == null) {
|
||||
return null;
|
||||
}
|
||||
// 创建目标对象
|
||||
T target = targetClass.getDeclaredConstructor().newInstance();
|
||||
// 复制属性
|
||||
BeanUtils.copyProperties(source, target);
|
||||
return target;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user