Compare commits

...

9 Commits

Author SHA1 Message Date
孙小云 d9786fc6c8 修改convert 2026-01-21 13:51:04 +08:00
孙小云 f866ca9170 修改convert 2026-01-21 13:43:27 +08:00
孙小云 03cc474428 修改convert 2026-01-21 13:18:33 +08:00
孙小云 af4501cda2 修改convert 2026-01-21 11:14:31 +08:00
孙小云 234a8d41cd 修改convert 2026-01-21 10:21:20 +08:00
孙小云 14f4975ebf 添加接口 2026-01-20 17:05:25 +08:00
孙小云 14a2ff5006 添加接口 2026-01-20 15:48:34 +08:00
孙小云 61f3932313 添加接口 2026-01-20 14:54:53 +08:00
孙小云 4963fbdbab 完成 getAllGroupIds 逻辑 2026-01-20 14:44:54 +08:00
3 changed files with 58 additions and 2 deletions

View File

@ -0,0 +1,56 @@
package com.ruoyi.common.core.utils;
import org.springframework.beans.BeanUtils;
import java.util.List;
import java.util.stream.Collectors;
/**
* 通用转换器基类
*
* @param <F> Source类型
* @param <T> Target类型
* @author ruoyi
*/
public abstract class BaseConvert<F, T> {
private final Class<F> sourceClass;
private final Class<T> targetClass;
protected BaseConvert(Class<F> sourceClass, Class<T> targetClass) {
this.sourceClass = sourceClass;
this.targetClass = targetClass;
}
protected T innerFrom(F source) {
if (source == null) return null;
try {
T target = targetClass.getDeclaredConstructor().newInstance();
BeanUtils.copyProperties(source, target);
return target;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
protected F innerTo(T target) {
if (target == null) return null;
try {
F source = sourceClass.getDeclaredConstructor().newInstance();
BeanUtils.copyProperties(target, source);
return source;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
protected List<T> innerFromList(List<F> sourceList) {
if (sourceList == null) return null;
return sourceList.stream().map(this::innerFrom).collect(Collectors.toList());
}
protected List<F> innerToList(List<T> targetList) {
if (targetList == null) return null;
return targetList.stream().map(this::innerTo).collect(Collectors.toList());
}
}

@ -1 +1 @@
Subproject commit 12c7674d534677d43edc097ca08bcb792fe4ed6e Subproject commit e7a33e89a63a89b6ee4b661bd3a8d9bb893ee4d1

@ -1 +1 @@
Subproject commit 69af79b84290b26ce491dc8d9b658cb46b781060 Subproject commit f42a12af0451cabd3e386f6491c3331eb1f29c96