fix(): merge conflicts
This commit is contained in:
@@ -17,7 +17,6 @@ import com.project.movienight.application.ports.output.IdGenerator
|
|||||||
import com.project.movienight.domain.exception.DomainException
|
import com.project.movienight.domain.exception.DomainException
|
||||||
import com.project.movienight.domain.exception.EntityNotFoundException
|
import com.project.movienight.domain.exception.EntityNotFoundException
|
||||||
import com.project.movienight.domain.model.FilmLibrary
|
import com.project.movienight.domain.model.FilmLibrary
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@@ -32,28 +31,14 @@ class FilmLibraryService(
|
|||||||
RemoveFilmFromLibraryUseCase,
|
RemoveFilmFromLibraryUseCase,
|
||||||
GetFilmLibraryUseCase,
|
GetFilmLibraryUseCase,
|
||||||
ListFilmLibraryEntriesUseCase {
|
ListFilmLibraryEntriesUseCase {
|
||||||
private val log = LoggerFactory.getLogger(javaClass)
|
|
||||||
|
|
||||||
override fun create(command: CreateFilmLibraryCommand): FilmLibrary {
|
override fun create(command: CreateFilmLibraryCommand): FilmLibrary {
|
||||||
log.info("Creating film library for user: {}", command.userId)
|
findByUserId(command.userId)?.let { return it }
|
||||||
log.debug("Create library request: userId={}, name={}", command.userId, command.name)
|
|
||||||
|
|
||||||
val existing = findByUserId(command.userId)
|
|
||||||
if (existing != null) {
|
|
||||||
log.debug("Library already exists for user {}: libraryId={}", command.userId, existing.id)
|
|
||||||
return existing
|
|
||||||
}
|
|
||||||
|
|
||||||
log.warn("Library not found for user {}, cannot create", command.userId)
|
|
||||||
throw EntityNotFoundException(entity = "Film library", id = command.userId.toString())
|
throw EntityNotFoundException(entity = "Film library", id = command.userId.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addFilm(command: AddFilmToLibraryCommand): FilmLibrary {
|
override fun addFilm(command: AddFilmToLibraryCommand): FilmLibrary {
|
||||||
log.info("Adding film to library: userId={}, filmId={}", command.userId, command.filmId)
|
|
||||||
|
|
||||||
val existingEntry = findByUserAndFilmId(command.userId, command.filmId)
|
val existingEntry = findByUserAndFilmId(command.userId, command.filmId)
|
||||||
if (existingEntry != null) {
|
if (existingEntry != null) {
|
||||||
log.debug("Film already in library, resetting as not viewed: entryId={}", existingEntry.id)
|
|
||||||
val saved =
|
val saved =
|
||||||
filmLibraryRepository.save(
|
filmLibraryRepository.save(
|
||||||
existingEntry.copy(
|
existingEntry.copy(
|
||||||
@@ -62,12 +47,6 @@ class FilmLibraryService(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
businessMetricsService.recordLibraryEvent()
|
businessMetricsService.recordLibraryEvent()
|
||||||
log.info(
|
|
||||||
"Film re-added to library: userId={}, filmId={}, entryId={}",
|
|
||||||
command.userId,
|
|
||||||
command.filmId,
|
|
||||||
saved.id,
|
|
||||||
)
|
|
||||||
return saved
|
return saved
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,56 +62,34 @@ class FilmLibraryService(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
businessMetricsService.recordLibraryEvent()
|
businessMetricsService.recordLibraryEvent()
|
||||||
log.info(
|
|
||||||
"Film added to library: userId={}, filmId={}, entryId={}",
|
|
||||||
command.userId,
|
|
||||||
command.filmId,
|
|
||||||
saved.id,
|
|
||||||
)
|
|
||||||
return saved
|
return saved
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removeFilm(command: RemoveFilmFromLibraryCommand): FilmLibrary {
|
override fun removeFilm(command: RemoveFilmFromLibraryCommand): FilmLibrary {
|
||||||
log.info("Removing film from library: userId={}, filmId={}", command.userId, command.filmId)
|
|
||||||
|
|
||||||
val existingLibrary =
|
val existingLibrary =
|
||||||
if (command.libraryId != null) {
|
if (command.libraryId != null) {
|
||||||
log.debug("Looking up by libraryId: {}", command.libraryId)
|
|
||||||
filmLibraryRepository.findById(command.libraryId)
|
filmLibraryRepository.findById(command.libraryId)
|
||||||
?: throw EntityNotFoundException(entity = "Film library", id = command.libraryId.toString())
|
?: throw EntityNotFoundException(entity = "Film library", id = command.libraryId.toString())
|
||||||
} else {
|
} else {
|
||||||
log.debug("Looking up by userId and filmId")
|
|
||||||
findByUserAndFilmId(command.userId, command.filmId)
|
findByUserAndFilmId(command.userId, command.filmId)
|
||||||
?: throw EntityNotFoundException(entity = "Film library", id = command.filmId.toString())
|
?: throw EntityNotFoundException(entity = "Film library", id = command.filmId.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existingLibrary.userId != command.userId || existingLibrary.filmId != command.filmId) {
|
if (existingLibrary.userId != command.userId || existingLibrary.filmId != command.filmId) {
|
||||||
log.warn("Film not found in user's library: userId={}, filmId={}", command.userId, command.filmId)
|
|
||||||
throw DomainException("Film with id ${command.filmId} not found in user's library")
|
throw DomainException("Film with id ${command.filmId} not found in user's library")
|
||||||
}
|
}
|
||||||
|
|
||||||
filmLibraryRepository.deleteById(existingLibrary.id)
|
filmLibraryRepository.deleteById(existingLibrary.id)
|
||||||
businessMetricsService.recordLibraryEvent()
|
businessMetricsService.recordLibraryEvent()
|
||||||
log.info(
|
|
||||||
"Film removed from library: userId={}, filmId={}, entryId={}",
|
|
||||||
command.userId,
|
|
||||||
command.filmId,
|
|
||||||
existingLibrary.id,
|
|
||||||
)
|
|
||||||
return existingLibrary
|
return existingLibrary
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun markViewed(command: MarkFilmViewedCommand): FilmLibrary {
|
override fun markViewed(command: MarkFilmViewedCommand): FilmLibrary {
|
||||||
log.info("Marking film as viewed: userId={}, filmId={}", command.userId, command.filmId)
|
|
||||||
|
|
||||||
val existingEntry = findByUserAndFilmId(command.userId, command.filmId)
|
val existingEntry = findByUserAndFilmId(command.userId, command.filmId)
|
||||||
val watchedAt = command.watchedAt ?: java.time.LocalDateTime.now()
|
val watchedAt = command.watchedAt ?: java.time.LocalDateTime.now()
|
||||||
|
|
||||||
log.debug("Marking as viewed at: {}", watchedAt)
|
|
||||||
|
|
||||||
val saved =
|
val saved =
|
||||||
if (existingEntry == null) {
|
if (existingEntry == null) {
|
||||||
log.debug("Film not in library, creating new entry as viewed")
|
|
||||||
filmLibraryRepository.save(
|
filmLibraryRepository.save(
|
||||||
FilmLibrary(
|
FilmLibrary(
|
||||||
id = idGenerator.generateId(),
|
id = idGenerator.generateId(),
|
||||||
@@ -144,11 +101,6 @@ class FilmLibraryService(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
log.debug(
|
|
||||||
"Updating existing entry: entryId={}, was viewed={}",
|
|
||||||
existingEntry.id,
|
|
||||||
existingEntry.isViewed,
|
|
||||||
)
|
|
||||||
filmLibraryRepository.save(
|
filmLibraryRepository.save(
|
||||||
existingEntry.copy(
|
existingEntry.copy(
|
||||||
isViewed = true,
|
isViewed = true,
|
||||||
@@ -157,41 +109,20 @@ class FilmLibraryService(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
businessMetricsService.recordLibraryEvent()
|
businessMetricsService.recordLibraryEvent()
|
||||||
log.info(
|
|
||||||
"Film marked as viewed: userId={}, filmId={}, entryId={}",
|
|
||||||
command.userId,
|
|
||||||
command.filmId,
|
|
||||||
saved.id,
|
|
||||||
)
|
|
||||||
return saved
|
return saved
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getLibrary(query: GetFilmLibraryQuery): FilmLibrary {
|
override fun getLibrary(query: GetFilmLibraryQuery): FilmLibrary =
|
||||||
log.debug("Getting library for user: {}", query.userId)
|
findByUserId(query.userId)
|
||||||
val library =
|
?: throw EntityNotFoundException(entity = "Film library", id = query.userId.toString())
|
||||||
findByUserId(query.userId)
|
|
||||||
?: throw EntityNotFoundException(entity = "Film library", id = query.userId.toString())
|
|
||||||
log.debug("Library found: userId={}, libraryId={}", query.userId, library.id)
|
|
||||||
return library
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun list(userId: UUID): List<FilmLibrary> {
|
override fun list(userId: UUID): List<FilmLibrary> = filmLibraryRepository.findAll().filter { it.userId == userId }
|
||||||
log.debug("Listing all library entries for user: {}", userId)
|
|
||||||
val entries = filmLibraryRepository.findAll().filter { it.userId == userId }
|
|
||||||
log.info("User {} has {} films in library", userId, entries.size)
|
|
||||||
return entries
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun findByUserId(userId: UUID): FilmLibrary? =
|
private fun findByUserId(userId: UUID): FilmLibrary? =
|
||||||
filmLibraryRepository.findAll().firstOrNull {
|
filmLibraryRepository.findAll().firstOrNull { it.userId == userId }
|
||||||
it.userId == userId
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun findByUserAndFilmId(
|
private fun findByUserAndFilmId(
|
||||||
userId: UUID,
|
userId: UUID,
|
||||||
filmId: UUID,
|
filmId: UUID,
|
||||||
): FilmLibrary? =
|
): FilmLibrary? = filmLibraryRepository.findAll().firstOrNull { it.userId == userId && it.filmId == filmId }
|
||||||
filmLibraryRepository.findAll().firstOrNull {
|
|
||||||
it.userId == userId && it.filmId == filmId
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,25 +36,22 @@ class FilmService(
|
|||||||
private val log = LoggerFactory.getLogger(javaClass)
|
private val log = LoggerFactory.getLogger(javaClass)
|
||||||
|
|
||||||
override fun create(command: CreateFilmCommand): Film {
|
override fun create(command: CreateFilmCommand): Film {
|
||||||
log.info("Creating new film: title='{}', contentType={}", command.title, command.contentType)
|
|
||||||
log.debug(
|
|
||||||
"Create film request details: title='{}', descriptionLength={}, genres={}, releaseYear={}",
|
|
||||||
command.title,
|
|
||||||
command.description.length,
|
|
||||||
command.genres,
|
|
||||||
command.releaseYear,
|
|
||||||
)
|
|
||||||
|
|
||||||
val sample = Timer.start(meterRegistry)
|
val sample = Timer.start(meterRegistry)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
log.debug(
|
||||||
|
"Create film request received: title='{}', descriptionLength={}",
|
||||||
|
command.title,
|
||||||
|
command.description.length,
|
||||||
|
)
|
||||||
|
|
||||||
if (filmConfig.isBlocked(command.title)) {
|
if (filmConfig.isBlocked(command.title)) {
|
||||||
log.warn("Film creation blocked: title contains blocked pattern '{}'", command.title)
|
log.debug("Create film blocked by title policy: title='{}'", command.title)
|
||||||
filmBlockedCounter.increment()
|
filmBlockedCounter.increment()
|
||||||
throw BlockedValueException(target = "Film", field = "title")
|
throw BlockedValueException(target = "Film", field = "title")
|
||||||
}
|
}
|
||||||
if (filmConfig.isBlocked(command.description)) {
|
if (filmConfig.isBlocked(command.description)) {
|
||||||
log.warn("Film creation blocked: description contains blocked pattern")
|
log.debug("Create film blocked by description policy")
|
||||||
filmBlockedCounter.increment()
|
filmBlockedCounter.increment()
|
||||||
throw BlockedValueException(target = "Film", field = "description")
|
throw BlockedValueException(target = "Film", field = "description")
|
||||||
}
|
}
|
||||||
@@ -78,7 +75,6 @@ class FilmService(
|
|||||||
|
|
||||||
val saved = filmRepository.save(film)
|
val saved = filmRepository.save(film)
|
||||||
filmCreatedCounter.increment()
|
filmCreatedCounter.increment()
|
||||||
log.info("Film created successfully: id={}, title='{}'", saved.id, saved.title)
|
|
||||||
return saved
|
return saved
|
||||||
} finally {
|
} finally {
|
||||||
sample.stop(createFilmTimer)
|
sample.stop(createFilmTimer)
|
||||||
@@ -89,25 +85,18 @@ class FilmService(
|
|||||||
id: UUID,
|
id: UUID,
|
||||||
command: EditFilmCommand,
|
command: EditFilmCommand,
|
||||||
): Film {
|
): Film {
|
||||||
log.info("Editing film: id={}", id)
|
|
||||||
log.debug(
|
|
||||||
"Edit film request details: id={}, title='{}', descriptionLength={}, genres={}",
|
|
||||||
id,
|
|
||||||
command.title,
|
|
||||||
command.description.length,
|
|
||||||
command.genres,
|
|
||||||
)
|
|
||||||
|
|
||||||
val sample = Timer.start(meterRegistry)
|
val sample = Timer.start(meterRegistry)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
log.debug("Edit film with id: {}", id)
|
||||||
|
|
||||||
if (filmConfig.isBlocked(command.title)) {
|
if (filmConfig.isBlocked(command.title)) {
|
||||||
log.warn("Film edit blocked: title contains blocked pattern '{}'", command.title)
|
log.debug("Edit film blocked by title policy: title='{}'", command.title)
|
||||||
filmBlockedCounter.increment()
|
filmBlockedCounter.increment()
|
||||||
throw BlockedValueException(target = "Film", field = "title")
|
throw BlockedValueException(target = "Film", field = "title")
|
||||||
}
|
}
|
||||||
if (filmConfig.isBlocked(command.description)) {
|
if (filmConfig.isBlocked(command.description)) {
|
||||||
log.warn("Film edit blocked: description contains blocked pattern")
|
log.debug("Edit film blocked by description policy")
|
||||||
filmBlockedCounter.increment()
|
filmBlockedCounter.increment()
|
||||||
throw BlockedValueException(target = "Film", field = "description")
|
throw BlockedValueException(target = "Film", field = "description")
|
||||||
}
|
}
|
||||||
@@ -115,12 +104,10 @@ class FilmService(
|
|||||||
var film = filmRepository.findById(id)
|
var film = filmRepository.findById(id)
|
||||||
|
|
||||||
if (film == null) {
|
if (film == null) {
|
||||||
log.warn("Film not found for edit: id='{}'", id)
|
log.debug("Film not found for edit: id='{}'", id)
|
||||||
throw EntityNotFoundException(entity = "Film", id = id.toString())
|
throw EntityNotFoundException(entity = "Film", id = id.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Existing film found: id={}, current title='{}'", film.id, film.title)
|
|
||||||
|
|
||||||
film =
|
film =
|
||||||
film.copy(
|
film.copy(
|
||||||
title = command.title,
|
title = command.title,
|
||||||
@@ -139,7 +126,6 @@ class FilmService(
|
|||||||
|
|
||||||
val saved = filmRepository.save(film)
|
val saved = filmRepository.save(film)
|
||||||
filmEditedCounter.increment()
|
filmEditedCounter.increment()
|
||||||
log.info("Film edited successfully: id={}, new title='{}'", saved.id, saved.title)
|
|
||||||
return saved
|
return saved
|
||||||
} finally {
|
} finally {
|
||||||
sample.stop(editFilmTimer)
|
sample.stop(editFilmTimer)
|
||||||
@@ -147,54 +133,34 @@ class FilmService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun delete(id: UUID) {
|
override fun delete(id: UUID) {
|
||||||
log.info("Deleting film: id={}", id)
|
|
||||||
|
|
||||||
val sample = Timer.start(meterRegistry)
|
val sample = Timer.start(meterRegistry)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
log.debug("Delete film with id: {}", id)
|
||||||
|
|
||||||
val film = filmRepository.findById(id)
|
val film = filmRepository.findById(id)
|
||||||
|
|
||||||
if (film == null) {
|
if (film == null) {
|
||||||
log.warn("Film not found for delete: id='{}'", id)
|
log.debug("Film not found for delete: id='{}'", id)
|
||||||
throw EntityNotFoundException(entity = "Film", id = id.toString())
|
throw EntityNotFoundException(entity = "Film", id = id.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Film found for deletion: id={}, title='{}'", film.id, film.title)
|
|
||||||
|
|
||||||
filmRepository.deleteById(id)
|
filmRepository.deleteById(id)
|
||||||
|
|
||||||
filmDeletedCounter.increment()
|
filmDeletedCounter.increment()
|
||||||
log.info("Film deleted successfully: id={}, title='{}'", id, film.title)
|
|
||||||
|
log.info("Film deleted: id='{}'", id)
|
||||||
} finally {
|
} finally {
|
||||||
sample.stop(deleteFilmTimer)
|
sample.stop(deleteFilmTimer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getById(id: UUID): Film {
|
override fun getById(id: UUID): Film =
|
||||||
log.debug("Fetching film by id: {}", id)
|
filmRepository.findById(id) ?: throw EntityNotFoundException(entity = "Film", id = id.toString())
|
||||||
val film =
|
|
||||||
filmRepository.findById(id)
|
|
||||||
?: throw EntityNotFoundException(entity = "Film", id = id.toString())
|
|
||||||
log.debug("Film found: id={}, title='{}'", film.id, film.title)
|
|
||||||
return film
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAll(): List<Film> {
|
override fun getAll(): List<Film> = filmRepository.findAll()
|
||||||
log.debug("Fetching all films")
|
|
||||||
val films = filmRepository.findAll()
|
|
||||||
log.info("Retrieved {} films from database", films.size)
|
|
||||||
return films
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun searchByTitle(title: String): Film? {
|
override fun searchByTitle(title: String): Film? = filmRepository.findByTitle(title)
|
||||||
log.debug("Searching film by title: '{}'", title)
|
|
||||||
val film = filmRepository.findByTitle(title)
|
|
||||||
if (film != null) {
|
|
||||||
log.info("Film found by title '{}': id={}", title, film.id)
|
|
||||||
} else {
|
|
||||||
log.debug("No film found with title: '{}'", title)
|
|
||||||
}
|
|
||||||
return film
|
|
||||||
}
|
|
||||||
|
|
||||||
private val filmCreatedCounter =
|
private val filmCreatedCounter =
|
||||||
Counter
|
Counter
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import com.project.movienight.config.UserServiceProperties
|
|||||||
import com.project.movienight.domain.exception.BlockedValueException
|
import com.project.movienight.domain.exception.BlockedValueException
|
||||||
import com.project.movienight.domain.exception.EntityNotFoundException
|
import com.project.movienight.domain.exception.EntityNotFoundException
|
||||||
import com.project.movienight.domain.model.User
|
import com.project.movienight.domain.model.User
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
import org.springframework.stereotype.Service
|
import org.springframework.stereotype.Service
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
@@ -27,14 +26,8 @@ class UserService(
|
|||||||
DeleteUserUseCase,
|
DeleteUserUseCase,
|
||||||
GetUserByIdUseCase,
|
GetUserByIdUseCase,
|
||||||
GetAllUsersUseCase {
|
GetAllUsersUseCase {
|
||||||
private val log = LoggerFactory.getLogger(javaClass)
|
|
||||||
|
|
||||||
override fun create(command: CreateUserCommand): User {
|
override fun create(command: CreateUserCommand): User {
|
||||||
log.info("Creating new user with email: {}", command.email)
|
|
||||||
log.debug("Create user request: name='{}', email='{}'", command.name, command.email)
|
|
||||||
|
|
||||||
if (userConfig.isBlocked(command.name)) {
|
if (userConfig.isBlocked(command.name)) {
|
||||||
log.warn("User creation blocked: name contains blocked pattern '{}'", command.name)
|
|
||||||
throw BlockedValueException(target = "User", field = "name")
|
throw BlockedValueException(target = "User", field = "name")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,29 +39,18 @@ class UserService(
|
|||||||
library = null,
|
library = null,
|
||||||
jellyfinUserId = null,
|
jellyfinUserId = null,
|
||||||
)
|
)
|
||||||
val saved = userRepository.save(user)
|
return userRepository.save(user)
|
||||||
|
|
||||||
log.info("User created successfully: id={}, email='{}'", saved.id, saved.email)
|
|
||||||
return saved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun edit(
|
override fun edit(
|
||||||
id: UUID,
|
id: UUID,
|
||||||
command: EditUserCommand,
|
command: EditUserCommand,
|
||||||
): User {
|
): User {
|
||||||
log.info("Editing user: id={}", id)
|
|
||||||
log.debug("Edit user request: id={}, name='{}', jellyfinUserId={}", id, command.name, command.jellyfinUserId)
|
|
||||||
|
|
||||||
if (userConfig.isBlocked(command.name)) {
|
if (userConfig.isBlocked(command.name)) {
|
||||||
log.warn("User edit blocked: name contains blocked pattern '{}'", command.name)
|
|
||||||
throw BlockedValueException(target = "User", field = "name")
|
throw BlockedValueException(target = "User", field = "name")
|
||||||
}
|
}
|
||||||
|
|
||||||
var user =
|
var user = userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
||||||
userRepository.findById(id)
|
|
||||||
?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
|
||||||
|
|
||||||
log.debug("Existing user found: id={}, current name='{}'", user.id, user.name)
|
|
||||||
|
|
||||||
user =
|
user =
|
||||||
user.copy(
|
user.copy(
|
||||||
@@ -76,38 +58,16 @@ class UserService(
|
|||||||
jellyfinUserId = command.jellyfinUserId ?: user.jellyfinUserId,
|
jellyfinUserId = command.jellyfinUserId ?: user.jellyfinUserId,
|
||||||
)
|
)
|
||||||
|
|
||||||
val saved = userRepository.save(user)
|
return userRepository.save(user)
|
||||||
log.info("User edited successfully: id={}, new name='{}'", saved.id, saved.name)
|
|
||||||
return saved
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun delete(id: UUID) {
|
override fun delete(id: UUID) {
|
||||||
log.info("Deleting user: id={}", id)
|
userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
||||||
log.debug("Delete user request: id={}", id)
|
|
||||||
|
|
||||||
val user =
|
|
||||||
userRepository.findById(id)
|
|
||||||
?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
|
||||||
|
|
||||||
log.debug("User found for deletion: id={}, email='{}'", user.id, user.email)
|
|
||||||
|
|
||||||
userRepository.deleteById(id)
|
userRepository.deleteById(id)
|
||||||
log.info("User deleted successfully: id={}", id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getById(id: UUID): User {
|
override fun getById(id: UUID): User =
|
||||||
log.debug("Fetching user by id: {}", id)
|
userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
||||||
val user =
|
|
||||||
userRepository.findById(id)
|
|
||||||
?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
|
||||||
log.debug("User found: id={}, name='{}', email='{}'", user.id, user.name, user.email)
|
|
||||||
return user
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getAll(): List<User> {
|
override fun getAll(): List<User> = userRepository.findAll()
|
||||||
log.debug("Fetching all users")
|
|
||||||
val users = userRepository.findAll()
|
|
||||||
log.info("Retrieved {} users from database", users.size)
|
|
||||||
return users
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user