mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 06:25:51 +01:00
40 lines
1.7 KiB
Scala
40 lines
1.7 KiB
Scala
package model
|
|
|
|
import scala.slick.driver.H2Driver.simple._
|
|
|
|
object Accounts extends Table[Account]("ACCOUNT") {
|
|
def userId = column[Long]("USER_ID", O AutoInc)
|
|
def userName = column[String]("USER_NAME")
|
|
def mailAddress = column[String]("MAIL_ADDRESS")
|
|
def password = column[String]("PASSWORD")
|
|
def userType = column[Int]("USER_TYPE")
|
|
def url = column[String]("URL")
|
|
def registeredDate = column[java.sql.Date]("REGISTERED_DATE") // TODO convert java.util.Date later
|
|
def updatedDate = column[java.sql.Date]("UPDATED_DATE")
|
|
def lastLoginDate = column[java.sql.Date]("LAST_LOGIN_DATE")
|
|
def * = userId.? ~ userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> (Account, Account.unapply _)
|
|
def ins = userName ~ mailAddress ~ password ~ userType ~ url.? ~ registeredDate ~ updatedDate ~ lastLoginDate.? <> ({ t => Account(None, t._1, t._2, t._3, t._4, t._5, t._6, t._7, t._8)}, { (o: Account) => Some((o.userName, o.mailAddress, o.password, o.userType, o.url, o.registeredDate, o.updatedDate, o.lastLoginDate))})
|
|
}
|
|
|
|
case class Account(
|
|
userId: Option[Long],
|
|
userName: String,
|
|
mailAddress: String,
|
|
password: String,
|
|
userType: Int,
|
|
url: Option[String],
|
|
registeredDate: java.sql.Date,
|
|
updatedDate: java.sql.Date,
|
|
lastLoginDate: Option[java.sql.Date]
|
|
)
|
|
|
|
class AccountDao {
|
|
import Database.threadLocalSession
|
|
|
|
// def insert(o: Account): Account = Accounts.ins returning Accounts.* insert o
|
|
def insert(o: Account): Long = Accounts.ins returning Accounts.userId insert o
|
|
|
|
def select(key: Long): Option[Account] = Query(Accounts) filter(_.userId is key.bind) firstOption
|
|
|
|
}
|