This commit is contained in:
3
pom.xml
3
pom.xml
@ -13,10 +13,11 @@
|
||||
|
||||
<groupId>com.imyeyu.spring</groupId>
|
||||
<artifactId>timi-spring</artifactId>
|
||||
<version>0.0.2</version>
|
||||
<version>0.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<springboot.version>3.4.0</springboot.version>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,10 +11,12 @@ import java.lang.annotation.Target;
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2023-08-09 10:36
|
||||
* @deprecated 0.0.3 过时,0.0.5 移除,单参数建议 url 传参
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Deprecated
|
||||
public @interface RequestSingleParam {
|
||||
|
||||
}
|
||||
|
||||
@ -20,8 +20,10 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-10-13 16:29
|
||||
* @deprecated 0.0.3 过时,0.0.5 移除,单参数建议 url 传参
|
||||
*/
|
||||
@Component
|
||||
@Deprecated
|
||||
public class RequestSingleParamResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user