add shoes
This commit is contained in:
parent
628fb039d6
commit
7e66b88679
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_23_PREVIEW" project-jdk-name="23" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -1,15 +1,18 @@
|
||||
package org.example
|
||||
|
||||
import org.example.data.UserRepository
|
||||
import org.example.data.UserRepositoryImpl
|
||||
import org.example.domain.UserUseCaseImpl
|
||||
import org.example.ui.MainMenuUI
|
||||
import org.example.ui.UserUI
|
||||
|
||||
|
||||
//class_student
|
||||
//localuser - где нет rtk
|
||||
//844SystemUser
|
||||
fun main() {
|
||||
val userRepository = UserRepositoryImpl()
|
||||
val userUseCase = UserUseCaseImpl(userRepository)
|
||||
val userUI = UserUI(userUseCase)
|
||||
userUI.authorize()
|
||||
userUI.changePassword()
|
||||
userUI.authorize()
|
||||
val mainMenuUI = MainMenuUI(userUI)
|
||||
mainMenuUI.displayStartMenu()
|
||||
}
|
7
src/main/kotlin/data/ShoesRepository.kt
Normal file
7
src/main/kotlin/data/ShoesRepository.kt
Normal file
@ -0,0 +1,7 @@
|
||||
package org.example.data
|
||||
|
||||
interface ShoesRepository {
|
||||
fun addShoes()
|
||||
fun getAllShoes()
|
||||
fun removeShoes()
|
||||
}
|
19
src/main/kotlin/data/ShoesRepositoryImpl.kt
Normal file
19
src/main/kotlin/data/ShoesRepositoryImpl.kt
Normal file
@ -0,0 +1,19 @@
|
||||
package org.example.data
|
||||
|
||||
import org.example.data.model.ShoesDTO
|
||||
|
||||
class ShoesRepositoryImpl: ShoesRepository {
|
||||
val shoesSource = mutableListOf(shoesList)
|
||||
|
||||
override fun addShoes(vararg shoes: ShoesDTO): {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun getAllShoes() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun removeShoes() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
@ -1,7 +1,18 @@
|
||||
package org.example.data
|
||||
|
||||
import org.example.data.model.ShoesDTO
|
||||
import org.example.data.model.UserDTO
|
||||
|
||||
val shoesList = listOf(
|
||||
ShoesDTO(
|
||||
shoesId = 1,
|
||||
shoesName = "1",
|
||||
shoesDescription = "123",
|
||||
shoesUrl = "3",
|
||||
category = "123"
|
||||
)
|
||||
)
|
||||
|
||||
val userList = listOf(
|
||||
UserDTO(
|
||||
userId = 1,
|
||||
|
9
src/main/kotlin/data/model/ShoesDTO.kt
Normal file
9
src/main/kotlin/data/model/ShoesDTO.kt
Normal file
@ -0,0 +1,9 @@
|
||||
package org.example.data.model
|
||||
|
||||
data class ShoesDTO (
|
||||
val shoesId: Int,
|
||||
val shoesName: String,
|
||||
val shoesDescription: String,
|
||||
val shoesUrl: String,
|
||||
val category: String,
|
||||
)
|
72
src/main/kotlin/ui/MainMenuUI.kt
Normal file
72
src/main/kotlin/ui/MainMenuUI.kt
Normal file
@ -0,0 +1,72 @@
|
||||
package org.example.ui
|
||||
|
||||
class MainMenuUI(
|
||||
private val userUI: UserUI
|
||||
){
|
||||
val menuItems = listOf(
|
||||
"1. Авторизоваться",
|
||||
"2. Зарегестрироваться",
|
||||
"3. Exit"
|
||||
|
||||
)
|
||||
val menuAuthorizedItems = listOf(
|
||||
"1. Change password",
|
||||
"2. Edit profile",
|
||||
"3. Exit"
|
||||
|
||||
)
|
||||
private fun displayMenuItem(menuItem: () -> Unit){
|
||||
try {
|
||||
menuItem()
|
||||
}
|
||||
catch (e: Exception){
|
||||
println(e.message)
|
||||
userUI.userAuthorized?.let {
|
||||
displayMenuForAuthorizeUser()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun displayStartMenu(){
|
||||
print(menuItems.joinToString("\n"))
|
||||
val menuPosition = readlnOrNull()?.toIntOrNull()
|
||||
if(menuPosition == null) displayStartMenu()
|
||||
when(menuPosition){
|
||||
1 -> {
|
||||
displayMenuItem {
|
||||
userUI.authorize()
|
||||
displayMenuForAuthorizeUser()
|
||||
}
|
||||
}
|
||||
2 -> {
|
||||
userUI.registration()
|
||||
}
|
||||
3 ->{
|
||||
return
|
||||
}
|
||||
else -> {
|
||||
displayStartMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun displayMenuForAuthorizeUser(){
|
||||
print(menuAuthorizedItems.joinToString("\n"))
|
||||
val menuPosition = readlnOrNull()?.toIntOrNull()
|
||||
if(menuPosition == null) displayMenuForAuthorizeUser()
|
||||
when(menuPosition){
|
||||
1 -> {
|
||||
displayMenuItem {
|
||||
userUI.changePassword()
|
||||
}
|
||||
}
|
||||
2 -> {
|
||||
userUI.edit()
|
||||
}
|
||||
3 -> {
|
||||
return
|
||||
}
|
||||
else -> displayMenuForAuthorizeUser()
|
||||
}
|
||||
}
|
||||
}
|
@ -26,6 +26,11 @@ class UserUI(private val userUseCase: UserUseCase) {
|
||||
userAuthorized = user
|
||||
println(userResponseToString(user))
|
||||
}
|
||||
|
||||
fun edit(){
|
||||
|
||||
}
|
||||
|
||||
fun changePassword(){
|
||||
checkNotNull(userAuthorized){
|
||||
"Вы не авторизованы"
|
||||
|
Loading…
Reference in New Issue
Block a user