|
@@ -258,12 +258,34 @@ public class JSONObject extends JSON implements Map<String, Object>, Cloneable,
|
|
}
|
|
}
|
|
|
|
|
|
public Long getLong(String key) throws YosException {
|
|
public Long getLong(String key) throws YosException {
|
|
- fieldContainsCheck(key, "Long");
|
|
|
|
- Object value = get(key);
|
|
|
|
|
|
+ if (isTableUniqueColumnName(key)) {
|
|
|
|
+ return getLongValue(key, -1L);
|
|
|
|
+ } else {
|
|
|
|
+ fieldContainsCheck(key, "Long");
|
|
|
|
+ Object value = get(key);
|
|
|
|
+ return castToLong(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- return castToLong(value);
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 检查是否为表id字段
|
|
|
|
+ *
|
|
|
|
+ * @param key
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private static boolean isTableUniqueColumnName(String key) {
|
|
|
|
+ try {
|
|
|
|
+ if (tableuniquecolumnnameList.isEmpty()) {
|
|
|
|
+ tableuniquecolumnnameList = new DBConnect().runSqlQuery("select uniquecolumnname from sys_object").toArrayList("uniquecolumnname");
|
|
|
|
+ }
|
|
|
|
+ return tableuniquecolumnnameList.contains(key);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static ArrayList<String> tableuniquecolumnnameList = new ArrayList<>();
|
|
|
|
|
|
public long getLongValue(String key) {
|
|
public long getLongValue(String key) {
|
|
Object value = get(key);
|
|
Object value = get(key);
|
|
@@ -371,7 +393,7 @@ public class JSONObject extends JSON implements Map<String, Object>, Cloneable,
|
|
}
|
|
}
|
|
if (!Keepspecialcharacters) {
|
|
if (!Keepspecialcharacters) {
|
|
value = value.toString().replaceAll("([';])+|(--)+", "");//去除特殊字符,防止sql注入
|
|
value = value.toString().replaceAll("([';])+|(--)+", "");//去除特殊字符,防止sql注入
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
value = value.toString().replace("'", "\\'");
|
|
value = value.toString().replace("'", "\\'");
|
|
}
|
|
}
|
|
return value.toString();
|
|
return value.toString();
|
|
@@ -379,6 +401,7 @@ public class JSONObject extends JSON implements Map<String, Object>, Cloneable,
|
|
|
|
|
|
/**
|
|
/**
|
|
* 验证是否为时间格式
|
|
* 验证是否为时间格式
|
|
|
|
+ *
|
|
* @param key
|
|
* @param key
|
|
* @param pattern
|
|
* @param pattern
|
|
* @param defValue
|
|
* @param defValue
|
|
@@ -406,7 +429,7 @@ public class JSONObject extends JSON implements Map<String, Object>, Cloneable,
|
|
}
|
|
}
|
|
if (!Keepspecialcharacters) {
|
|
if (!Keepspecialcharacters) {
|
|
value = value.toString().replaceAll("([';])+|(--)+", "");//去除特殊字符,防止sql注入
|
|
value = value.toString().replaceAll("([';])+|(--)+", "");//去除特殊字符,防止sql注入
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
value = value.toString().replace("'", "\\'");
|
|
value = value.toString().replace("'", "\\'");
|
|
}
|
|
}
|
|
return value.toString();
|
|
return value.toString();
|