Procházet zdrojové kódy

集成组件beanutils

RuoYi před 6 roky
rodič
revize
0cec24d90b

+ 8 - 0
pom.xml

@@ -28,6 +28,7 @@
 		<oshi.version>3.9.1</oshi.version>
 		<commons.io.version>2.5</commons.io.version>
 		<commons.fileupload.version>1.3.3</commons.fileupload.version>
+		<commons.beanutils.version>1.9.3</commons.beanutils.version>
 		<jsoup.version>1.11.3</jsoup.version>
 		<poi.version>3.17</poi.version>
 		<velocity.version>1.7</velocity.version>
@@ -137,6 +138,13 @@
 				<version>${commons.fileupload.version}</version>
 			</dependency>
 			
+			<!-- 简化反射封工具类 -->
+			<dependency>
+				<groupId>commons-beanutils</groupId>
+				<artifactId>commons-beanutils</artifactId>
+				<version>${commons.beanutils.version}</version>
+			</dependency>
+			
 			<!-- HTML解析器 -->
 			<dependency>
 				<groupId>org.jsoup</groupId>

+ 8 - 2
ruoyi-common/pom.xml

@@ -47,18 +47,24 @@
 		    <artifactId>jackson-databind</artifactId>
 		</dependency>
 
-		<!--io常用工具类 -->
+		<!-- io常用工具类 -->
 		<dependency>
 			<groupId>commons-io</groupId>
 			<artifactId>commons-io</artifactId>
 		</dependency>
 
-		<!--文件上传工具类 -->
+		<!-- 文件上传工具类 -->
 		<dependency>
 			<groupId>commons-fileupload</groupId>
 			<artifactId>commons-fileupload</artifactId>
 		</dependency>
 		
+		<!-- 简化反射封工具类 -->
+		<dependency>
+			<groupId>commons-beanutils</groupId>
+			<artifactId>commons-beanutils</artifactId>
+		</dependency>
+		
 		<!-- HTML解析器 -->
 		<dependency>
 			<groupId>org.jsoup</groupId>

+ 2 - 14
ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java

@@ -11,7 +11,7 @@ import java.util.regex.Pattern;
  * 
  * @author ruoyi
  */
-public class BeanUtils
+public class BeanUtils extends org.apache.commons.beanutils.BeanUtils
 {
     /** Bean方法名中属性名开始的下标 */
     private static final int BEAN_METHOD_PROP_INDEX = 3;
@@ -30,21 +30,9 @@ public class BeanUtils
      */
     public static void copyBeanProp(Object dest, Object src)
     {
-        List<Method> destSetters = getSetterMethods(dest);
-        List<Method> srcGetters = getGetterMethods(src);
         try
         {
-            for (Method setter : destSetters)
-            {
-                for (Method getter : srcGetters)
-                {
-                    if (isMethodPropEquals(setter.getName(), getter.getName())
-                            && setter.getParameterTypes()[0].equals(getter.getReturnType()))
-                    {
-                        setter.invoke(dest, getter.invoke(src));
-                    }
-                }
-            }
+            copyProperties(dest, src);
         }
         catch (Exception e)
         {