|
|
@@ -2,14 +2,25 @@ package com.java110.api.listener.configMenu;
|
|
|
|
|
|
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.common.constant.ServiceCodeConfigMenuConstant;
|
|
|
|
|
|
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 @@ public class BindingConfigMenuListener extends AbstractServiceApiListener {
|
|
|
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());
|
|
|
+ ResponseEntity<String> responseEntity = new ResponseEntity<String>("", HttpStatus.OK);
|
|
|
+
|
|
|
+ context.setResponseEntity(responseEntity);
|
|
|
|
|
|
- //将 rest header 信息传递到下层服务中去
|
|
|
- super.freshHttpHeader(header, context.getRequestCurrentHeaders());
|
|
|
+ }
|
|
|
|
|
|
- ResponseEntity<String> responseEntity = this.callService(context, service.getServiceCode(), paramInObj);
|
|
|
+ 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, "参数异常,保存菜单组失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- context.setResponseEntity(responseEntity);
|
|
|
+ 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
|
|
|
@@ -99,43 +134,6 @@ public class BindingConfigMenuListener extends AbstractServiceApiListener {
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
private boolean hasKey(JSONObject info, String key) {
|
|
|
if (!info.containsKey(key)
|
|
|
|| StringUtil.isEmpty(info.getString(key))
|
|
|
@@ -165,4 +163,11 @@ public class BindingConfigMenuListener extends AbstractServiceApiListener {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public IMenuInnerServiceSMO getMenuInnerServiceSMOImpl() {
|
|
|
+ return menuInnerServiceSMOImpl;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setMenuInnerServiceSMOImpl(IMenuInnerServiceSMO menuInnerServiceSMOImpl) {
|
|
|
+ this.menuInnerServiceSMOImpl = menuInnerServiceSMOImpl;
|
|
|
+ }
|
|
|
}
|