Open patrykcelinski opened 4 years ago
object HomeController {
case class CreateNoteRequest(title: String, body: String, userId: Int)
case class RegisterUserRequest(name: String, lastName: String, email: String, password: String)
case class UpdatePasswordRequest(userId: Int, oldPassword: String, newPassword: String)
implicit val readsCreateNoteRequest: Reads[CreateNoteRequest] = Json.reads[CreateNoteRequest]
implicit val readsUserNoteRequest: Reads[RegisterUserRequest] = Json.reads[RegisterUserRequest]
implicit val readsUpdatePasswordRequest: Reads[UpdatePasswordRequest] = Json.reads[UpdatePasswordRequest]
}
zastanawiam sie jak ograniczyc dostep tylko dla controllera, private[HomeController] nie dziala
https://github.com/SuperXtra/NotepadApi/blob/be211e4f50aaee61a7bcfeb548bd2376fccf6aa6/app/model/dto/NoteDto.scala#L5
Move these classes to companion object of their controllers and rename e.g. NoteDto -> CreateNoteRequest, RegisterUserRequest. Make them private for controller so it won't leak to service layer.
This is bad:
Should be something like::
You should use these CreateNoteRequest object just to deserialize request entity. Then service shouldn't know about them.
BTW there is a bug in
createNote
method that Id was always 0.