feat: 审核通过移动文件到approved,拒绝删除pending文件
- StorageService 新增 delete() - approve: 文件 pending → approved - reject: 删除 pending 文件
This commit is contained in:
@@ -135,6 +135,10 @@ public class AdminController {
|
|||||||
|
|
||||||
Long reviewerId = (Long) request.getAttribute("accountId");
|
Long reviewerId = (Long) request.getAttribute("accountId");
|
||||||
|
|
||||||
|
// 删除 pending 文件
|
||||||
|
storageService.delete(config.getStoragePath());
|
||||||
|
|
||||||
|
config.setStoragePath(null);
|
||||||
config.setStatus(ConfigStatus.REJECTED);
|
config.setStatus(ConfigStatus.REJECTED);
|
||||||
config.setReviewerId(reviewerId);
|
config.setReviewerId(reviewerId);
|
||||||
config.setReviewedAt(LocalDateTime.now());
|
config.setReviewedAt(LocalDateTime.now());
|
||||||
|
|||||||
@@ -55,4 +55,10 @@ public class CachedStorageService implements StorageService {
|
|||||||
if (isQiniuMode()) return local.exists(path) || qiniu.exists(path);
|
if (isQiniuMode()) return local.exists(path) || qiniu.exists(path);
|
||||||
return local.exists(path);
|
return local.exists(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String path) {
|
||||||
|
local.delete(path);
|
||||||
|
if (isQiniuMode()) qiniu.delete(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,4 +63,13 @@ public class LocalStorageService implements StorageService {
|
|||||||
public boolean exists(String path) {
|
public boolean exists(String path) {
|
||||||
return Files.exists(baseDir.resolve(path));
|
return Files.exists(baseDir.resolve(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String path) {
|
||||||
|
try {
|
||||||
|
Files.deleteIfExists(baseDir.resolve(path));
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("删除文件失败 {}: {}", path, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,17 @@ public class QiniuStorageService implements StorageService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String path) {
|
||||||
|
ensureInit();
|
||||||
|
try {
|
||||||
|
bucketManager.delete(bucket, path);
|
||||||
|
log.debug("Qiniu 删除: {}", path);
|
||||||
|
} catch (QiniuException e) {
|
||||||
|
log.warn("Qiniu 删除失败 {}: {}", path, e.response != null ? e.response.error : e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static String env(String key) { return System.getenv(key); }
|
private static String env(String key) { return System.getenv(key); }
|
||||||
private static String env(String key, String def) {
|
private static String env(String key, String def) {
|
||||||
String v = System.getenv(key);
|
String v = System.getenv(key);
|
||||||
|
|||||||
@@ -15,4 +15,7 @@ public interface StorageService {
|
|||||||
|
|
||||||
/** 检查是否存在 */
|
/** 检查是否存在 */
|
||||||
boolean exists(String path);
|
boolean exists(String path);
|
||||||
|
|
||||||
|
/** 删除文件 */
|
||||||
|
void delete(String path);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user