mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
💩 优化代码, 更新注释格式, 去除无用 import
This commit is contained in:
@@ -4,8 +4,6 @@ import im.zhaojun.zfile.model.enums.StorageTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,12 +2,10 @@ package im.zhaojun.zfile.model.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
|
||||
/**
|
||||
* @author zhaojun
|
||||
|
||||
@@ -14,13 +14,15 @@ public interface FilterConfigRepository extends JpaRepository<FilterConfig, Inte
|
||||
|
||||
/**
|
||||
* 获取驱动器下的所有规则
|
||||
* @param driveId 驱动器 ID
|
||||
* @param driveId
|
||||
* 驱动器 ID
|
||||
*/
|
||||
List<FilterConfig> findByDriveId(Integer driveId);
|
||||
|
||||
/**
|
||||
* 根据驱动器 ID 删除其所有的规则
|
||||
* @param driveId 驱动器 ID
|
||||
* @param driveId
|
||||
* 驱动器 ID
|
||||
*/
|
||||
void deleteByDriveId(Integer driveId);
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package im.zhaojun.zfile.service;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import im.zhaojun.zfile.model.entity.FilterConfig;
|
||||
import im.zhaojun.zfile.repository.FilterConfigRepository;
|
||||
@@ -11,13 +9,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author zhaojun
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package im.zhaojun.zfile.util;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import im.zhaojun.zfile.exception.PreviewException;
|
||||
import im.zhaojun.zfile.model.constant.ZFileConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -16,13 +17,19 @@ import java.net.URLConnection;
|
||||
public class HttpUtil {
|
||||
|
||||
/**
|
||||
* 最大支持文件预览大小: 1M
|
||||
* 获取 URL 对应的文件内容
|
||||
*
|
||||
* @param url
|
||||
* 文件 URL
|
||||
* @return 文件 URL
|
||||
*/
|
||||
public static String getTextContent(String url) {
|
||||
RestTemplate restTemplate = SpringContextHolder.getBean("restTemplate");
|
||||
|
||||
if (getRemoteFileSize(url) > (1024 * ZFileConstant.TEXT_MAX_FILE_SIZE_KB)) {
|
||||
throw new PreviewException("存储源跨域请求失败, 服务器中转状态, 预览文件超出大小, 最大支持 1M");
|
||||
long maxFileSize = 1024 * ZFileConstant.TEXT_MAX_FILE_SIZE_KB;
|
||||
|
||||
if (getRemoteFileSize(url) > maxFileSize) {
|
||||
throw new PreviewException("预览文件超出大小, 最大支持 " + FileUtil.readableFileSize(maxFileSize));
|
||||
}
|
||||
|
||||
String result = restTemplate.getForObject(url, String.class);
|
||||
|
||||
Reference in New Issue
Block a user