IDが指定されなかった場合に自動で生成するように

This commit is contained in:
ろむねこ 2024-01-26 15:26:04 +09:00
parent 2f9df5a225
commit 8acbe6338b
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -244,6 +245,9 @@ public class LacertaLibraryImpl implements LacertaLibrary {
public CompletableFuture<Void> createTag(DocumentTag tag) { public CompletableFuture<Void> createTag(DocumentTag tag) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
TagEntity tagEntity = convertDocumentTagToTagEntity(tag); TagEntity tagEntity = convertDocumentTagToTagEntity(tag);
if (Objects.isNull(tagEntity.id) || tagEntity.id.isEmpty()) {
tagEntity.id = UUID.randomUUID().toString();
}
database.tagDao().insert(tagEntity); database.tagDao().insert(tagEntity);
logger.debug("LacertaLibraryImpl", "Database Query: Inserted TagEntity (" + tag.getId() + ")"); logger.debug("LacertaLibraryImpl", "Database Query: Inserted TagEntity (" + tag.getId() + ")");
return null; return null;