package com.qianwen.core.boot.file; import com.fasterxml.jackson.annotation.JsonIgnore; import java.io.File; import java.io.IOException; import com.qianwen.core.boot.props.BladeFileProperties; import com.qianwen.core.tool.utils.DateUtil; import com.qianwen.core.tool.utils.SpringUtil; import org.springframework.web.multipart.MultipartFile; /* loaded from: blade-core-boot-9.3.0.0-SNAPSHOT.jar:org/springblade/core/boot/file/LocalFile.class */ public class LocalFile { private Object fileId; @JsonIgnore private MultipartFile file; private String domain; private String dir; private String uploadPath; private String uploadVirtualPath; private String fileName; private String originalFileName; private static BladeFileProperties fileProperties; public void setFileId(final Object fileId) { this.fileId = fileId; } @JsonIgnore public void setFile(final MultipartFile file) { this.file = file; } public void setDomain(final String domain) { this.domain = domain; } public void setDir(final String dir) { this.dir = dir; } public void setUploadPath(final String uploadPath) { this.uploadPath = uploadPath; } public void setUploadVirtualPath(final String uploadVirtualPath) { this.uploadVirtualPath = uploadVirtualPath; } public void setFileName(final String fileName) { this.fileName = fileName; } public void setOriginalFileName(final String originalFileName) { this.originalFileName = originalFileName; } public boolean equals(final Object o) { if (o == this) { return true; } if (o instanceof LocalFile) { LocalFile other = (LocalFile) o; if (other.canEqual(this)) { Object this$fileId = getFileId(); Object other$fileId = other.getFileId(); if (this$fileId == null) { if (other$fileId != null) { return false; } } else if (!this$fileId.equals(other$fileId)) { return false; } Object this$file = getFile(); Object other$file = other.getFile(); if (this$file == null) { if (other$file != null) { return false; } } else if (!this$file.equals(other$file)) { return false; } Object this$domain = getDomain(); Object other$domain = other.getDomain(); if (this$domain == null) { if (other$domain != null) { return false; } } else if (!this$domain.equals(other$domain)) { return false; } Object this$dir = getDir(); Object other$dir = other.getDir(); if (this$dir == null) { if (other$dir != null) { return false; } } else if (!this$dir.equals(other$dir)) { return false; } Object this$uploadPath = getUploadPath(); Object other$uploadPath = other.getUploadPath(); if (this$uploadPath == null) { if (other$uploadPath != null) { return false; } } else if (!this$uploadPath.equals(other$uploadPath)) { return false; } Object this$uploadVirtualPath = getUploadVirtualPath(); Object other$uploadVirtualPath = other.getUploadVirtualPath(); if (this$uploadVirtualPath == null) { if (other$uploadVirtualPath != null) { return false; } } else if (!this$uploadVirtualPath.equals(other$uploadVirtualPath)) { return false; } Object this$fileName = getFileName(); Object other$fileName = other.getFileName(); if (this$fileName == null) { if (other$fileName != null) { return false; } } else if (!this$fileName.equals(other$fileName)) { return false; } Object this$originalFileName = getOriginalFileName(); Object other$originalFileName = other.getOriginalFileName(); return this$originalFileName == null ? other$originalFileName == null : this$originalFileName.equals(other$originalFileName); } return false; } return false; } protected boolean canEqual(final Object other) { return other instanceof LocalFile; } public int hashCode() { Object $fileId = getFileId(); int result = (1 * 59) + ($fileId == null ? 43 : $fileId.hashCode()); Object $file = getFile(); int result2 = (result * 59) + ($file == null ? 43 : $file.hashCode()); Object $domain = getDomain(); int result3 = (result2 * 59) + ($domain == null ? 43 : $domain.hashCode()); Object $dir = getDir(); int result4 = (result3 * 59) + ($dir == null ? 43 : $dir.hashCode()); Object $uploadPath = getUploadPath(); int result5 = (result4 * 59) + ($uploadPath == null ? 43 : $uploadPath.hashCode()); Object $uploadVirtualPath = getUploadVirtualPath(); int result6 = (result5 * 59) + ($uploadVirtualPath == null ? 43 : $uploadVirtualPath.hashCode()); Object $fileName = getFileName(); int result7 = (result6 * 59) + ($fileName == null ? 43 : $fileName.hashCode()); Object $originalFileName = getOriginalFileName(); return (result7 * 59) + ($originalFileName == null ? 43 : $originalFileName.hashCode()); } public String toString() { return "LocalFile(fileId=" + getFileId() + ", file=" + getFile() + ", domain=" + getDomain() + ", dir=" + getDir() + ", uploadPath=" + getUploadPath() + ", uploadVirtualPath=" + getUploadVirtualPath() + ", fileName=" + getFileName() + ", originalFileName=" + getOriginalFileName() + ")"; } public Object getFileId() { return this.fileId; } public MultipartFile getFile() { return this.file; } public String getDomain() { return this.domain; } public String getDir() { return this.dir; } public String getUploadPath() { return this.uploadPath; } public String getUploadVirtualPath() { return this.uploadVirtualPath; } public String getFileName() { return this.fileName; } public String getOriginalFileName() { return this.originalFileName; } private static BladeFileProperties getBladeFileProperties() { if (fileProperties == null) { fileProperties = (BladeFileProperties) SpringUtil.getBean(BladeFileProperties.class); } return fileProperties; } public LocalFile(MultipartFile file, String dir) { this.dir = dir; this.file = file; this.fileName = file.getName(); this.originalFileName = file.getOriginalFilename(); this.domain = getBladeFileProperties().getUploadDomain(); this.uploadPath = BladeFileUtil.formatUrl(File.separator + getBladeFileProperties().getUploadRealPath() + File.separator + dir + File.separator + DateUtil.format(DateUtil.now(), "yyyyMMdd") + File.separator + this.originalFileName); this.uploadVirtualPath = BladeFileUtil.formatUrl(getBladeFileProperties().getUploadCtxPath().replace(getBladeFileProperties().getContextPath(), "") + File.separator + dir + File.separator + DateUtil.format(DateUtil.now(), "yyyyMMdd") + File.separator + this.originalFileName); } public LocalFile(MultipartFile file, String dir, String uploadPath, String uploadVirtualPath) { this(file, dir); if (null != uploadPath) { this.uploadPath = BladeFileUtil.formatUrl(uploadPath); this.uploadVirtualPath = BladeFileUtil.formatUrl(uploadVirtualPath); } } public void transfer() { transfer(getBladeFileProperties().getCompress().booleanValue()); } public void transfer(boolean compress) { IFileProxy fileFactory = FileProxyManager.me().getDefaultFileProxyFactory(); transfer(fileFactory, compress); } public void transfer(IFileProxy fileFactory, boolean compress) { try { File file = new File(this.uploadPath); if (null != fileFactory) { String[] path = fileFactory.path(file, this.dir); this.uploadPath = path[0]; this.uploadVirtualPath = path[1]; file = fileFactory.rename(file, path[0]); } File pfile = file.getParentFile(); if (!pfile.exists()) { pfile.mkdirs(); } this.file.transferTo(file); if (compress) { fileFactory.compress(this.uploadPath); } } catch (IOException | IllegalStateException e) { e.printStackTrace(); } } }