@@ -136,7 +136,7 @@ public abstract class AbstractVerifier<T extends Object> implements Verifier<T>,
136136 ROLE_MAP .put (UNKNOWN , new Entry <String , Object >());
137137 ROLE_MAP .put (LOGIN , new Entry <String , Object >("userId>" , 0 ));
138138 ROLE_MAP .put (CONTACT , new Entry <String , Object >("userId{}" , "contactIdList" ));
139- ROLE_MAP .put (CIRCLE , new Entry <String , Object >("userId-()" , "verifyCircle()" )); // "userId{}", "circleIdList")); // 还是 {"userId":"currentUserId", "userId{}": "contactIdList", "@combine": "userId,userId{}" } ?
139+ ROLE_MAP .put (CIRCLE , new Entry <String , Object >("userId-()" , "verifyCircle()" )); // "userId{}", "circleIdList")); // 还是 {"userId":"currentUserId", "userId{}": "contactIdList", "@combine": "userId,userId{}" } ?
140140 ROLE_MAP .put (OWNER , new Entry <String , Object >("userId" , "userId" ));
141141 ROLE_MAP .put (ADMIN , new Entry <String , Object >("userId-()" , "verifyAdmin()" ));
142142
@@ -183,8 +183,17 @@ public abstract class AbstractVerifier<T extends Object> implements Verifier<T>,
183183 REQUEST_MAP = new HashMap <>(ACCESS_MAP .size ()*7 ); // 单个与批量增删改
184184
185185 COMPILE_MAP = new HashMap <String , Pattern >();
186+
187+ COMPILE_MAP .put ("PHONE" ,Pattern .compile ("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\ d{8}$" ));
188+ COMPILE_MAP .put ("QQ" ,Pattern .compile ("[1-9][0-9]{4,}" ));
189+ COMPILE_MAP .put ("EMAIL" ,Pattern .compile ("^\\ w+([-+.]\\ w+)*@\\ w+([-.]\\ w+)*\\ .\\ w+([-.]\\ w+)*$" ));
190+ COMPILE_MAP .put ("IDCARD" ,Pattern .compile ("(^\\ d{15}$)|(^\\ d{18}$)|(^\\ d{17}(\\ d|X|x)$)" ));
191+ COMPILE_MAP .put ("TEL" ,Pattern .compile ("(^\\ (\\ d{3,4}-)|\\ d{3,4}-\\ )?\\ d{7,8}$" ));
192+ COMPILE_MAP .put ("IDCARD" ,Pattern .compile ("(^\\ d{15}$)|(^\\ d{18}$)|(^\\ d{17}(\\ d|X|x)$)" ));
193+
186194 }
187195
196+
188197 /**获取权限Map,每种操作都只允许对应的角色
189198 * @param access
190199 * @return
@@ -272,7 +281,7 @@ public boolean verifyAccess(SQLConfig config) throws Exception {
272281 if (role == null ) {
273282 role = UNKNOWN ;
274283 }
275- else {
284+ else {
276285 if (ROLE_MAP .containsKey (role ) == false ) {
277286 Set <String > NAMES = ROLE_MAP .keySet ();
278287 throw new IllegalArgumentException ("角色 " + role + " 不存在!" +
@@ -302,8 +311,8 @@ public void verifyRole(SQLConfig config, String table, RequestMethod method, Str
302311 * @param method
303312 * @param role
304313 * @return
305- * @throws Exception
306- * @see {@link apijson.JSONObject#KEY_ROLE}
314+ * @throws Exception
315+ * @see {@link apijson.JSONObject#KEY_ROLE}
307316 */
308317 public void verifyAllowRole (SQLConfig config , String table , RequestMethod method , String role ) throws Exception {
309318 Log .d (TAG , "verifyAllowRole table = " + table + "; method = " + method + "; role = " + role );
@@ -333,8 +342,8 @@ public void verifyAllowRole(SQLConfig config, String table, RequestMethod method
333342 * @param method
334343 * @param role
335344 * @return
336- * @throws Exception
337- * @see {@link apijson.JSONObject#KEY_ROLE}
345+ * @throws Exception
346+ * @see {@link apijson.JSONObject#KEY_ROLE}
338347 */
339348 public void verifyUseRole (SQLConfig config , String table , RequestMethod method , String role ) throws Exception {
340349 Log .d (TAG , "verifyUseRole table = " + table + "; method = " + method + "; role = " + role );
@@ -367,7 +376,7 @@ public void verifyUseRole(SQLConfig config, String table, RequestMethod method,
367376
368377 //key!{}:[] 或 其它没有明确id的条件 等 可以和key{}:list组合。类型错误就报错
369378 requestId = config .getWhere (visitorIdKey , true );//JSON里数值不能保证是Long,可能是Integer
370- @ SuppressWarnings ("unchecked" )
379+ @ SuppressWarnings ("unchecked" )
371380 Collection <Object > requestIdArray = (Collection <Object >) config .getWhere (visitorIdKey + "{}" , true );//不能是 &{}, |{} 不要传,直接{}
372381 if (requestId != null ) {
373382 if (requestIdArray == null ) {
@@ -378,7 +387,7 @@ public void verifyUseRole(SQLConfig config, String table, RequestMethod method,
378387
379388 if (requestIdArray == null ) {//可能是@得到 || requestIdArray.isEmpty()) {//请求未声明key:id或key{}:[...]条件,自动补全
380389 config .putWhere (visitorIdKey +"{}" , JSON .parseArray (list ), true ); //key{}:[]有效,SQLConfig里throw NotExistException
381- }
390+ }
382391 else {//请求已声明key:id或key{}:[]条件,直接验证
383392 for (Object id : requestIdArray ) {
384393 if (id == null ) {
@@ -463,7 +472,7 @@ public void verifyLogin() throws Exception {
463472 if (((Number ) visitorId ).longValue () <= 0 ) {
464473 throw new NotLoggedInException ("未登录或登录过期,请登录后再操作!" );
465474 }
466- }
475+ }
467476 else if (visitorId instanceof String ) {
468477 if (StringUtil .isEmpty (visitorId , true )) {
469478 throw new NotLoggedInException ("未登录或登录过期,请登录后再操作!" );
@@ -925,7 +934,7 @@ public static <T extends Object> JSONObject parse(@NotNull final RequestMethod m
925934 // 判断必要字段是否都有<<<<<<<<<<<<<<<<<<<
926935 String [] musts = StringUtil .split (must );
927936 Set <String > mustSet = new HashSet <String >();
928-
937+
929938 if (musts != null && musts .length > 0 ) {
930939 for (String s : musts ) {
931940 if (real .get (s ) == null && real .get (s +"@" ) == null ) { // 可能传null进来,这里还会通过 real.containsKey(s) == false) {
0 commit comments