chore(adapters/persistence): removed inmemory adapters
This commit is contained in:
-35
@@ -1,35 +0,0 @@
|
||||
package com.project.movienight.adapters.persistence.inmemory
|
||||
|
||||
import com.project.movienight.application.ports.output.FilmLibraryRepositoryPort
|
||||
import com.project.movienight.domain.model.FilmLibrary
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@Repository
|
||||
class FilmLibraryRepositoryAdapter : FilmLibraryRepositoryPort {
|
||||
private val storage: MutableMap<UUID, FilmLibrary> = ConcurrentHashMap()
|
||||
private val userIdIndex: MutableMap<UUID, UUID> = ConcurrentHashMap()
|
||||
|
||||
override fun save(filmLibrary: FilmLibrary): FilmLibrary {
|
||||
storage[filmLibrary.id] = filmLibrary
|
||||
userIdIndex[filmLibrary.userId] = filmLibrary.id
|
||||
return filmLibrary
|
||||
}
|
||||
|
||||
override fun findById(id: UUID): FilmLibrary? {
|
||||
return storage[id]
|
||||
}
|
||||
|
||||
override fun findAll(): List<FilmLibrary> {
|
||||
return storage.values.toList()
|
||||
}
|
||||
|
||||
override fun deleteById(id: UUID) {
|
||||
val filmLibrary = storage[id]
|
||||
if (filmLibrary != null) {
|
||||
userIdIndex.remove(filmLibrary.userId)
|
||||
}
|
||||
storage.remove(id)
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.project.movienight.adapters.persistence.inmemory
|
||||
|
||||
import com.project.movienight.application.ports.output.FilmRepositoryPort
|
||||
import com.project.movienight.domain.model.Film
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@Repository
|
||||
class FilmRepositoryAdapter : FilmRepositoryPort {
|
||||
private val films: MutableMap<UUID, Film> = ConcurrentHashMap()
|
||||
|
||||
override fun save(film: Film): Film {
|
||||
films[film.id] = film
|
||||
|
||||
return film
|
||||
}
|
||||
|
||||
override fun findById(id: UUID): Film? = films[id]
|
||||
|
||||
override fun findAll(): List<Film> = films.values.toList()
|
||||
|
||||
override fun deleteById(id: UUID) {
|
||||
films.remove(id)
|
||||
}
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package com.project.movienight.adapters.persistence.inmemory
|
||||
|
||||
import com.project.movienight.application.ports.output.UserRepositoryPort
|
||||
import com.project.movienight.domain.model.User
|
||||
import org.springframework.stereotype.Repository
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@Repository
|
||||
class UserRepositoryAdapter : UserRepositoryPort {
|
||||
private val users: MutableMap<UUID, User> = ConcurrentHashMap()
|
||||
|
||||
override fun save(user: User): User {
|
||||
users[user.id] = user
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
override fun findById(id: UUID): User? = users[id]
|
||||
|
||||
override fun findAll(): List<User> = users.values.toList()
|
||||
|
||||
override fun deleteById(id: UUID) {
|
||||
users.remove(id)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user