Browse Source

需改图片上传路径和访问地址,增加图片地址配置。测试环境配置修改

wanxl 1 year ago
parent
commit
aafb595817

+ 5 - 1
src/main/java/com/template/controller/UploadServlet.java

@@ -4,6 +4,7 @@ package com.template.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.template.common.utils.FileUtil;
 import com.template.common.utils.FileUtil;
 import com.template.model.result.CommonResult;
 import com.template.model.result.CommonResult;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
@@ -21,6 +22,9 @@ import java.nio.file.Files;
 @RequestMapping("/auto/upload")
 @RequestMapping("/auto/upload")
 public class UploadServlet {
 public class UploadServlet {
 
 
+    @Value("${image-url}")
+    private String imageUrl;
+
     @PostMapping("/save")
     @PostMapping("/save")
     protected CommonResult doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     protected CommonResult doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
         // 获取文件内容
         // 获取文件内容
@@ -45,7 +49,7 @@ public class UploadServlet {
 //            out.write(buffer, 0, bytesRead);
 //            out.write(buffer, 0, bytesRead);
 //        }
 //        }
 //        out.close();
 //        out.close();
-        String url="https://chtech.ncjti.edu.cn/hotel/image/"+fileNameWithPath;
+        String url=imageUrl+fileNameWithPath;
 //        response.getWriter().println(url);
 //        response.getWriter().println(url);
         JSONObject jsonObject = new JSONObject();
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("url",url);
         jsonObject.put("url",url);

+ 2 - 0
src/main/resources/application-dev.yml

@@ -126,3 +126,5 @@ wechat:
       domain: https://chtech.ncjti.edu.cn/hotel/ihotel #回调地址
       domain: https://chtech.ncjti.edu.cn/hotel/ihotel #回调地址
       secret: 18e17f97e674e1c03fc255f12d12ca4d
       secret: 18e17f97e674e1c03fc255f12d12ca4d
       serialNum: 61A33563F6158C1B921A27A23A4E94E963DD53DD
       serialNum: 61A33563F6158C1B921A27A23A4E94E963DD53DD
+#图片上传地址
+image-url: https://chtech.ncjti.edu.cn/hotel/image/

+ 2 - 0
src/main/resources/application-prod.yml

@@ -110,3 +110,5 @@ wechat:
       apiKey3: nanchangjiaotongxueyuan202188888
       apiKey3: nanchangjiaotongxueyuan202188888
       apiKey: chuanghaikeji2021chuanghaikeji20
       apiKey: chuanghaikeji2021chuanghaikeji20
       domain: http://73j8db.natappfree.cc  #回调地址
       domain: http://73j8db.natappfree.cc  #回调地址
+#图片上传地址
+image-url: https://chtech.ncjti.edu.cn/hotel/image/

+ 5 - 3
src/main/resources/application-test.yml

@@ -51,9 +51,9 @@ spring:
         max-wait: 60000s
         max-wait: 60000s
 mybatis-plus:
 mybatis-plus:
   mapper-locations: classpath:/mapper/template/*.xml
   mapper-locations: classpath:/mapper/template/*.xml
-  #  configuration:
-  #    #开启sql打印
-  #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  configuration:
+      #开启sql打印
+      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
   #    #关闭sql打印
   #    #关闭sql打印
   #    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
   #    log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
   global-config:
   global-config:
@@ -131,3 +131,5 @@ wechat:
       domain: https://chtech.ncjti.edu.cn/hotel/ihotel #回调地址
       domain: https://chtech.ncjti.edu.cn/hotel/ihotel #回调地址
       secret: 18e17f97e674e1c03fc255f12d12ca4d
       secret: 18e17f97e674e1c03fc255f12d12ca4d
       serialNum: 61A33563F6158C1B921A27A23A4E94E963DD53DD
       serialNum: 61A33563F6158C1B921A27A23A4E94E963DD53DD
+#图片上传地址
+image-url: https://chtech.ncjti.edu.cn/testingServer/image/

+ 2 - 0
src/main/resources/application.yml

@@ -123,3 +123,5 @@ wechat:
       domain: https://chtech.ncjti.edu.cn/hotel/ihotel #回调地址
       domain: https://chtech.ncjti.edu.cn/hotel/ihotel #回调地址
       secret: 18e17f97e674e1c03fc255f12d12ca4d
       secret: 18e17f97e674e1c03fc255f12d12ca4d
       serialNum: 61A33563F6158C1B921A27A23A4E94E963DD53DD
       serialNum: 61A33563F6158C1B921A27A23A4E94E963DD53DD
+#图片上传地址
+image-url: https://chtech.ncjti.edu.cn/hotel/image/