diff --git a/bookstore/srv/mashup.cds b/bookstore/srv/mashup.cds index 74b8f4cb..857091a6 100644 --- a/bookstore/srv/mashup.cds +++ b/bookstore/srv/mashup.cds @@ -10,12 +10,22 @@ // using { sap.capire.bookshop.Books } from '@capire/bookshop'; using { ReviewsService.Reviews } from '@capire/reviews'; +using { managed, cuid } from '@sap/cds/common'; + extend Books with { reviews : Composition of many Reviews on reviews.subject = $self.ID; rating : type of Reviews:rating; // average rating numberOfReviews : Integer @title : '{i18n>NumberOfReviews}'; + Y_characteristics : Composition of many Y_Characteristic on Y_characteristics.parent = $self; } +entity Y_Characteristic : cuid, managed { + parent : Association to one Books; + characteristicId : String; + name : String; + value : String; + uom : String; +} // // Extend Orders with Books as Products diff --git a/bookstore/test/requests.http b/bookstore/test/requests.http index c42b4bd4..65080cc7 100644 --- a/bookstore/test/requests.http +++ b/bookstore/test/requests.http @@ -79,3 +79,36 @@ Authorization: Basic alice: "dateOfBirth": "1564-04-26", "dateOfDeath": "1616-04-23" } + +### Create book +POST {{bookshop}}/admin/Books +Content-Type: application/json +Authorization: Basic alice: + +{ + "ID": 291, + "title": "Ttile1", + "author_ID": 107, + "numberOfReviews": 3, + "Y_characteristics": [{ + "ID": "e326afd9-4688-4bf5-9664-783ff997cdf5", + "characteristicId": "myid", + "name": "myname" + }] +} + +### Update book +PUT {{bookshop}}/admin/Books(291) +Content-Type: application/json +Authorization: Basic alice: + +{ + "title": "Ttile111111111", + "author_ID": 107, + "numberOfReviews": 4, + "Y_characteristics": [{ + "ID": "e326afd9-4688-4bf5-9664-783ff997cdf5", + "characteristicId": "myid123", + "name": "myname123" + }] +}