v0.0.3
All checks were successful
CI/CD / build-deploy (pull_request) Successful in 13s

This commit is contained in:
Timi
2026-02-10 18:55:53 +08:00
parent d2d904fe53
commit 13ae5016e8
4 changed files with 22 additions and 1 deletions

View File

@@ -14,9 +14,12 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
@@ -491,4 +494,17 @@ public class TimiSpring {
}
return new RequestRange(start, end);
}
public static void copyPropertiesNotNull(Object source, Object target) {
BeanWrapper srcBean = new BeanWrapperImpl(source);
BeanWrapper targetBean = new BeanWrapperImpl(target);
for (PropertyDescriptor pd : srcBean.getPropertyDescriptors()) {
String propertyName = pd.getName();
Object srcValue = srcBean.getPropertyValue(propertyName);
if (srcValue != null && targetBean.isWritableProperty(propertyName)) {
targetBean.setPropertyValue(propertyName, srcValue);
}
}
}
}