Improved module name <functional-area>-<Command|Query>....

Standalone services now use the Event Store Server (many tests still use the embedded server)
This commit is contained in:
Chris Richardson
2015-04-14 19:08:07 -07:00
parent d166c9b852
commit 2e31853ad2
150 changed files with 1237 additions and 109 deletions

View File

@@ -0,0 +1,10 @@
apply plugin: 'scala'
dependencies {
compile "org.scala-lang:scala-library:2.10.2"
compile project(":transactions-command-side-backend")
compile project(":common-web")
testCompile "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
testCompile scalaTestDependency
}

View File

@@ -0,0 +1,11 @@
package net.chrisrichardson.eventstore.examples.bank.web.transactions
import net.chrisrichardson.eventstore.examples.bank.transactions.TransactionConfiguration
import org.springframework.context.annotation.{ComponentScan, Configuration, Import}
@Configuration
@Import(Array(classOf[TransactionConfiguration]))
@ComponentScan
class CommandSideWebTransactionsConfiguration {
}

View File

@@ -0,0 +1,11 @@
package net.chrisrichardson.eventstore.examples.bank.web.transactions.controllers
import net.chrisrichardson.eventstore.EntityId
import net.chrisrichardson.eventstore.examples.bank.transactions.TransferStates
case class CreateMoneyTransferResponse(transactionId : String)
case class MoneyTransferRequest(fromAccountId : EntityId, toAccountId : EntityId, amount: BigDecimal)
case class GetMoneyTransferResponse(transactionId : String, status : String)

View File

@@ -0,0 +1,30 @@
package net.chrisrichardson.eventstore.examples.bank.web.transactions.controllers
import net.chrisrichardson.eventstore.EntityId
import net.chrisrichardson.eventstore.EventStore
import net.chrisrichardson.eventstore.examples.bank.backend.common.transactions.TransferDetails
import net.chrisrichardson.eventstore.examples.bank.transactions.{MoneyTransferService, MoneyTransfer}
import net.chrisrichardson.eventstore.examples.bank.web.util.WebUtil
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation._
import scala.concurrent.ExecutionContext.Implicits.global
@RestController
class MoneyTransferController @Autowired()(moneyTransferService : MoneyTransferService,
eventStore : EventStore) {
@RequestMapping(value=Array("/transfers"), method = Array(RequestMethod.POST))
def create(@RequestBody transferDetails : TransferDetails) = WebUtil.toDeferredResult {
for (transaction <- moneyTransferService.transferMoney(transferDetails))
yield CreateMoneyTransferResponse(transaction.entityId.id)
}
@RequestMapping(value=Array("/transfers/{transferId}"), method = Array(RequestMethod.GET))
def get(@PathVariable transferId : String) = {
val f = eventStore.find[MoneyTransfer](EntityId(transferId))
WebUtil.toDeferredResult(f map(transactionAggregate => GetMoneyTransferResponse(transferId, transactionAggregate.entity.state.getClass.getSimpleName)))
}
}