From bb8c33129097eb5a189356aa34c48ac5986fd699 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 24 八月 2020 08:58:10 +0800
Subject: [PATCH] Merge branch 'master' of https://github.com/java110/MicroCommunity
---
service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java | 49 +++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 43 insertions(+), 6 deletions(-)
diff --git a/service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java b/service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java
index 39d5648..1f0798d 100644
--- a/service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java
+++ b/service-front/src/main/java/com/java110/front/smo/impl/PrivilegeServiceSMOImpl.java
@@ -2,11 +2,12 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.java110.core.component.BaseComponentSMO;
+import com.java110.core.context.IPageData;
+import com.java110.front.smo.IPrivilegeServiceSMO;
import com.java110.utils.constant.ServiceConstant;
import com.java110.utils.util.Assert;
-import com.java110.core.context.IPageData;
-import com.java110.core.component.BaseComponentSMO;
-import com.java110.front.smo.IPrivilegeServiceSMO;
+import com.java110.utils.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@@ -223,10 +224,34 @@
return privileges;
}
+
JSONObject resultObj = JSONObject.parseObject(privileges.getBody().toString());
+ JSONArray privilegeArrays = resultObj.getJSONArray("privileges");
+ JSONObject privilegeObj = null;
- return new ResponseEntity<String>(resultObj.getJSONArray("privileges").toJSONString(), HttpStatus.OK);
+ JSONArray tmpPrivilegeArrays = new JSONArray();
+
+ for (int privilegeIndex = 0; privilegeIndex < privilegeArrays.size(); privilegeIndex++) {
+ privilegeObj = privilegeArrays.getJSONObject(privilegeIndex);
+ hasSameData(privilegeObj, tmpPrivilegeArrays);
+ }
+ return new ResponseEntity<String>(tmpPrivilegeArrays.toJSONString(), HttpStatus.OK);
+ }
+
+ private void hasSameData(JSONObject privilegeObj, JSONArray tmpPrivilegeArrays) {
+ JSONObject tmpPrivilegeObj = null;
+ for (int tmpPrivilegeIndex = 0; tmpPrivilegeIndex < tmpPrivilegeArrays.size(); tmpPrivilegeIndex++) {
+ tmpPrivilegeObj = tmpPrivilegeArrays.getJSONObject(tmpPrivilegeIndex);
+ if (privilegeObj.getString("pId").equals(tmpPrivilegeObj.getString("pId"))) {
+ if (!StringUtil.isEmpty(privilegeObj.getString("pgId"))) {
+ tmpPrivilegeArrays.remove(tmpPrivilegeIndex);
+ tmpPrivilegeArrays.add(privilegeObj);
+ }
+ return;
+ }
+ }
+ tmpPrivilegeArrays.add(privilegeObj);
}
@Override
@@ -270,7 +295,7 @@
JSONObject privilegeInfoObj = JSONObject.parseObject(pd.getReqData());
Assert.jsonObjectHaveKey(privilegeInfoObj, "pgId", "璇锋眰鎶ユ枃涓湭鍖呭惈鏉冮檺缁処D 鑺傜偣");
- Assert.jsonObjectHaveKey(privilegeInfoObj, "pId", "璇锋眰鎶ユ枃涓湭鍖呭惈鏉冮檺ID 鑺傜偣");
+ //Assert.jsonObjectHaveKey(privilegeInfoObj, "pId", "璇锋眰鎶ユ枃涓湭鍖呭惈鏉冮檺ID 鑺傜偣");
ResponseEntity<String> storeInfo = super.getStoreInfo(pd, restTemplate);
@@ -297,7 +322,11 @@
Assert.hasLength(pd.getUserId(), "鐢ㄦ埛鏈櫥褰曡鍏堢櫥褰�");
JSONObject privilegeInfoObj = JSONObject.parseObject(pd.getReqData());
- Assert.jsonObjectHaveKey(privilegeInfoObj, "staffId", "璇锋眰鎶ユ枃涓湭鍖呭惈鍛樺伐ID 鑺傜偣");
+ //Assert.jsonObjectHaveKey(privilegeInfoObj, "staffId", "璇锋眰鎶ユ枃涓湭鍖呭惈鍛樺伐ID 鑺傜偣");
+
+ if (!privilegeInfoObj.containsKey("staffId")) {
+ privilegeInfoObj.put("staffId", pd.getUserId());
+ }
ResponseEntity<String> storeInfo = super.getStoreInfo(pd, restTemplate);
@@ -319,6 +348,14 @@
JSONArray privileges = resultObj.getJSONArray("privileges");
+ JSONArray tmpPrivilegeArrays = new JSONArray();
+
+ JSONObject privilegeObj = null;
+ for (int privilegeIndex = 0; privilegeIndex < privileges.size(); privilegeIndex++) {
+ privilegeObj = privileges.getJSONObject(privilegeIndex);
+ hasSameData(privilegeObj, tmpPrivilegeArrays);
+ }
+
JSONObject resObj = new JSONObject();
resObj.put("datas", privileges);
--
Gitblit v1.8.0