Skip to content

Commit

Permalink
Client:同步adt版至studio版
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Sep 5, 2017
1 parent 438c615 commit 1c26f95
Show file tree
Hide file tree
Showing 28 changed files with 747 additions and 1,096 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,37 @@
public @interface MethodAccess {

/**@see {@link RequestMethod#GET}
* @return 该请求方法允许的结构 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
* @return 该请求方法允许的角色 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
*/
RequestRole[] GET() default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};

/**@see {@link RequestMethod#HEAD}
* @return 该请求方法允许的结构 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
* @return 该请求方法允许的角色 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
*/
RequestRole[] HEAD() default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};

/**@see {@link RequestMethod#POST_GET}
* @return 该请求方法允许的结构 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
* @return 该请求方法允许的角色 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
*/
RequestRole[] POST_GET() default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};

/**@see {@link RequestMethod#POST_HEAD}
* @return 该请求方法允许的结构 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
* @return 该请求方法允许的角色 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};
*/
RequestRole[] POST_HEAD() default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN};

/**@see {@link RequestMethod#POST}
* @return 该请求方法允许的结构 default {LOGIN, ADMIN};
* @return 该请求方法允许的角色 default {LOGIN, ADMIN};
*/
RequestRole[] POST() default {LOGIN, ADMIN};

/**@see {@link RequestMethod#PUT}
* @return 该请求方法允许的结构 default {OWNER, ADMIN};
* @return 该请求方法允许的角色 default {OWNER, ADMIN};
*/
RequestRole[] PUT() default {OWNER, ADMIN};

/**@see {@link RequestMethod#DELETE}
* @return 该请求方法允许的结构 default {OWNER, ADMIN};
* @return 该请求方法允许的角色 default {OWNER, ADMIN};
*/
RequestRole[] DELETE() default {OWNER, ADMIN};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,24 @@ public static String getCorrectJson(String s) {
public static String getCorrectJson(String s, boolean isArray) {
s = StringUtil.getTrimedString(s);
// if (isArray) {
// if (s.startsWith("\"")) {
// while (s.startsWith("\"")) {
// s = s.substring(1);
// }
// if (s.endsWith("\"")) {
// while (s.endsWith("\"")) {
// s = s.substring(0, s.length() - 1);
// }
// }
return s;//isJsonCorrect(s) ? s : null;
}

/**json转JSONObject
/**obj转JSONObject
* @param json
* @return
*/
public static JSONObject parseObject(Object obj) {
if (obj instanceof JSONObject) {
return (JSONObject) obj;
}
return parseObject(toJSONString(obj));
}
/**json转JSONObject
Expand Down Expand Up @@ -114,12 +117,16 @@ public static <T> T parseObject(JSONObject object, Class<T> clazz) {
* @return
*/
public static <T> T parseObject(String json, Class<T> clazz) {
try {
int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
features |= Feature.OrderedField.getMask();
return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
} catch (Exception e) {
Log.i(TAG, "parseObject catch \n" + e.getMessage());
if (clazz == null) {
Log.e(TAG, "parseObject clazz == null >> return null;");
} else {
try {
int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE;
features |= Feature.OrderedField.getMask();
return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features);
} catch (Exception e) {
Log.i(TAG, "parseObject catch \n" + e.getMessage());
}
}
return null;
}
Expand All @@ -131,6 +138,16 @@ public static <T> T parseObject(String json, Class<T> clazz) {
public static JSONArray parseArray(List<Object> list) {
return new JSONArray(list);
}
/**obj转JSONArray
* @param json
* @return
*/
public static JSONArray parseArray(Object obj) {
if (obj instanceof JSONArray) {
return (JSONArray) obj;
}
return parseArray(toJSONString(obj));
}
/**json转JSONArray
* @param json
* @return
Expand All @@ -157,10 +174,14 @@ public static <T> List<T> parseArray(JSONArray array, Class<T> clazz) {
* @return
*/
public static <T> List<T> parseArray(String json, Class<T> clazz) {
try {
return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true), clazz);
} catch (Exception e) {
Log.i(TAG, "parseArray catch \n" + e.getMessage());
if (clazz == null) {
Log.e(TAG, "parseArray clazz == null >> return null;");
} else {
try {
return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true), clazz);
} catch (Exception e) {
Log.i(TAG, "parseArray catch \n" + e.getMessage());
}
}
return null;
}
Expand Down
Loading

0 comments on commit 1c26f95

Please sign in to comment.