From e0d63122bdf695e7d45ee58bf2ccad6862678a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=8D=E3=82=80=E3=81=AD=E3=81=93?= Date: Wed, 17 Jan 2024 12:52:13 +0900 Subject: [PATCH] =?UTF-8?q?getRecentDocument=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lacerta/data/impl/LacertaLibraryImpl.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 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 bf6a8a8f..01a7209f 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 @@ -1,14 +1,19 @@ package one.nem.lacerta.data.impl; +import java.text.DateFormat; import java.util.ArrayList; +import java.util.List; import javax.inject.Inject; 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.document.DocumentDetail; import one.nem.lacerta.source.database.LacertaDatabase; +import one.nem.lacerta.source.database.common.DateTypeConverter; +import one.nem.lacerta.source.database.entity.DocumentEntity; import one.nem.lacerta.utils.LacertaLogger; public class LacertaLibraryImpl implements LacertaLibrary { @@ -21,12 +26,23 @@ public class LacertaLibraryImpl implements LacertaLibrary { @Override public ArrayList getRecentDocument(int limit) { - return null; + List documentEntities = database.documentDao().getRecentDocument(limit); + + ArrayList listItems = new ArrayList<>(); + for (DocumentEntity documentEntity : documentEntities) { + ListItem listItem = new ListItem(); + listItem.setItemType(ListItemType.ITEM_TYPE_DOCUMENT); + listItem.setTitle(documentEntity.title); + listItem.setDescription(DateFormat.getDateInstance().format(documentEntity.updatedAt)); + listItem.setItemId(documentEntity.id); + listItems.add(listItem); + } + return listItems; } @Override public ArrayList getRecentDocument(int limit, int offset) { - return null; + return null; // TODO-rca: Implement } @Override