Selaa lähdekoodia

获取文件信息

“zhifk” 2 vuotta sitten
vanhempi
commit
2f883ca6a9

+ 2 - 0
blade-ops-api/blade-resource-api/src/main/java/org/springblade/resource/vo/NewBladeFile.java

@@ -11,4 +11,6 @@ public class NewBladeFile {
     private String originalName;
     private Long attachId;
     private Integer page;
+    private Long fileSize;
+    private Long fileType;
 }

+ 1 - 1
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/LargeFileEndpoint.java

@@ -294,7 +294,7 @@ public class LargeFileEndpoint {
 					newBladeFile = this.commonFileClient.pngOrJpgToPdf(multipartFile);
 				}
 				BeanUtils.copyProperties(bladeFile, newBladeFile);
-
+				newBladeFile.setFileSize(multipartFile.getSize()/1024);
 				//删除本地文件
 				file1.delete();
 				iLargeFileService.updateLargeFileDeleted(param.getIdentifier());

+ 2 - 0
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java

@@ -226,6 +226,7 @@ public class OssEndpoint {
 		}
 
 		BeanUtils.copyProperties(bladeFile, newBladeFile);
+		newBladeFile.setFileSize(file.getSize()/1024);
 		return R.data(newBladeFile);
 	}
 
@@ -262,6 +263,7 @@ public class OssEndpoint {
 		}
 
 		BeanUtils.copyProperties(bladeFile, newBladeFile);
+		newBladeFile.setFileSize(file.getSize()/1024);
 		return R.data(newBladeFile.getPdfUrl());
 	}
 

+ 5 - 1
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/ArchiveFile.java

@@ -256,5 +256,9 @@ public class ArchiveFile extends BaseEntity {
 
 	@ApiModelProperty("文件大小")
 	Long fileSize;
-
+	/**
+	 * 数据源类型,1原生,2数字化
+	 */
+	@ApiModelProperty("数据源类型,1原生,2数字化")
+	private Integer sourceType;
 }

+ 3 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileAutoController.java

@@ -79,6 +79,9 @@ public class ArchiveFileAutoController extends BladeController {
                             saveVo.setIsCertification(new Integer("0").equals(saveVo.getIsNeedCertification()) ? 1 : 0);
                             saveVo.setArchiveId(archive.getId());
                             saveVo.setOriginId(archive.getId());
+                            String name = saveVo.getFileUrl().substring(saveVo.getFileUrl().lastIndexOf(".")+1);
+                            saveVo.setFileType((long) FileUtils.getFileType(name));
+                            saveVo.setSourceType(2);
                             list.add(saveVo);
                             if(saveVo.getFilePage() != null && !saveVo.getFilePage().equals("")){
                                 pageN = pageN + saveVo.getFilePage();

+ 3 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileController.java

@@ -87,6 +87,9 @@ public class ArchiveFileController extends BladeController {
                     saveVo.setSort(l+i);
                     saveVo.setStatus(new Integer("0").equals(saveVo.getIsApproval()) ? 2 : 0);
                     saveVo.setIsCertification(new Integer("0").equals(saveVo.getIsNeedCertification()) ? 1 : 0);
+                    String name = saveVo.getFileUrl().substring(saveVo.getFileUrl().lastIndexOf(".")+1);
+                    saveVo.setFileType((long) FileUtils.getFileType(name));
+                    saveVo.setSourceType(2);
                     i++;
                 }
             }

+ 19 - 5
blade-service/blade-archive/src/main/java/org/springblade/archive/utils/FileUtils.java

@@ -563,10 +563,24 @@ public class FileUtils {
         urls.add(file2);
 
         doForPageNumberUseItextpdf(urls,null);
-
     }
-
-
-
-
+    public static final  String MAP4_AVI = "avi、wmv、mpeg、mp4、m4v、mov、asf、flv、f4v、rmvb、rm、3gp、vob";
+    public static final  String XLS_XLSX = "xlsx、xls";
+    public static final  String DOC_DOCX = "doc、docx";
+    public static final  String IMAGE_JPG = "bmp、jpg、png、tif、gif、pcx、tga、exif、fpx、svg、psd、cdr、pcd、dxf、ufo、eps、ai、raw、WMF、webp、avif、apng";
+    public static int getFileType(String fileName) {
+        fileName = fileName.toLowerCase();
+        if(IMAGE_JPG.contains(fileName)){
+            return 1;
+        }else if(MAP4_AVI.contains(fileName)){
+            return 2;
+        }else if(XLS_XLSX.contains(fileName)){
+            return 3;
+        }else if(DOC_DOCX.contains(fileName)){
+            return 4;
+        }else if("pdf".contains(fileName)){
+            return 5;
+        }
+        return 99;
+    }
 }

+ 1 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.xml

@@ -53,6 +53,7 @@
         <result column="is_archive" property="isArchive"/>
         <result column="page_num" property="pageNum"/>
         <result column="file_size" property="fileSize"/>
+        <result column="source_type" property="sourceType"/>
     </resultMap>
     <update id="recoveryByIds">
         update u_archive_file set is_deleted = 0 where