From a1a2cf7535373390f7cb29fb4e7c4f7a22a0a915 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@MS-20170306HGUF>
Date: 星期六, 22 二月 2020 18:38:57 +0800
Subject: [PATCH] 动态发圈-素材
---
fanli/src/main/java/com/yeshi/fanli/controller/admin/UploadController.java | 67 ++++++---------------------------
1 files changed, 13 insertions(+), 54 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 6079622..49caef7 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
@@ -9,8 +9,6 @@
import java.util.UUID;
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Controller;
@@ -21,31 +19,27 @@
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.tencentcloud.COSManager;
-import com.yeshi.fanli.entity.common.AdminUser;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.AdminUserService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
import com.yeshi.fanli.service.inter.order.OrderProcessService;
import com.yeshi.fanli.service.inter.order.OrderService;
-import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
+import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
import com.yeshi.fanli.util.CMQManager;
import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.FilePathEnum;
+import com.yeshi.fanli.util.RedisKeyEnum;
import com.yeshi.fanli.util.RedisManager;
import com.yeshi.fanli.util.StringUtil;
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")
public class UploadController {
- @Resource
- private HongBaoService hongBaoService;
@Resource
private OrderService orderService;
@@ -81,7 +75,7 @@
String contentType = file.getContentType();
String type = contentType.substring(contentType.indexOf("/") + 1);
String uploadFilePath = COSManager.getInstance()
- .uploadFile(inputStream, UUID.randomUUID().toString().replace("-", "") + "." + type).getUrl();
+ .uploadFile(inputStream, FilePathEnum.section.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type).getUrl();
out.print(JsonUtil.loadTrueResult(uploadFilePath));
} catch (IOException e) {
e.printStackTrace();
@@ -104,7 +98,7 @@
String contentType = file.getContentType();
String type = contentType.substring(contentType.indexOf("/") + 1);
String uploadFilePath = COSManager.getInstance()
- .uploadFile(inputStream, UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk")
+ .uploadFile(inputStream, FilePathEnum.apk.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk")
.getUrl();
out.print(JsonUtil.loadTrueResult(uploadFilePath));
} catch (Exception e) {
@@ -122,7 +116,7 @@
String contentType = file.getContentType();
String type = contentType.substring(contentType.indexOf("/") + 1);
String uploadFilePath = COSManager.getInstance()
- .uploadFile(inputStream, "section/" + date + "/" + timeMillis + "." + type).getUrl();
+ .uploadFile(inputStream, FilePathEnum.section.getPath() + timeMillis + "." + type).getUrl();
JSONObject data = new JSONObject();
data.put("original", file.getOriginalFilename());
data.put("name", file.getOriginalFilename());
@@ -156,7 +150,7 @@
while (its.hasNext()) {
String key = its.next();
List<TaoBaoOrder> orders = map.get(key);
- String redisKey = "addorderqueue-" + key;
+ String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.addOrderQueue, key);
// redis鍋氶鐜囬檺鍒�
if (Constant.IS_OUTNET) {
try {
@@ -169,7 +163,7 @@
}
}
- CMQManager.getInstance().addTaoBaoOrderMsg(key, orders);
+ CMQManager.getInstance().addTaoBaoOrderMsg(key);
try {
// 6灏忔椂鍐呬笉鍐嶅鐞�
if (Constant.IS_OUTNET) {
@@ -228,19 +222,8 @@
* @param response
* @param out
*/
- @RequestNoLogin()
@RequestMapping(value = "uploadOrderFile")
- public void uploadOrderFile(@RequestParam("file") CommonsMultipartFile file, Long uid, HttpServletRequest request,
- 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;
- }
+ public void uploadOrderFile(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
if (file == null) {
out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓嶈兘涓虹┖"));
@@ -280,19 +263,8 @@
* @param file
* @param out
*/
- @RequestNoLogin()
@RequestMapping(value = "uploadPicture")
- public void uploadPicture(@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;
- }
+ public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
if (file == null) {
out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓虹┖"));
@@ -304,7 +276,7 @@
String contentType = file.getContentType();
String type = contentType.substring(contentType.indexOf("/") + 1);
// 涓婁紶鏂囦欢鐩稿浣嶇疆
- String fileUrl="/img/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
+ String fileUrl=FilePathEnum.section.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
String uploadPath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
@@ -316,9 +288,6 @@
data.put("type", "." + type);
data.put("state", "SUCCESS");
out.print(JsonUtil.loadTrueResult(data));
-
- out.print(JsonUtil.loadTrueResult(uploadPath));
-
} catch (IOException e) {
out.print(JsonUtil.loadFalseResult("涓婁紶鍥剧墖澶辫触"));
e.printStackTrace();
@@ -333,17 +302,7 @@
* @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;
- }
+ public void installPackage(@RequestParam("file") CommonsMultipartFile file, PrintWriter out) {
if (file == null) {
out.print(JsonUtil.loadFalseResult("涓婁紶鏂囦欢涓虹┖"));
@@ -356,7 +315,7 @@
String type = contentType.substring(contentType.indexOf("/") + 1);
// 涓婁紶鏂囦欢鐩稿浣嶇疆
- String fileUrl="/apk/admin" + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
+ String fileUrl= FilePathEnum.apk.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
--
Gitblit v1.8.0