Browse Source

oss修改

wangliang 4 năm trước cách đây
mục cha
commit
829108390e

+ 14 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TBAttachment.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.themis.common.contanst.Constants;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -61,6 +62,19 @@ public class TBAttachment implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Long createTime; //创建时间
 
+    public TBAttachment(){
+
+    }
+
+    public TBAttachment(String path,String name,String type,BigDecimal size,String md5){
+        this.id = Constants.idGen.next();
+        this.path = path;
+        this.name = name;
+        this.type = type;
+        this.size = size;
+        this.md5 = md5;
+    }
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }

+ 2 - 15
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBAttachmentServiceImpl.java

@@ -9,7 +9,6 @@ import com.qmth.themis.business.enums.UploadFileEnum;
 import com.qmth.themis.business.service.TBAttachmentService;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.OssUtil;
-import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import org.apache.commons.codec.digest.DigestUtils;
@@ -96,13 +95,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             if (!Objects.equals(fileMd5, md5)) {
                 throw new BusinessException("md5不一致");
             }
-            tbAttachment = new TBAttachment();
-            tbAttachment.setId(Constants.idGen.next());
-            tbAttachment.setPath(path);
-            tbAttachment.setName(fileName);
-            tbAttachment.setType(format);
-            tbAttachment.setSize(b);
-            tbAttachment.setMd5(fileMd5);
+            tbAttachment = new TBAttachment(path, fileName, format, b, fileMd5);
 
             boolean oss = (boolean) map.get(SystemConstant.OSS);
             LocalDateTime nowTime = LocalDateTime.now();
@@ -187,13 +180,7 @@ public class TBAttachmentServiceImpl extends ServiceImpl<TBAttachmentMapper, TBA
             log.info("format:{}", format);
             log.info("size:{}", b);
             log.info("md5:{}", md5);
-            tbAttachment = new TBAttachment();
-            tbAttachment.setId(Constants.idGen.next());
-            tbAttachment.setPath(path);
-            tbAttachment.setName(fileName);
-            tbAttachment.setType(format);
-            tbAttachment.setSize(b);
-            tbAttachment.setMd5(md5);
+            tbAttachment = new TBAttachment(path, fileName, format, b, md5);
 
             boolean oss = (boolean) map.get(SystemConstant.OSS);
             LocalDateTime nowTime = LocalDateTime.now();