io.zenwave360.sdk.resources.jdl.orders-model-eda-idl.jdl Maven / Gradle / Ivy
/* Customers */
@aggregate
@search(elasticsearch)
@searchCriteria
entity Customer {
username String required minlength(3) maxlength(250),
password String required minlength(3) maxlength(250),
email String required minlength(3) maxlength(250),
firstName String required minlength(3) maxlength(250),
lastName String required minlength(3) maxlength(250)
}
/* Orders */
enum OrderStatus { CONFIRMED, SHIPPED, DELIVERED }
@aggregate
@searchCriteria(CustomerOrderSearchCriteria)
entity CustomerOrder { // Order is a reserved word
date Instant,
status OrderStatus
@dbref customer Customer
orderedItems OrderedItem[]
paymentDetails PaymentDetails[]
shippingDetails ShippingDetails
}
@skip
entity CustomerOrderSearchCriteria {
status OrderStatus
dateFrom Instant
dateTo Instant
}
@embedded
entity OrderedItem {
catalogItemId Long,
name String required minlength(3) maxlength(250),
price BigDecimal required,
quantity Integer
}
@embedded
entity PaymentDetails {
creditCardNumber String
}
@embedded
entity ShippingDetails {
address String
}
services {
service CustomeUseCases (Customer) {
createCustomer(Customer) Customer events onCustomerEvent(CustomerCreated)
updateCustomer(id, customer Customer) Customer events onCustomerEvent(CustomerUpdated), onCustomerAddressEvent(CustomerAddressUpdated)
deleteCustomer(id) void events onCustomerEvent(CustomerDeleted)
}
service CustomerOrderUseCases (CustomerOrder) {
createCustomerOrder(CustomerOrder) CustomerOrder events onCustomerOrderEvent(CustomerOrderCreated)
updateCustomerOrder(id, customerOrder CustomerOrder) CustomerOrder events onCustomerOrderEvent(CustomerOrderUpdated)
deleteCustomerOrder(id) events onCustomerOrderEvent(CustomerOrderDeleted)
}
}
events {
event CustomerCreated {
customerId Long
customer Customer
}
event CustomerUpdated {
customerId Long
customer Customer
}
event CustomerAddressUpdated {
customerId Long
address Address
}
operation onCustomerEvent {
channel customers
events CustomerCreated, CustomerUpdated
}
operation onCustomerAddressEvent {
channel customers
events CustomerAddressUpdated
}
operation onCustomerOrderEvent {
channel customerOrders
events CustomerOrderCreated, CustomerOrderUpdated
}
}