Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions db/orders.cds
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ entity Orders : cuid, managed {
entity OrderItems : cuid {
parent : Association to Orders;
book : Association to Books @mandatory @assert.target;
@mandatory
@assert.range: [(0), _]
quantity : Integer;
amount : Decimal(9, 2);
}
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<version>3.3.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

Expand All @@ -23,11 +23,11 @@

<!-- DEPENDENCIES VERSION -->
<jdk.version>21</jdk.version>
<cds.services.version>3.4.1</cds.services.version>
<cds.services.version>3.5.0</cds.services.version>
<cloud.sdk.version>5.13.0</cloud.sdk.version>
<xsuaa.version>3.5.3</xsuaa.version>
<cf-java-logging-support.version>3.8.4</cf-java-logging-support.version>
<cds.cdsdk-version>8.4.2</cds.cdsdk-version>
<cds.cdsdk-version>8.5.0</cds.cdsdk-version>
<cds-feature-attachments.version>1.0.5</cds-feature-attachments.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ public void beforeCreateOrder(Stream<Orders> orders, EventContext context) {
order.getItems().forEach(orderItem -> {
// validation of the Order creation request
Integer quantity = orderItem.getQuantity();
if (quantity == null || quantity <= 0) {
// errors with localized messages from property files
// exceptions abort the request and set an error http status code
// messages in contrast allow to collect multiple errors
messages.error(MessageKeys.QUANTITY_REQUIRE_MINIMUM)
.target("in", ORDERS, o -> o.Items(i -> i.ID().eq(orderItem.getId()).and(i.IsActiveEntity().eq(orderItem.getIsActiveEntity()))).quantity());
}

String bookId = orderItem.getBookId();

if(quantity == null || quantity <= 0 || bookId == null) {
Expand Down
Loading