From 8a524787c88a9128cc69af890d4181a01aad0e8c Mon Sep 17 00:00:00 2001
From: 吴学文 <wuxuewen@wuxuewendeMacBook-Pro.local>
Date: 星期六, 06 七月 2019 23:09:33 +0800
Subject: [PATCH] 修改代码生成器生成的app 加入user_id 的问题

---
 java110-core/src/main/java/com/java110/core/context/DataFlow.java |   40 +++++++++++++++++++++++++++++++++++-----
 1 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/java110-core/src/main/java/com/java110/core/context/DataFlow.java b/java110-core/src/main/java/com/java110/core/context/DataFlow.java
index d6b28e1..41fa130 100644
--- a/java110-core/src/main/java/com/java110/core/context/DataFlow.java
+++ b/java110-core/src/main/java/com/java110/core/context/DataFlow.java
@@ -2,8 +2,9 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.java110.common.constant.CommonConstant;
 import com.java110.common.util.DateUtil;
-import com.java110.common.util.SequenceUtil;
+import com.java110.core.factory.GenerateCodeFactory;
 import com.java110.common.util.StringUtil;
 import com.java110.entity.center.AppRoute;
 import com.java110.entity.center.Business;
@@ -115,7 +116,7 @@
     }
 
     @Override
-    public Orders getOrder() {
+    public IOrders getOrder() {
         return this;
     }
 
@@ -218,8 +219,18 @@
         try{
             Business business = null;
             JSONObject reqInfoObj = JSONObject.parseObject(reqInfo);
-            JSONObject orderObj = reqInfoObj.getJSONObject("orders");
-            JSONArray businessArray = reqInfoObj.getJSONArray("business");
+            JSONObject orderObj = refreshOrderObj(reqInfoObj,headerAll);
+            Object businessObj = reqInfoObj.get("business");
+            JSONArray businessArray = null;
+            if(businessObj instanceof JSONObject){
+                businessArray = new JSONArray();
+                businessArray.add(reqInfoObj.getJSONObject("business"));
+            }else if(businessObj instanceof JSONArray){
+                businessArray = reqInfoObj.getJSONArray("business");
+            }else{
+                // 涓嶅仛澶勭悊
+            }
+
             this.setReqData(reqInfo);
             this.setReqJson(reqInfoObj);
             this.setDataFlowId(orderObj.containsKey("dataFlowId")?orderObj.getString("dataFlowId"):"-1");
@@ -269,7 +280,7 @@
             this.setReqData(reqInfo);
             this.setDataFlowId("-1");
             this.setAppId(headerAll.get("appId"));
-            this.setTransactionId(StringUtil.isNullOrNone(headerAll.get("transactionId"))? SequenceUtil.getTransactionId():headerAll.get("transactionId"));
+            this.setTransactionId(StringUtil.isNullOrNone(headerAll.get("transactionId"))? GenerateCodeFactory.getTransactionId():headerAll.get("transactionId"));
             this.setUserId(StringUtil.isNullOrNone(headerAll.get("userId"))? "-1":headerAll.get("userId"));
             this.setOrderTypeCd("T");
             this.setRemark(StringUtil.isNullOrNone(headerAll.get("remark"))? "":headerAll.get("remark"));
@@ -301,4 +312,23 @@
         return this;
     }
 
+    private JSONObject refreshOrderObj(JSONObject reqInfoObj,Map<String,String> headerAll){
+
+        JSONObject reqInfoOrder = reqInfoObj.getJSONObject("orders");
+
+        if(!reqInfoOrder.containsKey("appId")) {
+            reqInfoOrder.put("appId", headerAll.get(CommonConstant.HTTP_APP_ID));
+        }
+        if(!reqInfoOrder.containsKey("transactionId")) {
+            reqInfoOrder.put("transactionId", headerAll.get(CommonConstant.HTTP_TRANSACTION_ID));
+        }
+        if(!reqInfoOrder.containsKey("sign")) {
+            reqInfoOrder.put("sign", headerAll.get(CommonConstant.HTTP_SIGN));
+        }
+
+        if(!reqInfoOrder.containsKey("requestTime")) {
+            reqInfoOrder.put("requestTime", headerAll.get(CommonConstant.HTTP_REQ_TIME));
+        }
+        return reqInfoOrder;
+    }
 }

--
Gitblit v1.8.0