diff --git a/src/main/kotlin/Main.kt b/src/main/kotlin/Main.kt index cb45742..279a514 100644 --- a/src/main/kotlin/Main.kt +++ b/src/main/kotlin/Main.kt @@ -1,17 +1,24 @@ package org.example import org.example.data.authorize +import org.example.data.registration import org.example.data.users import org.example.domain.request.UserAuthorizeRequest +import org.example.domain.request.UserRegistrationRequest fun main() { users.forEach { println(it) } val email = readlnOrNull() + val lastname = readlnOrNull() val password = readlnOrNull() checkNotNull(email) + checkNotNull(lastname) checkNotNull(password) - val user = authorize(UserAuthorizeRequest(email, password)) + val user = registration(UserRegistrationRequest(lastname, email, password)) println(user) + users.forEach { + println(it) + } } diff --git a/src/main/kotlin/data/localdata.kt b/src/main/kotlin/data/localdata.kt index 3e80511..efd13d6 100644 --- a/src/main/kotlin/data/localdata.kt +++ b/src/main/kotlin/data/localdata.kt @@ -3,18 +3,19 @@ package org.example.data import io.github.serpro69.kfaker.Faker import org.example.domain.entity.User import org.example.domain.request.UserAuthorizeRequest +import org.example.domain.request.UserRegistrationRequest import java.util.* data class LocalUser( val uuid: UUID, var lastname: String, - var firstname: String, + var firstname: String? = null, var email: String, - var url: String, + var url: String? = null, var password: String, - var phone: String + var phone: String? = null ) -val users = generateUsers(100) +val users = generateUsers(100).toMutableList() fun generateUsers(userCount: Int): List{ val localUserList = mutableListOf() val faker = Faker() @@ -51,3 +52,17 @@ fun authorize(userAuthorizeRequest: UserAuthorizeRequest): User{ else throw IllegalArgumentException("Пароли не совпадают") } +fun registration(userRegistrationRequest: UserRegistrationRequest):User{ + val user = LocalUser( + uuid = UUID.randomUUID(), + lastname = userRegistrationRequest.lastname, + email = userRegistrationRequest.password, + password = userRegistrationRequest.password + ) + users.add(user) + return User( + uuid = user.uuid, + lastname = user.lastname, + email = user.email + ) +} \ No newline at end of file diff --git a/src/main/kotlin/domain/entity/User.kt b/src/main/kotlin/domain/entity/User.kt index 1e46feb..83b75f0 100644 --- a/src/main/kotlin/domain/entity/User.kt +++ b/src/main/kotlin/domain/entity/User.kt @@ -6,8 +6,8 @@ import kotlin.uuid.Uuid data class User( val uuid:UUID, var lastname: String, - var firstname: String, + var firstname: String? = null, var email: String, - var url: String, - var phone:String + var url: String? = null, + var phone:String? = null ) diff --git a/src/main/kotlin/domain/request/UserRegistrationRequest.kt b/src/main/kotlin/domain/request/UserRegistrationRequest.kt new file mode 100644 index 0000000..493a042 --- /dev/null +++ b/src/main/kotlin/domain/request/UserRegistrationRequest.kt @@ -0,0 +1,7 @@ +package org.example.domain.request + +data class UserRegistrationRequest( + val lastname:String, + val email: String, + val password: String +)