Created
January 4, 2015 00:26
-
-
Save sergiopvilar/7fba93a13ad8edde69b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.scrumplus.entity | |
import java.util.Date | |
import javax.persistence._ | |
import com.scrumplus.core.framework.crud.{AppEntity, BaseCRUD} | |
import scala.beans.BeanProperty | |
/** | |
* @project simple-heroku-webapp | |
* @author sergiovilar | |
* @date: 12/21/14 | |
*/ | |
@Entity | |
@Table(name="user") | |
class User extends AppEntity{ | |
@Transient | |
override val validations = Map( | |
"email" -> Map( | |
"function" -> ((bo: BaseCRUD[User], email: String) => bo.findBy("email", email).size() > 0), | |
"message" -> "201: Este email já está em uso" | |
), | |
"username" -> Map( | |
"function" -> ((bo: BaseCRUD[User], username: String) => bo.findBy("username", username).size() > 0), | |
"message" -> "202: Este nome de usuário já está em uso" | |
) | |
) | |
@Id | |
@Column | |
@GeneratedValue | |
@BeanProperty | |
var id: Long = 0 | |
// ----- Dados pessoais | |
@Column | |
@BeanProperty | |
var name = "" | |
@Column | |
@BeanProperty | |
var lastName = "" | |
@Column(unique=true) | |
@BeanProperty | |
var email = "" | |
@Column | |
@BeanProperty | |
var username = "" | |
@Column | |
var password = "" | |
def setPassword(pass: String) = password = pass | |
// ----- Status | |
@Column | |
@BeanProperty | |
var active = true | |
@Column | |
@BeanProperty | |
var lastLogin = new Date() | |
@Column | |
var created = new Date() | |
def getCreated() = created | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment