Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Separação tecnologia da implementação da regra do negócio. Com isso mudar de tecnologia de persistência e framework web fica bem mais fácil
post("/") {
contentType = "application/json"
authenticated { jsonObject =>
val entityManager = entityManagerFactory.createEntityManager()
val userRepository = new UserRepository(entityManager)
val userPersistenceAdapter = new NewUserPersistenceAdapterJPA(userRepository)
val usecase = new NewUserUsecase(userPersistenceAdapter)
val savedUser = usecase.save( User( jsonObject ) )
writeOkResponse( ProtocolResponse.prepare(savedUser.state) )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.