实名认证

This commit is contained in:
2025-02-17 15:45:55 +08:00
parent 8baee4b858
commit 7af47e35b8
18 changed files with 351 additions and 51 deletions

View File

@ -0,0 +1,32 @@
package com.ruoyi.common.tool;
import org.springframework.stereotype.Service;
import java.io.File;
@Service
public class FileDeletionService {
/**
* 根据文件路径删除文件
* @param filePath 文件的完整路径
* @return 如果文件删除成功返回 true否则返回 false
*/
public boolean deleteFileByPath(String filePath) {
if (filePath == null || filePath.isEmpty()) {
return false;
}
File file = new File(filePath);
// 检查文件是否存在并且是一个普通文件
if (file.exists() && file.isFile()) {
try {
// 执行删除操作
return file.delete();
} catch (SecurityException e) {
// 处理没有权限删除文件的异常
System.err.println("没有权限删除文件: " + filePath);
return false;
}
}
return false;
}
}