5959public class Structure {
6060 private static final String TAG = "Structure" ;
6161
62-
63-
6462 private Structure () {}
6563
6664
67-
68-
6965 /**从request提取target指定的内容
7066 * @param method
7167 * @param name
7268 * @param target
7369 * @param request
74- * @param creator
70+ * @param creator
7571 * @return
7672 * @throws Exception
7773 */
7874 public static JSONObject parseRequest (@ NotNull final RequestMethod method , final String name
7975 , final JSONObject target , final JSONObject request , final SQLCreator creator ) throws Exception {
76+ return parseRequest (method , name , target , request , Parser .MAX_UPDATE_COUNT , creator );
77+ }
78+ /**从request提取target指定的内容
79+ * @param method
80+ * @param name
81+ * @param target
82+ * @param request
83+ * @param maxUpdateCount
84+ * @param creator
85+ * @return
86+ * @throws Exception
87+ */
88+ public static JSONObject parseRequest (@ NotNull final RequestMethod method , final String name
89+ , final JSONObject target , final JSONObject request , final int maxUpdateCount , final SQLCreator creator ) throws Exception {
8090 Log .i (TAG , "parseRequest method = " + method + "; name = " + name
8191 + "; target = \n " + JSON .toJSONString (target )
8292 + "\n request = \n " + JSON .toJSONString (request ));
@@ -107,13 +117,13 @@ public JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj
107117 }
108118 } else {
109119 if (RequestMethod .isQueryMethod (method ) == false ) {
110- verifyId (method .name (), name , key , robj , KEY_ID , true );
111- verifyId (method .name (), name , key , robj , KEY_USER_ID , false );
120+ verifyId (method .name (), name , key , robj , KEY_ID , maxUpdateCount , true );
121+ verifyId (method .name (), name , key , robj , KEY_USER_ID , maxUpdateCount , false );
112122 }
113123 }
114124 }
115125
116- return parseRequest (method , key , tobj , robj , creator );
126+ return parseRequest (method , key , tobj , robj , maxUpdateCount , creator );
117127 }
118128 });
119129
@@ -128,7 +138,7 @@ public JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj
128138 * @param atLeastOne 至少有一个不为null
129139 */
130140 private static void verifyId (@ NotNull String method , @ NotNull String name , @ NotNull String key
131- , @ NotNull JSONObject robj , @ NotNull String idKey , boolean atLeastOne ) {
141+ , @ NotNull JSONObject robj , @ NotNull String idKey , final int maxUpdateCount , boolean atLeastOne ) {
132142 //单个修改或删除
133143 Object id = null ;
134144 try {
@@ -154,9 +164,9 @@ private static void verifyId(@NotNull String method, @NotNull String name, @NotN
154164 + " 里面 " + idKey + " 和 " + idInKey + " 至少传其中一个!" );
155165 }
156166 } else {
157- if (idIn .size () > 10 ) { //不允许一次操作10条以上记录
167+ if (idIn .size () > maxUpdateCount ) { //不允许一次操作 maxUpdateCount 条以上记录
158168 throw new IllegalArgumentException (method + "请求," + name + "/" + key
159- + " 里面的 " + idInKey + ":[] 中[]的长度不能超过10 !" );
169+ + " 里面的 " + idInKey + ":[] 中[]的长度不能超过 " + maxUpdateCount + " !" );
160170 }
161171 //解决 id{}: ["1' OR 1='1'))--"] 绕过id{}限制
162172 //new ArrayList<Long>(idIn) 不能检查类型,Java泛型擦除问题,居然能把 ["a"] 赋值进去还不报错
0 commit comments