操作メソッド実装

This commit is contained in:
ろむねこ 2024-01-25 15:58:28 +09:00
parent ea0e52a602
commit 950e0fe2dc
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -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<Void> 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<Void> updateTag(DocumentTag tag) {
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<Void> deleteTag(String tagId) {
return CompletableFuture.supplyAsync(() -> {
database.tagDao().deleteById(tagId);
logger.debug("LacertaLibraryImpl", "Database Query: Deleted TagEntity (" + tagId + ")");
return null;
});
}
@Override
public CompletableFuture<Void> addTagToDocument(String documentId, String tagId) {
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<Void> removeTagFromDocument(String documentId, String tagId) {
CompletableFuture.supplyAsync(() -> {
database.toxiDocumentTagDao().deleteByDocumentIdAndTagId(documentId, tagId);
logger.debug("LacertaLibraryImpl", "Database Query: Deleted ToxiDocumentTagEntity");
return null;
});
}
/**