From: 刘洪青 Date: Sat, 12 Oct 2019 01:54:04 +0000 (+0800) Subject: fix: 接口返回异常的处理 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=8042c8e7e73c06e005d3e9f94e0f8eb9548fcaa4;p=institute%2Fsw-backend.git 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 @@ public class AuthzService { return null; } - JSONObject data = jsonObject.getJSONObject("data"); - - JSONArray roleArray = data.getJSONArray("roles"); - - List roles = roleArray.toJavaList(Role.class); - log.debug("{}", roles); + if (jsonObject.getIntValue("code") == 0) { + JSONObject data = jsonObject.getJSONObject("data"); + + JSONArray roleArray = data.getJSONArray("roles"); + + List roles = roleArray.toJavaList(Role.class); + log.debug("roles: [{}]", roles); + + return 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 @@ public class UserService { return null; } - JSONObject data = jsonObject.getJSONObject("data"); - - UserInfoModel userInfoModel = data.toJavaObject(UserInfoModel.class); - log.debug("userInfoModel: [{}]", userInfoModel); + if (jsonObject.getIntValue("code") == 0) { + JSONObject data = jsonObject.getJSONObject("data"); + + UserInfoModel userInfoModel = data.toJavaObject(UserInfoModel.class); + log.debug("userInfoModel: [{}]", userInfoModel); + + return userInfoModel; + } - return userInfoModel; + return null; } }