Persistance: Note can now be put in the trash

This commit is contained in:
2020-08-17 18:51:33 +02:00
parent 4e2fe463e0
commit 15de81394c
8 changed files with 120 additions and 34 deletions
@@ -38,7 +38,10 @@ class NoteService(
}
fun find(userId: Int, uuid: UUID) = noteRepository.find(userId, uuid)
fun delete(userId: Int, uuid: UUID) = noteRepository.delete(userId, uuid)
fun trash(userId: Int, uuid: UUID) = noteRepository.delete(userId, uuid, permanent = false)
fun restore(userId: Int, uuid: UUID) = noteRepository.restore(userId, uuid)
fun delete(userId: Int, uuid: UUID) = noteRepository.delete(userId, uuid, permanent = true)
}
data class PaginatedNotes(val pages: Int, val notes: List<PersistedNoteMetadata>)
@@ -6,12 +6,23 @@ import be.simplenotes.domain.model.PersistedNoteMetadata
import java.util.*
interface NoteRepository {
fun findAll(userId: Int, limit: Int = 20, offset: Int = 0, tag: String? = null): List<PersistedNoteMetadata>
fun findAll(
userId: Int,
limit: Int = 20,
offset: Int = 0,
tag: String? = null,
deleted: Boolean = false
): List<PersistedNoteMetadata>
fun count(userId: Int, tag: String? = null, deleted: Boolean = false): Int
fun delete(userId: Int, uuid: UUID, permanent: Boolean = false): Boolean
fun restore(userId: Int, uuid: UUID): Boolean
// These methods only access notes where `Notes.deleted = false`
fun getTags(userId: Int): List<String>
fun exists(userId: Int, uuid: UUID): Boolean
fun create(userId: Int, note: Note): PersistedNote
fun find(userId: Int, uuid: UUID): PersistedNote?
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, tag: String? = null): Int
}