云文件管理系统上传组件优化
This commit is contained in:
@@ -307,4 +307,52 @@ public class FileController {
|
||||
List<FileEntity> folders = fileService.getMovableFolders(principal.getUserId(), excludeIds, currentFolderId);
|
||||
return ResponseEntity.ok(Map.of("data", folders));
|
||||
}
|
||||
|
||||
@PostMapping("/batchCancelShare")
|
||||
public ResponseEntity<?> batchCancelShare(
|
||||
@AuthenticationPrincipal UserPrincipal principal,
|
||||
@RequestBody Map<String, Object> request) {
|
||||
Object idsObj = request.get("ids");
|
||||
if (idsObj == null) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "请选择要取消共享的文件"));
|
||||
}
|
||||
List<Long> ids = new ArrayList<>();
|
||||
if (idsObj instanceof List) {
|
||||
for (Object id : (List<?>) idsObj) {
|
||||
if (id instanceof Number) {
|
||||
ids.add(((Number) id).longValue());
|
||||
} else if (id instanceof String) {
|
||||
ids.add(Long.parseLong((String) id));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Long fileId : ids) {
|
||||
fileService.cancelShare(fileId, principal.getUserId());
|
||||
}
|
||||
return ResponseEntity.ok(Map.of("message", "批量取消共享成功"));
|
||||
}
|
||||
|
||||
@PostMapping("/batchRestore")
|
||||
public ResponseEntity<?> batchRestore(
|
||||
@AuthenticationPrincipal UserPrincipal principal,
|
||||
@RequestBody Map<String, Object> request) {
|
||||
Object idsObj = request.get("ids");
|
||||
if (idsObj == null) {
|
||||
return ResponseEntity.badRequest().body(Map.of("message", "请选择要还原的文件"));
|
||||
}
|
||||
List<Long> ids = new ArrayList<>();
|
||||
if (idsObj instanceof List) {
|
||||
for (Object id : (List<?>) idsObj) {
|
||||
if (id instanceof Number) {
|
||||
ids.add(((Number) id).longValue());
|
||||
} else if (id instanceof String) {
|
||||
ids.add(Long.parseLong((String) id));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Long fileId : ids) {
|
||||
fileService.restoreFile(fileId, principal.getUserId());
|
||||
}
|
||||
return ResponseEntity.ok(Map.of("message", "批量还原成功"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user