Skip to content

Commit 5b2a013

Browse files
committed
add BeanConvertor
1 parent 3980d45 commit 5b2a013

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<groupId>com.codingapi.springboot</groupId>
1313
<artifactId>springboot-parent</artifactId>
14-
<version>1.1.0</version>
14+
<version>1.1.1</version>
1515

1616
<url>https://github.com/codingapi/springboot-framewrok</url>
1717
<name>springboot-parent</name>

springboot-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.codingapi.springboot</groupId>
66
<artifactId>springboot-parent</artifactId>
7-
<version>1.1.0</version>
7+
<version>1.1.1</version>
88
</parent>
99
<artifactId>springboot-example</artifactId>
1010

springboot-starter-data-permission/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>1.1.0</version>
9+
<version>1.1.1</version>
1010
</parent>
1111

1212

springboot-starter-security-jwt/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>1.1.0</version>
9+
<version>1.1.1</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security-jwt</artifactId>

springboot-starter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.codingapi.springboot</groupId>
66
<artifactId>springboot-parent</artifactId>
7-
<version>1.1.0</version>
7+
<version>1.1.1</version>
88
</parent>
99
<artifactId>springboot-starter</artifactId>
1010

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.codingapi.springboot.framework.convert;
2+
3+
import org.springframework.beans.BeanUtils;
4+
5+
import java.lang.reflect.InvocationTargetException;
6+
7+
public class BeanConvertor {
8+
9+
public static <T,S> T convert(S source, Class<T> clazz){
10+
if(source==null){
11+
return null;
12+
}
13+
T target = null;
14+
try {
15+
target = clazz.getDeclaredConstructor().newInstance();
16+
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
17+
return null;
18+
}
19+
BeanUtils.copyProperties(source,target);
20+
return target;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)