Browse Source

fix 1.文件上传完善 2.部分参数类型修改

classic_blue 3 weeks ago
parent
commit
bd3c66d774

+ 123 - 0
fuintBackend/configure/test/application.properties

@@ -0,0 +1,123 @@
+# 数据库配置
+spring.datasource.url=jdbc:mysql://101.126.146.250:3306/fuint-food?useUnicode=true&characterEncoding=UTF8&useSSL=false
+spring.datasource.username=root
+spring.datasource.password=XYY1q2w!
+
+# Redis配置
+spring.session.store-type=redis
+spring.session.redis.namespace=fuint
+# Redis数据库索引(默认为0)
+spring.redis.database=0 
+# Redis服务器地址(生产)
+spring.redis.host=192.168.1.44
+# Redis服务器连接端口
+spring.redis.port=6379
+# Redis服务器连接密码(默认为空)
+spring.redis.password=fuint123
+# 连接池最大连接数(使用负值表示没有限制)
+spring.redis.pool.max-active=-1
+# 连接池最大阻塞等待时间(使用负值表示没有限制)
+spring.redis.pool.max-wait=-1 
+# 连接池中的最大空闲连接
+spring.redis.pool.max-idle=8 
+# 连接池中的最小空闲连接
+spring.redis.pool.min-idle=0 
+# 连接超时时间(毫秒)
+spring.redis.timeout=0
+
+# 系统名称
+system.name = fuint餐饮会员系统
+
+# 前端h5地址
+website.url=https://www.fuint.cn/h5/
+
+# 上传图片本地地址
+images.root=C:/fuintFoodSystem_v1.3/fuintBackend/fuint-application/target/classes
+images.path=/static/uploadImages/
+
+# 上传图片服务器域名
+images.upload.url=http://localhost:8080
+
+# 上传图片允许的大小(单位:MB)
+images.upload.maxSize=5
+
+################## 定时脚本配置 #########################
+# 定时发送消息
+message.job.switch = 1
+message.job.time = 0 0/1 * * * ?
+
+# 卡券到期处理
+couponExpire.job.switch = 1
+couponExpire.job.time = 0 0/1 * * * ?
+
+# 订单超时取消
+orderCancel.job.switch = 1
+orderCancel.job.time = 0 0/1 * * * ?
+
+# 分佣提成计算
+commission.job.switch = 1
+commission.job.time = 0 0/1 * * * ?
+
+################## 阿里云短信配置 #######################
+# 短信接口模式[0-关闭 1-打开]
+aliyun.sms.mode = 0
+aliyun.sms.accessKeyId=LTAI4GJMjV123oXsrQJLnPZt
+aliyun.sms.accessKeySecret=eGVBL30u5Ypj234d7XODlwYKWTaGT
+# 阿里云短信签名
+aliyun.sms.signName=延禾技术
+
+################## 阿里云OSS存储配置######################
+# 模式[0-关闭 1-打开]
+aliyun.oss.mode = 0
+aliyun.oss.accessKeyId = LTAI4GJMjVhBa212rQJLnPZtt
+aliyun.oss.accessKeySecret = eGVBL30u53456gXd7XODlwYKWTaGT
+aliyun.oss.endpoint = https://oss-cn-shenzhen.aliyuncs.com
+aliyun.oss.bucketName = fuint-application
+# 上传文件夹
+aliyun.oss.folder = uploads
+# 访问域名
+aliyun.oss.domain = https://fuint-application.oss-cn-shenzhen.aliyuncs.com
+
+huaweicloud.obs.mode = 1
+huaweicloud.obs.expireSeconds=1000
+huaweicloud.obs.endpoint=obs.cn-north-4.myhuaweicloud.com
+huaweicloud.obs.accessKey=C9WI47G4DXXN2EMIL1OO
+huaweicloud.obs.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
+huaweicloud.obs.bucketName=v-xiaoyaotravel
+huaweicloud.moderation.accessKey=C9WI47G4DXXN2EMIL1OO
+huaweicloud.moderation.secretKey=tfrZ9aw8wjfotUlG6IUCMjtAgzIzErL5qpPPt9AO
+huaweicloud.moderation.region=cn-north-4
+huaweicloud.moderation.projectId=23089a903d5041b4a55170556cf8cae1
+
+huaweicloud.obs.folder = fuint_uploads
+huaweicloud.obs.domain = https://v-xiaoyaotravel.obs.cn-north-4.myhuaweicloud.com
+
+
+################## 微信相关配置 ##########################
+# 公众号配置
+weixin.official.appId=wxf4327ef05c27a0
+weixin.official.appSecret=1f55e8749332234d9a074873d8e6a3
+
+# 小程序配置
+wxpay.appId=wxb6af3741686162bc
+wxpay.appSecret=76a538bfa5b55a72de6214d5f0be5540
+wxpay.mchId=1636980848
+wxpay.apiV2=fuyuan20201030yanhe9999999999999
+wxpay.certPath=/usr/local/fuint/cert/apiclient_cert.p12
+wxpay.domain=https://www.fuint.cn/fuint-application
+
+################## 支付宝支付相关配置 ######################
+alipay.appId = 应用编号
+alipay.privateKey = 应用私钥
+alipay.publicKey = 支付宝公钥(通过应用公钥上传到支付宝开放平台换取支付宝公钥)
+alipay.serverUrl=https://openapi.alipay.com/gateway.do
+alipay.domain=https://www.fuint.cn/fuint-application/clientApi/pay/aliPayCallback
+
+################ 微信订阅模板消息配置 ######################
+weixin.subMessage.orderCreated=[{'key':'time', 'name':'订单时间'},{'key':'orderSn', 'name':'订单号'},{'key':'remark', 'name':'备注信息'}]
+weixin.subMessage.deliverGoods=[{'key':'receiver', 'name':'收货人'}, {'key':'orderSn', 'name':'订单号'}, {'key':'expressCompany', 'name':'快递公司'}, {'key':'expressNo', 'name':'快递单号'}]
+weixin.subMessage.couponExpire=[{'key':'name', 'name':'卡券名称'}, {'key':'expireTime', 'name':'到期时间'},{'key':'tips', 'name':'温馨提示'}]
+weixin.subMessage.couponArrival=[{'key':'name', 'name':'卡券名称'},{'key':'amount', 'name':'金额'},{'key':'tips', 'name':'温馨提示'}]
+weixin.subMessage.balanceChange=[{'key':'amount', 'name':'变动金额'},{'key':'time', 'name':'变动时间'},{'key':'tips', 'name':'温馨提示'}]
+weixin.subMessage.couponConfirm=[{'key':'name', 'name':'卡券名称'},{'key':'time', 'name':'核销时间'}]
+weixin.subMessage.pointChange=[{'key':'amount', 'name':'变动数量'},{'key':'time', 'name':'变动时间'},{'key':'remark', 'name':'备注信息'}]

