Template location and permission control of index.html generated by SAP CAP project cds watch

Get into the habit of writing together! This is the 8th day of my participation in the "Nuggets Daily New Plan · April Update Challenge", click to view the details of the event .

Use to cds initinitialize a CAP application, then npm install, cds watchstart the server.

Create a schema file with the following content:

namespace sap.ui.riskmanagement;
using { managed } from '@sap/cds/common';
  entity Risks : managed {
    key ID      : UUID  @(Core.Computed : true);
    title       : String(100);
  }
  entity Mitigations : managed {
    key ID       : UUID  @(Core.Computed : true);
    risks        : Association to many Risks on risks.miti = $self;
  }
复制代码

Note that schema files can define namespaces.

The keys for these two models are automatically populated by the CAP server, which is exposed to service users using the annotation @(Core.Computed : true).

Only the entity cannot be consumed by the end user and needs to be exposed to the outside through the service.

Create a new file in srvthe folder risk-service.cds, note that this file and the entity schema file are in a different folder (the former is in db):

using { sap.ui.riskmanagement as my } from '../db/schema';
@path: 'service/risk'
service RiskService {
  entity Risks as projection on my.Risks;
    annotate Risks with @odata.draft.enabled;
  entity Mitigations as projection on my.Mitigations;
    annotate Mitigations with @odata.draft.enabled;
}
复制代码

Use the auto-generated page to cds watchsee :

The template file location for this index.html:

node_modules@sap\cds-dk\node_modules@sap\cds\app\index.html

rolesIn the application security file (xs-security.json), the role templates property enables you to define an array that lists one or more (with corresponding scopes and any required properties) required to access a particular application module ). Multiple role templates can be defined, each with their own scope and properties.

one example:

"role-templates": [ 
     { 
      "name"                : "Editor", 
      "description"         : "View, edit, delete books", 
      "scope-references"    : [ 
                              "$XSAPPNAME.Edit", "$XSAPPNAME.Delete"  
                              ], 
      "attribute-references": [ 
                              "Country", "CostCenter" 
                              ]  
     },
]
复制代码

A role template must be instantiated. This is especially true for any attributes and concrete attribute values ​​defined in the role template, which require customization and therefore cannot be provided automatically. Role templates that contain only "local" scope can be instantiated without user interaction. The same is true for foreign scopes, where the scope owner has declared consent in some kind of whitelist (eg for "public" use or known "friends").

Guess you like

Origin juejin.im/post/7084074755745136671
Recommended