Sfoglia il codice sorgente

bugfix-导入/图片上传

Aslee 3 anni fa
parent
commit
a6e1112dac

+ 2 - 2
src/main/java/com/caimei/config/ApiConfig.java

@@ -30,8 +30,8 @@ public class ApiConfig implements WebMvcConfigurer {
                 .addPathPatterns("/shop/**")
 //                .addPathPatterns("/upload/**")
                 .addPathPatterns("/user/update/password")
-                .addPathPatterns("/data/**");
-//                .excludePathPatterns("/order/shareCode");
+                .addPathPatterns("/data/**")
+                .excludePathPatterns("/auth/export/excel");
         registry.addInterceptor(wxApiInterceptor)
                 .addPathPatterns("/wx/data/**")
                 .addPathPatterns("/wx/user/token/check")

+ 0 - 1
src/main/java/com/caimei/controller/UploadApi.java

@@ -60,7 +60,6 @@ public class UploadApi {
         if (file != null ) {
             // 保存文件
             saveFile = uploadService.saveFile(file);
-            saveFile = imageDomain + "/" + saveFile;
             map.put("data", saveFile);
             map.put("msg", "上传成功");
             logger.info("【图片上传】>>>>>>>>>>>>>>>>图片上传成功:" + saveFile);

+ 4 - 2
src/main/java/com/caimei/service/impl/AuthServiceImpl.java

@@ -601,12 +601,14 @@ public class AuthServiceImpl implements AuthService {
                         if (j == 3 || j == 4) {
 //                            productSheet.addMergedRegion(new CellRangeAddress(j + 1,j + 1,j + 1,j + 1)) ;
                             // 头像
-                            InputStream imageStream = getImageStream(productData.get(j));
+                            String imageUrl = productData.get(j);
+                            String fileType = imageUrl.substring(imageUrl.lastIndexOf(".") + 1);
+                            InputStream imageStream = getImageStream(imageUrl);
                             if (null != imageStream) {
                                 try {
                                     BufferedImage bufferedImage = ImageIO.read(imageStream);
                                     ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
-                                    ImageIO.write(bufferedImage, "jpg", byteArrayOut);
+                                    ImageIO.write(bufferedImage, fileType, byteArrayOut);
                                     byte[] data = byteArrayOut.toByteArray();
                                     HSSFPatriarch drawingPatriarch = productSheet.createDrawingPatriarch();
                                     // 设置图片位置