開放平臺的API支持解析引用字段的查詢語法,可以將返回結構中的特定字段(如id等)解析出更詳盡的內容,語法格式為
GET /asset?resolve={"fields":["fieldA","fieldB"]}
其中fieldA和fieldB為需要解析的字段,多個需要解析的字段間以逗號隔開。
以“查詢機構”的API為例:
未添加字段解析
請求參數(shù): GET /department
響應參數(shù):
[{ "defaultRoles": [], "roles": [], "permissions": [], "parent": null, "admins": [], "name": "DepA_1", "company": "5e01aa7a5ee76858e03a490e", "createdBy": "5e01aa7a5ee76858e03a490f", "createdAt": "2019-12-24T06:06:17.738Z", "updatedAt": "2019-12-24T06:06:17.738Z", "id": "5e01aad95ee76858e03a587d", "children": [] }]
其中company為此機構所屬企業(yè)的id。
添加字段解析
例如想查詢該機構所屬企業(yè)的的詳細信息,則需要解析company字段: 請求參數(shù):
GET /department?resolve={"fields":["company","parent"]}
響應參數(shù):
[{ "defaultRoles": [], "roles": [], "permissions": [], "parent": null, "admins": [], "name": "DepA_1", "company": { "admins": ["5e01aa7a5ee76858e03a490f"], "verified": false, "isOperator": true, "operators": [], "industries": [], "permissions": [], "name": "ABC", "createdAt": "2019-12-24T06:04:47.135Z", "updatedAt": "2019-12-24T06:04:47.135Z", "id": "5e01aa7a5ee76858e03a490e" }, "createdBy": "5e01aa7a5ee76858e03a490f", "createdAt": "2019-12-24T06:06:17.738Z", "updatedAt": "2019-12-24T06:06:17.738Z", "id": "5e01aad95ee76858e03a587d", "children": [] }]
則company的{}中括號中即為解析出來的該機構所屬企業(yè)的的詳細信息。
目前支持解析字段查詢的API如下:
GET /application
GET /company
GET /company/:id
GET /department
GET /department/:id
GET /permission
GET /permission/:id
GET /resource
GET /resource/:id
GET /company/:id/resource
GET /user/:id/resource
GET /user/permission/:id
GET /role
GET /role/:id
GET /user
GET /user/:id