.
This commit is contained in:
9
orders/api/external.cds
Normal file
9
orders/api/external.cds
Normal file
@@ -0,0 +1,9 @@
|
||||
context external {
|
||||
|
||||
/** This is a stand-in for arbitrary ordered Products */
|
||||
entity Products @(cds.persistence.skip:'always') {
|
||||
key ID : String;
|
||||
data : String;
|
||||
}
|
||||
|
||||
}
|
||||
21
orders/api/orders-service-comp.cds
Normal file
21
orders/api/orders-service-comp.cds
Normal file
@@ -0,0 +1,21 @@
|
||||
using { cuid, managed, User, Currency } from '@sap/cds/common';
|
||||
using { sap.capire.orders as my } from '../db/schema';
|
||||
using { external.Products } from './external';
|
||||
|
||||
|
||||
service OrdersService {
|
||||
|
||||
entity Orders : cuid, managed {
|
||||
OrderNo : String @title:'Order Number'; //> readable key
|
||||
Items : Composition of many {
|
||||
key ID : UUID;
|
||||
product : Association to Products;
|
||||
amount : Integer;
|
||||
title : String; //> intentionally replicated as snapshot from product.title
|
||||
price : Double;
|
||||
};
|
||||
buyer : User;
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
}
|
||||
40
orders/api/orders-service.cds
Normal file
40
orders/api/orders-service.cds
Normal file
@@ -0,0 +1,40 @@
|
||||
using { cuid, managed, User, Currency } from '@sap/cds/common';
|
||||
using { sap.capire.orders as my } from '../db/schema';
|
||||
using { external.Products } from './external';
|
||||
|
||||
|
||||
// GET Orders
|
||||
// GET Orders()/Items
|
||||
// GET Orders?$Items
|
||||
|
||||
service OwnService {
|
||||
entity Orders as projection on OrdersService.Orders;
|
||||
entity Products as projection on OrdersService.Products;
|
||||
}
|
||||
|
||||
service OrdersService {
|
||||
|
||||
entity Orders : cuid, managed {
|
||||
OrderNo : String @title:'Order Number'; //> readable key
|
||||
Items : Composition of many Orders_Items; // on Items.up_ = $self;
|
||||
// MoreItems : Composition of many Orders_Items; // on Items.up_ = $self;
|
||||
// Items_ID
|
||||
buyer : User;
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
entity Orders_Items {
|
||||
key ID : UUID;
|
||||
// up_ : Association to Orders;
|
||||
product : Association to Products; //> {ID}
|
||||
// product_ID
|
||||
amount : Integer;
|
||||
title : String; //> intentionally replicated as snapshot from product.title
|
||||
price : Double;
|
||||
}
|
||||
|
||||
// entity Products {
|
||||
// key ID : UUID;
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user