mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-03 03:55:58 +01:00
Merge branch 'master' of https://github.com/takezoe/gitbucket.git
This commit is contained in:
@@ -31,6 +31,7 @@ object MyBuild extends Build {
|
|||||||
"commons-io" % "commons-io" % "2.4",
|
"commons-io" % "commons-io" % "2.4",
|
||||||
"org.pegdown" % "pegdown" % "1.2.1",
|
"org.pegdown" % "pegdown" % "1.2.1",
|
||||||
"org.apache.commons" % "commons-compress" % "1.5",
|
"org.apache.commons" % "commons-compress" % "1.5",
|
||||||
|
"com.typesafe.slick" %% "slick" % "1.0.0",
|
||||||
"com.h2database" % "h2" % "1.3.171",
|
"com.h2database" % "h2" % "1.3.171",
|
||||||
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
|
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
|
||||||
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
|
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
|
||||||
|
|||||||
39
src/main/scala/model/Account.scala
Normal file
39
src/main/scala/model/Account.scala
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package servlet
|
|||||||
import javax.servlet._
|
import javax.servlet._
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import javax.servlet.http.HttpServletRequest
|
import javax.servlet.http.HttpServletRequest
|
||||||
|
import scala.slick.session.Database
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the transaction with the open session in view pattern.
|
* Controls the transaction with the open session in view pattern.
|
||||||
@@ -21,9 +22,14 @@ class TransactionFilter extends Filter {
|
|||||||
chain.doFilter(req, res)
|
chain.doFilter(req, res)
|
||||||
} else {
|
} else {
|
||||||
// TODO begin transaction!
|
// TODO begin transaction!
|
||||||
logger.debug("TODO begin transaction")
|
val context = req.getServletContext
|
||||||
chain.doFilter(req, res)
|
Database.forURL(context.getInitParameter("db.url"),
|
||||||
logger.debug("TODO end transaction")
|
context.getInitParameter("db.user"),
|
||||||
|
context.getInitParameter("db.password")) withTransaction {
|
||||||
|
logger.debug("TODO begin transaction")
|
||||||
|
chain.doFilter(req, res)
|
||||||
|
logger.debug("TODO end transaction")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user