Compare commits
5 Commits
openSAP-we
...
openSAP-we
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62f32abf74 | ||
|
|
536282388c | ||
|
|
75e767ed5c | ||
|
|
ba1eead6db | ||
|
|
8233703815 |
@@ -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-week3-unit1
|
||||
git clone https://github.com/sap-samples/cloud-cap-samples projects/cloud-cap-samples -b openSAP-week2-unit3
|
||||
cd projects/cloud-cap-samples
|
||||
```
|
||||
|
||||
|
||||
@@ -8,11 +8,7 @@
|
||||
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
|
||||
"install": "(npm -s run lerna) && lerna bootstrap --hoist",
|
||||
"cleanup": "lerna clean -y && rm -fr node_modules",
|
||||
"bookshop": "cds watch packages/bookshop",
|
||||
"bookshop-enhanced": "cds watch packages/bookshop-enhanced",
|
||||
"reviews-service": "cds watch packages/reviews-service",
|
||||
"bookstore": "cds watch packages/bookstore",
|
||||
"media-server": "cds watch packages/media-server"
|
||||
"bookshop": "cds watch packages/bookshop"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "^3",
|
||||
|
||||
@@ -11,6 +11,7 @@ entity Books : managed {
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
@cds.autoexpose
|
||||
entity Authors : managed {
|
||||
key ID : Integer;
|
||||
name : String(111);
|
||||
|
||||
@@ -3,9 +3,7 @@ using { sap.capire.bookshop as my } from '../db/schema';
|
||||
@path:'/browse'
|
||||
service CatalogService {
|
||||
|
||||
@readonly entity Books as SELECT from my.Books {*,
|
||||
author.name as author
|
||||
} excluding { createdBy, modifiedBy };
|
||||
@readonly entity Books as SELECT from my.Books { * } excluding { createdBy, modifiedBy };
|
||||
|
||||
@requires_: 'authenticated-user'
|
||||
@insertonly entity Orders as projection on my.Orders;
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
### Service Document
|
||||
GET http://localhost:4004/admin/Authors
|
||||
|
||||
### Create Author
|
||||
POST http://localhost:4004/admin/Authors HTTP/1.1
|
||||
content-Type: application/json
|
||||
|
||||
{
|
||||
"ID": 105,
|
||||
"name": "J.K. Rowling",
|
||||
"dateOfBirth": null,
|
||||
"dateOfDeath": null,
|
||||
"placeOfBirth": "",
|
||||
"placeOfDeath": ""
|
||||
}
|
||||
### Update Author
|
||||
PATCH http://localhost:4004/admin/Authors/105 HTTP/1.1
|
||||
content-Type: application/json
|
||||
|
||||
{
|
||||
"placeOfBirth": "United Kingdom"
|
||||
}
|
||||
|
||||
### Delete Author
|
||||
DELETE http://localhost:4004/admin/Authors/105 HTTP/1.1
|
||||
@@ -1,18 +1,14 @@
|
||||
### Service Document
|
||||
GET http://localhost:4004/browse
|
||||
### Browse Books
|
||||
GET http://localhost:4004/browse/Books
|
||||
|
||||
### Service $metadata document
|
||||
GET http://localhost:4004/browse/$metadata
|
||||
### Browse Books with expanded Authors
|
||||
GET http://localhost:4004/browse/Books?$expand=author
|
||||
|
||||
### Browsing Books
|
||||
GET http://localhost:4004/browse/Books?
|
||||
# &$select=title,author
|
||||
# &$expand=currency
|
||||
# &sap-language=de
|
||||
### Try to insert into Books
|
||||
POST http://localhost:4004/browse/Books
|
||||
Content-Type: application/json
|
||||
|
||||
### Browsing Authors
|
||||
GET http://localhost:4004/admin/Authors?
|
||||
# &$select=name,dateOfBirth,placeOfBirth
|
||||
# &$expand=books($select=title;$expand=currency)
|
||||
# &$filter=ID eq 101
|
||||
# &sap-language=de
|
||||
{
|
||||
"title": "Anna Karenina",
|
||||
"stock": 10
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
|
||||
### List Books with their current stocks
|
||||
GET http://localhost:4004/admin/Books?$select=ID,stock
|
||||
|
||||
### List all Orders
|
||||
### List all Orders - deep read
|
||||
GET http://localhost:4004/admin/Orders?
|
||||
&$expand=Items
|
||||
|
||||
### Submit Orders
|
||||
### Submit Orders - deep insert
|
||||
POST http://localhost:4004/browse/Orders
|
||||
Content-Type: application/json
|
||||
|
||||
{ "OrderNo":"2019-09...", "Items":[
|
||||
{ "OrderNo":"1234", "Items":[
|
||||
{ "book_ID":201, "amount":5 },
|
||||
{ "book_ID":207, "amount":3 }
|
||||
]}
|
||||
|
||||
# Sending this three times should result in a 409: 5 exceeds stock for book #201
|
||||
### Try to get the Orders
|
||||
GET http://localhost:4004/browse/Orders
|
||||
Reference in New Issue
Block a user