From 950e0fe2dcb3d879116689dd797c33460bc8a880 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:58:28 +0900 Subject: [PATCH] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E3=83=A1=E3=82=BD=E3=83=83?= =?UTF-8?q?=E3=83=89=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 | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) 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 58640876..6d89bb2f 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 @@ -26,6 +26,7 @@ import one.nem.lacerta.source.database.common.DateTypeConverter; import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.source.database.entity.FolderEntity; import one.nem.lacerta.source.database.entity.TagEntity; +import one.nem.lacerta.source.database.entity.ToxiDocumentTagEntity; import one.nem.lacerta.utils.FeatureSwitch; import one.nem.lacerta.utils.LacertaLogger; @@ -234,28 +235,51 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public CompletableFuture createTag(DocumentTag tag) { return CompletableFuture.supplyAsync(() -> { - + TagEntity tagEntity = convertDocumentTagToTagEntity(tag); + database.tagDao().insert(tagEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Inserted TagEntity (" + tag.getId() + ")"); + return null; }); } @Override public CompletableFuture updateTag(DocumentTag tag) { - return null; + return CompletableFuture.supplyAsync(() -> { + TagEntity tagEntity = convertDocumentTagToTagEntity(tag); + database.tagDao().update(tagEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Updated TagEntity (" + tag.getId() + ")"); + return null; + }); } @Override public CompletableFuture deleteTag(String tagId) { - return null; + return CompletableFuture.supplyAsync(() -> { + database.tagDao().deleteById(tagId); + logger.debug("LacertaLibraryImpl", "Database Query: Deleted TagEntity (" + tagId + ")"); + return null; + }); } @Override public CompletableFuture addTagToDocument(String documentId, String tagId) { - return null; + CompletableFuture.supplyAsync(() -> { + ToxiDocumentTagEntity toxiDocumentTagEntity = new ToxiDocumentTagEntity(); + toxiDocumentTagEntity.documentId = documentId; + toxiDocumentTagEntity.tagId = tagId; + database.toxiDocumentTagDao().insert(toxiDocumentTagEntity); + logger.debug("LacertaLibraryImpl", "Database Query: Inserted ToxiDocumentTagEntity"); + return null; + }); } @Override public CompletableFuture removeTagFromDocument(String documentId, String tagId) { - return null; + CompletableFuture.supplyAsync(() -> { + database.toxiDocumentTagDao().deleteByDocumentIdAndTagId(documentId, tagId); + logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentTagEntity"); + return null; + }); } /**