Fix updating in AccountService.

This commit is contained in:
takezoe
2013-06-04 18:29:08 +09:00
parent 79a0ba5630
commit 2b599a3052

View File

@@ -13,12 +13,11 @@ trait AccountService {
def createAccount(account: Account): Unit = Accounts.* insert account def createAccount(account: Account): Unit = Accounts.* insert account
def updateAccount(account: Account): Unit = { def updateAccount(account: Account): Unit =
val q = for { Query(Accounts)
a <- Accounts if a.userName is account.userName.bind .filter { a => a.userName is account.userName.bind }
} yield a.password ~ a.mailAddress ~ a.userType ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? .map { a => a.password ~ a.mailAddress ~ a.userType ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? }
.update (
q.update(
account.password, account.password,
account.mailAddress, account.mailAddress,
account.userType, account.userType,
@@ -26,15 +25,10 @@ trait AccountService {
account.registeredDate, account.registeredDate,
account.updatedDate, account.updatedDate,
account.lastLoginDate) account.lastLoginDate)
}
def updateLastLoginDate(userName: String): Unit = { def updateLastLoginDate(userName: String): Unit =
val q = for { Query(Accounts).filter(_.userName is userName.bind).map(_.lastLoginDate)
a <- Accounts if a.userName is userName.bind .update(new java.sql.Date(System.currentTimeMillis))
} yield a.lastLoginDate
q.update(new java.sql.Date(System.currentTimeMillis))
}
} }