sync API
This commit is contained in:
@@ -14,7 +14,10 @@
|
||||
"requires": {
|
||||
"API_BUSINESS_PARTNER": {
|
||||
"kind": "odata",
|
||||
"model": "srv/external/API_BUSINESS_PARTNER"
|
||||
"model": "srv/external/API_BUSINESS_PARTNER",
|
||||
"credentials": {
|
||||
"destination": "API098"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using { sap.capire.bookshop as my } from '../db/schema';
|
||||
using { API_BUSINESS_PARTNER.A_BusinessPartnerAddress } from './external/API_BUSINESS_PARTNER.csn';
|
||||
|
||||
@path:'/browse'
|
||||
service CatalogService {
|
||||
@@ -7,6 +8,15 @@ service CatalogService {
|
||||
author.name as author
|
||||
} excluding { createdBy, modifiedBy };
|
||||
|
||||
@readonly entity Addresses as projection on A_BusinessPartnerAddress {
|
||||
key AddressID,
|
||||
key BusinessPartner,
|
||||
StreetName,
|
||||
CityName,
|
||||
HouseNumber,
|
||||
Country
|
||||
};
|
||||
|
||||
@requires_: 'authenticated-user'
|
||||
@insertonly entity Orders as projection on my.Orders;
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@ const cds = require('@sap/cds')
|
||||
const { Books } = cds.entities
|
||||
|
||||
/** Service implementation for CatalogService */
|
||||
module.exports = cds.service.impl(function() {
|
||||
module.exports = cds.service.impl(async function() {
|
||||
const bupaSrv = await cds.connect.to('API_BUSINESS_PARTNER')
|
||||
const { A_BusinessPartnerAddress } = bupaSrv.entities
|
||||
this.after ('READ', 'Books', each => each.stock > 111 && _addDiscount2(each,11))
|
||||
this.before ('CREATE', 'Orders', _reduceStock)
|
||||
this.on('READ', 'Addresses', req => bupaSrv.run(req.query.from(A_BusinessPartnerAddress)))
|
||||
})
|
||||
|
||||
/** Add some discount for overstocked books */
|
||||
|
||||
5
packages/bookshop/srv/external/data/API_BUSINESS_PARTNER-A_BusinessPartnerAddress.csv
vendored
Normal file
5
packages/bookshop/srv/external/data/API_BUSINESS_PARTNER-A_BusinessPartnerAddress.csv
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
BusinessPartner;AddressID;CityName;PostalCode;Country;StreetName;HouseNumber
|
||||
ALICE;62640;Walldorf;69190;GER;Dietmer-Hopp-Allee;16
|
||||
ALICE;62641;Berlin;69390;GER;Berlin-Street;19
|
||||
BOB;62341;Karlsruhe;61390;GER;Karlsruhe-Street;19
|
||||
anonymous;61321;Sometown;61290;GER;Sometown-Street;19
|
||||
|
Reference in New Issue
Block a user