Map<String,Object> resultMap = new HashMap<String,Object>();
List<UserTo> resultList = new ArrayList<UserTo>();
String userIdField=getUserInfoConfig().getUserIdField();
String userNameField=getUserInfoConfig().getUserNameField();
String sqlText=getUserInfoConfig().getSqlText();
SqlCommand sqlCommand = getSqlCommand();
String sql = "SELECT USERTABLE.* FROM ("+sqlText+") USERTABLE WHERE 1=1";
String countSql = "SELECT count(*) FROM ("+sqlText+") USERTABLE WHERE 1=1";
String whereSql = "";
if(queryMap != null && queryMap.containsKey("USERID")){
whereSql += " AND "+userIdField+" LIKE '%"+queryMap.get("USERID")+"%'";
}
if(queryMap != null && queryMap.containsKey("USERNAME")){
whereSql += " AND "+userNameField+" LIKE '%"+queryMap.get("USERNAME")+"%' ";
}
sql += whereSql;
countSql += whereSql;
int count = Integer.parseInt(sqlCommand.queryForValue(countSql).toString());
if (page != null) {
Pagination pagination = Context.getProcessEngineConfiguration().getDbConfig().getPagination();
sql = pagination.getPaginationSql(sql, page.getFirstResult(), page.getMaxResults(), "*",null);
}
List<Map<String, Object>> dataObj = sqlCommand.queryForList(sql, null);
for(int i= 0;i<dataObj.size();i++){
if (dataObj.get(i).get(userIdField) != null) {
UserTo userTo = new UserTo(StringUtil.getString(dataObj.get(i).get(userIdField)), StringUtil.getString(dataObj.get(i).get(userNameField)), dataObj.get(i));
resultList.add(userTo);