chore: restore original directory structure (project under code-review-graph-main/)
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
package com.example
|
||||
|
||||
import java.util.UUID
|
||||
|
||||
interface UserRepository {
|
||||
fun findById(id: Int): User?
|
||||
fun save(user: User)
|
||||
}
|
||||
|
||||
data class User(val id: Int, val name: String, val email: String)
|
||||
|
||||
class InMemoryRepo : UserRepository {
|
||||
private val users = mutableMapOf<Int, User>()
|
||||
|
||||
override fun findById(id: Int): User? = users[id]
|
||||
|
||||
override fun save(user: User) {
|
||||
users[user.id] = user
|
||||
println("Saved user ${user.id}")
|
||||
}
|
||||
}
|
||||
|
||||
fun createUser(repo: UserRepository, name: String, email: String): User {
|
||||
val user = User(1, name, email)
|
||||
repo.save(user)
|
||||
return user
|
||||
}
|
||||
Reference in New Issue
Block a user