if StringUtilsisNotEmptyfilterSql && StringUtilsisNotEmptyaddFilterSql if filterSqlendsWithand if addFilterSqlstartsWith and resultFilterSql = where +
if (StringUtils.isNotEmpty(filterSql) && StringUtils.isNotEmpty(addFilterSql)) { String andCondition = " and "; String whereCondition = " where "; if (filterSql.endsWith("and ")) { if (addFilterSql.startsWith(andCondition)) { resultFilterSql = whereCondition + filterSql.substring(0, filterSql.length() - 5) + " " + addFilterSql; } else { resultFilterSql = whereCondition + filterSql + addFilterSql; } } else { if (addFilterSql.startsWith(andCondition)) { resultFilterSql = whereCondition + filterSql + addFilterSql; } else { resultFilterSql = whereCondition + filterSql + andCondition + addFilterSql; } } } else if (StringUtils.isNotEmpty(filterSql)) { String andCondition = " and "; String whereCondition = " where "; if (filterSql.endsWith("and ")) { resultFilterSql = whereCondition + filterSql.substring(0, filterSql.length() - 5); } else { resultFilterSql = whereCondition + filterSql; } } else if(StringUtils.isNotEmpty(addFilterSql)) { String andCondition = " and "; String whereCondition = " where "; if (filterSql.startsWith(andCondition)) { resultFilterSql = whereCondition + addFilterSql.replaceFirst(andCondition,""); } else { resultFilterSql = whereCondition + addFilterSql; } } else { resultFilterSql = " ";
原文地址: http://www.cveoy.top/t/topic/ifnh 著作权归作者所有。请勿转载和采集!