Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邬友楠
test
Commits
25d8efbe
Commit
25d8efbe
authored
Sep 01, 2020
by
雍欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
如果RowSetUtil.toList方法的参数cls是Map类型,自动给查询结果绑定上字典TextView
parent
f6179b25
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
+30
-22
RowSetUtil.java
...a/src/main/java/com/huigou/data/jdbc/util/RowSetUtil.java
+23
-16
SelectSqlInvokeStrategy.java
...a/com/topsunit/query/binding/SelectSqlInvokeStrategy.java
+7
-6
No files found.
huigou-data/src/main/java/com/huigou/data/jdbc/util/RowSetUtil.java
View file @
25d8efbe
...
...
@@ -23,7 +23,7 @@ import com.huigou.util.StringUtil;
/**
* 数据集工具类
*
*
* @author gongmm
*/
public
final
class
RowSetUtil
{
...
...
@@ -32,7 +32,7 @@ public final class RowSetUtil {
/**
* 数据集转换为对象列表
*
*
* @param rs
* @param className
* @return
...
...
@@ -59,7 +59,16 @@ public final class RowSetUtil {
while
(
rs
.
next
())
{
Object
obj
=
cls
.
newInstance
();
for
(
int
i
=
0
;
i
<
iCol
;
i
++)
{
ClassHelper
.
setProperty
(
obj
,
propertyNameArr
[
i
],
rs
.
getObject
(
i
+
1
));
String
key
=
propertyNameArr
[
i
];
Object
value
=
rs
.
getObject
(
i
+
1
);
ClassHelper
.
setProperty
(
obj
,
key
,
value
);
if
(
obj
instanceof
Map
)
{
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
obj
;
String
textView
=
DictUtil
.
getDictionaryDetailText
(
key
,
value
);
if
(
textView
!=
null
)
{
map
.
put
(
key
+
"TextView"
,
textView
);
}
}
}
result
.
add
((
T
)
obj
);
}
...
...
@@ -81,7 +90,7 @@ public final class RowSetUtil {
/**
* 数据集转换为对象
*
*
* @param rs
* @param cls
* @return
...
...
@@ -134,7 +143,7 @@ public final class RowSetUtil {
/**
* 数据集转换为Map对象
*
*
* @param rs
* @return
* @throws Exception
...
...
@@ -162,7 +171,7 @@ public final class RowSetUtil {
/**
* 数据集转换为Map对象
*
*
* @param rs
* @return
* @throws SQLException
...
...
@@ -190,7 +199,7 @@ public final class RowSetUtil {
/**
* 数据集转换为Map对象
*
*
* @param rs
* @return
* @throws SQLException
...
...
@@ -213,7 +222,7 @@ public final class RowSetUtil {
/**
* 数据集转换为Map对象列表
*
*
* @param rs
* @return
* @throws Exception
...
...
@@ -240,9 +249,8 @@ public final class RowSetUtil {
/**
* 结果集装换对象数组列表
*
* @param rs
* 结果集
*
* @param rs 结果集
* @return
*/
public
static
List
<
Object
[]>
toArrayList
(
SqlRowSet
rs
)
{
...
...
@@ -261,9 +269,8 @@ public final class RowSetUtil {
/**
* 数据集转换为对象数组
*
* @param rs
* 数据集
*
* @param rs 数据集
* @return
*/
public
static
Object
[]
toArray
(
SqlRowSet
rs
)
{
...
...
@@ -280,7 +287,7 @@ public final class RowSetUtil {
/**
* 设置SQL参数
*
*
* @param ps
* @param objs
* @throws SQLException
...
...
@@ -295,7 +302,7 @@ public final class RowSetUtil {
/**
* 数据库类型装换
*
*
* @param value
* @throws SQLException
* @d
...
...
query-spring/src/main/java/com/topsunit/query/binding/SelectSqlInvokeStrategy.java
View file @
25d8efbe
...
...
@@ -35,14 +35,15 @@ final class SelectSqlInvokeStrategy extends ObtainSqlInvokeStrategy {
// 无查询参数
if
(
Collection
.
class
.
isAssignableFrom
(
returnType
))
{
return
sqlExecutor
.
queryToList
(
sql
,
resultType
.
value
());
}
if
(
Map
.
class
.
isAssignableFrom
(
returnType
))
{
}
else
if
(
Map
.
class
.
isAssignableFrom
(
returnType
))
{
return
sqlExecutor
.
queryToMap
(
sql
);
}
else
{
if
(
resultType
!=
null
)
{
return
sqlExecutor
.
queryOneToObject
(
sql
,
resultType
.
value
());
}
else
{
return
Map
.
class
.
isAssignableFrom
(
returnType
)
?
sqlExecutor
.
queryToMap
(
sql
)
:
sqlExecutor
.
queryOneToObject
(
sql
,
returnType
);
}
}
return
resultType
!=
null
?
sqlExecutor
.
queryOneToObject
(
sql
,
resultType
.
value
())
:
sqlExecutor
.
queryOneToObject
(
sql
,
returnType
);
}
if
(
args
.
length
==
1
)
{
if
(
args
[
0
]
instanceof
Map
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment