add ui logic
This commit is contained in:
parent
8d99444a62
commit
067cc9f74f
@ -4,16 +4,6 @@ data class User(val number : String,
|
|||||||
var numberInt: Int, )
|
var numberInt: Int, )
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
//var/val - изменяемая/не изменяемая
|
|
||||||
// list/mutablelist - изменяемая/не изменяемая
|
|
||||||
val number = User("123", 123)
|
|
||||||
val listNumbers = listOf(number, number, number)
|
|
||||||
val listMutableNumbers = mutableListOf(number, number, number)
|
|
||||||
// listMutableNumbers.add(number)
|
|
||||||
// listMutableNumbers.removeFirst()
|
|
||||||
// listMutableNumbers.replaceAll { }
|
|
||||||
// listMutableNumbers.map { }
|
|
||||||
listNumbers.forEach {
|
|
||||||
println(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
43
src/main/kotlin/ui/UserUI.kt
Normal file
43
src/main/kotlin/ui/UserUI.kt
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package org.example.ui
|
||||||
|
|
||||||
|
import org.example.domain.UserUseCase
|
||||||
|
import org.example.domain.request.AuthorizeRequest
|
||||||
|
import org.example.domain.response.UserResponse
|
||||||
|
|
||||||
|
class UserUI(private val userUseCase: UserUseCase) {
|
||||||
|
fun authorize(){
|
||||||
|
val email = readlnOrNull()
|
||||||
|
checkNotNull(email){
|
||||||
|
"Почта не должна отсутствовать"
|
||||||
|
}
|
||||||
|
val password = readlnOrNull()
|
||||||
|
checkNotNull(password){
|
||||||
|
"Пароль не должен отсутствовать"
|
||||||
|
}
|
||||||
|
val authorizeRequest = AuthorizeRequest(
|
||||||
|
email = email,
|
||||||
|
password = password,)
|
||||||
|
val user = userUseCase.authorize(authorizeRequest)
|
||||||
|
println(UserResponseToString(user))
|
||||||
|
}
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user