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