Selaa lähdekoodia

feat:
文件导出新增word模式

18339543638 2 vuotta sitten
vanhempi
commit
b0596603a2

+ 14 - 4
tr-modules-api/tr-module-export-api/src/main/java/cn/tr/module/export/bean/ExportResult.java

@@ -1,6 +1,8 @@
 package cn.tr.module.export.bean;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.tr.module.export.enums.ExportType;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -12,16 +14,24 @@ import lombok.NoArgsConstructor;
  * @Date: 2023年06月15日
  */
 @Data
-@AllArgsConstructor(staticName = "of")
+@AllArgsConstructor
 @NoArgsConstructor
 public class ExportResult {
     private String fileName;
     private String base64;
-
+    private ExportType type;
     public String getFileName() {
-        if (StrUtil.endWith(fileName, ".xlsx")) {
+        if(CollectionUtil.size(StrUtil.split(fileName,"."))>2){
             return fileName;
         }
-        return fileName+".xlsx";
+        return fileName+type.getSuffix();
+    }
+
+    public static ExportResult of(String fileName,String base64){
+        return new ExportResult(fileName,base64,ExportType.EXCEL);
+    }
+
+    public static ExportResult of(String fileName,String base64,ExportType type){
+        return new ExportResult(fileName,base64,type);
     }
 }

+ 19 - 0
tr-modules-api/tr-module-export-api/src/main/java/cn/tr/module/export/enums/ExportType.java

@@ -0,0 +1,19 @@
+package cn.tr.module.export.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Enum : ExportType
+ * @Description :
+ * @Author : LF
+ * @Date: 2023年09月25日
+ */
+@AllArgsConstructor
+@Getter
+public enum ExportType {
+    DOCX(".docx"),
+    EXCEL(".xlsx");
+    @Getter
+    private String suffix;
+}