style(format): run ktlint format
This commit is contained in:
@@ -62,10 +62,11 @@ class FilmRepository(
|
||||
)
|
||||
|
||||
override fun findByTitle(title: String): Film? {
|
||||
val films = jdbc.query(
|
||||
val films =
|
||||
jdbc.query(
|
||||
"SELECT id, title, description FROM films WHERE title = ?",
|
||||
filmRowMapper,
|
||||
title
|
||||
title,
|
||||
)
|
||||
return films.firstOrNull()
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ class FilmController(
|
||||
FilmResponse.fromDomain(
|
||||
editFilmUseCase.edit(
|
||||
id = id,
|
||||
command = EditFilmCommand(
|
||||
command =
|
||||
EditFilmCommand(
|
||||
title = request.title,
|
||||
description = request.description,
|
||||
),
|
||||
@@ -72,16 +73,13 @@ class FilmController(
|
||||
@GetMapping("/{id}")
|
||||
fun getById(
|
||||
@PathVariable id: UUID,
|
||||
): FilmResponse =
|
||||
FilmResponse.fromDomain(getFilmByIdUseCase.getById(id))
|
||||
): FilmResponse = FilmResponse.fromDomain(getFilmByIdUseCase.getById(id))
|
||||
|
||||
@GetMapping("/search")
|
||||
fun searchByTitle(
|
||||
@RequestParam title: String,
|
||||
): FilmResponse? =
|
||||
searchFilmByTitleUseCase.searchByTitle(title)?.let { FilmResponse.fromDomain(it) }
|
||||
): FilmResponse? = searchFilmByTitleUseCase.searchByTitle(title)?.let { FilmResponse.fromDomain(it) }
|
||||
|
||||
@GetMapping
|
||||
fun getAll(): List<FilmResponse> =
|
||||
getAllFilmsUseCase.getAll().map { FilmResponse.fromDomain(it) }
|
||||
fun getAll(): List<FilmResponse> = getAllFilmsUseCase.getAll().map { FilmResponse.fromDomain(it) }
|
||||
}
|
||||
|
||||
@@ -63,8 +63,9 @@ class FilmLibraryController(
|
||||
fun getAllFilmsInLibrary(
|
||||
@PathVariable userId: UUID,
|
||||
): List<FilmResponse> {
|
||||
val library = getFilmLibraryUseCase.getLibrary(
|
||||
GetFilmLibraryQuery(userId = userId)
|
||||
val library =
|
||||
getFilmLibraryUseCase.getLibrary(
|
||||
GetFilmLibraryQuery(userId = userId),
|
||||
)
|
||||
|
||||
val film = getFilmByIdUseCase.getById(library.filmId)
|
||||
@@ -105,8 +106,9 @@ class FilmLibraryController(
|
||||
fun getAvailableFilms(
|
||||
@PathVariable userId: UUID,
|
||||
): List<FilmResponse> {
|
||||
val userLibrary = getFilmLibraryUseCase.getLibrary(
|
||||
GetFilmLibraryQuery(userId = userId)
|
||||
val userLibrary =
|
||||
getFilmLibraryUseCase.getLibrary(
|
||||
GetFilmLibraryQuery(userId = userId),
|
||||
)
|
||||
|
||||
val allFilms = getAllFilmsUseCase.getAll()
|
||||
|
||||
@@ -46,14 +46,12 @@ class UserController(
|
||||
)
|
||||
|
||||
@GetMapping
|
||||
fun getAll(): List<UserResponse> =
|
||||
getAllUsersUseCase.getAll().map { UserResponse.fromDomain(it) }
|
||||
fun getAll(): List<UserResponse> = getAllUsersUseCase.getAll().map { UserResponse.fromDomain(it) }
|
||||
|
||||
@GetMapping("/{id}")
|
||||
fun getById(
|
||||
@PathVariable id: UUID,
|
||||
): UserResponse =
|
||||
UserResponse.fromDomain(getUserByIdUseCase.getById(id))
|
||||
): UserResponse = UserResponse.fromDomain(getUserByIdUseCase.getById(id))
|
||||
|
||||
@PatchMapping("/{id}")
|
||||
fun edit(
|
||||
@@ -63,7 +61,8 @@ class UserController(
|
||||
UserResponse.fromDomain(
|
||||
editUserUseCase.edit(
|
||||
id = id,
|
||||
command = EditUserCommand(
|
||||
command =
|
||||
EditUserCommand(
|
||||
name = request.name,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -28,7 +28,6 @@ class FilmService(
|
||||
GetFilmByIdUseCase,
|
||||
GetAllFilmsUseCase,
|
||||
SearchFilmByTitleUseCase {
|
||||
|
||||
override fun create(command: CreateFilmCommand): Film {
|
||||
if (filmConfig.isBlocked(command.title)) {
|
||||
throw BlockedValueException(target = "Film", field = "title")
|
||||
@@ -37,7 +36,8 @@ class FilmService(
|
||||
throw BlockedValueException(target = "Film", field = "description")
|
||||
}
|
||||
|
||||
val film = Film(
|
||||
val film =
|
||||
Film(
|
||||
id = idGenerator.generateId(),
|
||||
title = command.title,
|
||||
description = command.description,
|
||||
@@ -45,7 +45,10 @@ class FilmService(
|
||||
return filmRepository.save(film)
|
||||
}
|
||||
|
||||
override fun edit(id: UUID, command: EditFilmCommand): Film {
|
||||
override fun edit(
|
||||
id: UUID,
|
||||
command: EditFilmCommand,
|
||||
): Film {
|
||||
if (filmConfig.isBlocked(command.title)) {
|
||||
throw BlockedValueException(target = "Film", field = "title")
|
||||
}
|
||||
@@ -63,9 +66,8 @@ class FilmService(
|
||||
filmRepository.deleteById(id)
|
||||
}
|
||||
|
||||
override fun getById(id: UUID): Film {
|
||||
return filmRepository.findById(id) ?: throw EntityNotFoundException(entity = "Film", id = id.toString())
|
||||
}
|
||||
override fun getById(id: UUID): Film =
|
||||
filmRepository.findById(id) ?: throw EntityNotFoundException(entity = "Film", id = id.toString())
|
||||
|
||||
override fun getAll(): List<Film> = filmRepository.findAll()
|
||||
|
||||
|
||||
@@ -26,13 +26,13 @@ class UserService(
|
||||
DeleteUserUseCase,
|
||||
GetUserByIdUseCase,
|
||||
GetAllUsersUseCase {
|
||||
|
||||
override fun create(command: CreateUserCommand): User {
|
||||
if (userConfig.isBlocked(command.name)) {
|
||||
throw BlockedValueException(target = "User", field = "name")
|
||||
}
|
||||
|
||||
val user = User(
|
||||
val user =
|
||||
User(
|
||||
id = idGenerator.generateId(),
|
||||
name = command.name,
|
||||
email = command.email,
|
||||
@@ -59,9 +59,8 @@ class UserService(
|
||||
userRepository.deleteById(id)
|
||||
}
|
||||
|
||||
override fun getById(id: UUID): User {
|
||||
return userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
||||
}
|
||||
override fun getById(id: UUID): User =
|
||||
userRepository.findById(id) ?: throw EntityNotFoundException(entity = "User", id = id.toString())
|
||||
|
||||
override fun getAll(): List<User> = userRepository.findAll()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user