From 1ea4b15d77229b238f622f9e38c8b31244d5fa04 Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Thu, 2 Nov 2023 08:40:01 +0530 Subject: [PATCH 1/3] . --- bookstore/srv/mashup.cds | 23 ++++++----------------- etc/samples.drawio.svg | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/bookstore/srv/mashup.cds b/bookstore/srv/mashup.cds index 7344ff1a..74b8f4cb 100644 --- a/bookstore/srv/mashup.cds +++ b/bookstore/srv/mashup.cds @@ -4,20 +4,16 @@ // respective reuse packages and services // -using { sap.capire.bookshop.Books } from '@capire/bookshop'; // // Extend Books with access to Reviews and average ratings // +using { sap.capire.bookshop.Books } from '@capire/bookshop'; using { ReviewsService.Reviews } from '@capire/reviews'; extend Books with { reviews : Composition of many Reviews on reviews.subject = $self.ID; - - @Common.Label : '{i18n>Rating}' - rating : Decimal; - - @Common.Label : '{i18n>NumberOfReviews}' - numberOfReviews : Integer; + rating : type of Reviews:rating; // average rating + numberOfReviews : Integer @title : '{i18n>NumberOfReviews}'; } @@ -25,18 +21,11 @@ extend Books with { // Extend Orders with Books as Products // using { sap.capire.orders.Orders } from '@capire/orders'; -extend Orders with { - extend Items with { - book : Association to Books on product.ID = book.ID - } +extend Orders:Items with { + book : Association to Books on product.ID = book.ID } - -// Add orders fiori app (in case of embedded orders service) +// Ensure models from all imported packages are loaded using from '@capire/orders/app/fiori'; - -// Add data browser using from '@capire/data-viewer'; - -// Incorporate pre-build extensions from... using from '@capire/common'; diff --git a/etc/samples.drawio.svg b/etc/samples.drawio.svg index 2588e138..43febc30 100644 --- a/etc/samples.drawio.svg +++ b/etc/samples.drawio.svg @@ -1,4 +1,4 @@ - + From 1e0ac9609c8139cc83a30ddead0a6ee632d8b238 Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Mon, 6 Nov 2023 04:58:43 +0100 Subject: [PATCH 2/3] . --- bookshop/db/schema.cds | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bookshop/db/schema.cds b/bookshop/db/schema.cds index f2fb626f..930f19eb 100644 --- a/bookshop/db/schema.cds +++ b/bookshop/db/schema.cds @@ -2,25 +2,25 @@ using { Currency, managed, sap } from '@sap/cds/common'; namespace sap.capire.bookshop; entity Books : managed { - key ID : Integer; - title : localized String(111) @mandatory ; - descr : localized String(1111); - author : Association to Authors @mandatory; - genre : Association to Genres; - stock : Integer; - price : Decimal; + key ID : Integer; + title : localized String(111) @mandatory; + descr : localized String(1111); + author : Association to Authors @mandatory; + genre : Association to Genres; + stock : Integer; + price : Decimal; currency : Currency; - image : LargeBinary @Core.MediaType : 'image/png'; + image : LargeBinary @Core.MediaType: 'image/png'; } entity Authors : managed { - key ID : Integer; - name : String(111) @mandatory; + key ID : Integer; + name : String(111) @mandatory; dateOfBirth : Date; dateOfDeath : Date; placeOfBirth : String; placeOfDeath : String; - books : Association to many Books on books.author = $self; + books : Association to many Books on books.author = $self; } /** Hierarchically organized Code List for Genres */ From 1ff14d3a09d7a9bcb9162e9cdf4fa80992acd874 Mon Sep 17 00:00:00 2001 From: Daniel Hutzel Date: Mon, 6 Nov 2023 05:03:10 +0100 Subject: [PATCH 3/3] cosmetics --- bookshop/srv/admin-service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bookshop/srv/admin-service.js b/bookshop/srv/admin-service.js index 7a5d5804..d737a65a 100644 --- a/bookshop/srv/admin-service.js +++ b/bookshop/srv/admin-service.js @@ -8,6 +8,6 @@ module.exports = class AdminService extends cds.ApplicationService { init(){ /** Generate primary keys for target entity in request */ async function genid (req) { - const {ID} = await cds.tx(req).run (SELECT.one.from(req.target).columns('max(ID) as ID')) - req.data.ID = ID - ID % 100 + 100 + 1 + const {id} = await SELECT.one.from(req.target).columns('max(ID) as id') + req.data.ID = id - id % 100 + 100 + 1 }