commit | 8042c8e7e73c06e005d3e9f94e0f8eb9548fcaa4 | [log] [tgz] |
---|---|---|
author | 刘洪青 <hongqing.liu@supwisdom.com> | 周六 10月 12 09:54:04 2019 +0800 |
committer | 刘洪青 <hongqing.liu@supwisdom.com> | 周六 10月 12 09:54:04 2019 +0800 |
tree | 83db10e91a731fc1fbe58d16ec6aed9f87b31936 | |
parent | 074887426d57c7afa4f2d6ac8c5470631ae42f9a [diff] |
fix: 接口返回异常的处理
diff --git a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/AuthzService.java b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/AuthzService.java index 1d040b6..5ee463b 100644 --- a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/AuthzService.java +++ b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/AuthzService.java
@@ -26,13 +26,17 @@ return null; } - JSONObject data = jsonObject.getJSONObject("data"); + if (jsonObject.getIntValue("code") == 0) { + JSONObject data = jsonObject.getJSONObject("data"); + + JSONArray roleArray = data.getJSONArray("roles"); + + List<Role> roles = roleArray.toJavaList(Role.class); + log.debug("roles: [{}]", roles); + + return roles; + } - JSONArray roleArray = data.getJSONArray("roles"); - - List<Role> roles = roleArray.toJavaList(Role.class); - log.debug("{}", roles); - - return roles; + return null; } }
diff --git a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/UserService.java b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/UserService.java index 777c596..75182da 100644 --- a/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/UserService.java +++ b/gateway/src/main/java/com/supwisdom/institute/backend/gateway/agent/poa/service/UserService.java
@@ -23,12 +23,16 @@ return null; } - JSONObject data = jsonObject.getJSONObject("data"); + if (jsonObject.getIntValue("code") == 0) { + JSONObject data = jsonObject.getJSONObject("data"); + + UserInfoModel userInfoModel = data.toJavaObject(UserInfoModel.class); + log.debug("userInfoModel: [{}]", userInfoModel); + + return userInfoModel; + } - UserInfoModel userInfoModel = data.toJavaObject(UserInfoModel.class); - log.debug("userInfoModel: [{}]", userInfoModel); - - return userInfoModel; + return null; } }