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:
10
scala-spring/transactions-command-side-web/build.gradle
Normal file
10
scala-spring/transactions-command-side-web/build.gradle
Normal 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
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user