| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.BufferedWriter;
|
| | | import java.io.File;
|
| | | import java.io.FileWriter;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | |
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.ShamUser;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.taobao.ScanHistory;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | 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.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/upload")
|
| | |
| | | List<TaoBaoOrder> orderList = null ;
|
| | | try {
|
| | | orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
|
| | | out.print(JsonUtil.loadTrueResult("上传文件成功"));
|
| | | out.print(JsonUtil.loadTrueResult("上传成功,系统正在处理中..."));
|
| | | } catch (IOException e) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件失败"));
|
| | | e.printStackTrace();
|
| | |
| | |
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 上传图片jsonp
|
| | | * @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;
|
| | | }
|
| | | |
| | | 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="/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));
|
| | | |
| | | } 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="/img/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();
|
| | | }
|
| | | }
|
| | | }
|