Skip to content

Commit e8dc76c

Browse files
authored
Merge pull request hs-web#101 from hs-web/3.0.x
3.0.x
2 parents 8a4cfab + fbd2a0d commit e8dc76c

File tree

144 files changed

+409
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+409
-225
lines changed

hsweb-authorization/hsweb-authorization-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-authorization</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-authorization/hsweb-authorization-basic/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-authorization</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-authorization/hsweb-authorization-jwt/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-authorization</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-auth-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-authorization-oauth2</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
</parent>
2828
<modelVersion>4.0.0</modelVersion>
2929

hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-authorization-oauth2</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
</parent>
2828
<modelVersion>4.0.0</modelVersion>
2929

hsweb-authorization/hsweb-authorization-oauth2/hsweb-authorization-oauth2-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-authorization-oauth2</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
<!--<relativePath>../../pom.xml</relativePath>-->
2828
</parent>
2929
<modelVersion>4.0.0</modelVersion>

hsweb-authorization/hsweb-authorization-oauth2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-authorization</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-authorization/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-framework</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-boost/hsweb-boost-aop/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-boost</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
</parent>
2828
<modelVersion>4.0.0</modelVersion>
2929

hsweb-boost/hsweb-boost-excel/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-boost</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-boost/hsweb-boost-ftp/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-boost</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

hsweb-boost/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-framework</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
</parent>
2828
<modelVersion>4.0.0</modelVersion>
2929

hsweb-commons/hsweb-commons-bean/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>hsweb-commons</artifactId>
77
<groupId>org.hswebframework.web</groupId>
8-
<version>3.0.2</version>
8+
<version>3.0.3</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

