瀏覽代碼

修改添加员工业务逻辑

wuxw 7 年之前
父節點
當前提交
bb57307122

+ 26 - 0
Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java

@@ -201,6 +201,32 @@ public abstract class AbstractServiceApiDataFlowListener implements ServiceDataF
 
     }
 
+    /**
+     * 刷入order信息
+     * @param httpHeaders http 头信息
+     * @param headers 头部信息
+     */
+    protected void freshHttpHeader(HttpHeaders httpHeaders, Map<String, String> headers) {
+        for(String key : headers.keySet()){
+
+            if(CommonConstant.HTTP_APP_ID.equals(key)) {
+                httpHeaders.add("appId", headers.get(key));
+            }
+            if(CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
+                httpHeaders.add("transactionId", headers.get(key));
+            }
+
+            if(CommonConstant.HTTP_REQ_TIME.equals(key)) {
+                httpHeaders.add("requestTime", headers.get(key));
+            }
+
+            if(CommonConstant.HTTP_USER_ID.equals(key)){
+                httpHeaders.add("userId",headers.get(key));
+            }
+        }
+
+    }
+
 
     public RestTemplate getRestTemplate() {
         return restTemplate;

+ 7 - 6
Api/src/main/java/com/java110/api/listener/users/AddStaffServiceListener.java

@@ -3,10 +3,7 @@ package com.java110.api.listener.users;
 import com.alibaba.fastjson.JSONObject;
 import com.java110.api.listener.AbstractServiceApiDataFlowListener;
 import com.java110.common.cache.MappingCache;
-import com.java110.common.constant.CommonConstant;
-import com.java110.common.constant.MappingConstant;
-import com.java110.common.constant.ServiceCodeConstant;
-import com.java110.common.constant.UserLevelConstant;
+import com.java110.common.constant.*;
 import com.java110.common.util.Assert;
 import com.java110.core.annotation.Java110Listener;
 import com.java110.core.context.DataFlowContext;
@@ -67,8 +64,9 @@ public class AddStaffServiceListener extends AbstractServiceApiDataFlowListener{
 
 
         JSONObject business = JSONObject.parseObject("{\"datas\":{}}");
-        business.put(CommonConstant.HTTP_BUSINESS_SERVICE_CODE,ServiceCodeConstant.SERVICE_CODE_SAVE_USER_INFO);
-        business.put(CommonConstant.HTTP_BUSINESS_SERVICE_NAME,"用户注册");
+        business.put(CommonConstant.HTTP_BUSINESS_TYPE_CD, BusinessTypeConstant.BUSINESS_TYPE_SAVE_USER_INFO);
+        business.put(CommonConstant.HTTP_SEQ,1);
+        business.put(CommonConstant.HTTP_INVOKE_MODEL,CommonConstant.HTTP_INVOKE_MODEL_S);
 
         business.getJSONObject(CommonConstant.HTTP_BUSINESS_DATAS).put("businessUser",refreshParamIn(paramIn));
         HttpHeaders header = new HttpHeaders();
@@ -76,6 +74,9 @@ public class AddStaffServiceListener extends AbstractServiceApiDataFlowListener{
         dataFlowContext.getRequestCurrentHeaders().put(CommonConstant.HTTP_ORDER_TYPE_CD,"D");
         String paramInObj = super.restToCenterProtocol(business,dataFlowContext.getRequestCurrentHeaders()).toJSONString();
 
+        //将 rest header 信息传递到下层服务中去
+        super.freshHttpHeader(header,dataFlowContext.getRequestCurrentHeaders());
+
         HttpEntity<String> httpEntity = new HttpEntity<String>(paramInObj, header);
         //http://user-service/test/sayHello
         super.doRequest(dataFlowContext, service, httpEntity);

+ 1 - 2
OrderService/doc/businessRequestProtocol.json

@@ -8,8 +8,7 @@
   },
   "business": {
     "bId":"12345678",
-    "serviceCode": "querycustinfo",
-    "serviceName": "查询客户",
+    "businessTypeCd": "100100030001",
     "remark": "备注",
     "datas": {
       "params": {

+ 2 - 7
OrderService/doc/request_protocol.json

@@ -14,21 +14,16 @@ body:
       "value": "具体值"
     }]
   },
-  // 如果是批量方式 写成 "business":[{....}]
-  "business": {
+  "business": [{
     "businessTypeCd": "B",
     "invokeModel":"S",
     "remark": "备注",
         "seq":1,
     "datas": {
-      "params": {
-        //这个做查询时的参数
-      }
-      //这里是具体业务
     },
     "attrs": [{
       "specCd": "配置的字段ID",
       "value": "具体值"
     }]
-  }
+  }]
 }

+ 7 - 0
java110-common/src/main/java/com/java110/common/constant/CommonConstant.java

@@ -157,6 +157,13 @@ public class CommonConstant {
 
     public final static String HTTP_BUSINESS_SERVICE_CODE = "serviceCode";
     public final static String HTTP_BUSINESS_SERVICE_NAME = "serviceName";
+
+    public final static String HTTP_BUSINESS_TYPE_CD = "businessTypeCd";
+    public final static String HTTP_SEQ = "seq";
+    public final static String HTTP_INVOKE_MODEL = "invokeModel";
+    public final static String HTTP_INVOKE_MODEL_S = "S";//同步
+    public final static String HTTP_INVOKE_MODEL_A = "A";//异步
+
     public final static String HTTP_BUSINESS_DATAS = "datas";