Skip to content

Commit

Permalink
move models to subpackage users, rooms or reservations (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
makselivanov authored Oct 26, 2023
1 parent e0ee98a commit 557421a
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.tod87et.roomkn.server.auth

import org.tod87et.roomkn.server.models.LoginUserInfo
import org.tod87et.roomkn.server.models.UnregisteredUserInfo
import org.tod87et.roomkn.server.models.users.LoginUserInfo
import org.tod87et.roomkn.server.models.users.UnregisteredUserInfo

interface AccountController {
fun authenticateUser(loginUserInfo: LoginUserInfo): Result<AuthSession>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import com.auth0.jwt.algorithms.Algorithm
import io.ktor.util.logging.Logger
import org.tod87et.roomkn.server.database.ConstraintViolationException
import org.tod87et.roomkn.server.database.MissingElementException
import org.tod87et.roomkn.server.models.LoginUserInfo
import org.tod87et.roomkn.server.models.RegistrationUserInfo
import org.tod87et.roomkn.server.models.UnregisteredUserInfo
import org.tod87et.roomkn.server.models.users.LoginUserInfo
import org.tod87et.roomkn.server.models.users.RegistrationUserInfo
import org.tod87et.roomkn.server.models.users.UnregisteredUserInfo
import java.security.MessageDigest
import java.security.SecureRandom
import java.util.Date
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.tod87et.roomkn.server.database

import org.tod87et.roomkn.server.models.RegistrationUserInfo
import org.tod87et.roomkn.server.models.UserCredentialsInfo
import org.tod87et.roomkn.server.models.UserInfo
import org.tod87et.roomkn.server.models.users.RegistrationUserInfo
import org.tod87et.roomkn.server.models.users.UserCredentialsInfo
import org.tod87et.roomkn.server.models.users.UserInfo

interface CredentialsDatabase {
fun registerUser(user: RegistrationUserInfo): Result<UserInfo>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.tod87et.roomkn.server.database

import org.tod87et.roomkn.server.models.NewRoomInfo
import org.tod87et.roomkn.server.models.Reservation
import org.tod87et.roomkn.server.models.RoomInfo
import org.tod87et.roomkn.server.models.ShortRoomInfo
import org.tod87et.roomkn.server.models.ShortUserInfo
import org.tod87et.roomkn.server.models.UnregisteredReservation
import org.tod87et.roomkn.server.models.UserInfo
import org.tod87et.roomkn.server.models.rooms.NewRoomInfo
import org.tod87et.roomkn.server.models.reservations.Reservation
import org.tod87et.roomkn.server.models.rooms.RoomInfo
import org.tod87et.roomkn.server.models.rooms.ShortRoomInfo
import org.tod87et.roomkn.server.models.users.ShortUserInfo
import org.tod87et.roomkn.server.models.reservations.UnregisteredReservation
import org.tod87et.roomkn.server.models.users.UserInfo

interface Database {
fun getRooms(): Result<List<ShortRoomInfo>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction
import org.tod87et.roomkn.server.models.RegistrationUserInfo
import org.tod87et.roomkn.server.models.Reservation
import org.tod87et.roomkn.server.models.RoomInfo
import org.tod87et.roomkn.server.models.ShortRoomInfo
import org.tod87et.roomkn.server.models.ShortUserInfo
import org.tod87et.roomkn.server.models.UnregisteredReservation
import org.tod87et.roomkn.server.models.UserCredentialsInfo
import org.tod87et.roomkn.server.models.UserInfo
import org.tod87et.roomkn.server.models.users.RegistrationUserInfo
import org.tod87et.roomkn.server.models.reservations.Reservation
import org.tod87et.roomkn.server.models.rooms.RoomInfo
import org.tod87et.roomkn.server.models.rooms.ShortRoomInfo
import org.tod87et.roomkn.server.models.users.ShortUserInfo
import org.tod87et.roomkn.server.models.reservations.UnregisteredReservation
import org.tod87et.roomkn.server.models.users.UserCredentialsInfo
import org.tod87et.roomkn.server.models.users.UserInfo
import java.sql.Connection
import javax.sql.DataSource
import org.tod87et.roomkn.server.database.Database as RooMknDatabase
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.jetbrains.exposed.sql.deleteAll
import org.postgresql.util.PSQLException
import org.tod87et.roomkn.server.models.NewRoomInfo
import org.tod87et.roomkn.server.models.rooms.NewRoomInfo

class DatabaseSession private constructor(private val database: Database) :
RooMknDatabase, CredentialsDatabase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.reservations

import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.reservations

import kotlinx.datetime.Instant
import kotlinx.serialization.SerialName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.rooms

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.rooms

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.rooms

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.users

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.users

/** For internal use only. **Not** serializable */
class RegistrationUserInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.users

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.users

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.users

/** For internal use only. **Not** serializable */
class UserCredentialsInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.tod87et.roomkn.server.models
package org.tod87et.roomkn.server.models.users

import kotlinx.serialization.Serializable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import org.tod87et.roomkn.server.auth.AuthSession
import org.tod87et.roomkn.server.auth.AuthenticationProvider
import org.tod87et.roomkn.server.auth.NoSuchUserException
import org.tod87et.roomkn.server.auth.RegistrationFailedException
import org.tod87et.roomkn.server.models.LoginUserInfo
import org.tod87et.roomkn.server.models.UnregisteredUserInfo
import org.tod87et.roomkn.server.models.users.LoginUserInfo
import org.tod87et.roomkn.server.models.users.UnregisteredUserInfo

fun Route.accountRouting(authConfig: AuthConfig) {
val env = environment!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.ktor.server.response.respondText
import io.ktor.server.routing.Route
import io.ktor.server.routing.post
import org.tod87et.roomkn.server.database.DatabaseFactory.database
import org.tod87et.roomkn.server.models.UnregisteredReservation
import org.tod87et.roomkn.server.models.reservations.UnregisteredReservation

fun Route.reserveRouting() {
post("/reserve") { unregisteredReservation: UnregisteredReservation ->
Expand Down
4 changes: 2 additions & 2 deletions server/src/test/kotlin/org/tod87et/roomkn/server/AuthTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.tod87et.roomkn.server.KtorTestEnv.testJsonApplication
import org.tod87et.roomkn.server.database.DatabaseFactory
import org.tod87et.roomkn.server.models.LoginUserInfo
import org.tod87et.roomkn.server.models.UnregisteredUserInfo
import org.tod87et.roomkn.server.models.users.LoginUserInfo
import org.tod87et.roomkn.server.models.users.UnregisteredUserInfo
import kotlin.test.assertContains
import kotlin.test.assertEquals

Expand Down
16 changes: 8 additions & 8 deletions server/src/test/kotlin/org/tod87et/roomkn/server/DatabaseTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import org.tod87et.roomkn.server.database.ConstraintViolationException
import org.tod87et.roomkn.server.database.DatabaseSession
import org.tod87et.roomkn.server.database.MissingElementException
import org.tod87et.roomkn.server.database.ReservationException
import org.tod87et.roomkn.server.models.NewRoomInfo
import org.tod87et.roomkn.server.models.RegistrationUserInfo
import org.tod87et.roomkn.server.models.Reservation
import org.tod87et.roomkn.server.models.RoomInfo
import org.tod87et.roomkn.server.models.ShortRoomInfo
import org.tod87et.roomkn.server.models.ShortUserInfo
import org.tod87et.roomkn.server.models.UnregisteredReservation
import org.tod87et.roomkn.server.models.UserInfo
import org.tod87et.roomkn.server.models.rooms.NewRoomInfo
import org.tod87et.roomkn.server.models.users.RegistrationUserInfo
import org.tod87et.roomkn.server.models.reservations.Reservation
import org.tod87et.roomkn.server.models.rooms.RoomInfo
import org.tod87et.roomkn.server.models.rooms.ShortRoomInfo
import org.tod87et.roomkn.server.models.users.ShortUserInfo
import org.tod87et.roomkn.server.models.reservations.UnregisteredReservation
import org.tod87et.roomkn.server.models.users.UserInfo
import javax.sql.DataSource
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
Expand Down

0 comments on commit 557421a

Please sign in to comment.