フォルダの一覧を取得するメソッド作成

This commit is contained in:
ろむねこ 2024-01-25 12:07:48 +09:00
parent 03d78b1200
commit ccfed654df
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
2 changed files with 28 additions and 0 deletions

View File

@ -20,6 +20,9 @@ public interface LacertaLibrary {
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit); CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit);
CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset); CompletableFuture<LibraryItemPage> getLibraryPage(String pageId, int limit, int offset);
// Get Folder List
CompletableFuture<ArrayList<ListItem>> getFolderList(String parentId);
// Create Folder // Create Folder
CompletableFuture<String> createFolder(String parentId, String name); CompletableFuture<String> createFolder(String parentId, String name);

View File

@ -127,6 +127,31 @@ public class LacertaLibraryImpl implements LacertaLibrary {
}); });
} }
@Override
public CompletableFuture<ArrayList<ListItem>> getFolderList(String parentId) {
return CompletableFuture.supplyAsync(() -> {
List<FolderEntity> folderEntities;
if (parentId == null) { // When root folder
folderEntities = database.folderDao().findRootFolders();
} else {
folderEntities = database.folderDao().findByParentId(parentId);
}
ArrayList<ListItem> listItems = new ArrayList<>();
for (FolderEntity childFolderEntity : folderEntities) {
logger.debug("LacertaLibraryImpl", "childFolderEntity.name: " + childFolderEntity.name);
ListItem listItem = new ListItem();
listItem.setItemType(ListItemType.ITEM_TYPE_FOLDER);
listItem.setTitle(childFolderEntity.name);
listItem.setDescription("フォルダ"); // TODO-rca: ハードコーディングやめる
listItem.setItemId(childFolderEntity.id);
listItems.add(listItem);
}
return listItems;
});
}
@Override @Override
public CompletableFuture<String> createFolder(String parentId, String name) { public CompletableFuture<String> createFolder(String parentId, String name) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {