diff --git a/pom.xml b/pom.xml
index 8c901e2..4493382 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,11 @@
fastjson
1.2.9
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.15.1
+
org.projectlombok
lombok
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java
index ad3a5e7..3c1e7a4 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/auth/LoginFilter.java
@@ -42,7 +42,7 @@ public class LoginFilter implements Filter {
"cashierService/location/**",//高德 获取行政区域
"cashierService/home/homePageUp",//首页上半
"cashierService/home",//首页
-
+ "cashierService/common/**",//通用接口
"cashierService/distirict/**",//首页其它接口
"cashierService/login/**",//登录部分接口不校验
"cashierService/notify/**",//登录部分接口不校验
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java
index 036b95d..6f6617a 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/CommonController.java
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.controller;
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
+import com.chaozhanggui.system.cashierservice.service.FileService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.LocationUtils;
@@ -12,15 +13,12 @@ import com.chaozhanggui.system.cashierservice.util.ValidateCodeUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.gson.*;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
-import java.io.IOException;
-import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -39,6 +37,8 @@ public class CommonController {
private RedisUtils redisUtils;
@Resource
private TbPlatformDictMapper platformDictMapper;
+ @Resource
+ private FileService fileService;
/**
* 一分钟
*/
@@ -100,4 +100,9 @@ public class CommonController {
JsonNode jsonNode = mapper.readTree(gpsInfo);
return Result.success(CodeEnum.SUCCESS, jsonNode);
}
+
+ @RequestMapping("common/upload")
+ public Result upload(MultipartFile file) throws Exception {
+ return new Result(CodeEnum.SUCCESS, fileService.uploadFile(file));
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java
index ce1bbb8..0d6ee0b 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/ProductVo.java
@@ -25,6 +25,7 @@ public class ProductVo {
private Integer id;
private String name; // 商品名称
private BigDecimal lowPrice; // 售价
+ private String groupNum; // 数量
private String unitName; // 单位
/**
* 商品标签
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/FileService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/FileService.java
new file mode 100644
index 0000000..0d079ae
--- /dev/null
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/FileService.java
@@ -0,0 +1,66 @@
+package com.chaozhanggui.system.cashierservice.service;
+
+import com.aliyun.oss.OSS;
+import com.aliyun.oss.OSSClientBuilder;
+import com.aliyun.oss.common.auth.CredentialsProvider;
+import com.aliyun.oss.common.auth.DefaultCredentialProvider;
+import com.chaozhanggui.system.cashierservice.util.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.PostConstruct;
+import java.util.UUID;
+
+@Service
+@Slf4j
+public class FileService {
+
+ @Value("${aliyun.keyid}")
+ private String accessKeyId;
+ @Value("${aliyun.keysecret}")
+ private String accessKeySecret;
+ @Value("${aliyun.oss.endpoint}")
+ private String endpoint;
+ @Value("${aliyun.oss.bucketname}")
+ private String bucketName;
+
+ // 创建阿里云登录凭证
+ public CredentialsProvider credentialsProvider;
+
+ @PostConstruct
+ public void init() {
+ credentialsProvider = new DefaultCredentialProvider(accessKeyId, accessKeySecret);
+ }
+
+
+ public String uploadFile(MultipartFile file) throws Exception {
+ String suffix = FilenameUtils.getExtension(file.getResource().getFilename());
+ String path = getPath("upload", suffix);
+ OSS client = new OSSClientBuilder().build(endpoint, credentialsProvider);
+ try {
+ client.putObject(bucketName, path, file.getInputStream());
+ client.shutdown();
+ } catch (Exception e) {
+ throw new Exception("上传异常");
+ }
+
+ return "https://" + bucketName + "." + endpoint + "/" + path;
+ }
+
+ public String getPath(String prefix, String suffix) {
+ //生成uuid
+ String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+ //文件路径
+ String path = DateUtils.getDays() + "/" + uuid;
+
+ if (StringUtils.isNotBlank(prefix)) {
+ path = prefix + "/" + path;
+ }
+
+ return path + "." + suffix;
+ }
+}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
index 63cbc81..f4eeaa5 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
@@ -229,7 +229,7 @@ public class OrderService {
// date.setTotalNumber(number);
// }
// }
- return Result.success(CodeEnum.ENCRYPT, tbOrderInfos);
+ return Result.success(CodeEnum.ENCRYPT, new PageInfo<>(tbOrderInfos));
}
diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java b/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java
index 75189f0..d1b2527 100644
--- a/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java
+++ b/src/main/java/com/chaozhanggui/system/cashierservice/util/ValidateCodeUtil.java
@@ -1,8 +1,5 @@
package com.chaozhanggui.system.cashierservice.util;
-import cn.hutool.core.date.DateUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import com.chaozhanggui.system.cashierservice.sign.Result;
@@ -10,11 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.awt.image.BufferedImage;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 337ac0e..98cbeb9 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -50,4 +50,8 @@ logging:
#阿里云相关配置
aliyun:
keyid: LTAI5tPdEfYSZcqHbjCrtPRD
- keysecret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy
\ No newline at end of file
+ keysecret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy
+ oss:
+ bucketname: cashier-oss
+ endpoint: oss-cn-beijing.aliyuncs.com
+