Move packages + remove circular dependencies
This commit is contained in:
+10
-9
@@ -1,19 +1,20 @@
|
||||
package be.simplenotes.persistance
|
||||
|
||||
import be.simplenotes.domain.usecases.repositories.NoteRepository
|
||||
import be.simplenotes.domain.usecases.repositories.UserRepository
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.converters.UserConverter
|
||||
import be.simplenotes.persistance.notes.NoteRepositoryImpl
|
||||
import be.simplenotes.persistance.users.UserRepositoryImpl
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.converters.NoteConverterImpl
|
||||
import be.simplenotes.persistance.converters.UserConverter
|
||||
import be.simplenotes.persistance.converters.UserConverterImpl
|
||||
import be.simplenotes.persistance.notes.NoteRepositoryImpl
|
||||
import be.simplenotes.persistance.repositories.NoteRepository
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.persistance.users.UserRepositoryImpl
|
||||
import com.zaxxer.hikari.HikariConfig
|
||||
import com.zaxxer.hikari.HikariDataSource
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import org.koin.dsl.bind
|
||||
import org.koin.dsl.module
|
||||
import org.koin.dsl.onClose
|
||||
import org.mapstruct.factory.Mappers
|
||||
import javax.sql.DataSource
|
||||
|
||||
private fun hikariDataSource(conf: DataSourceConfig): HikariDataSource {
|
||||
@@ -33,8 +34,8 @@ val migrationModule = module {
|
||||
}
|
||||
|
||||
val persistanceModule = module {
|
||||
single { Mappers.getMapper(NoteConverter::class.java) }
|
||||
single { Mappers.getMapper(UserConverter::class.java) }
|
||||
single<NoteConverter> { NoteConverterImpl() }
|
||||
single<UserConverter> { UserConverterImpl() }
|
||||
single<UserRepository> { UserRepositoryImpl(get(), get()) }
|
||||
single<NoteRepository> { NoteRepositoryImpl(get(), get()) }
|
||||
single { hikariDataSource(get()) } bind DataSource::class onClose { it?.close() }
|
||||
+1
-1
@@ -4,8 +4,8 @@ import be.simplenotes.types.ExportedNote
|
||||
import be.simplenotes.types.Note
|
||||
import be.simplenotes.types.PersistedNote
|
||||
import be.simplenotes.types.PersistedNoteMetadata
|
||||
import be.simplenotes.domain.usecases.repositories.NoteRepository
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.repositories.NoteRepository
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.dsl.*
|
||||
import me.liuwj.ktorm.entity.*
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package be.simplenotes.persistance.repositories
|
||||
|
||||
import be.simplenotes.types.ExportedNote
|
||||
import be.simplenotes.types.Note
|
||||
import be.simplenotes.types.PersistedNote
|
||||
import be.simplenotes.types.PersistedNoteMetadata
|
||||
import java.util.*
|
||||
|
||||
interface NoteRepository {
|
||||
|
||||
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 export(userId: Int): List<ExportedNote>
|
||||
fun findAllDetails(userId: Int): List<PersistedNote>
|
||||
|
||||
fun makePublic(userId: Int, uuid: UUID): Boolean
|
||||
fun makePrivate(userId: Int, uuid: UUID): Boolean
|
||||
fun findPublic(uuid: UUID): PersistedNote?
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package be.simplenotes.persistance.repositories
|
||||
|
||||
import be.simplenotes.types.PersistedUser
|
||||
import be.simplenotes.types.User
|
||||
|
||||
interface UserRepository {
|
||||
fun create(user: User): PersistedUser?
|
||||
fun find(username: String): PersistedUser?
|
||||
fun find(id: Int): PersistedUser?
|
||||
fun exists(username: String): Boolean
|
||||
fun exists(id: Int): Boolean
|
||||
fun delete(id: Int): Boolean
|
||||
fun findAll(): List<Int>
|
||||
}
|
||||
+1
-1
@@ -2,8 +2,8 @@ package be.simplenotes.persistance.users
|
||||
|
||||
import be.simplenotes.types.PersistedUser
|
||||
import be.simplenotes.types.User
|
||||
import be.simplenotes.domain.usecases.repositories.UserRepository
|
||||
import be.simplenotes.persistance.converters.UserConverter
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.dsl.*
|
||||
import me.liuwj.ktorm.entity.any
|
||||
@@ -0,0 +1,18 @@
|
||||
module simplenotes.persistance {
|
||||
requires kotlin.stdlib;
|
||||
|
||||
exports be.simplenotes.persistance to simplenotes.app;
|
||||
exports be.simplenotes.persistance.repositories to simplenotes.domain;
|
||||
|
||||
requires simplenotes.types;
|
||||
|
||||
requires ktorm.core;
|
||||
requires java.sql;
|
||||
requires simplenotes.config;
|
||||
requires kotlin.stdlib.jdk7;
|
||||
requires java.compiler;
|
||||
requires org.mapstruct;
|
||||
requires org.flywaydb.core;
|
||||
requires com.zaxxer.hikari;
|
||||
requires koin.core;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package be.simplenotes.persistance
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package be.simplenotes.persistance.converters
|
||||
|
||||
import be.simplenotes.types.*
|
||||
import be.simplenotes.persistance.notes.NoteEntity
|
||||
import be.simplenotes.types.*
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.Nested
|
||||
+4
-3
@@ -1,13 +1,14 @@
|
||||
package be.simplenotes.persistance.notes
|
||||
|
||||
import be.simplenotes.types.*
|
||||
import be.simplenotes.domain.usecases.repositories.NoteRepository
|
||||
import be.simplenotes.domain.usecases.repositories.UserRepository
|
||||
import be.simplenotes.persistance.DbMigrations
|
||||
import be.simplenotes.persistance.converters.NoteConverter
|
||||
import be.simplenotes.persistance.migrationModule
|
||||
import be.simplenotes.persistance.persistanceModule
|
||||
import be.simplenotes.config.DataSourceConfig
|
||||
import be.simplenotes.persistance.repositories.NoteRepository
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.types.*
|
||||
import be.simplenotes.types.*
|
||||
import me.liuwj.ktorm.database.Database
|
||||
import me.liuwj.ktorm.dsl.eq
|
||||
import me.liuwj.ktorm.entity.filter
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package be.simplenotes.persistance.users
|
||||
|
||||
import be.simplenotes.types.User
|
||||
import be.simplenotes.domain.usecases.repositories.UserRepository
|
||||
import be.simplenotes.persistance.repositories.UserRepository
|
||||
import be.simplenotes.persistance.DbMigrations
|
||||
import be.simplenotes.persistance.migrationModule
|
||||
import be.simplenotes.persistance.persistanceModule
|
||||
Reference in New Issue
Block a user