Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Dec 28, 2023
2 parents 0b6c845 + 454fa46 commit 2705830
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ public Flux<DataBuffer> read(String id, Function<ReaderContext, Mono<Void>> befo
});
}

@Override
public Mono<Integer> delete(String id) {
return doDelete(id);
}

public Mono<Integer> doDelete(String id) {
return repository
.deleteById(id);
}

@EventListener
public void handleDeleteEvent(EntityDeletedEvent<FileEntity> event) {
for (FileEntity fileEntity : event.getEntity()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public interface FileManager {
Flux<DataBuffer> read(String id,
Function<ReaderContext, Mono<Void>> beforeRead);

Mono<Integer> delete(String id);

interface ReaderContext {
FileInfo info();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import lombok.AllArgsConstructor;
import org.hswebframework.web.authorization.Authentication;
import org.hswebframework.web.authorization.annotation.Authorize;
import org.hswebframework.web.authorization.annotation.DeleteAction;
import org.hswebframework.web.authorization.annotation.Resource;
import org.hswebframework.web.authorization.exception.AccessDenyException;
import org.jetlinks.community.io.file.FileInfo;
import org.jetlinks.community.io.file.FileManager;
Expand All @@ -24,6 +26,7 @@
@RestController
@RequestMapping("/file")
@AllArgsConstructor
@Resource(id= "file-manager",name = "文件管理")
@Tag(name = "需身份认证的文件管理")
public class FileManagerController {

Expand Down Expand Up @@ -100,4 +103,13 @@ public Mono<Void> read(@PathVariable String fileId,

}));
}

@DeleteMapping("/{fileId}")
@DeleteAction
@Operation(summary = "删除文件")
public Mono<Integer> delete(@PathVariable String fileId) {
return fileManager
.delete(fileId);
}

}

0 comments on commit 2705830

Please sign in to comment.