Compare commits

..

8 Commits

Author SHA1 Message Date
Christian Georgi
f28bfbb768 Update README.md 2020-04-20 17:12:04 +02:00
Christian Georgi
7d8ca4d4a1 Add package-lock.json, fix readme 2020-04-02 16:15:51 +02:00
Christian Georgi
61aa81a806 Update readme 2020-03-23 17:11:22 +01:00
D065023
e7c395671b rm other packages 2020-03-20 10:54:25 +01:00
Dr. David Kunz
cd245c4641 Update package.json 2020-02-11 11:50:15 +01:00
D065023
d081438a6a default 2020-01-29 15:22:26 +01:00
D065023
79c3a22224 rm amqp and req 2020-01-29 15:21:13 +01:00
D065023
9c30ad7584 package.json 2020-01-29 14:58:14 +01:00
6 changed files with 24 additions and 6 deletions

View File

@@ -11,7 +11,7 @@ In SAP Business Application Studio, open a terminal.
Then clone the repo with this specific branch:
```sh
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit1-final
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week4-unit2-final
cd projects/cloud-cap-samples
```

View File

@@ -35,8 +35,8 @@ entity Authors : managed {
entity Orders : cuid, managed {
OrderNo : String @title : 'Order Number'; //> readable key
status : Status default 'processing';
Items : Composition of many OrderItems
status : Status default 'processing';
Items : Composition of many OrderItems
on Items.parent = $self;
total : Decimal(9, 2)@readonly;
currency : Currency;

View File

@@ -18,7 +18,10 @@
"requires": {
"API_BUSINESS_PARTNER": {
"kind": "odata",
"model": "srv/external/API_BUSINESS_PARTNER"
"model": "srv/external/API_BUSINESS_PARTNER",
"--credentials": {
"destination": "cap-api098"
}
}
}
}

View File

@@ -1,4 +1,5 @@
using { sap.capire.bookshop as my } from '../db/schema';
using { API_BUSINESS_PARTNER as external } from './external/API_BUSINESS_PARTNER.csn';
@path:'/browse'
service CatalogService {
@@ -7,6 +8,14 @@ service CatalogService {
author.name as author
} excluding { createdBy, modifiedBy };
@readonly entity BusinessPartners as projection on external.A_BusinessPartner {
key BusinessPartner as ID,
FirstName,
MiddleName,
LastName,
BusinessPartnerIsBlocked
};
@requires_: 'authenticated-user'
@insertonly entity Orders as projection on my.Orders;

View File

@@ -1,10 +1,12 @@
const cds = require('@sap/cds')
/** Service implementation for CatalogService */
module.exports = cds.service.impl(function () {
const { Books, Orders } = this.entities
module.exports = cds.service.impl(async function () {
const { Books, Orders, BusinessPartners } = this.entities
const bupaSrv = await cds.connect.to('API_BUSINESS_PARTNER')
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
this.before('CREATE', Orders, _reduceStock)
this.on('READ', BusinessPartners, req => bupaSrv.tx(req).run(req.query))
/** Add some discount for overstocked books */
function _addDiscount2(each, discount) {

View File

@@ -0,0 +1,4 @@
BusinessPartner;FirstName;MiddleName;LastName;BusinessPartnerIsBlocked
ALICE;Alice;In;Wonderland;false
BOB;Bob;The;Builder;false
JABBA;Jabba;The;Hutt;true
1 BusinessPartner FirstName MiddleName LastName BusinessPartnerIsBlocked
2 ALICE Alice In Wonderland false
3 BOB Bob The Builder false
4 JABBA Jabba The Hutt true