| | |
| | | |
| | | import com.alibaba.druid.sql.SQLUtils; |
| | | import com.alibaba.druid.sql.ast.SQLExpr; |
| | | import com.alibaba.druid.sql.ast.SQLObject; |
| | | import com.alibaba.druid.sql.ast.SQLStatement; |
| | | import com.alibaba.druid.sql.ast.statement.*; |
| | | import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement; |
| | |
| | | import com.alibaba.druid.util.JdbcUtils; |
| | | import com.hx.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | if(sqlSelect.length() > 7){ |
| | | sqlSelect.append(","); |
| | | } |
| | | expr = sqlSelectItem.getExpr().toString(); |
| | | if(expr.indexOf("SELECT") == -1){ |
| | | |
| | | out.delete(0, out.length()) ; |
| | | sqlSelectItem.accept(sqlastOutputVisitor) ; |
| | | expr = out.toString(); |
| | | sqlSelect.append(expr); |
| | | if(!StringUtils.isEmpty(sqlSelectItem.getAlias())){ |
| | | sqlSelect.append(" AS "+sqlSelectItem.getAlias()); |
| | | } |
| | | |
| | | /* if(expr.indexOf("SELECT") == -1){ |
| | | sqlSelect.append(expr); |
| | | }else{ |
| | | sqlSelect.append("("); |
| | | sqlSelect.append(selectSqlHandle(expr,aesKeysTable,tableMaps,columns)); |
| | | sqlSelect.append(")"); |
| | | if(!StringUtils.isEmpty(sqlSelectItem.getAlias())){ |
| | | //sqlSelect.append("("); |
| | | sqlSelect.append(expr); |
| | | //sqlSelect.append(")"); |
| | | *//* if(!StringUtils.isEmpty(sqlSelectItem.getAlias())){ |
| | | sqlSelect.append(" AS "+sqlSelectItem.getAlias()); |
| | | } |
| | | } |
| | | }*//* |
| | | }*/ |
| | | } |
| | | |
| | | //解析from |
| | |
| | | return sqlSelect.toString()+sql; |
| | | } |
| | | |
| | | /** |
| | | * 处理select返回字段的参数 |
| | | * @param sql |
| | | * @param aesKeysTable |
| | | * @param tableMaps |
| | | * @param columns |
| | | * @return |
| | | */ |
| | | public static String selectSqlHandle(String sql,Map<String,Map<String,String>> aesKeysTable |
| | | ,Map<String,String> tableMaps,Collection<TableStat.Column> columns){ |
| | | |