Skip to content

Commit

Permalink
feat(backend): WIP: Courier location
Browse files Browse the repository at this point in the history
  • Loading branch information
BartlomiejRasztabiga committed Oct 7, 2023
1 parent a70503f commit 7f21224
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 16 deletions.
4 changes: 2 additions & 2 deletions delivery/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val axonVersion = "4.8.3"
val kotestVersion = "5.7.2"

dependencies {
implementation("me.rasztabiga.thesis:shared:0.16.7")
implementation("me.rasztabiga.thesis:shared:0.16.8")

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
Expand All @@ -53,7 +53,7 @@ dependencies {

implementation("com.google.maps:google-maps-services:2.2.0")

testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.7"))
testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.axonframework:axon-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package me.rasztabiga.thesis.delivery.domain.command.aggregate

import me.rasztabiga.thesis.delivery.domain.command.command.CreateCourierCommand
import me.rasztabiga.thesis.delivery.domain.command.command.UpdateCourierAvailabilityCommand
import me.rasztabiga.thesis.delivery.domain.command.command.UpdateCourierLocationCommand
import me.rasztabiga.thesis.shared.adapter.`in`.rest.api.Location
import me.rasztabiga.thesis.shared.domain.command.event.CourierAvailabilityUpdatedEvent
import me.rasztabiga.thesis.shared.domain.command.event.CourierCreatedEvent
import org.axonframework.commandhandling.CommandHandler
Expand All @@ -18,6 +20,7 @@ internal class Courier {
private lateinit var id: String
private lateinit var name: String
private var availability: Availability = Availability.OFFLINE
private var location: Location? = null

constructor()

Expand All @@ -36,6 +39,16 @@ internal class Courier {
)
}

@CommandHandler
fun handle(command: UpdateCourierLocationCommand) {
apply(
CourierLocationUpdatedEvent(
id = command.id,
location = command.location
)
)
}

@EventSourcingHandler
fun on(event: CourierCreatedEvent) {
this.id = event.courierId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class OrderDelivery {
@CommandHandler
constructor(command: CreateOrderDeliveryOfferCommand, calculateDeliveryFeePort: CalculateDeliveryFeePort) {
val baseFee = calculateDeliveryFeePort.calculateBaseFee(
command.restaurantLocation.streetAddress,
command.deliveryLocation.streetAddress
command.restaurantLocation.streetAddress!!,
command.deliveryLocation.streetAddress!!
)

apply(
Expand Down
4 changes: 2 additions & 2 deletions order/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ val axonVersion = "4.8.3"
val kotestVersion = "5.7.2"

dependencies {
implementation("me.rasztabiga.thesis:shared:0.16.7")
implementation("me.rasztabiga.thesis:shared:0.16.8")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-security")
Expand All @@ -52,7 +52,7 @@ dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib"))

testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.7"))
testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.axonframework:axon-test")
Expand Down
4 changes: 2 additions & 2 deletions payment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val axonVersion = "4.8.3"
val kotestVersion = "5.7.2"

dependencies {
implementation("me.rasztabiga.thesis:shared:0.16.7")
implementation("me.rasztabiga.thesis:shared:0.16.8")

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
Expand All @@ -53,7 +53,7 @@ dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib"))

testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.7"))
testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.axonframework:axon-test")
Expand Down
4 changes: 2 additions & 2 deletions query/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val axonVersion = "4.8.3"
val kotestVersion = "5.7.2"

dependencies {
implementation("me.rasztabiga.thesis:shared:0.16.7")
implementation("me.rasztabiga.thesis:shared:0.16.8")

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
Expand All @@ -55,7 +55,7 @@ dependencies {

implementation("com.google.maps:google-maps-services:2.2.0")

testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.7"))
testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.axonframework:axon-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ class CourierHandler(
courierRepository.save(entity)
}

@EventHandler
fun on(event: CourierLocationUpdatedEvent) {
val entity = getCourier(event.id)
entity.location = event.location
courierRepository.save(entity)
}

@QueryHandler
fun handle(query: FindCourierByIdQuery): Mono<CourierResponse> {
return courierRepository.load(query.courierId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ object OrderMapper {
deliveryAddressId = entity.deliveryAddressId,
deliveryLocation = entity.deliveryLocation,
courierId = entity.courierId,
courierLocation = entity.courierLocation,
deliveryFee = entity.deliveryFee
)
}
Expand Down
4 changes: 2 additions & 2 deletions restaurant/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val axonVersion = "4.8.3"
val kotestVersion = "5.7.2"

dependencies {
implementation("me.rasztabiga.thesis:shared:0.16.7")
implementation("me.rasztabiga.thesis:shared:0.16.8")

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
Expand All @@ -51,7 +51,7 @@ dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib"))

testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.7"))
testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.axonframework:axon-test")
Expand Down
4 changes: 2 additions & 2 deletions saga/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val axonVersion = "4.8.3"
val kotestVersion = "5.7.2"

dependencies {
implementation("me.rasztabiga.thesis:shared:0.16.7")
implementation("me.rasztabiga.thesis:shared:0.16.8")

implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-security")
Expand All @@ -52,7 +52,7 @@ dependencies {
implementation(kotlin("reflect"))
implementation(kotlin("stdlib"))

testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.7"))
testImplementation(testFixtures("me.rasztabiga.thesis:shared:0.16.8"))
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.axonframework:axon-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class OrderLifecycleSaga {
productId = it.productId
)
},
restaurantAddress = order.restaurantLocation.streetAddress,
deliveryAddress = order.deliveryLocation!!.streetAddress
restaurantAddress = order.restaurantLocation.streetAddress!!,
deliveryAddress = order.deliveryLocation!!.streetAddress!!
)
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package me.rasztabiga.thesis.shared.domain.command.event

import me.rasztabiga.thesis.shared.adapter.`in`.rest.api.Location
import org.axonframework.serialization.Revision

@Revision("1.0")
data class CourierLocationUpdatedEvent(
val id: String,
val location: Location
)

0 comments on commit 7f21224

Please sign in to comment.