From b05ee22c295238b39f8c05687d6b746d8fb4f0dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Mon, 22 Jan 2024 11:34:03 +0900 Subject: [PATCH] =?UTF-8?q?createFolder=E9=96=A2=E6=95=B0=E5=AE=9F?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/data/LacertaLibrary.java | 3 +++ .../lacerta/data/impl/LacertaLibraryImpl.java | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java index cb19b425..6d424179 100644 --- a/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java +++ b/data/src/main/java/one/nem/lacerta/data/LacertaLibrary.java @@ -21,4 +21,7 @@ public interface LacertaLibrary { CompletableFuture getLibraryPage(String pageId, int limit); CompletableFuture getLibraryPage(String pageId, int limit, int offset); + // Create Folder + CompletableFuture createFolder(String path, String name); + } 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 7fcf9cb5..7d7f7aaa 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 @@ -5,6 +5,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.inject.Inject; @@ -13,6 +14,7 @@ import one.nem.lacerta.data.LacertaLibrary; import one.nem.lacerta.model.LibraryItemPage; import one.nem.lacerta.model.ListItem; import one.nem.lacerta.model.ListItemType; +import one.nem.lacerta.model.PublicPath; import one.nem.lacerta.model.document.DocumentDetail; import one.nem.lacerta.source.database.LacertaDatabase; import one.nem.lacerta.source.database.common.DateTypeConverter; @@ -143,4 +145,26 @@ public class LacertaLibraryImpl implements LacertaLibrary { return null; }); } + + @Override + public CompletableFuture createFolder(String parentId, String name) { + return CompletableFuture.supplyAsync(() -> { + + FolderEntity parentFolderEntity = database.folderDao().findById(parentId); + PublicPath publicPath; + if (parentFolderEntity == null) { + publicPath = new PublicPath().resolve("/"); + } else { + publicPath = new PublicPath().resolve(parentFolderEntity.publicPath); + } + publicPath = publicPath.resolve(name); + + FolderEntity folderEntity = new FolderEntity(); + folderEntity.id = UUID.randomUUID().toString(); + folderEntity.name = name; + folderEntity.publicPath = publicPath.toString(); + database.folderDao().insert(folderEntity); + return folderEntity.id; + }); + } }