Compare commits

..

24 Commits

Author SHA1 Message Date
Heiko Witteborg
b97da977e5 Prepare for serve_on_root false 2023-06-16 10:07:48 +02:00
Christian Georgi
50085fe7be Better clone path 2020-04-20 17:09:47 +02:00
Christian Georgi
8c3733c9cd Add package-lock.json, fix readme 2020-04-02 15:54:15 +02:00
Christian Georgi
a412c41970 Update readme 2020-03-23 17:07:25 +01:00
Harini Gunabalan
e49e9ae823 Update README.md 2020-03-21 23:39:10 +01:00
Harini Gunabalan
6cc2741c3e Adding demo codebase of OpenSAP week3 unit1 2020-03-21 23:39:12 +01:00
Daniel
06755978b2 Removed work-around for auto-exposed entities 2020-02-15 14:31:07 +01:00
Daniel
02469acebb Moved @odata.draft.enabled to app model 2020-02-15 14:25:15 +01:00
Dr. David Kunz
e2b47228db Update services.js 2020-02-12 17:13:35 +01:00
Christian Georgi
13480ad99e Added issue URL again 2020-02-04 09:11:28 +01:00
Daniel
8071faa62d Adding requires.db: {kind:'sql'} 2020-02-03 07:55:56 +01:00
johannes-vogel
9ea294586a remove link 2020-01-31 08:49:54 +01:00
Lakshmi C Rajeev
a56a11ff3e Create index.cds 2020-01-28 10:58:24 +05:30
Matthias Bühl
b4084b45cb rollback change in master 2020-01-27 15:33:14 +01:00
Matthias Bühl
26e3c0d753 check autthorization in cat service 2020-01-27 15:29:43 +01:00
Lakshmi C Rajeev
6d0194acc0 Merge pull request #12 from LakshmiCR/master
Media-server implementation
2020-01-17 15:02:15 +05:30
Lakshmi C Rajeev
db75a99808 Merge branch 'master' into master 2020-01-17 15:01:59 +05:30
Volker Buzek
a04755efed feat(npm): add .npmrc for @sap-scope
- `npm set @sap...` is unnecessary
- update README.md accordingly
2020-01-14 14:55:36 +01:00
Lakshmi C Rajeev
ba72d7f478 Update package.json 2020-01-03 14:29:53 +05:30
Lakshmi C Rajeev
cd808c76dd Update media-service.js 2020-01-03 14:07:17 +05:30
Lakshmi C Rajeev
630bb2b19c Update package.json 2019-12-19 10:59:57 +05:30
Lakshmi C Rajeev
f9a7aa59de Update media-service.js 2019-12-19 10:43:22 +05:30
Lakshmi C Rajeev
9205e0893a Update media-service.js 2019-12-02 15:27:38 +05:30
Lakshmi C Rajeev
7137bf227e Media-server 2019-11-29 12:30:07 +05:30
9 changed files with 60 additions and 23 deletions

View File

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

View File

@@ -8,7 +8,11 @@
"lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save", "lerna": "npx --no-install lerna -v > /dev/null || npm i lerna --no-save",
"install": "(npm -s run lerna) && lerna bootstrap --hoist", "install": "(npm -s run lerna) && lerna bootstrap --hoist",
"cleanup": "lerna clean -y && rm -fr node_modules", "cleanup": "lerna clean -y && rm -fr node_modules",
"bookshop": "cds watch packages/bookshop" "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"
}, },
"dependencies": { "dependencies": {
"@sap/cds": "^3", "@sap/cds": "^3",

View File

@@ -11,7 +11,6 @@ entity Books : managed {
currency : Currency; currency : Currency;
} }
@cds.autoexpose
entity Authors : managed { entity Authors : managed {
key ID : Integer; key ID : Integer;
name : String(111); name : String(111);

View File

@@ -18,4 +18,4 @@
} }
} }
} }
} }

View File

@@ -3,9 +3,11 @@ using { sap.capire.bookshop as my } from '../db/schema';
@path:'/browse' @path:'/browse'
service CatalogService { service CatalogService {
@readonly entity Books as SELECT from my.Books { * } excluding { createdBy, modifiedBy }; @readonly entity Books as SELECT from my.Books {*,
author.name as author
} excluding { createdBy, modifiedBy };
@requires_: 'authenticated-user' @requires_: 'authenticated-user'
@insertonly entity Orders as projection on my.Orders; @insertonly entity Orders as projection on my.Orders;
} }

View File

@@ -23,4 +23,4 @@ async function _reduceStock (req) {
`${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}` `${OrderItems[i].amount} exceeds stock for book #${OrderItems[i].book_ID}`
) )
})) }))
} }

View File

@@ -0,0 +1,25 @@
### 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

View File

@@ -1,14 +1,18 @@
### Browse Books ### Service Document
GET http://localhost:4004/browse/Books GET http://localhost:4004/browse
### Browse Books with expanded Authors ### Service $metadata document
GET http://localhost:4004/browse/Books?$expand=author GET http://localhost:4004/browse/$metadata
### Try to insert into Books ### Browsing Books
POST http://localhost:4004/browse/Books GET http://localhost:4004/browse/Books?
Content-Type: application/json # &$select=title,author
# &$expand=currency
# &sap-language=de
{ ### Browsing Authors
"title": "Anna Karenina", GET http://localhost:4004/admin/Authors?
"stock": 10 # &$select=name,dateOfBirth,placeOfBirth
} # &$expand=books($select=title;$expand=currency)
# &$filter=ID eq 101
# &sap-language=de

View File

@@ -1,15 +1,18 @@
### List all Orders - deep read
### List Books with their current stocks
GET http://localhost:4004/admin/Books?$select=ID,stock
### List all Orders
GET http://localhost:4004/admin/Orders? GET http://localhost:4004/admin/Orders?
&$expand=Items &$expand=Items
### Submit Orders - deep insert ### Submit Orders
POST http://localhost:4004/browse/Orders POST http://localhost:4004/browse/Orders
Content-Type: application/json Content-Type: application/json
{ "OrderNo":"1234", "Items":[ { "OrderNo":"2019-09...", "Items":[
{ "book_ID":201, "amount":5 }, { "book_ID":201, "amount":5 },
{ "book_ID":207, "amount":3 } { "book_ID":207, "amount":3 }
]} ]}
### Try to get the Orders # Sending this three times should result in a 409: 5 exceeds stock for book #201
GET http://localhost:4004/browse/Orders