From 0a98cfd8a5089ef29c7a0a75a42771aa9171348f Mon Sep 17 00:00:00 2001 From: r-ca Date: Sun, 28 Jan 2024 09:06:56 +0900 Subject: [PATCH] =?UTF-8?q?uncombineDocument=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java index 4d92e314..39a4221d 100644 --- a/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java +++ b/data/src/main/java/one/nem/lacerta/data/impl/LacertaLibraryImpl.java @@ -321,7 +321,23 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public CompletableFuture uncombineDocument(String parentId, String childId) { - return null; + return CompletableFuture.supplyAsync(() -> { + DocumentEntity parentDocumentEntity = database.documentDao().findById(parentId); + DocumentEntity childDocumentEntity = database.documentDao().findById(childId); + if (parentDocumentEntity == null || childDocumentEntity == null) { + logger.warn("LacertaLibraryImpl", "DocumentEntity is not found."); + return null; + } + parentDocumentEntity.isCombineParent = false; + childDocumentEntity.isCombineChild = false; + database.documentDao().update(parentDocumentEntity); + database.documentDao().update(childDocumentEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Updated DocumentEntity"); + + database.toxiDocumentDao().deleteByParentIdAndChildId(parentId, childId); + logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentEntity"); + return null; + }); } @Override