Add AccountService#updateAccount()

This commit is contained in:
takezoe
2013-06-04 13:59:21 +09:00
parent 597e3d251c
commit 315da9caa5
2 changed files with 25 additions and 4 deletions

View File

@@ -6,14 +6,28 @@ import Database.threadLocalSession
trait AccountService {
def getAccountByUserName(userName: String): Option[Account] =
def getAccountByUserName(userName: String): Option[Account] =
Query(Accounts) filter(_.userName is userName.bind) firstOption
def getAllUsers(): List[Account] =
Query(Accounts) sortBy(_.userName) list
def getAllUsers(): List[Account] = Query(Accounts) sortBy(_.userName) list
def createAccount(account: Account): Unit = Accounts.* insert account
def updateAccount(account: Account): Unit = {
val q = for {
a <- Accounts if a.userName is account.userName.bind
} yield a.password ~ a.mailAddress ~ a.userType ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.?
q.update(
account.password,
account.mailAddress,
account.userType,
account.url,
account.registeredDate,
account.updatedDate,
account.lastLoginDate)
}
}
object AccountService {