From 9b4433fddf5b401edb0aace8a404ac733b122702 Mon Sep 17 00:00:00 2001
From: 田源 <tianyuan@vci-tech.com>
Date: 星期四, 03 四月 2025 14:35:02 +0800
Subject: [PATCH] 添加非密字段显示

---
 Source/BladeX-Tool/blade-core-boot/src/main/java/org/springblade/core/boot/file/LocalFile.java |  157 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 157 insertions(+), 0 deletions(-)

diff --git a/Source/BladeX-Tool/blade-core-boot/src/main/java/org/springblade/core/boot/file/LocalFile.java b/Source/BladeX-Tool/blade-core-boot/src/main/java/org/springblade/core/boot/file/LocalFile.java
new file mode 100644
index 0000000..3a66029
--- /dev/null
+++ b/Source/BladeX-Tool/blade-core-boot/src/main/java/org/springblade/core/boot/file/LocalFile.java
@@ -0,0 +1,157 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 搴勯獮 (smallchill@163.com)
+ */
+package org.springblade.core.boot.file;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.Data;
+import org.springblade.core.boot.props.BladeFileProperties;
+import org.springblade.core.tool.utils.DateUtil;
+import org.springblade.core.tool.utils.SpringUtil;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * 涓婁紶鏂囦欢灏佽
+ *
+ * @author Chill
+ */
+@Data
+public class LocalFile {
+	/**
+	 * 涓婁紶鏂囦欢鍦ㄩ檮浠惰〃涓殑id
+	 */
+	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;
+
+	private static BladeFileProperties getBladeFileProperties() {
+		if (fileProperties == null) {
+			fileProperties = 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());
+	}
+
+	/**
+	 * 鍥剧墖涓婁紶
+	 *
+	 * @param compress 鏄惁鍘嬬缉
+	 */
+	public void transfer(boolean compress) {
+		IFileProxy fileFactory = FileProxyManager.me().getDefaultFileProxyFactory();
+		this.transfer(fileFactory, compress);
+	}
+
+	/**
+	 * 鍥剧墖涓婁紶
+	 *
+	 * @param fileFactory 鏂囦欢涓婁紶宸ュ巶绫�
+	 * @param compress    鏄惁鍘嬬缉
+	 */
+	public void transfer(IFileProxy fileFactory, boolean compress) {
+		try {
+			File file = new File(uploadPath);
+
+			if (null != fileFactory) {
+				String[] path = fileFactory.path(file, 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 (IllegalStateException | IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+}

--
Gitblit v1.9.3