From 7d446240ff5d7525feb7815d3344cf6271c09a12 Mon Sep 17 00:00:00 2001
From: wuxw <928255095@qq.com>
Date: 星期一, 23 九月 2019 21:04:27 +0800
Subject: [PATCH] 暂存代码

---
 WebService/src/main/java/com/java110/web/controller/CallComponentController.java |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/WebService/src/main/java/com/java110/web/controller/CallComponentController.java b/WebService/src/main/java/com/java110/web/controller/CallComponentController.java
index 5e5987e..828dcbb 100644
--- a/WebService/src/main/java/com/java110/web/controller/CallComponentController.java
+++ b/WebService/src/main/java/com/java110/web/controller/CallComponentController.java
@@ -14,6 +14,7 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.lang.reflect.InvocationTargetException;
@@ -80,5 +81,60 @@
         }
     }
 
+    //缁勪欢涓婁紶鏂囦欢澶勭悊/callComponent/upload/
+
+    /**
+     * 璋冪敤缁勪欢 鏂囦欢涓婁紶
+     *
+     * @return
+     */
+
+    @RequestMapping(path = "/callComponent/upload/{componentCode}/{componentMethod}")
+    public ResponseEntity<String> callComponentUploadFile(
+            @PathVariable String componentCode,
+            @PathVariable String componentMethod,
+            @RequestParam("uploadFile") MultipartFile uploadFile,
+            //@RequestBody String info,
+            HttpServletRequest request) {
+        ResponseEntity<String> responseEntity = null;
+        try {
+            Assert.hasLength(componentCode, "鍙傛暟閿欒锛屾湭浼犲叆缁勪欢缂栫爜");
+            Assert.hasLength(componentMethod, "鍙傛暟閿欒锛屾湭浼犲叆璋冪敤缁勪欢鏂规硶");
+
+            Object componentInstance = ApplicationContextFactory.getBean(componentCode);
+
+            Assert.notNull(componentInstance, "鏈壘鍒扮粍浠跺搴旂殑澶勭悊绫伙紝璇风‘璁� " + componentCode);
+
+            Method cMethod = componentInstance.getClass().getDeclaredMethod(componentMethod, IPageData.class, MultipartFile.class);
+
+            Assert.notNull(cMethod, "鏈壘鍒扮粍浠跺搴斿鐞嗙被鐨勬柟娉曪紝璇风‘璁� " + componentCode + "鏂规硶锛�" + componentMethod);
+
+            IPageData pd = (IPageData) request.getAttribute(CommonConstant.CONTEXT_PAGE_DATA);
+
+            logger.debug("缁勪欢缂栫爜{}锛岀粍浠舵柟娉晎}锛宲d 涓簕}", componentCode, componentMethod, pd.toString());
+
+            responseEntity = (ResponseEntity<String>) cMethod.invoke(componentInstance, pd);
+
+        } catch (SMOException e) {
+            /*MultiValueMap<String, String> headers = new HttpHeaders();
+            headers.add("code", e.getResult().getCode());*/
+            responseEntity = new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+        } catch (Exception e) {
+            String msg = "";
+            if (e instanceof InvocationTargetException) {
+                Throwable targetEx = ((InvocationTargetException) e).getTargetException();
+                if (targetEx != null) {
+                    msg = targetEx.getMessage();
+                }
+            } else {
+                msg = e.getMessage();
+            }
+            responseEntity = new ResponseEntity<>(msg, HttpStatus.INTERNAL_SERVER_ERROR);
+        } finally {
+            logger.debug("缁勪欢璋冪敤杩斿洖淇℃伅涓簕}", responseEntity);
+            return responseEntity;
+        }
+    }
+
 
 }

--
Gitblit v1.8.0