From 5981b2cae7c20ec9021c8ccbe1a926f35f640210 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 03 一月 2019 17:43:18 +0800 Subject: [PATCH] Merge branch 'dev-hongbao' --- fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java | 68 +++++++++++++++++++++++++++++++--- 1 files changed, 62 insertions(+), 6 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..8a9c753 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,15 +304,71 @@ 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(); - - out.print(JsonUtil.loadTrueResult(uploadPath)); - + + 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)); } catch (IOException e) { out.print(JsonUtil.loadFalseResult("涓婁紶鍥剧墖澶辫触")); 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