+ 3 - 2
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/SettingServiceImpl.java

@@ -149,13 +149,14 @@ public class SettingServiceImpl extends ServiceImpl<MtSettingMapper, MtSetting>
     @Override
     public String getUploadBasePath() {
         String basePath = env.getProperty("images.upload.url");
-        String mode = env.getProperty("aliyun.oss.mode");
+//        String mode = env.getProperty("aliyun.oss.mode");
+        String mode = env.getProperty("huaweicloud.obs.mode");
 
         if (mode == null) {
             return basePath;
         } else {
             if (mode.equals("1")) {
-                String domain = env.getProperty("aliyun.oss.domain");
+                String domain = env.getProperty("huaweicloud.obs.domain");
                 if (StringUtil.isNotEmpty(domain)) {
                     basePath = domain;
                 }

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCateController.java

@@ -232,7 +232,7 @@ public class BackendCateController extends BaseController {
     @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('goods:cate:index')")
-    public ResponseObject info(HttpServletRequest request, @PathVariable("id") Integer id) throws BusinessCheckException {
+    public ResponseObject info(HttpServletRequest request, @PathVariable("id") Long id) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         AccountInfo accountDto = TokenUtil.getAccountInfoByToken(token);
         if (accountDto == null) {

+ 17 - 20
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendFileController.java

@@ -63,7 +63,7 @@
 //    @ApiOperation(value = "后台上传文件")
 //    @RequestMapping(value = "/upload", method = RequestMethod.POST)
 //    @CrossOrigin
-//    public ResponseObject uploadFileLocal(HttpServletRequest request) {
+//    public ResponseObject fileLocal(HttpServletRequest request) {
 //        String token = request.getHeader("Access-Token");
 //        String action = request.getParameter("action") == null ? "" : request.getParameter("action");
 //
@@ -206,10 +206,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.util.ResourceUtils;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -248,27 +245,27 @@ public class BackendFileController extends BaseController {
     /**
      * 后台上传文件
      *
-     * @param uploadFile
+     * @param file
      * @param token
      * @return ResponseObject
      */
     @ApiOperation(value = "后台上传文件")
     @RequestMapping(value = "/upload", method = RequestMethod.POST)
     @CrossOrigin
-    public ResponseObject uploadFileLocal(MultipartFile uploadFile, String token) {
-//        // 验证 token 是否有效
+    public ResponseObject fileLocal(@RequestParam("file") MultipartFile file) {
+        // 验证 token 是否有效
 //        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
 //        if (accountInfo == null) {
 //            return getFailureResult(1001, "请先登录");
 //        }
 
         // 校验上传的文件是否为空
-        if (uploadFile == null || uploadFile.isEmpty()) {
+        if (file == null || file.isEmpty()) {
             return getFailureResult(201, "上传的文件不能为空");
         }
 
         // 获取文件的原始文件名
-        String originalFilename = uploadFile.getOriginalFilename();
+        String originalFilename = file.getOriginalFilename();
         if (StringUtil.isEmpty(originalFilename)) {
             return getFailureResult(201, "上传文件获取失败");
         }
@@ -283,16 +280,16 @@ public class BackendFileController extends BaseController {
         }
 
         // 判断文件大小
-        if (uploadFile.getSize() > (maxSize * 1024 * 1024)) {
+        if (file.getSize() > (maxSize * 1024 * 1024)) {
             return getFailureResult(201, "上传的文件不能大于 " + maxSize + "MB");
         }
 
         // 获取文件类型
-        String fileType = uploadFile.getContentType();
+        String fileType = file.getContentType();
 
         // 保存文件并上传到华为云OBS
         try {
-            String fileName = saveFile(uploadFile);
+            String fileName = saveFile(file);
             String baseImage = settingService.getUploadBasePath();
             String filePath = baseImage + fileName;
             String url = filePath;
@@ -328,10 +325,10 @@ public class BackendFileController extends BaseController {
             resultMap.put("filePath", filePath);
             resultMap.put("fileName", fileName);
             resultMap.put("state", "SUCCESS");
-            resultMap.put("original", uploadFile.getOriginalFilename());
-            resultMap.put("size", uploadFile.getSize() + "");
+            resultMap.put("original", file.getOriginalFilename());
+            resultMap.put("size", file.getSize() + "");
             resultMap.put("title", fileName);
-            resultMap.put("type", uploadFile.getContentType());
+            resultMap.put("type", file.getContentType());
             resultMap.put("url", url);
             String ip = CommonUtil.getIPFromHttpRequest(null);
             logger.info("用户ip:{},上传文件url:{}", ip, url);
@@ -345,12 +342,12 @@ public class BackendFileController extends BaseController {
     /**
      * 保存文件到本地磁盘
      *
-     * @param uploadFile
+     * @param file
      * @return 文件路径
      * @throws Exception
      */
-    public String saveFile(MultipartFile uploadFile) throws Exception {
-        String fileName = uploadFile.getOriginalFilename();
+    public String saveFile(MultipartFile file) throws Exception {
+        String fileName = file.getOriginalFilename();
         String fileExtension = fileName.substring(fileName.lastIndexOf("."));
         String uuid = UUID.randomUUID().toString().replaceAll("-", "");
 
@@ -367,7 +364,7 @@ public class BackendFileController extends BaseController {
             if (!tempFile.getParentFile().exists()) {
                 tempFile.getParentFile().mkdirs();
             }
-            CommonUtil.saveMultipartFile(uploadFile, pathRoot + path);
+            CommonUtil.saveMultipartFile(file, pathRoot + path);
         } catch (Exception e) {
             throw new Exception("上传失败,请检查目录是否可写");
         }