Skip to content

Commit 2cab70c

Browse files
author
=
committed
feat: new fields added
1 parent 839cc4e commit 2cab70c

File tree

6 files changed

+14
-35
lines changed

6 files changed

+14
-35
lines changed

src/main/kotlin/com/example/plugins/Routing.kt renamed to src/main/kotlin/com/example/plugin/Routing.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.plugins
22

33
import com.example.fake.foodDtos
4+
import com.example.route.userRoute
45
import io.ktor.http.*
56
import io.ktor.server.application.*
67
import io.ktor.server.response.*
@@ -34,4 +35,6 @@ fun Application.configureRouting() {
3435
call.respond(stock)
3536
}
3637
}
38+
39+
userRoute()
3740
}

src/main/kotlin/com/example/plugins/UserRoute.kt

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package com.example.table
22

3+
import kotlinx.datetime.Clock
4+
import kotlinx.datetime.toJavaInstant
35
import org.jetbrains.exposed.sql.javatime.timestamp
46
import org.jetbrains.exposed.sql.Table
57

68
object Orders: Table() {
79
val id = integer("id").autoIncrement()
8-
val userId = integer("userId").references(Users.id)
10+
val userId = uuid("userId").references(Users.userId)
911
val foodId = integer("foodId").references(Foods.id)
1012
val quantity = integer("quantity")
11-
val orderTime = timestamp("orderTime")
13+
val orderTime = timestamp("orderTime").clientDefault { Clock.System.now().toJavaInstant() }
1214

1315
override val primaryKey = PrimaryKey(id)
1416
}

src/main/kotlin/com/example/table/Users.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import org.jetbrains.exposed.sql.Table
44

55
object Users : Table() {
66
val id = integer("id").autoIncrement()
7+
val userId = uuid("userId").uniqueIndex().autoGenerate()
78
val fullName = varchar("fullName", 128)
89
val email = varchar("email", 128)
910
val password = varchar("password", 128)
10-
val phoneNumber = varchar("phoneNumber", 128)
11-
val occupation = varchar("occupation", 128)
12-
val employer = varchar("employer", 128)
13-
val country = varchar("country", 128)
11+
val phoneNumber = varchar("phoneNumber", 128).nullable()
12+
val occupation = varchar("occupation", 128).nullable()
13+
val employer = varchar("employer", 128).nullable()
14+
val country = varchar("country", 128).nullable()
15+
val latitude = double("latitude").nullable()
16+
val longitude = double("longitude").nullable()
1417

1518
override val primaryKey = PrimaryKey(id)
1619
}

0 commit comments

Comments
 (0)