From 33347904770dcec1e45914ddb97219814d1197ca Mon Sep 17 00:00:00 2001 From: Akshat Jain Date: Fri, 23 May 2025 11:34:31 +0530 Subject: [PATCH] New UserService Init --- cap-notebook/demoapp/db/schema.cds | 21 +++++++++++++++++++ .../demoapp/srv/attachment-extension.cds | 9 +++++++- cap-notebook/demoapp/srv/user-service.cds | 10 +++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 cap-notebook/demoapp/srv/user-service.cds diff --git a/cap-notebook/demoapp/db/schema.cds b/cap-notebook/demoapp/db/schema.cds index 1aedfbac..aed7d872 100644 --- a/cap-notebook/demoapp/db/schema.cds +++ b/cap-notebook/demoapp/db/schema.cds @@ -35,3 +35,24 @@ entity Genres : CodeList { children : Composition of many Genres on children.parent = $self; } + +/** Adding {Notebooks,Writers} for user service */ +entity Notebooks : managed, cuid { + @mandatory title : localized String(111); + descr : localized String(1111); + @mandatory writer : Association to Writers; + stock : Integer; + price : Decimal; + currency : Currency; + image : LargeBinary @Core.MediaType: 'image/png'; +} + +entity Writers : managed, cuid { + @mandatory name : String(111); + dateOfBirth : Date; + dateOfDeath : Date; + placeOfBirth : String; + placeOfDeath : String; + notebooks : Association to many Notebooks + on notebooks.writer = $self; +} \ No newline at end of file diff --git a/cap-notebook/demoapp/srv/attachment-extension.cds b/cap-notebook/demoapp/srv/attachment-extension.cds index ff549738..01847cf5 100644 --- a/cap-notebook/demoapp/srv/attachment-extension.cds +++ b/cap-notebook/demoapp/srv/attachment-extension.cds @@ -1,4 +1,4 @@ -using {sap.capire.bookshop.Books} from '../db/schema'; +using {sap.capire.bookshop.Books, sap.capire.bookshop.Notebooks} from '../db/schema'; using {sap.attachments.Attachments, sap.attachments.StatusCode} from`com.sap.cds/sdm`; extend entity Books with { @@ -6,6 +6,13 @@ extend entity Books with { references : Composition of many Attachments @SDM.Attachments:{maxCount: 2, maxCountError: 'Only 2 attachments allowed'}; footnotes : Composition of many Attachments; } + +extend entity Notebooks with { + attachments : Composition of many Attachments @SDM.Attachments:{maxCount: 4, maxCountError:'Only 4 attachments allowed.'}; + references : Composition of many Attachments @SDM.attachments:{maxCount: 2, maxCountError:'Only 2 attachments allowed.'}; + footnotes : Composition of many Attachments; + +} entity Statuses @cds.autoexpose @readonly { key code : StatusCode; text : localized String(255); diff --git a/cap-notebook/demoapp/srv/user-service.cds b/cap-notebook/demoapp/srv/user-service.cds new file mode 100644 index 00000000..de644475 --- /dev/null +++ b/cap-notebook/demoapp/srv/user-service.cds @@ -0,0 +1,10 @@ +using {sap.capire.bookshop as my} from '../db/schema'; + +service UserService @(requires: [ + 'admin', + 'system-user' +]) { + @odata.draft.enabled + entity Notebooks as projection on my.Notebooks; + entity Writers as projection on my.Writers; +}