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 3491fc7d..ced8eabf 100644 --- a/data/src/main/java/one/nem/lacerta/data/Document.java +++ b/data/src/main/java/one/nem/lacerta/data/Document.java @@ -23,6 +23,8 @@ public interface Document { CompletableFuture deleteDocument(String documentId); + CompletableFuture moveDocument(String documentId, String parentId); + CompletableFuture updateDocument(DocumentDetail detail); CompletableFuture getDocument(String documentId); 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 523c7277..9c1e2c47 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 @@ -123,6 +123,19 @@ public class DocumentImpl implements Document { }); } + @Override + public CompletableFuture moveDocument(String documentId, String parentId) { + return CompletableFuture.supplyAsync(() -> { + DocumentEntity documentEntity = database.documentDao().findById(documentId); + if (documentEntity == null) { + throw new IllegalArgumentException("documentId is not found"); + } + documentEntity.parentId = parentId; + database.documentDao().update(documentEntity); + return null; + }); + } + @Override public CompletableFuture updateDocument(DocumentDetail detail) { return CompletableFuture.supplyAsync(() -> {