mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-22 16:03:15 +00:00
リネーム実装
This commit is contained in:
parent
cef688187a
commit
29f745bb5c
|
@ -18,6 +18,8 @@ public interface Document {
|
|||
|
||||
CompletableFuture<DocumentDetail> createDocument();
|
||||
|
||||
CompletableFuture<Void> renameDocument(String documentId, String name);
|
||||
|
||||
CompletableFuture<Void> deleteDocument(String documentId);
|
||||
|
||||
CompletableFuture<Void> updateDocument(DocumentDetail detail);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package one.nem.lacerta.data.impl;
|
||||
|
||||
import androidx.room.Update;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -124,6 +126,19 @@ public class DocumentImpl implements Document {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> renameDocument(String documentId, String name) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
DocumentEntity documentEntity = database.documentDao().findById(documentId);
|
||||
if (documentEntity == null) {
|
||||
throw new IllegalArgumentException("documentId is not found");
|
||||
}
|
||||
documentEntity.title = name;
|
||||
database.documentDao().update(documentEntity);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<DocumentDetail> getDocument(String documentId) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
|
|
Loading…
Reference in New Issue
Block a user