From a4ef0d013b9b2b7af152ec05623ccae0bf73ba2a Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期一, 09 三月 2020 15:45:30 +0800
Subject: [PATCH] 在listener 中加入bmo

---
 Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java |  175 ----------------------------------------------------------
 1 files changed, 0 insertions(+), 175 deletions(-)

diff --git a/Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java b/Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java
index 83c3c96..15ad7ac 100644
--- a/Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java
+++ b/Api/src/main/java/com/java110/api/listener/AbstractServiceApiDataFlowListener.java
@@ -45,92 +45,6 @@
     @Autowired
     private RestTemplate restTemplateNoLoadBalanced;
 
-    /**
-     * 璋冪敤涓嬫父鏈嶅姟
-     *
-     * @param event
-     * @return
-     */
-    protected ResponseEntity<String> callService(ServiceDataFlowEvent event) {
-
-        DataFlowContext dataFlowContext = event.getDataFlowContext();
-        AppService service = event.getAppService();
-        return callService(dataFlowContext, service, dataFlowContext.getReqJson());
-    }
-
-
-    /**
-     * 璋冪敤涓嬫父鏈嶅姟
-     *
-     * @param context
-     * @param serviceCode 涓嬫父鏈嶅姟
-     * @return
-     */
-    protected ResponseEntity<String> callService(DataFlowContext context, String serviceCode, Map paramIn) {
-
-        ResponseEntity responseEntity = null;
-        AppService appService = DataFlowFactory.getService(context.getAppId(), serviceCode);
-        if (appService == null) {
-            responseEntity = new ResponseEntity<String>("褰撳墠娌℃湁鏉冮檺璁块棶" + ServiceCodeConstant.SERVICE_CODE_QUERY_STORE_USERS, HttpStatus.UNAUTHORIZED);
-            context.setResponseEntity(responseEntity);
-            return responseEntity;
-        }
-        return callService(context, appService, paramIn);
-    }
-
-    /**
-     * 璋冪敤涓嬫父鏈嶅姟
-     *
-     * @param context
-     * @param appService 涓嬫父鏈嶅姟
-     * @return
-     */
-    protected ResponseEntity<String> callService(DataFlowContext context, AppService appService, Map paramIn) {
-
-        ResponseEntity responseEntity = null;
-        if (paramIn == null || paramIn.isEmpty()) {
-            paramIn = context.getReqJson();
-        }
-
-        RestTemplate tmpRestTemplate = appService.getServiceCode().startsWith("out.") ? restTemplateNoLoadBalanced : restTemplate;
-
-        String serviceUrl = appService.getUrl();
-        HttpEntity<String> httpEntity = null;
-        HttpHeaders header = new HttpHeaders();
-        for (String key : context.getRequestCurrentHeaders().keySet()) {
-            if (CommonConstant.HTTP_SERVICE.toLowerCase().equals(key.toLowerCase())) {
-                continue;
-            }
-            header.add(key, context.getRequestCurrentHeaders().get(key));
-        }
-        header.add(CommonConstant.HTTP_SERVICE.toLowerCase(), appService.getServiceCode());
-        try {
-            if (CommonConstant.HTTP_METHOD_GET.equals(appService.getMethod())) {
-                serviceUrl += "?";
-                for (Object key : paramIn.keySet()) {
-                    serviceUrl += (key + "=" + paramIn.get(key) + "&");
-                }
-
-                if (serviceUrl.endsWith("&")) {
-                    serviceUrl = serviceUrl.substring(0, serviceUrl.lastIndexOf("&"));
-                }
-                httpEntity = new HttpEntity<String>("", header);
-                responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.GET, httpEntity, String.class);
-            } else if (CommonConstant.HTTP_METHOD_PUT.equals(appService.getMethod())) {
-                httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header);
-                responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.PUT, httpEntity, String.class);
-            } else if (CommonConstant.HTTP_METHOD_DELETE.equals(appService.getMethod())) {
-                httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header);
-                responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.DELETE, httpEntity, String.class);
-            } else {
-                httpEntity = new HttpEntity<String>(JSONObject.toJSONString(paramIn), header);
-                responseEntity = tmpRestTemplate.exchange(serviceUrl, HttpMethod.POST, httpEntity, String.class);
-            }
-        } catch (HttpStatusCodeException e) { //杩欓噷spring 妗嗘灦 鍦�4XX 鎴� 5XX 鏃舵姏鍑� HttpServerErrorException 寮傚父锛岄渶瑕侀噸鏂板皝瑁呬竴涓�
-            responseEntity = new ResponseEntity<String>( e.getResponseBodyAsString(), e.getStatusCode());
-        }
-        return responseEntity;
-    }
 
 
     /**
@@ -257,95 +171,6 @@
 
             dataFlowContext.setResponseEntity(newResponseEntity);
         }
-    }
-
-
-    /**
-     * 灏唕est 鍗忚杞负 璁㈠崟鍗忚
-     *
-     * @param business
-     * @return
-     */
-    protected JSONObject restToCenterProtocol(JSONObject business, Map<String, String> headers) {
-
-        JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}");
-        freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers);
-        centerProtocol.getJSONArray("business").add(business);
-        return centerProtocol;
-    }
-
-    /**
-     * 灏唕est 鍗忚杞负 璁㈠崟鍗忚
-     *
-     * @param businesses 澶氫釜涓氬姟
-     * @param headers    璁㈠崟澶翠俊鎭�
-     * @return
-     */
-    protected JSONObject restToCenterProtocol(JSONArray businesses, Map<String, String> headers) {
-
-        JSONObject centerProtocol = JSONObject.parseObject("{\"orders\":{},\"business\":[]}");
-        freshOrderProtocol(centerProtocol.getJSONObject("orders"), headers);
-        centerProtocol.put("business", businesses);
-        return centerProtocol;
-    }
-
-    /**
-     * 鍒峰叆order淇℃伅
-     *
-     * @param orders  璁㈠崟淇℃伅
-     * @param headers 澶撮儴淇℃伅
-     */
-    protected void freshOrderProtocol(JSONObject orders, Map<String, String> headers) {
-        for (String key : headers.keySet()) {
-
-            if (CommonConstant.HTTP_APP_ID.equals(key)) {
-                orders.put("appId", headers.get(key));
-            }
-            if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
-                orders.put("transactionId", headers.get(key));
-            }
-            if (CommonConstant.HTTP_SIGN.equals(key)) {
-                orders.put("sign", headers.get(key));
-            }
-
-            if (CommonConstant.HTTP_REQ_TIME.equals(key)) {
-                orders.put("requestTime", headers.get(key));
-            }
-            if (CommonConstant.HTTP_ORDER_TYPE_CD.equals(key)) {
-                orders.put("orderTypeCd", headers.get(key));
-            }
-            if (CommonConstant.HTTP_USER_ID.equals(key)) {
-                orders.put("userId", headers.get(key));
-            }
-        }
-
-    }
-
-    /**
-     * 鍒峰叆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("app_id", headers.get(key));
-            }
-            if (CommonConstant.HTTP_TRANSACTION_ID.equals(key)) {
-                httpHeaders.add("transaction_id", headers.get(key));
-            }
-
-            if (CommonConstant.HTTP_REQ_TIME.equals(key)) {
-                httpHeaders.add("req_time", headers.get(key));
-            }
-
-            if (CommonConstant.HTTP_USER_ID.equals(key)) {
-                httpHeaders.add("user_id", headers.get(key));
-            }
-        }
-
     }
 
     /**

--
Gitblit v1.8.0