From d18cb9f2d48f889e1a944c46dde2886fdf93f9dd Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期一, 08 一月 2024 16:11:31 +0800
Subject: [PATCH] 优化代码
---
service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java b/service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java
index f5184bf..f45f092 100644
--- a/service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java
+++ b/service-api/src/main/java/com/java110/api/smo/GetCommunityStoreInfoSMOImpl.java
@@ -9,6 +9,7 @@
import com.java110.utils.cache.MappingCache;
import com.java110.utils.constant.MappingConstant;
import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.http.HttpMethod;
@@ -33,6 +34,17 @@
if (responseEntity.getStatusCode() != HttpStatus.OK) {
throw new IllegalArgumentException(responseEntity.getBody());
}
+
+ if (!StringUtil.isJsonObject(responseEntity.getBody())) {
+ // return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, responseEntity.getBody());
+ throw new IllegalArgumentException(responseEntity.getBody());
+ }
+
+ JSONObject paramJson = JSONObject.parseObject(responseEntity.getBody());
+ if (paramJson.containsKey("code") && paramJson.getIntValue("code") != 0) {
+ throw new IllegalArgumentException(paramJson.getString("msg"));
+ }
+
return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, responseEntity.getBody());
}
@@ -51,7 +63,11 @@
if (responseEntity.getStatusCode() != HttpStatus.OK) {
throw new IllegalArgumentException(responseEntity.getBody());
}
- return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, responseEntity.getBody());
+ JSONObject paramOut = JSONObject.parseObject(responseEntity.getBody());
+ if (paramOut.containsKey("code") && ResultVo.CODE_OK != paramOut.getIntValue("code")) {
+ throw new IllegalArgumentException(paramOut.getString("msg"));
+ }
+ return new ResultVo(paramOut.getIntValue("code"), paramOut.getString("msg"), paramOut.get("data"));
}
@Override
@@ -82,8 +98,8 @@
JSONArray privileges = data.getJSONArray("privileges");
- if(!SecureInvocation.secure(this.getClass())){
- return new ResultVo(ResultVo.CODE_OK,privileges.toJSONString(),ResultVo.EMPTY_ARRAY);
+ if (!SecureInvocation.secure(this.getClass())) {
+ return new ResultVo(ResultVo.CODE_OK, privileges.toJSONString(), ResultVo.EMPTY_ARRAY);
}
return new ResultVo(responseEntity.getStatusCode() == HttpStatus.OK ? ResultVo.CODE_OK : ResultVo.CODE_ERROR, privileges.toJSONString());
--
Gitblit v1.8.0