(refs #114)Add remove option to user management.

This commit is contained in:
takezoe
2013-11-02 13:44:47 +09:00
parent bcc2c8cc2d
commit 07bb326c06
5 changed files with 64 additions and 37 deletions

View File

@@ -57,7 +57,12 @@ trait AccountService {
def getAccountByMailAddress(mailAddress: String): Option[Account] =
Query(Accounts) filter(_.mailAddress is mailAddress.bind) firstOption
def getAllUsers(): List[Account] = Query(Accounts) sortBy(_.userName) list
def getAllUsers(includeRemoved: Boolean = true): List[Account] =
if(includeRemoved){
Query(Accounts) sortBy(_.userName) list
} else {
Query(Accounts) filter (_.removed is false.bind) sortBy(_.userName) list
}
def createAccount(userName: String, password: String, fullName: String, mailAddress: String, isAdmin: Boolean, url: Option[String]): Unit =
Accounts insert Account(
@@ -77,7 +82,7 @@ trait AccountService {
def updateAccount(account: Account): Unit =
Accounts
.filter { a => a.userName is account.userName.bind }
.map { a => a.password ~ a.fullName ~ a.mailAddress ~ a.isAdmin ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? }
.map { a => a.password ~ a.fullName ~ a.mailAddress ~ a.isAdmin ~ a.url.? ~ a.registeredDate ~ a.updatedDate ~ a.lastLoginDate.? ~ a.removed }
.update (
account.password,
account.fullName,
@@ -86,7 +91,8 @@ trait AccountService {
account.url,
account.registeredDate,
currentDate,
account.lastLoginDate)
account.lastLoginDate,
account.isRemoved)
def updateAvatarImage(userName: String, image: Option[String]): Unit =
Accounts.filter(_.userName is userName.bind).map(_.image.?).update(image)