From 29f745bb5c20362b7f59cfdd4657a6b07bfb96fd Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 23 Jan 2024 04:20:34 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AA=E3=83=8D=E3=83=BC=E3=83=A0=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/one/nem/lacerta/data/Document.java | 2 ++ .../one/nem/lacerta/data/impl/DocumentImpl.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/data/src/main/java/one/nem/lacerta/data/Document.java b/data/src/main/java/one/nem/lacerta/data/Document.java index cd38acfc..70610913 100644 --- a/data/src/main/java/one/nem/lacerta/data/Document.java +++ b/data/src/main/java/one/nem/lacerta/data/Document.java @@ -18,6 +18,8 @@ public interface Document { CompletableFuture createDocument(); + CompletableFuture renameDocument(String documentId, String name); + CompletableFuture deleteDocument(String documentId); CompletableFuture updateDocument(DocumentDetail detail); diff --git a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java index 888a47f6..7ee8511f 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/DocumentImpl.java @@ -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 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 getDocument(String documentId) { return CompletableFuture.supplyAsync(() -> {