Skip to content

Instantly share code, notes, and snippets.

@Hajto
Created September 12, 2015 14:21
Show Gist options
  • Save Hajto/a355b800f334a584a547 to your computer and use it in GitHub Desktop.
Save Hajto/a355b800f334a584a547 to your computer and use it in GitHub Desktop.
Trying to resolve problem
package model
import play.api.data.Form
import play.api.libs.json.Json
import model.SkillFormats.skillRecordFormat
import play.api.data._
import play.api.data.Forms._
object UserFormats {
implicit val userForm = Form(
mapping(
"login" -> text,
"password" -> text
)(UserLoginData.apply)(UserLoginData.unapply)
)
implicit val registerForm = Form(
mapping(
"name" -> text,
"surname" -> text,
"login" -> text,
"password" -> text,
"email" -> text
)
)(User.apply)(User.unapply)
implicit val userFormat = Json.format[User]
}
case class UserLoginData(login: String, password: String)
object User {
def apply(name: String, surname: String, login: String, password: String, email: String) =
new User(name, surname, login, password, email, List())
}
case class User(name: String, surname: String, login: String, password: String, email: String, skillSet: List[SkillRecord] = List()) {
// def apply(name: String, surname: String, login: String, password: String, email: String) =
// new User(name, surname, login, password, email, List())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment