Find notes by tags in notes list
This commit is contained in:
@@ -29,11 +29,11 @@ class NoteService(
|
||||
.map { Note(it.metadata, markdown = markdownText, html = it.html) }
|
||||
.map { noteRepository.update(userId, uuid, it) }
|
||||
|
||||
fun paginatedNotes(userId: Int, page: Int, itemsPerPage: Int = 20): PaginatedNotes {
|
||||
val count = noteRepository.count(userId)
|
||||
fun paginatedNotes(userId: Int, page: Int, itemsPerPage: Int = 20, tag: String? = null): PaginatedNotes {
|
||||
val count = noteRepository.count(userId, tag)
|
||||
val offset = (page - 1) * itemsPerPage
|
||||
val numberOfPages = (count / itemsPerPage) + 1
|
||||
val notes = if (count == 0) emptyList() else noteRepository.findAll(userId, itemsPerPage, offset)
|
||||
val notes = if (count == 0) emptyList() else noteRepository.findAll(userId, itemsPerPage, offset, tag)
|
||||
return PaginatedNotes(numberOfPages, notes)
|
||||
}
|
||||
|
||||
|
||||
@@ -13,5 +13,5 @@ interface NoteRepository {
|
||||
fun update(userId: Int, uuid: UUID, note: Note): PersistedNote?
|
||||
fun delete(userId: Int, uuid: UUID): Boolean
|
||||
fun getTags(userId: Int): List<String>
|
||||
fun count(userId: Int): Int
|
||||
fun count(userId: Int, tag: String? = null): Int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user