From 7afaa089c6a5f3b9091f315dc7a33399ceb50f2a Mon Sep 17 00:00:00 2001 From: NikitaOnianov Date: Mon, 27 Jan 2025 14:40:37 +0300 Subject: [PATCH] add menu commands --- src/main/data/UserRepository.kt | 12 ++++ src/main/data/UserRepositoryImpl.kt | 43 +++++++++++ src/main/data/localDataSource.kt | 24 +++++++ src/main/data/model/UserDTO.kt | 11 +++ src/main/kotlin/Main.kt | 42 ++++++++--- src/main/kotlin/data/UserRepository.kt | 12 ++++ src/main/kotlin/data/UserRepositoryImpl.kt | 43 +++++++++++ .../faetures/authorize/AuthorizeRepository.kt | 11 --- .../authorize/AuthorizeRepositoryImpl.kt | 21 ------ .../kotlin/data/faetures/model/UserDTO.kt | 13 ---- src/main/kotlin/data/localDataSource.kt | 24 +++++++ src/main/kotlin/data/model/UserDTO.kt | 11 +++ .../kotlin/domain/Request/AuthorizeRequest.kt | 2 +- .../domain/Request/RegistrationRequest.kt | 5 +- .../kotlin/domain/Response/UserResponse.kt | 16 ++--- .../kotlin/domain/Service/AuthorizeService.kt | 11 --- .../domain/Service/AuthorizeserviceImpl.kt | 17 ----- src/main/kotlin/domain/UserUseCase.kt | 12 ++++ src/main/kotlin/domain/UserUseCaseImpl.kt | 44 ++++++++++++ src/main/kotlin/domain/mapper.kt | 13 ++++ src/main/kotlin/ui/UserUI.kt | 71 +++++++++++++++++++ src/main/kotlin/ui/model/AuthorizeUI.kt | 19 ----- src/main/kotlin/ui/model/UserPresenter.kt | 3 - src/main/ui/UserUI.kt | 71 +++++++++++++++++++ 24 files changed, 436 insertions(+), 115 deletions(-) create mode 100644 src/main/data/UserRepository.kt create mode 100644 src/main/data/UserRepositoryImpl.kt create mode 100644 src/main/data/localDataSource.kt create mode 100644 src/main/data/model/UserDTO.kt create mode 100644 src/main/kotlin/data/UserRepository.kt create mode 100644 src/main/kotlin/data/UserRepositoryImpl.kt delete mode 100644 src/main/kotlin/data/faetures/authorize/AuthorizeRepository.kt delete mode 100644 src/main/kotlin/data/faetures/authorize/AuthorizeRepositoryImpl.kt delete mode 100644 src/main/kotlin/data/faetures/model/UserDTO.kt create mode 100644 src/main/kotlin/data/localDataSource.kt create mode 100644 src/main/kotlin/data/model/UserDTO.kt delete mode 100644 src/main/kotlin/domain/Service/AuthorizeService.kt delete mode 100644 src/main/kotlin/domain/Service/AuthorizeserviceImpl.kt create mode 100644 src/main/kotlin/domain/UserUseCase.kt create mode 100644 src/main/kotlin/domain/UserUseCaseImpl.kt create mode 100644 src/main/kotlin/domain/mapper.kt create mode 100644 src/main/kotlin/ui/UserUI.kt delete mode 100644 src/main/kotlin/ui/model/AuthorizeUI.kt delete mode 100644 src/main/kotlin/ui/model/UserPresenter.kt create mode 100644 src/main/ui/UserUI.kt diff --git a/src/main/data/UserRepository.kt b/src/main/data/UserRepository.kt new file mode 100644 index 0000000..dc250ff --- /dev/null +++ b/src/main/data/UserRepository.kt @@ -0,0 +1,12 @@ +package org.example.data + +import org.example.data.model.UserDTO +import org.example.domain.request.RegistrationRequest + +interface UserRepository { + fun addUser(registrationRequest: RegistrationRequest): UserDTO + fun removeUserById(userId: Int): Boolean + fun updateUserById(userId: Int, updatedUser: UserDTO): UserDTO + fun getAllUsers(): List + fun findUserById(userId: Int): UserDTO +} \ No newline at end of file diff --git a/src/main/data/UserRepositoryImpl.kt b/src/main/data/UserRepositoryImpl.kt new file mode 100644 index 0000000..ae9fc56 --- /dev/null +++ b/src/main/data/UserRepositoryImpl.kt @@ -0,0 +1,43 @@ +package org.example.data + +import org.example.data.model.UserDTO +import org.example.domain.request.RegistrationRequest + +class UserRepositoryImpl: UserRepository { + private val userSource: MutableList = userList.toMutableList() + + + override fun addUser(registrationRequest: RegistrationRequest): UserDTO { + val newUser = UserDTO( + userId = userSource.size + 1, + email = registrationRequest.email, + firstName = registrationRequest.firstName, + password = registrationRequest.password + ) + userSource.add(newUser) + return newUser + } + + override fun removeUserById(userId: Int): Boolean { + return userSource.removeIf { it.userId == userId } + } + + override fun updateUserById(userId: Int, updatedUser: UserDTO): UserDTO { + val oldUser = userSource.first { it.userId == userId } + oldUser.phone = updatedUser.phone + oldUser.address = updatedUser.address + oldUser.firstName = updatedUser.firstName + oldUser.lastName = updatedUser.lastName + oldUser.password = updatedUser.password + oldUser.email = updatedUser.email + return oldUser + } + + override fun getAllUsers(): List = userList + + override fun findUserById(userId: Int): UserDTO { + val findUser = userList.firstOrNull { it.userId == userId } + checkNotNull(findUser) + return findUser + } +} \ No newline at end of file diff --git a/src/main/data/localDataSource.kt b/src/main/data/localDataSource.kt new file mode 100644 index 0000000..d2f8a7b --- /dev/null +++ b/src/main/data/localDataSource.kt @@ -0,0 +1,24 @@ +package org.example.data + +import org.example.data.model.UserDTO + +val userList = listOf( + UserDTO( + userId = 1, + firstName = "Andrey", + password = "123", + email = "test@mail.ru" + ), + UserDTO( + userId = 2, + firstName = "Alexey", + password = "321", + email = "test2@mail.ru" + ), + UserDTO( + userId = 3, + firstName = "Oleg", + password = "423", + email = "test3@mail.ru", + ), +) \ No newline at end of file diff --git a/src/main/data/model/UserDTO.kt b/src/main/data/model/UserDTO.kt new file mode 100644 index 0000000..518121b --- /dev/null +++ b/src/main/data/model/UserDTO.kt @@ -0,0 +1,11 @@ +package org.example.data.model + +data class UserDTO( + val userId: Int, + var firstName: String, + var lastName: String? = null, + var password: String, + var email: String, + var phone: String? = null, + var address: String? = null, +) diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index 2617ec6..a0bb9b1 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1,14 +1,40 @@ package org.example -import org.example.data.faetures.authorize.AuthorizeRepositoryImpl -import org.example.domain.Service.AuthorizeserviceImpl -import org.example.ui.model.AuthorizeUI +import org.example.data.UserRepository +import org.example.data.UserRepositoryImpl +import org.example.domain.UserUseCaseImpl +import org.example.ui.UserUI fun main() { - val authorizeRepository = AuthorizeRepositoryImpl() - val authorizeServiceImpl = AuthorizeserviceImpl(authorizeRepository) - val authorizeUI = AuthorizeUI(authorizeServiceImpl) + val userRepository = UserRepositoryImpl() + val userUseCase = UserUseCaseImpl(userRepository) + val userUI = UserUI(userUseCase) - authorizeUI.registration() - authorizeUI.authorize() + while (true){ + // Меню команд + println("Выберерите команду:") + println("1. Авторизация") + println("2. Регистрация") + println("3. Выход") + print("Команда: ") + + // Выбор команды + val comand = readLine()?.toInt() + + if (comand == 1){ + println("Авторизавия") + userUI.authorize() + } + else if (comand == 2){ + println("Регистрация") + userUI.registration() + } + else if (comand == 3){ + break + } + else{ + println("Неверная команда!!!") + } + + } } \ No newline at end of file diff --git a/src/main/kotlin/data/UserRepository.kt b/src/main/kotlin/data/UserRepository.kt new file mode 100644 index 0000000..dc250ff --- /dev/null +++ b/src/main/kotlin/data/UserRepository.kt @@ -0,0 +1,12 @@ +package org.example.data + +import org.example.data.model.UserDTO +import org.example.domain.request.RegistrationRequest + +interface UserRepository { + fun addUser(registrationRequest: RegistrationRequest): UserDTO + fun removeUserById(userId: Int): Boolean + fun updateUserById(userId: Int, updatedUser: UserDTO): UserDTO + fun getAllUsers(): List + fun findUserById(userId: Int): UserDTO +} \ No newline at end of file diff --git a/src/main/kotlin/data/UserRepositoryImpl.kt b/src/main/kotlin/data/UserRepositoryImpl.kt new file mode 100644 index 0000000..ae9fc56 --- /dev/null +++ b/src/main/kotlin/data/UserRepositoryImpl.kt @@ -0,0 +1,43 @@ +package org.example.data + +import org.example.data.model.UserDTO +import org.example.domain.request.RegistrationRequest + +class UserRepositoryImpl: UserRepository { + private val userSource: MutableList = userList.toMutableList() + + + override fun addUser(registrationRequest: RegistrationRequest): UserDTO { + val newUser = UserDTO( + userId = userSource.size + 1, + email = registrationRequest.email, + firstName = registrationRequest.firstName, + password = registrationRequest.password + ) + userSource.add(newUser) + return newUser + } + + override fun removeUserById(userId: Int): Boolean { + return userSource.removeIf { it.userId == userId } + } + + override fun updateUserById(userId: Int, updatedUser: UserDTO): UserDTO { + val oldUser = userSource.first { it.userId == userId } + oldUser.phone = updatedUser.phone + oldUser.address = updatedUser.address + oldUser.firstName = updatedUser.firstName + oldUser.lastName = updatedUser.lastName + oldUser.password = updatedUser.password + oldUser.email = updatedUser.email + return oldUser + } + + override fun getAllUsers(): List = userList + + override fun findUserById(userId: Int): UserDTO { + val findUser = userList.firstOrNull { it.userId == userId } + checkNotNull(findUser) + return findUser + } +} \ No newline at end of file diff --git a/src/main/kotlin/data/faetures/authorize/AuthorizeRepository.kt b/src/main/kotlin/data/faetures/authorize/AuthorizeRepository.kt deleted file mode 100644 index bc5e7f5..0000000 --- a/src/main/kotlin/data/faetures/authorize/AuthorizeRepository.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.example.data.faetures.authorize - -import org.example.domain.Request.AuthorizeRequest -import org.example.domain.Request.RegistrationRequest -import org.example.domain.Response.UserResponse - - -interface AuthorizeRepository { - fun auth(authorizeRequest: AuthorizeRequest): UserResponse - fun resitration(request: RegistrationRequest): UserResponse -} \ No newline at end of file diff --git a/src/main/kotlin/data/faetures/authorize/AuthorizeRepositoryImpl.kt b/src/main/kotlin/data/faetures/authorize/AuthorizeRepositoryImpl.kt deleted file mode 100644 index 67c224f..0000000 --- a/src/main/kotlin/data/faetures/authorize/AuthorizeRepositoryImpl.kt +++ /dev/null @@ -1,21 +0,0 @@ -package org.example.data.faetures.authorize - -import io.github.serpro69.kfaker.Faker -import org.example.data.faetures.model.UserDTO -import org.example.domain.Request.AuthorizeRequest -import org.example.domain.Request.RegistrationRequest -import org.example.domain.Response.UserResponse - -class AuthorizeRepositoryImpl: AuthorizeRepository { - val faker = Faker() - val user = mutableListOf( - - ) - override fun auth(authorizeRequest: AuthorizeRequest): UserResponse { - TODO("Not yet implemented") - } - - override fun resitration(request: RegistrationRequest): UserResponse { - TODO("Not yet implemented") - } -} \ No newline at end of file diff --git a/src/main/kotlin/data/faetures/model/UserDTO.kt b/src/main/kotlin/data/faetures/model/UserDTO.kt deleted file mode 100644 index a4461e9..0000000 --- a/src/main/kotlin/data/faetures/model/UserDTO.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.example.data.faetures.model - -import java.util.UUID - -data class UserDTO( - val uuid: UUID, - var firstname: String, - var lastname: String?, - var email: String, - var number: String?, - var address: String?, - var photo: String? -) \ No newline at end of file diff --git a/src/main/kotlin/data/localDataSource.kt b/src/main/kotlin/data/localDataSource.kt new file mode 100644 index 0000000..d2f8a7b --- /dev/null +++ b/src/main/kotlin/data/localDataSource.kt @@ -0,0 +1,24 @@ +package org.example.data + +import org.example.data.model.UserDTO + +val userList = listOf( + UserDTO( + userId = 1, + firstName = "Andrey", + password = "123", + email = "test@mail.ru" + ), + UserDTO( + userId = 2, + firstName = "Alexey", + password = "321", + email = "test2@mail.ru" + ), + UserDTO( + userId = 3, + firstName = "Oleg", + password = "423", + email = "test3@mail.ru", + ), +) \ No newline at end of file diff --git a/src/main/kotlin/data/model/UserDTO.kt b/src/main/kotlin/data/model/UserDTO.kt new file mode 100644 index 0000000..518121b --- /dev/null +++ b/src/main/kotlin/data/model/UserDTO.kt @@ -0,0 +1,11 @@ +package org.example.data.model + +data class UserDTO( + val userId: Int, + var firstName: String, + var lastName: String? = null, + var password: String, + var email: String, + var phone: String? = null, + var address: String? = null, +) diff --git a/src/main/kotlin/domain/Request/AuthorizeRequest.kt b/src/main/kotlin/domain/Request/AuthorizeRequest.kt index ee4fa9b..11ba605 100644 --- a/src/main/kotlin/domain/Request/AuthorizeRequest.kt +++ b/src/main/kotlin/domain/Request/AuthorizeRequest.kt @@ -1,4 +1,4 @@ -package org.example.domain.Request +package org.example.domain.request data class AuthorizeRequest( val email: String, diff --git a/src/main/kotlin/domain/Request/RegistrationRequest.kt b/src/main/kotlin/domain/Request/RegistrationRequest.kt index f310756..0d5d133 100644 --- a/src/main/kotlin/domain/Request/RegistrationRequest.kt +++ b/src/main/kotlin/domain/Request/RegistrationRequest.kt @@ -1,8 +1,7 @@ -package org.example.domain.Request +package org.example.domain.request data class RegistrationRequest ( - val firstname: String, val email: String, val password: String, - + val firstName: String ) \ No newline at end of file diff --git a/src/main/kotlin/domain/Response/UserResponse.kt b/src/main/kotlin/domain/Response/UserResponse.kt index 7fec8f8..1fdd8f2 100644 --- a/src/main/kotlin/domain/Response/UserResponse.kt +++ b/src/main/kotlin/domain/Response/UserResponse.kt @@ -1,10 +1,10 @@ -package org.example.domain.Response +package org.example.domain.response data class UserResponse( - val firstname: String, - val lastname: String?, - val email: String, - val number: String?, - val address: String?, - val photo: String? -) \ No newline at end of file + val userId: Int, + var firstName: String, + var lastName: String? = null, + var email: String, + var phone: String? = null, + var address: String? = null, +) diff --git a/src/main/kotlin/domain/Service/AuthorizeService.kt b/src/main/kotlin/domain/Service/AuthorizeService.kt deleted file mode 100644 index f80bcd9..0000000 --- a/src/main/kotlin/domain/Service/AuthorizeService.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.example.domain.Service - -import org.example.domain.Request.AuthorizeRequest -import org.example.domain.Request.RegistrationRequest -import org.example.ui.model.UserPresenter - - -interface AuthorizeService { - fun auth(authorizeRequest: AuthorizeRequest): UserPresenter - fun registration(registrationRequest: RegistrationRequest): UserPresenter -} \ No newline at end of file diff --git a/src/main/kotlin/domain/Service/AuthorizeserviceImpl.kt b/src/main/kotlin/domain/Service/AuthorizeserviceImpl.kt deleted file mode 100644 index 345e230..0000000 --- a/src/main/kotlin/domain/Service/AuthorizeserviceImpl.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.example.domain.Service - -import org.example.data.faetures.authorize.AuthorizeRepository -import org.example.domain.Request.AuthorizeRequest -import org.example.domain.Request.RegistrationRequest -import org.example.ui.model.UserPresenter - -class AuthorizeserviceImpl(private val authorizeRepository: AuthorizeRepository): AuthorizeService { - override fun auth(authorizeRequest: AuthorizeRequest): UserPresenter { - val user = authorizeRepository.auth(authorizeRequest) - return UserPresenter() - } - - override fun registration(registrationRequest: RegistrationRequest): UserPresenter { - TODO("Not yet implemented") - } -} \ No newline at end of file diff --git a/src/main/kotlin/domain/UserUseCase.kt b/src/main/kotlin/domain/UserUseCase.kt new file mode 100644 index 0000000..504fb54 --- /dev/null +++ b/src/main/kotlin/domain/UserUseCase.kt @@ -0,0 +1,12 @@ +package org.example.domain + +import org.example.domain.request.AuthorizeRequest +import org.example.domain.request.RegistrationRequest +import org.example.domain.response.UserResponse + +interface UserUseCase { + fun authorize(authorizeRequest: AuthorizeRequest): UserResponse + fun registration(registrationRequest: RegistrationRequest): UserResponse + fun changePassword() + fun changeProfile() +} \ No newline at end of file diff --git a/src/main/kotlin/domain/UserUseCaseImpl.kt b/src/main/kotlin/domain/UserUseCaseImpl.kt new file mode 100644 index 0000000..cbc9e08 --- /dev/null +++ b/src/main/kotlin/domain/UserUseCaseImpl.kt @@ -0,0 +1,44 @@ +package org.example.domain + +import org.example.data.UserRepository +import org.example.domain.request.AuthorizeRequest +import org.example.domain.request.RegistrationRequest +import org.example.domain.response.UserResponse + +class UserUseCaseImpl(private val userRepository: UserRepository): UserUseCase { + override fun authorize(authorizeRequest: AuthorizeRequest): UserResponse { + val findUser = userRepository.getAllUsers() + .firstOrNull { + it.email == authorizeRequest.email + } + checkNotNull(findUser){ + "Пользователь с такой почтой не найден" + } + require(findUser.password == authorizeRequest.password){ + "Пароли не совпадают" + } + return UserDtoToUserResponse(findUser) + } + + override fun registration(registrationRequest: RegistrationRequest): UserResponse { + //уникальность почты + val isUnique = userRepository.getAllUsers().firstOrNull{ + it.email == registrationRequest.email + } == null + require(isUnique){ + "Такая почта уже существует" + } + val newUser = userRepository.addUser(registrationRequest) + return UserDtoToUserResponse(newUser) + } + + + + override fun changePassword() { + TODO("Not yet implemented") + } + + override fun changeProfile() { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/src/main/kotlin/domain/mapper.kt b/src/main/kotlin/domain/mapper.kt new file mode 100644 index 0000000..6885c6e --- /dev/null +++ b/src/main/kotlin/domain/mapper.kt @@ -0,0 +1,13 @@ +package org.example.domain + +import org.example.data.model.UserDTO +import org.example.domain.response.UserResponse + +fun UserDtoToUserResponse(userDTO: UserDTO) = UserResponse( + lastName = userDTO.lastName, + firstName = userDTO.firstName, + email = userDTO.email, + phone = userDTO.phone, + userId = userDTO.userId, + address = userDTO.address, +) \ No newline at end of file diff --git a/src/main/kotlin/ui/UserUI.kt b/src/main/kotlin/ui/UserUI.kt new file mode 100644 index 0000000..485a73c --- /dev/null +++ b/src/main/kotlin/ui/UserUI.kt @@ -0,0 +1,71 @@ +package org.example.ui + +import org.example.domain.UserUseCase +import org.example.domain.request.AuthorizeRequest +import org.example.domain.request.RegistrationRequest +import org.example.domain.response.UserResponse + +class UserUI(private val userUseCase: UserUseCase) { + fun authorize(){ + println("Введите почту") + val email = readlnOrNull() + checkNotNull(email){ + "Почта не должна отсутствовать" + } + println("Введите пароль") + val password = readlnOrNull() + checkNotNull(password){ + "Пароль не должен отсутствовать" + } + val authorizeRequest = AuthorizeRequest( + email = email, + password = password,) + val user = userUseCase.authorize(authorizeRequest) + println(userResponseToString(user)) + } + + fun registration(){ + println("Введите имя") + val firstName = readlnOrNull() + checkNotNull(firstName){ + "Имя не должно отсутствовать" + } + println("Введите почту") + val email = readlnOrNull() + checkNotNull(email){ + "Почта не должна отсутствовать" + } + println("Введите пароль") + val password = readlnOrNull() + checkNotNull(password){ + "Пароль не должен отсутствовать" + } + val registrationRequest = RegistrationRequest( + email = email, + firstName = firstName, + password = password + ) + val newUser = userUseCase.registration(registrationRequest) + userResponseToString(newUser) + } + + private fun userResponseToString(userResponse: UserResponse): String{ + val printOutput = StringBuilder() + printOutput.append("Ваша почта ${userResponse.email}") + printOutput.appendLine() + printOutput.append("Ваше имя ${userResponse.firstName}") + if (!userResponse.lastName.isNullOrBlank()){ + printOutput.appendLine() + printOutput.append("Ваше фамилия ${userResponse.lastName}") + } + if (!userResponse.phone.isNullOrBlank()){ + printOutput.appendLine() + printOutput.append("Ваш телефон ${userResponse.phone}") + } + if (!userResponse.address.isNullOrBlank()){ + printOutput.appendLine() + printOutput.append("Ваш адрес ${userResponse.phone}") + } + return printOutput.toString() + } +} \ No newline at end of file diff --git a/src/main/kotlin/ui/model/AuthorizeUI.kt b/src/main/kotlin/ui/model/AuthorizeUI.kt deleted file mode 100644 index 6ad97dd..0000000 --- a/src/main/kotlin/ui/model/AuthorizeUI.kt +++ /dev/null @@ -1,19 +0,0 @@ -package org.example.ui.model - -import org.example.domain.Request.AuthorizeRequest -import org.example.domain.Service.AuthorizeService - -class AuthorizeUI(val authorizeService: AuthorizeService) { - fun authorize(){ - println("Enter the email") - val email = readlnOrNull() - println("Enter the password") - val password = readlnOrNull() - checkNotNull(email) - checkNotNull(password) - authorizeService.auth(AuthorizeRequest(email = email, password = password)) - } - fun registration(){ - - } -} \ No newline at end of file diff --git a/src/main/kotlin/ui/model/UserPresenter.kt b/src/main/kotlin/ui/model/UserPresenter.kt deleted file mode 100644 index 693ee8b..0000000 --- a/src/main/kotlin/ui/model/UserPresenter.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.example.ui.model - -data class UserPresenter() diff --git a/src/main/ui/UserUI.kt b/src/main/ui/UserUI.kt new file mode 100644 index 0000000..485a73c --- /dev/null +++ b/src/main/ui/UserUI.kt @@ -0,0 +1,71 @@ +package org.example.ui + +import org.example.domain.UserUseCase +import org.example.domain.request.AuthorizeRequest +import org.example.domain.request.RegistrationRequest +import org.example.domain.response.UserResponse + +class UserUI(private val userUseCase: UserUseCase) { + fun authorize(){ + println("Введите почту") + val email = readlnOrNull() + checkNotNull(email){ + "Почта не должна отсутствовать" + } + println("Введите пароль") + val password = readlnOrNull() + checkNotNull(password){ + "Пароль не должен отсутствовать" + } + val authorizeRequest = AuthorizeRequest( + email = email, + password = password,) + val user = userUseCase.authorize(authorizeRequest) + println(userResponseToString(user)) + } + + fun registration(){ + println("Введите имя") + val firstName = readlnOrNull() + checkNotNull(firstName){ + "Имя не должно отсутствовать" + } + println("Введите почту") + val email = readlnOrNull() + checkNotNull(email){ + "Почта не должна отсутствовать" + } + println("Введите пароль") + val password = readlnOrNull() + checkNotNull(password){ + "Пароль не должен отсутствовать" + } + val registrationRequest = RegistrationRequest( + email = email, + firstName = firstName, + password = password + ) + val newUser = userUseCase.registration(registrationRequest) + userResponseToString(newUser) + } + + private fun userResponseToString(userResponse: UserResponse): String{ + val printOutput = StringBuilder() + printOutput.append("Ваша почта ${userResponse.email}") + printOutput.appendLine() + printOutput.append("Ваше имя ${userResponse.firstName}") + if (!userResponse.lastName.isNullOrBlank()){ + printOutput.appendLine() + printOutput.append("Ваше фамилия ${userResponse.lastName}") + } + if (!userResponse.phone.isNullOrBlank()){ + printOutput.appendLine() + printOutput.append("Ваш телефон ${userResponse.phone}") + } + if (!userResponse.address.isNullOrBlank()){ + printOutput.appendLine() + printOutput.append("Ваш адрес ${userResponse.phone}") + } + return printOutput.toString() + } +} \ No newline at end of file