Skip to content

Commit d662ca3

Browse files
committed
将隐藏字段功能单独抽取方法 isHideColumn,方便重写来自定义
1 parent 73ae17b commit d662ca3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

APIJSONORM/src/main/java/apijson/orm/AbstractSQLExecutor.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,8 @@ protected void executeAppJoin(SQLConfig config, List<JSONObject> resultList, Map
514514
protected JSONObject onPutColumn(@NotNull SQLConfig config, @NotNull ResultSet rs, @NotNull ResultSetMetaData rsmd
515515
, final int tablePosition, @NotNull JSONObject table, final int columnIndex, Map<String, JSONObject> childMap) throws Exception {
516516

517-
if (rsmd.getColumnName(columnIndex).startsWith("_")) {
518-
Log.i(TAG, "select while (rs.next()){ ..."
519-
+ " >> rsmd.getColumnName(i).startsWith(_) >> continue;");
517+
if (isHideColumn(config, rs, rsmd, tablePosition, table, columnIndex, childMap)) {
518+
Log.i(TAG, "onPutColumn isHideColumn(config, rs, rsmd, tablePosition, table, columnIndex, childMap) >> return table;");
520519
return table;
521520
}
522521

@@ -572,6 +571,22 @@ protected JSONObject onPutColumn(@NotNull SQLConfig config, @NotNull ResultSet r
572571

573572
return table;
574573
}
574+
575+
/**如果不需要这个功能,在子类重写并直接 return false; 来提高性能
576+
* @param config
577+
* @param rs
578+
* @param rsmd
579+
* @param tablePosition
580+
* @param table
581+
* @param columnIndex
582+
* @param childMap
583+
* @return
584+
* @throws SQLException
585+
*/
586+
protected boolean isHideColumn(@NotNull SQLConfig config, @NotNull ResultSet rs, @NotNull ResultSetMetaData rsmd
587+
, final int tablePosition, @NotNull JSONObject table, final int columnIndex, Map<String, JSONObject> childMap) throws SQLException {
588+
return rsmd.getColumnName(columnIndex).startsWith("_");
589+
}
575590

576591
/**resultList.put(position, table);
577592
* @param config

0 commit comments

Comments
 (0)