消除魔法值

master
星期八 5 years ago
parent 3821b1bdef
commit afb036a2ca
  1. 8
      src/main/java/com/lq/code/util/HttpKit.java
  2. 7
      src/main/java/com/lq/code/util/sql/AbstractDbBuiler.java

@ -23,6 +23,10 @@ import java.util.Map.Entry;
* @author
*/
public class HttpKit {
/**
* 问号
*/
public static final String QUESTION_MARK = "?";
private static final String DEFAULT_CHARSET = "UTF-8";
private static final Logger LOGGER = Logger.getLogger(HttpKit.class);
@ -158,8 +162,8 @@ public class HttpKit {
return url;
}
StringBuilder sb = new StringBuilder(url);
if (url.indexOf("?") == -1) {
sb.append("?");
if (url.indexOf(QUESTION_MARK) == -1) {
sb.append(QUESTION_MARK);
} else {
sb.append("&");
}

@ -10,6 +10,11 @@ import java.util.Set;
*/
public abstract class AbstractDbBuiler {
/**
* 括号
*/
public static final String BRACKETS = ")";
/**
* 自动同步表结构
* @param classSet
@ -47,7 +52,7 @@ public abstract class AbstractDbBuiler {
//SQL 转成大写适
String upperCaseSql = sql.toUpperCase();
//统计SQL排除排序SQL代码
if (sql.lastIndexOf(SqlConstant.ORDER_SQL)>sql.lastIndexOf(")")){
if (sql.lastIndexOf(SqlConstant.ORDER_SQL)>sql.lastIndexOf(BRACKETS)){
sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length(),upperCaseSql.lastIndexOf(SqlConstant.ORDER_SQL)));
}else{
sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length()));

Loading…
Cancel
Save