Quellcode durchsuchen

增加本机图片映射

peiguo vor 5 Jahren
Ursprung
Commit
968edd6f35

+ 2 - 2
admin-ui/app/whepi/scan/qrImg.js

@@ -114,12 +114,12 @@ define(function (require) {
                                         {
                                             field: 'outImg', title: '外出二维码', minWidth: 300, maxWidth: 400,
                                             formatter: function (value) {
-                                                return "<img  src='" + value + "'/>";
+                                                return "<img  src='/whepi" + value + "'/>";
                                             },
                                         },
                                         {field: 'inImg', title: '进入二维码', minWidth: 300, maxWidth: 400,
                                             formatter: function (value) {
-                                                return "<img  src='" + value + "'/>";
+                                                return "<img  src='/whepi" + value + "'/>";
                                             },},
                                         {field: 'timeUpdate', title: '修改时间', maxWidth: 200, formatter: $.fn.fmatter.ts},
                                     ]

+ 11 - 11
whepi-web/src/main/java/com/bofeng/unit/QRCode.java

@@ -185,12 +185,12 @@ public class QRCode {
      * @return
      */
     public static String decryptByBase64(String base64) {
-        SimpleDateFormat sdf = new SimpleDateFormat("/yyyy/MM/dd");
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
         if (Strings.isNullOrEmpty(base64)) {
             return "";
         }
-        String filePath = programUploadPath + sdf.format(new Date()) + "/" + IdWorker.getId() + ".jpg";
-        File path = new File(programUploadPath + sdf.format(new Date()));
+        String filePath = programUploadPath + "/upload/" + sdf.format(new Date()) + "/" + IdWorker.getId() + ".jpg";
+        File path = new File(programUploadPath  + "/upload/" + sdf.format(new Date()));
         if (!path.exists()) {
             path.mkdirs();
         }
@@ -203,12 +203,12 @@ public class QRCode {
         return filePath.replace(programUploadPath, "");
     }
 
-    public static void main(String[] args) throws IOException, WriterException {
-        Long startTime = System.currentTimeMillis();
-        System.out.println("******************************");
-        String file = createBase64Img("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx02a4ee296708dfd4&redirect_uri=http%3A%2F%2Fpeiguo.ng.yvanui.com%2Fuser%2FscanEstate.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect", "家园互助平台", "巡检扫码");
-        Long endTime = System.currentTimeMillis();
-        System.out.println(file);
-        System.out.println((endTime - startTime) + " |" +(endTime - startTime)/ 1000);
-    }
+//    public static void main(String[] args) throws IOException, WriterException {
+//        Long startTime = System.currentTimeMillis();
+//        System.out.println("******************************");
+//        String file = createBase64Img("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx02a4ee296708dfd4&redirect_uri=http%3A%2F%2Fpeiguo.ng.yvanui.com%2Fuser%2FscanEstate.html&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect", "家园互助平台", "巡检扫码");
+//        Long endTime = System.currentTimeMillis();
+//        System.out.println(file);
+//        System.out.println((endTime - startTime) + " |" +(endTime - startTime)/ 1000);
+//    }
 }

+ 2 - 0
whepi-web/src/main/java/com/bofeng/wx/controller/ScanAdminController.java

@@ -24,8 +24,10 @@ import lombok.SneakyThrows;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.ServletOutputStream;

+ 10 - 0
yvan-platform/src/main/java/com/yvan/mvc/JztdMvcAutoConfigration.java

@@ -8,6 +8,7 @@ import org.springframework.http.MediaType;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 
 import java.util.List;
@@ -26,6 +27,15 @@ public class JztdMvcAutoConfigration extends WebMvcConfigurerAdapter {
     }
 
     /**
+     * 本机图片映射
+     * @param registry
+     */
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry.addResourceHandler("/whepi/upload/**").addResourceLocations("file:"+ "D:\\uoplad\\whepi" + "/upload/");
+    }
+
+    /**
      * 默认输出 json
      */
     @Override