From 03ccfbd24ffc036e6c4c9715d927c755dd92adf3 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期六, 31 八月 2019 23:45:30 +0800
Subject: [PATCH] 菜单配置开发完成待测试

---
 Api/src/main/java/com/java110/api/listener/configMenu/BindingConfigMenuListener.java |  109 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 57 insertions(+), 52 deletions(-)

diff --git a/Api/src/main/java/com/java110/api/listener/configMenu/BindingConfigMenuListener.java b/Api/src/main/java/com/java110/api/listener/configMenu/BindingConfigMenuListener.java
index 197fb9b..5e61f23 100644
--- a/Api/src/main/java/com/java110/api/listener/configMenu/BindingConfigMenuListener.java
+++ b/Api/src/main/java/com/java110/api/listener/configMenu/BindingConfigMenuListener.java
@@ -2,14 +2,25 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.common.cache.MappingCache;
+import com.java110.common.constant.DomainContant;
+import com.java110.common.constant.ResponseConstant;
+import com.java110.common.exception.ListenerExecuteException;
+import com.java110.common.util.BeanConvertUtil;
 import com.java110.common.util.StringUtil;
 import com.java110.api.listener.AbstractServiceApiListener;
 import com.java110.common.util.Assert;
 import com.java110.core.context.DataFlowContext;
+import com.java110.core.smo.menu.IMenuInnerServiceSMO;
+import com.java110.dto.basePrivilege.BasePrivilegeDto;
+import com.java110.dto.menu.MenuDto;
+import com.java110.dto.menuGroup.MenuGroupDto;
 import com.java110.entity.center.AppService;
 import com.java110.event.service.api.ServiceDataFlowEvent;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import com.java110.common.constant.CommonConstant;
 import com.java110.common.constant.ServiceCodeConstant;
@@ -20,12 +31,19 @@
 
 import com.java110.core.annotation.Java110Listener;
 
+import java.util.Map;
+
 /**
  * 淇濆瓨灏忓尯渚﹀惉
  * add by wuxw 2019-06-30
  */
 @Java110Listener("bindingConfigMenuListener")
 public class BindingConfigMenuListener extends AbstractServiceApiListener {
+
+    @Autowired
+    private IMenuInnerServiceSMO menuInnerServiceSMOImpl;
+
+
     @Override
     protected void validate(ServiceDataFlowEvent event, JSONObject reqJson) {
         //Assert.hasKeyAndValue(reqJson, "xxx", "xxx");
@@ -57,30 +75,47 @@
         JSONObject addMenuView = getObj(infos, "addMenuView");
         JSONObject addPrivilegeView = getObj(infos, "addPrivilegeView");
         if (!hasKey(viewMenuGroupInfo, "gId")) {
-            viewMenuGroupInfo.put("gId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.MENU_GROUP));
-            viewMenuGroupInfo.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
-            businesses.add(addBusinessMenuGroup(viewMenuGroupInfo, context));
+            saveMenuGroup(viewMenuGroupInfo, context);
         }
         if (!hasKey(addMenuView, "mId")) {
-            addMenuView.put("mId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.MENU));
-            addMenuView.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
-            businesses.add(addBusinessMenu(addMenuView, context));
+            saveMenu(addMenuView, context);
         }
         if (!hasKey(addPrivilegeView, "pId")) {
-            addPrivilegeView.put("pId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.BASE_PRIVILEGE));
-            addPrivilegeView.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
-            businesses.add(addBusinessPrivilege(addPrivilegeView, context));
+            saveMenuPrivilege(addPrivilegeView, context);
         }
 
 
-        JSONObject paramInObj = super.restToCenterProtocol(businesses, context.getRequestCurrentHeaders());
-
-        //灏� rest header 淇℃伅浼犻�掑埌涓嬪眰鏈嶅姟涓幓
-        super.freshHttpHeader(header, context.getRequestCurrentHeaders());
-
-        ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
+        ResponseEntity<String> responseEntity = new ResponseEntity<String>("", HttpStatus.OK);
 
         context.setResponseEntity(responseEntity);
+
+    }
+
+    private void saveMenuGroup(Map info, DataFlowContext context) {
+        info.put("gId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.MENU_GROUP));
+        info.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+        MenuGroupDto menuGroupDto = BeanConvertUtil.covertBean(info, MenuGroupDto.class);
+        if (menuInnerServiceSMOImpl.saveMenuGroup(menuGroupDto) < 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鍙傛暟寮傚父锛屼繚瀛樿彍鍗曠粍澶辫触");
+        }
+    }
+
+    private void saveMenu(Map info, DataFlowContext context) {
+        info.put("mId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.MENU));
+        info.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+        MenuDto menuDto = BeanConvertUtil.covertBean(info, MenuDto.class);
+        if (menuInnerServiceSMOImpl.saveMenu(menuDto) < 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鍙傛暟寮傚父锛屼繚瀛樿彍鍗曞け璐�");
+        }
+    }
+
+    private void saveMenuPrivilege(Map info, DataFlowContext context) {
+        info.put("pId", GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.BASE_PRIVILEGE));
+        info.put("userId", context.getRequestCurrentHeaders().get(CommonConstant.HTTP_USER_ID));
+        BasePrivilegeDto basePrivilegeDto = BeanConvertUtil.covertBean(info, BasePrivilegeDto.class);
+        if (menuInnerServiceSMOImpl.saveBasePrivilege(basePrivilegeDto) < 1) {
+            throw new ListenerExecuteException(ResponseConstant.RESULT_CODE_ERROR, "鍙傛暟寮傚父锛屼繚瀛樿彍鍗曟潈闄愬け璐�");
+        }
     }
 
     @Override
@@ -96,43 +131,6 @@
     @Override
     public int getOrder() {
         return DEFAULT_ORDER;
-    }
-
-
-    private JSONObject addBusinessMenuGroup(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        //business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_MENU_GROUP_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessObj = new JSONObject();
-        businessObj.putAll(paramInJson);
-        //璁$畻 搴旀敹閲戦
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessMenuGroup", businessObj);
-        return business;
-    }
-
-    private JSONObject addBusinessMenu(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        //business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_MENU_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessObj = new JSONObject();
-        businessObj.putAll(paramInJson);
-        //璁$畻 搴旀敹閲戦
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessMenu", businessObj);
-        return business;
-    }
-
-    private JSONObject addBusinessPrivilege(JSONObject paramInJson, DataFlowContext dataFlowContext) {
-        JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        //business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_PRIVILEGE_INFO);
-        business.put(CommonConstant.HTTP_SEQ, DEFAULT_SEQ);
-        business.put(CommonConstant.HTTP_INVOKE_MODEL, CommonConstant.HTTP_INVOKE_MODEL_S);
-        JSONObject businessObj = new JSONObject();
-        businessObj.putAll(paramInJson);
-        //璁$畻 搴旀敹閲戦
-        business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessPrivilege", businessObj);
-        return business;
     }
 
 
@@ -165,4 +163,11 @@
     }
 
 
+    public IMenuInnerServiceSMO getMenuInnerServiceSMOImpl() {
+        return menuInnerServiceSMOImpl;
+    }
+
+    public void setMenuInnerServiceSMOImpl(IMenuInnerServiceSMO menuInnerServiceSMOImpl) {
+        this.menuInnerServiceSMOImpl = menuInnerServiceSMOImpl;
+    }
 }

--
Gitblit v1.8.0