hsweb-commons/hsweb-commons-controller/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-commons</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
<relativePath>../pom.xml</relativePath>
2828
</parent>
2929
<modelVersion>4.0.0</modelVersion>

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-commons-dao</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
<relativePath>../pom.xml</relativePath>
2828
</parent>
2929
<modelVersion>4.0.0</modelVersion>

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-commons-dao</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
<relativePath>../pom.xml</relativePath>
2828
</parent>
2929
<modelVersion>4.0.0</modelVersion>

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/MyBatisAutoConfiguration.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
3232
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
3333
import org.springframework.beans.factory.annotation.Autowired;
34-
import org.springframework.beans.factory.annotation.Qualifier;
35-
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
36-
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3734
import org.springframework.boot.context.properties.ConfigurationProperties;
3835
import org.springframework.boot.context.properties.EnableConfigurationProperties;
3936
import org.springframework.context.annotation.Bean;
@@ -109,7 +106,7 @@ public Transaction newTransaction(DataSource dataSource, TransactionIsolationLev
109106
factory.setMapperLocations(mybatisProperties.resolveMapperLocations());
110107

111108
SqlSessionFactory sqlSessionFactory = factory.getObject();
112-
MybatisUtils.sqlSession=sqlSessionFactory;
109+
MybatisUtils.sqlSession = sqlSessionFactory;
113110

114111
EnumDictHandlerRegister.typeHandlerRegistry = sqlSessionFactory.getConfiguration().getTypeHandlerRegistry();
115112
EnumDictHandlerRegister.register("org.hswebframework.web;" + mybatisProperties.getTypeHandlersPackage());
@@ -121,8 +118,6 @@ public Transaction newTransaction(DataSource dataSource, TransactionIsolationLev
121118
}
122119
EasyOrmSqlBuilder.getInstance().entityFactory = entityFactory;
123120

124-
sqlSessionFactory.getConfiguration().getTypeAliasRegistry();
125-
126121
return sqlSessionFactory;
127122
}
128123

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/EasyOrmSqlBuilder.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,19 @@ protected RDBTableMetaData createMeta(String tableName, String resultMapId) {
175175
}
176176
column.setJavaType(resultMapping.getJavaType());
177177
column.setProperty("resultMapping", resultMapping);
178-
ValueConverter dateConvert = new DateTimeConverter("yyyy-MM-dd HH:mm:ss", column.getJavaType()) {
179-
@Override
180-
public Object getData(Object value) {
181-
if (value instanceof Number) {
182-
return new Date(((Number) value).longValue());
178+
//时间
179+
if (column.getJdbcType() == JDBCType.DATE || column.getJdbcType() == JDBCType.TIMESTAMP) {
180+
ValueConverter dateConvert = new DateTimeConverter("yyyy-MM-dd HH:mm:ss", column.getJavaType()) {
181+
@Override
182+
public Object getData(Object value) {
183+
if (value instanceof Number) {
184+
return new Date(((Number) value).longValue());
185+
}
186+
return super.getData(value);
183187
}
184-
return super.getData(value);
185-
}
186-
};
187-
if (column.getJdbcType() == JDBCType.DATE) {
188-
column.setValueConverter(dateConvert);
189-
} else if (column.getJdbcType() == JDBCType.TIMESTAMP) {
188+
};
190189
column.setValueConverter(dateConvert);
191-
} else if (column.getJdbcType() == JDBCType.NUMERIC) {
190+
} else if (TypeUtils.isNumberType(column)) { //数字
192191
column.setValueConverter(new NumberValueConverter(column.getJavaType()));
193192
}
194193
rdbTableMetaData.addColumn(column);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.hswebframework.web.dao.mybatis.builder;
2+
3+
import org.hswebframework.ezorm.rdb.meta.RDBColumnMetaData;
4+
5+
import java.math.BigDecimal;
6+
import java.math.BigInteger;
7+
import java.sql.JDBCType;
8+
import java.util.Arrays;
9+
import java.util.List;
10+
11+
/**
12+
* @author zhouhao
13+
* @since 3.0.3
14+
*/
15+
public class TypeUtils {
16+
private static final List<Class> numberType = Arrays.asList(
17+
byte.class, Byte.class
18+
, short.class, Short.class
19+
, int.class, Integer.class
20+
, float.class, Float.class
21+
, double.class, Double.class
22+
, long.class, Long.class
23+
, BigDecimal.class, BigInteger.class
24+
);
25+
26+
private static final List<JDBCType> numberJdbcType = Arrays.asList(
27+
JDBCType.TINYINT, JDBCType.DECIMAL, JDBCType.NUMERIC,
28+
JDBCType.BIGINT, JDBCType.SMALLINT, JDBCType.INTEGER,
29+
JDBCType.DECIMAL, JDBCType.BIT
30+
);
31+
32+
public static boolean isNumberType(RDBColumnMetaData columnMetaData) {
33+
return numberType.contains(columnMetaData.getJavaType())
34+
|| Number.class.isAssignableFrom(columnMetaData.getJavaType())
35+
|| numberJdbcType.contains(columnMetaData.getJdbcType());
36+
}
37+
38+
}

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/main/java/org/hswebframework/web/dao/mybatis/builder/jpa/JpaAnnotationParser.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.hswebframework.ezorm.rdb.meta.converter.DateTimeConverter;
99
import org.hswebframework.ezorm.rdb.meta.converter.NumberValueConverter;
1010
import org.hswebframework.utils.ClassUtils;
11+
import org.hswebframework.web.dao.mybatis.builder.TypeUtils;
1112
import org.hswebframework.web.dict.EnumDict;
1213
import org.springframework.core.annotation.AnnotationUtils;
1314

@@ -25,6 +26,7 @@
2526
import java.util.*;
2627
import java.util.concurrent.ConcurrentHashMap;
2728
import java.util.function.BiFunction;
29+
import java.util.function.Function;
2830

2931
/**
3032
* jpa 注解解析器
@@ -34,21 +36,34 @@
3436
*/
3537
public class JpaAnnotationParser {
3638

37-
private static final Map<Class, RDBTableMetaData> metaDataCache = new ConcurrentHashMap<>(256);
38-
3939
private static final Map<Class, JDBCType> jdbcTypeMapping = new HashMap<>();
4040

4141
private static final List<BiFunction<Class, PropertyDescriptor, JDBCType>> jdbcTypeConvert = new ArrayList<>();
4242

4343
static {
4444
jdbcTypeMapping.put(String.class, JDBCType.VARCHAR);
4545

46+
jdbcTypeMapping.put(Byte.class, JDBCType.TINYINT);
47+
jdbcTypeMapping.put(byte.class, JDBCType.TINYINT);
48+
49+
jdbcTypeMapping.put(Short.class, JDBCType.INTEGER);
50+
jdbcTypeMapping.put(short.class, JDBCType.INTEGER);
51+
4652
jdbcTypeMapping.put(Integer.class, JDBCType.INTEGER);
4753
jdbcTypeMapping.put(int.class, JDBCType.INTEGER);
54+
55+
jdbcTypeMapping.put(Character.class, JDBCType.CHAR);
56+
jdbcTypeMapping.put(char.class, JDBCType.CHAR);
57+
58+
jdbcTypeMapping.put(Long.class, JDBCType.BIGINT);
59+
jdbcTypeMapping.put(long.class, JDBCType.BIGINT);
60+
4861
jdbcTypeMapping.put(Double.class, JDBCType.DECIMAL);
4962
jdbcTypeMapping.put(double.class, JDBCType.DECIMAL);
63+
5064
jdbcTypeMapping.put(Float.class, JDBCType.DECIMAL);
5165
jdbcTypeMapping.put(float.class, JDBCType.DECIMAL);
66+
5267
jdbcTypeMapping.put(Boolean.class, JDBCType.BIT);
5368
jdbcTypeMapping.put(boolean.class, JDBCType.BIT);
5469

@@ -89,6 +104,7 @@ public class JpaAnnotationParser {
89104
});
90105
}
91106

107+
92108
public static RDBTableMetaData parseMetaDataFromEntity(Class entityClass) {
93109
Table table = AnnotationUtils.findAnnotation(entityClass, Table.class);
94110
if (table == null) {
@@ -133,11 +149,10 @@ public Object getData(Object value) {
133149
}
134150
};
135151

136-
if (columnMetaData.getJdbcType() == JDBCType.DATE) {
152+
if (columnMetaData.getJdbcType() == JDBCType.DATE
153+
|| columnMetaData.getJdbcType() == JDBCType.TIMESTAMP) {
137154
columnMetaData.setValueConverter(dateConvert);
138-
} else if (columnMetaData.getJdbcType() == JDBCType.TIMESTAMP) {
139-
columnMetaData.setValueConverter(dateConvert);
140-
} else if (columnMetaData.getJdbcType() == JDBCType.NUMERIC) {
155+
} else if (TypeUtils.isNumberType(columnMetaData)) {
141156
columnMetaData.setValueConverter(new NumberValueConverter(columnMetaData.getJavaType()));
142157
}
143158

@@ -147,6 +162,7 @@ public Object getData(Object value) {
147162
return tableMetaData;
148163
}
149164

165+
150166
private static <T extends Annotation> T getAnnotation(Class entityClass, PropertyDescriptor descriptor, Class<T> type) {
151167
T ann = null;
152168
try {

hsweb-commons/hsweb-commons-dao/hsweb-commons-dao-mybatis/src/test/java/org/hswebframework/web/dao/mybatis/builder/SqlParamParserTest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22

33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.serializer.SerializerFeature;
5-
import lombok.AllArgsConstructor;
6-
import lombok.Builder;
7-
import lombok.Data;
8-
import lombok.NoArgsConstructor;
5+
import lombok.*;
96
import org.hswebframework.ezorm.core.param.Term;
107
import org.hswebframework.web.commons.entity.QueryEntity;
118
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
129
import org.junit.Assert;
1310
import org.junit.Test;
11+
import org.springframework.asm.ClassReader;
1412

13+
import java.lang.invoke.LambdaMetafactory;
1514
import java.util.HashMap;
1615
import java.util.LinkedHashMap;
1716
import java.util.Map;
17+
import java.util.function.Function;
1818

1919
import static org.junit.Assert.*;
2020

@@ -23,6 +23,17 @@
2323
* @since 1.0
2424
*/
2525
public class SqlParamParserTest {
26+
@SneakyThrows
27+
public static <T> void test(Function<T, Object> function) {
28+
Class t=function.getClass();
29+
30+
System.out.println(t);
31+
}
32+
33+
public static void main(String[] args) {
34+
test(TestQueryEntity::getName$like);
35+
}
36+
2637

2738
@Test
2839
public void testParseQueryParam() {

hsweb-commons/hsweb-commons-dao/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-commons</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
<relativePath>../pom.xml</relativePath>
2828
</parent>
2929
<modelVersion>4.0.0</modelVersion>

hsweb-commons/hsweb-commons-entity/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-commons</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
</parent>
2828
<modelVersion>4.0.0</modelVersion>
2929

hsweb-commons/hsweb-commons-model/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<parent>
2424
<artifactId>hsweb-commons</artifactId>
2525
<groupId>org.hswebframework.web</groupId>
26-
<version>3.0.2</version>
26+
<version>3.0.3</version>
2727
</parent>
2828
<modelVersion>4.0.0</modelVersion>
2929

0 commit comments

Comments
 (0)