Skip to content

Commit

Permalink
Use mongoOperations directly in GameViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
johanhaleby committed Dec 22, 2023
1 parent 375b096 commit 52b37e2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package org.occurrent.example.domain.rps.decidermodel.web.cqrs.gameplay
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL
import org.occurrent.dsl.subscription.blocking.Subscriptions
import org.occurrent.dsl.view.currentState
import org.occurrent.dsl.view.materialized
import org.occurrent.dsl.view.updateView
import org.occurrent.dsl.view.view
Expand All @@ -30,6 +29,7 @@ import org.occurrent.example.domain.rps.decidermodel.web.cqrs.gameplay.GameStatu
import org.springframework.data.annotation.Id
import org.springframework.data.annotation.TypeAlias
import org.springframework.data.mongodb.core.MongoOperations
import org.springframework.data.mongodb.core.findById
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.http.MediaType
import org.springframework.stereotype.Component
Expand Down Expand Up @@ -74,7 +74,7 @@ sealed interface GameReadModel {
class GameViewController(private val mongoOperations: MongoOperations) {

@GetMapping("/{gameId}")
fun showGame(@PathVariable("gameId") gameId: GameId): GameReadModel? = gameView.currentState(mongoOperations, gameId)
fun showGame(@PathVariable("gameId") gameId: GameId): GameReadModel? = mongoOperations.findById(gameId)
}

private val gameView = view<GameReadModel?, GameEvent>(
Expand Down

0 comments on commit 52b37e2

Please sign in to comment.