Commit 25d8efbe authored by 雍欢's avatar 雍欢

如果RowSetUtil.toList方法的参数cls是Map类型,自动给查询结果绑定上字典TextView

parent f6179b25
......@@ -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
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment