Pārlūkot izejas kodu

fix 文件上传不判断是否传过

Administrator 4 gadi atpakaļ
vecāks
revīzija
c1196a64ae

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/dto/GalleryImgDto.java

@@ -25,4 +25,12 @@ public class GalleryImgDto implements Serializable {
     private String qrCodeUrl;
     private String concat;
     private String remark;
+    /**
+     * 附件地址
+     */
+    private String path;
+    /**
+     * 附件缩略图地址
+     */
+    private String thumbnailPath;
 }

+ 9 - 6
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FileServiceImpl.java

@@ -68,7 +68,8 @@ public class FileServiceImpl implements IFileService {
         //获取配置文件中图片文件存储路径
         String profile = RuoYiConfig.getProfile();
         for (MultipartFile file : files) {
-            String fileHash = FileHashUtil.getFileHash(file);
+            //把图片是否重复的校验部分暂时关闭
+/*            String fileHash = FileHashUtil.getFileHash(file);
             // 表示文件存在过了
             ZbFile hashFile = zbFileService.findByHash(fileHash);
             if (hashFile != null) {
@@ -89,7 +90,7 @@ public class FileServiceImpl implements IFileService {
                         .detail(imgDetailInfo)
                         .build());
                 continue;
-            }
+            }*/
 
             String name = file.getOriginalFilename();
             String code = FileUtils.getRandomFileName(name);
@@ -123,7 +124,7 @@ public class FileServiceImpl implements IFileService {
             xmFile.setName(name);
             xmFile.setPath(pathname);
             xmFile.setUploadTime(new Date());
-            xmFile.setFileHash(fileHash);
+            //xmFile.setFileHash(fileHash);
             xmFile.setSize(file.getSize());
             xmFile.setUrl("?path=" + URLEncoder.createDefault().encode(pathname, Charset.defaultCharset()));
             xmFile.setDetail(JSON.toJSONString(imgDetailInfo));
@@ -155,7 +156,9 @@ public class FileServiceImpl implements IFileService {
         String url = ruoYiConfig.getUrl();
         //获取配置文件中图片文件存储路径
         String profile = RuoYiConfig.getProfile();
-        String fileHash = FileHashUtil.getFileHash(file);
+
+        //把图片是否重复的校验部分暂时关闭
+/*        String fileHash = FileHashUtil.getFileHash(file);
         // 表示文件存在过了
         ZbFile hashFile = zbFileService.findByHash(fileHash);
         if (hashFile != null) {
@@ -166,7 +169,7 @@ public class FileServiceImpl implements IFileService {
                     .fileSize(hashFile.getSize())
                     .detail(JSON.parseObject(hashFile.getDetail(), ImgDetailInfo.class))
                     .build();
-        }
+        }*/
         String timeFormat = FileUtils.getTimeFileDir();
         String name = file.getName();
         String pathname = timeFormat + File.separator + name;
@@ -181,7 +184,7 @@ public class FileServiceImpl implements IFileService {
         xmFile.setName(name);
         xmFile.setPath(pathname);
         xmFile.setUploadTime(new Date());
-        xmFile.setFileHash(fileHash);
+        //xmFile.setFileHash(fileHash);
         xmFile.setSize(file.length());
         xmFile.setUrl("?path=" + URLEncoder.createDefault().encode(pathname, Charset.defaultCharset()));
         zbFileService.save(xmFile);

+ 1 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ZbGalleryServiceImpl.java

@@ -129,10 +129,9 @@ public class ZbGalleryServiceImpl extends ServiceImpl<ZbGalleryMapper, ZbGallery
         }
 
         Long galleryId = gallery.getId();
-        //对应图片信息删除
+        //对应图片信息删除
         galleryImgService.removeByGalleryId(galleryId);
 
-        //在添加
         //判断是否修改图库时,是否包含图片
         if (zbGallery.getImgInfos().size() > 0) {
             List<ZbGalleryImg> imgList = zbGallery.getImgInfos().stream().filter(e -> e.getId() != null).map(x -> {

+ 3 - 1
ruoyi-system/src/main/resources/mapper/system/ZbGalleryImgMapper.xml

@@ -58,7 +58,9 @@
     <select id="getByGalleryId" resultType="com.ruoyi.system.dto.GalleryImgDto">
         SELECT
             zgi.thumb_id file_id,
-            zf.url ,
+            zf.url,
+            zf.path,
+            zf.thumbnail_path,
             zgi.watermark_type,
             zgi.watermark_color,
             zgi.location,