-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin solution branch #1
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.axoniq.demo.bikerental.coreapi.payment | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
|
||
@Entity | ||
data class PaymentStatus( | ||
@Id var id: String, | ||
val amount: Int, | ||
val reference: String, | ||
val status: Status = Status.PENDING, | ||
) { | ||
fun approved() = this.copy(status = Status.APPROVED) | ||
fun rejected() = this.copy(status = Status.REJECTED) | ||
|
||
enum class Status { PENDING, APPROVED, REJECTED } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.axoniq.demo.bikerental.coreapi.payment | ||
|
||
import org.axonframework.commandhandling.RoutingKey | ||
import org.axonframework.modelling.command.TargetAggregateIdentifier | ||
|
||
data class PreparePaymentCommand( | ||
val amount: Int, | ||
@RoutingKey val paymentReference: String | ||
) | ||
|
||
data class ConfirmPaymentCommand( | ||
@TargetAggregateIdentifier val paymentId: String | ||
) | ||
|
||
data class RejectPaymentCommand( | ||
@TargetAggregateIdentifier val paymentId: String | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.axoniq.demo.bikerental.coreapi.payment | ||
|
||
data class PaymentConfirmedEvent( | ||
val paymentId: String, | ||
val paymentReference: String | ||
) | ||
|
||
data class PaymentPreparedEvent( | ||
val paymentId: String, | ||
val amount: Int, | ||
val paymentReference: String | ||
) | ||
|
||
data class PaymentRejectedEvent( | ||
val paymentId: String, | ||
val paymentReference: String | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.axoniq.demo.bikerental.coreapi.rental | ||
|
||
import jakarta.persistence.Entity | ||
import jakarta.persistence.Id | ||
|
||
@Entity | ||
data class BikeStatus( | ||
@Id | ||
var bikeId: String, | ||
val bikeType: String, | ||
val location: String, | ||
val status: RentalStatus = RentalStatus.AVAILABLE, | ||
val renter: String? = null, | ||
) { | ||
|
||
fun returnedAt(location: String) = this.copy( | ||
location = location, | ||
status = RentalStatus.AVAILABLE, | ||
renter = null | ||
) | ||
|
||
fun requestedBy(renter: String) = this.copy( | ||
status = RentalStatus.REQUESTED, | ||
renter = renter | ||
) | ||
|
||
fun rentedBy(renter: String) = this.copy( | ||
status = RentalStatus.RENTED, | ||
renter = renter | ||
) | ||
|
||
val description: String | ||
get() = when (status) { | ||
RentalStatus.RENTED -> "Bike $bikeId was rented by $renter in $location" | ||
RentalStatus.AVAILABLE -> "Bike $bikeId is available for rental in $location." | ||
RentalStatus.REQUESTED -> "Bike $bikeId is requested by $renter in $location" | ||
} | ||
} | ||
|
||
enum class RentalStatus { | ||
AVAILABLE, | ||
REQUESTED, | ||
RENTED | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to root pom