style(format): run ktlint format

This commit is contained in:
ITQ
2026-05-03 21:08:43 +03:00
parent 9c7a562323
commit d9f45a9e4c
6 changed files with 49 additions and 48 deletions
@@ -62,10 +62,11 @@ class FilmRepository(
) )
override fun findByTitle(title: String): Film? { override fun findByTitle(title: String): Film? {
val films = jdbc.query( val films =
jdbc.query(
"SELECT id, title, description FROM films WHERE title = ?", "SELECT id, title, description FROM films WHERE title = ?",
filmRowMapper, filmRowMapper,
title title,
) )
return films.firstOrNull() return films.firstOrNull()
} }
@@ -56,7 +56,8 @@ class FilmController(
FilmResponse.fromDomain( FilmResponse.fromDomain(
editFilmUseCase.edit( editFilmUseCase.edit(
id = id, id = id,
command = EditFilmCommand( command =
EditFilmCommand(
title = request.title, title = request.title,
description = request.description, 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,8 +63,9 @@ 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,8 +106,9 @@ 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,7 +61,8 @@ class UserController(
UserResponse.fromDomain( UserResponse.fromDomain(
editUserUseCase.edit( editUserUseCase.edit(
id = id, id = id,
command = EditUserCommand( command =
EditUserCommand(
name = request.name, 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,7 +36,8 @@ class FilmService(
throw BlockedValueException(target = "Film", field = "description") throw BlockedValueException(target = "Film", field = "description")
} }
val film = Film( val film =
Film(
id = idGenerator.generateId(), id = idGenerator.generateId(),
title = command.title, title = command.title,
description = command.description, description = command.description,
@@ -45,7 +45,10 @@ class FilmService(
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,13 +26,13 @@ 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 =
User(
id = idGenerator.generateId(), id = idGenerator.generateId(),
name = command.name, name = command.name,
email = command.email, email = command.email,
@@ -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()
} }