Merge pull request 'v0.0.3' (#2) from dev into master

Reviewed-on: #2
This commit is contained in:
2026-02-10 10:56:12 +00:00
4 changed files with 22 additions and 1 deletions

View File

@ -13,10 +13,11 @@
<groupId>com.imyeyu.spring</groupId> <groupId>com.imyeyu.spring</groupId>
<artifactId>timi-spring</artifactId> <artifactId>timi-spring</artifactId>
<version>0.0.2</version> <version>0.0.3</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<java.version>21</java.version>
<springboot.version>3.4.0</springboot.version> <springboot.version>3.4.0</springboot.version>
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target> <maven.compiler.target>21</maven.compiler.target>

View File

@ -14,9 +14,12 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSession;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import java.beans.PropertyDescriptor;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -491,4 +494,17 @@ public class TimiSpring {
} }
return new RequestRange(start, end); 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);
}
}
}
} }

View File

@ -11,10 +11,12 @@ import java.lang.annotation.Target;
* *
* @author 夜雨 * @author 夜雨
* @version 2023-08-09 10:36 * @version 2023-08-09 10:36
* @deprecated 0.0.3 过时0.0.5 移除,单参数建议 url 传参
*/ */
@Target(ElementType.PARAMETER) @Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Documented @Documented
@Deprecated
public @interface RequestSingleParam { public @interface RequestSingleParam {
} }

View File

@ -20,8 +20,10 @@ import org.springframework.web.method.support.ModelAndViewContainer;
* *
* @author 夜雨 * @author 夜雨
* @since 2025-10-13 16:29 * @since 2025-10-13 16:29
* @deprecated 0.0.3 过时0.0.5 移除,单参数建议 url 传参
*/ */
@Component @Component
@Deprecated
public class RequestSingleParamResolver implements HandlerMethodArgumentResolver { public class RequestSingleParamResolver implements HandlerMethodArgumentResolver {
/** /**