From 44edd1c23ed20a2e21f35d4c7475732368e9af25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Thu, 25 Jan 2024 15:01:18 +0900 Subject: [PATCH] =?UTF-8?q?moveDocument=E3=82=92=E5=AE=9A=E7=BE=A9,=20?= =?UTF-8?q?=E5=AE=9F=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 | 13 +++++++++++++ 2 files changed, 15 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 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(() -> {