SAP CAP 项目 cds watch 生成的 index.html 的模板位置和权限控制
使用 cds init 初始化一個 CAP 應(yīng)用,然后 npm install, cds watch 啟動服務(wù)器。
創(chuàng)建一個 schema 文件,內(nèi)容如下:
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;}注意,schema 文件可以定義 namespace.
這兩個模型的 key 由 CAP 服務(wù)器自動填充,該服務(wù)器使用注釋 @(Core.Computed : true) 向服務(wù)用戶公開。
只有 entity 還無法被 end user 消費(fèi),需要通過 service 暴露給外部。
在 srv 文件夾里新建一個文件 risk-service.cds,注意這個文件和 entity schema 文件在不同的文件夾(前者在 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; }使用 cds watch 看到的自動生成的頁面:
這個 index.html 的模板文件位置:
node_modules@sap\cds-dk\node_modules@sap\cds\app\index.html
在應(yīng)用程序安全文件 (xs-security.json) 中,role templates 屬性使您能夠定義一個數(shù)組,其中列出了訪問特定應(yīng)用程序模塊所需的一個或多個 roles(具有相應(yīng)的范圍和任何必需的屬性)??梢远x多個角色模板,每個模板都有自己的范圍和屬性。
一個例子:
"role-templates": [ { "name" : "Editor", "description" : "View, edit, delete books", "scope-references" : [ "$XSAPPNAME.Edit", "$XSAPPNAME.Delete" ], "attribute-references": [ "Country", "CostCenter" ] }, ]必須實(shí)例化角色模板。 對于角色模板中定義的任何屬性和具體的屬性值尤其如此,這些屬性需要定制,因此無法自動提供。 只包含“本地”范圍的角色模板可以在沒有用戶交互的情況下被實(shí)例化。 對于 foreign scope 也是如此,其中范圍所有者已在某種白名單中聲明同意(例如,供“公共”使用或已知“朋友”使用)。
總結(jié)
以上是生活随笔為你收集整理的SAP CAP 项目 cds watch 生成的 index.html 的模板位置和权限控制的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于 A15 Bionic,古尔曼称苹果
- 下一篇: 新裂缝不断出现 整栋楼可怕!租户砸断承重