From 399a1db3846dd02ed247343266962ade9c3b988e Mon Sep 17 00:00:00 2001
From: 喻健 <喻健@Admin>
Date: 星期三, 21 十一月 2018 16:21:24 +0800
Subject: [PATCH] 后台系统参数调整
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java | 67 +++++++++++++++++++++++++++++++--
1 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java
index 030c11c..040ccd0 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java
@@ -250,7 +250,7 @@
List<TaoBaoOrder> orderList = null;
try {
orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
- out.print(JsonUtil.loadTrueResult("涓婁紶鏂囦欢鎴愬姛"));
+ out.print(JsonUtil.loadTrueResult("涓婁紶鎴愬姛,绯荤粺姝e湪澶勭悊涓�..."));
} catch (IOException e) {
out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢澶辫触"));
e.printStackTrace();
@@ -304,10 +304,19 @@
String contentType = file.getContentType();
String type = contentType.substring(contentType.indexOf("/") + 1);
// 涓婁紶鏂囦欢鐩稿浣嶇疆
- String fileUrl = UUID.randomUUID().toString().replace("-", "") + "." + type;
-
+ String fileUrl="/img/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+
String uploadPath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
-
+
+ JSONObject data = new JSONObject();
+ data.put("original", file.getOriginalFilename());
+ data.put("name", file.getOriginalFilename());
+ data.put("url", uploadPath);
+ data.put("size", file.getSize() + "");
+ data.put("type", "." + type);
+ data.put("state", "SUCCESS");
+ out.print(JsonUtil.loadTrueResult(data));
+
out.print(JsonUtil.loadTrueResult(uploadPath));
} catch (IOException e) {
@@ -315,4 +324,54 @@
e.printStackTrace();
}
}
+
+ /**
+ *
+ * 鏂规硶璇存槑: 涓婁紶Apk瀹夎鍖�
+ *
+ * @param file
+ * @param out
+ */
+ @RequestMapping(value = "installPackage")
+ public void installPackage(@RequestParam("file") CommonsMultipartFile file, Long uid,
+ HttpServletResponse response, PrintWriter out) {
+
+ response.setHeader("Access-Control-Allow-Origin", "*");
+ response.setHeader("Access-Control-Allow-Methods", "*");
+
+ AdminUser admin = adminUserService.selectByPrimaryKey(uid);
+ if (admin == null) {
+ out.print(JsonUtil.loadFalseResult("褰撳墠璐︽埛楠岃瘉澶辫触"));
+ return;
+ }
+
+ if (file == null) {
+ out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓虹┖"));
+ return;
+ }
+
+ try {
+ InputStream inputStream = file.getInputStream();
+ String contentType = file.getContentType();
+ String type = contentType.substring(contentType.indexOf("/") + 1);
+
+ // 涓婁紶鏂囦欢鐩稿浣嶇疆
+ String fileUrl="/apk/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
+
+ String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
+
+ JSONObject data = new JSONObject();
+ data.put("original", file.getOriginalFilename());
+ data.put("name", file.getOriginalFilename());
+ data.put("url", uploadFilePath);
+ data.put("size", file.getSize() + "");
+ data.put("type", "." + type);
+ data.put("state", "SUCCESS");
+ out.print(JsonUtil.loadTrueResult(data));
+
+ } catch (Exception e) {
+ out.print(JsonUtil.loadFalseResult("涓婁紶澶辫触"));
+ e.printStackTrace();
+ }
+ }
}
--
Gitblit v1.8.0