リネーム実装

This commit is contained in:
r-ca 2024-01-23 04:20:34 +09:00
parent cef688187a
commit 29f745bb5c
No known key found for this signature in database
GPG Key ID: 6A72911AC73464A9
2 changed files with 17 additions and 0 deletions

View File

@ -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);

View File

@ -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(() -> {