This commit is contained in:
D065023
2020-01-29 09:55:21 +01:00
parent 9b41615ac8
commit bf162c23cc
3 changed files with 14 additions and 8 deletions

View File

@@ -4,6 +4,7 @@
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
"license": "SAP SAMPLE CODE LICENSE",
"dependencies": {
"@sap/xb-msg-amqp-v100": "latest",
"@sap/cds": "latest",
"express": "*"
},
@@ -18,10 +19,16 @@
"API_BUSINESS_PARTNER": {
"kind": "odata",
"model": "srv/external/API_BUSINESS_PARTNER",
"--credentials": {
"credentials": {
"destination": "cap-api098"
}
},
"messaging": {
"kind": "enterprise-messaging",
"credentials": {
"prefix": "sap/S4HANAOD/c098/BO"
}
}
}
}
}
}

View File

@@ -9,7 +9,7 @@ service CatalogService {
} excluding { createdBy, modifiedBy };
@readonly entity Addresses as projection on A_BusinessPartnerAddress {
key AddressID,
key AddressID as ID,
key BusinessPartner,
StreetName,
HouseNumber,
@@ -18,8 +18,8 @@ service CatalogService {
Country
};
event OrdersOutdated {
orders: array of my.Orders
event OrderOutdated {
ID: UUID;
};
@requires_: 'authenticated-user'

View File

@@ -10,9 +10,8 @@ module.exports = cds.service.impl(async function () {
bupaSrv.on('BusinessPartner/Changed', async msg => {
console.log('>> Received message', msg.data)
const BUSINESSPARTNER = msg.data.KEY[0].BUSINESSPARTNER
const orders = await cds.tx(msg).run(SELECT.from(Orders).where({ createdBy: BUSINESSPARTNER }))
this.emit('OrdersOutdated', { orders })
console.log('<< Emitting message', { orders })
const orders = await cds.tx(msg).run(SELECT('ID').from(Orders).where({ createdBy: BUSINESSPARTNER }))
orders.forEach(order => this.emit('OrderOutdated', order) && console.log('<< Emitting message', order))
})
/** Add some discount for overstocked books */