From de30eb241c49e3626f33db4f2dba4df736fd71a1 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 22 Jan 2024 23:29:49 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E3=82=92=E6=AD=A3=E5=B8=B8=E3=81=AB=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=AA?= =?UTF-8?q?=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 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 2403426e..2d5d1f93 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 @@ -71,16 +71,29 @@ public class LacertaLibraryImpl implements LacertaLibrary { return CompletableFuture.supplyAsync(() -> { LibraryItemPage libraryItemPage = new LibraryItemPage(); - FolderEntity folderEntity = database.folderDao().findById(pageId); - if (folderEntity == null) { - logger.warn("LacertaLibraryImpl", pageId + " is not found."); - return null; - } + List folderEntities; + List documentEntities; - List folderEntities = database.folderDao().findByParentId(pageId); - logger.debug("LacertaLibraryImpl", "folderEntities.size(): " + folderEntities.size()); - List documentEntities = database.documentDao().findByParentId(pageId); - logger.debug("LacertaLibraryImpl", "documentEntities.size(): " + documentEntities.size()); + if (pageId == null) { // When root folder + libraryItemPage.setPageTitle("ライブラリ"); + libraryItemPage.setPageId(null); + libraryItemPage.setParentId(null); + + folderEntities = database.folderDao().findRootFolders(); + documentEntities = database.documentDao().findRootDocuments(); + } else { + FolderEntity folderEntity = database.folderDao().findById(pageId); + if (folderEntity == null) { + logger.warn("LacertaLibraryImpl", pageId + " is not found."); + return null; + } + libraryItemPage.setPageTitle(folderEntity.name); + libraryItemPage.setPageId(folderEntity.id); + libraryItemPage.setParentId(folderEntity.parentId); + + folderEntities = database.folderDao().findByParentId(pageId); + documentEntities = database.documentDao().findByParentId(pageId); + } ArrayList listItems = new ArrayList<>(); for (FolderEntity childFolderEntity : folderEntities) { @@ -103,9 +116,6 @@ public class LacertaLibraryImpl implements LacertaLibrary { listItems.add(listItem); } - libraryItemPage.setPageTitle(folderEntity.name); - libraryItemPage.setPageId(folderEntity.id); - libraryItemPage.setParentId(folderEntity.parentId); libraryItemPage.setListItems(listItems); logger.debug("LacertaLibraryImpl", "libraryItemPage.getListItems().size(): " + libraryItemPage.getListItems().size());