Skip to content
Snippets Groups Projects
Commit 3c507afd authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Add Account and Session model

parent 4077a8fa
No related branches found
No related tags found
No related merge requests found
package de.tobias.playpad.server.account
import com.j256.ormlite.dao.ForeignCollection
import com.j256.ormlite.field.{DatabaseField, ForeignCollectionField}
import com.j256.ormlite.table.DatabaseTable
/**
* Created by tobias on 15.02.17.
*/
@DatabaseTable(tableName = "Account") class Account() {
@DatabaseField(generatedId = true) val id: Int = 0
@DatabaseField(unique = true) var username: String = _ // Mail Address
@DatabaseField() var password: String = _
@ForeignCollectionField var sessions: ForeignCollection[Session] = _
def this(username: String, password: String) {
this()
this.username = username
this.password = password
}
def getId: Int = id
}
package de.tobias.playpad.server.account
import java.sql.Date
import com.j256.ormlite.field.DatabaseField
import com.j256.ormlite.table.DatabaseTable
/**
* Created by tobias on 15.02.17.
*/
@DatabaseTable(tableName = "Session") class Session() {
@DatabaseField(generatedId = true) private val id: Int = 0
@DatabaseField(foreign = true, foreignAutoCreate = true, foreignAutoRefresh = true) private var account: Account = _
@DatabaseField var key: String = _
@DatabaseField var createDate: Date = _
def this(key: String, createDate: Date) {
this()
this.key = key
this.createDate = createDate
}
def getId: Int = id
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment