From 92c681fabac989d1a9f16fa13202d7f5ccac52d9 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 14 一月 2019 10:22:22 +0800 Subject: [PATCH] 订单优化 + 后台提现曲线图 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java | 84 ++++++++++++++++++++++++++++++++--------- 1 files changed, 65 insertions(+), 19 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..34b1bbc 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 @@ -12,6 +12,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import net.sf.json.JSONObject; + import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @@ -36,9 +38,6 @@ import com.yeshi.fanli.util.TimeUtil; import com.yeshi.fanli.util.annotation.RequestNoLogin; import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; - -import freemarker.core.ArithmeticEngine.ConservativeEngine; -import net.sf.json.JSONObject; @Controller @RequestMapping("admin/new/api/v1/upload") @@ -250,7 +249,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(); @@ -282,17 +281,8 @@ */ @RequestNoLogin() @RequestMapping(value = "uploadPicture") - public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, Long uid, HttpServletResponse response, + public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, 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("涓婁紶鏂囦欢涓虹┖")); @@ -304,15 +294,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