Created
October 25, 2015 16:26
-
-
Save agnaldo4j/aae4f2cb85eaaf057211 to your computer and use it in GitHub Desktop.
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
This file contains 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
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