imported
This commit is contained in:
@@ -18,14 +18,7 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"API_BUSINESS_PARTNER": {
|
"API_BUSINESS_PARTNER": {
|
||||||
"kind": "odata",
|
"kind": "odata",
|
||||||
"model": "srv/external/API_BUSINESS_PARTNER",
|
"model": "srv/external/API_BUSINESS_PARTNER"
|
||||||
"--credentials": {
|
|
||||||
"prefix": "sap/S4HANAOD/c098/BO",
|
|
||||||
"destination": "cap-api098"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"--messaging": {
|
|
||||||
"kind": "enterprise-messaging"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using { sap.capire.bookshop as my } from '../db/schema';
|
using { sap.capire.bookshop as my } from '../db/schema';
|
||||||
using { API_BUSINESS_PARTNER as external } from './external/API_BUSINESS_PARTNER.csn';
|
|
||||||
|
|
||||||
@path:'/browse'
|
@path:'/browse'
|
||||||
service CatalogService {
|
service CatalogService {
|
||||||
@@ -8,14 +7,6 @@ service CatalogService {
|
|||||||
author.name as author
|
author.name as author
|
||||||
} excluding { createdBy, modifiedBy };
|
} excluding { createdBy, modifiedBy };
|
||||||
|
|
||||||
@readonly entity BusinessPartners as projection on external.A_BusinessPartner {
|
|
||||||
key BusinessPartner as ID,
|
|
||||||
FirstName,
|
|
||||||
MiddleName,
|
|
||||||
LastName,
|
|
||||||
BusinessPartnerIsBlocked
|
|
||||||
};
|
|
||||||
|
|
||||||
@requires_: 'authenticated-user'
|
@requires_: 'authenticated-user'
|
||||||
@insertonly entity Orders as projection on my.Orders;
|
@insertonly entity Orders as projection on my.Orders;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
const cds = require('@sap/cds')
|
const cds = require('@sap/cds')
|
||||||
|
|
||||||
/** Service implementation for CatalogService */
|
/** Service implementation for CatalogService */
|
||||||
module.exports = cds.service.impl(async function () {
|
module.exports = cds.service.impl(function () {
|
||||||
const { Books, Orders, BusinessPartners } = this.entities
|
const { Books, Orders } = this.entities
|
||||||
const bupaSrv = await cds.connect.to('API_BUSINESS_PARTNER')
|
|
||||||
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
this.after('READ', Books, each => each.stock > 111 && _addDiscount2(each, 11))
|
||||||
this.before('CREATE', Orders, _reduceStock)
|
this.before('CREATE', Orders, _reduceStock)
|
||||||
this.on('READ', BusinessPartners, req => bupaSrv.tx(req).run(req.query))
|
|
||||||
|
|
||||||
/** Add some discount for overstocked books */
|
/** Add some discount for overstocked books */
|
||||||
function _addDiscount2(each, discount) {
|
function _addDiscount2(each, discount) {
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
BusinessPartner;FirstName;MiddleName;LastName;BusinessPartnerIsBlocked
|
|
||||||
ALICE;Alice;In;Wonderland;false
|
|
||||||
BOB;Bob;The;Builder;false
|
|
||||||
JABBA;Jabba;The;Hutt;true
|
|
||||||
|
Reference in New Issue
Block a user