Skip to content

目录

资源说明

目录定义

目录是衡石系统内为方便用户管理应用应用下的资源而设定的系统功能,展示为树形结构,通过该功能可实现业务区域划分、资源与资源使用权限的集中管理

目录结构说明

字段类型描述
idBIGINT目录id
titleSTRING目录标题
parentIdBIGINT父目录id
areaSTRING目录所在区域: PERSONAL_AREA 、PUBLIC_AREA 、 DATA_MART 、 APP_MART、SUBJECT_AREA
optionsOBJECT目录配置信息
options.rootTypeSTRING区域级根节点的类型: PUBLIC_ROOT_FOLDER 、PERSONAL_ROOT_FOLDER
options.childrenOrderARRAY子目录排序
options.appOrderARRAY目录内应用排序
updatedAtDATETIME目录最后更新时间
updatedByDATETIME目录最后修改者的userId
createdAtDATETIME目录创建时间
updatedByDATETIME目录最后修改者的userId
tenantIdLONG租户id
idPathARRAY路径id

区域说明

状态值意义
PERSONAL_AREA个人区,用户私有(3.0版本未实现目录功能)
PUBLIC_AREA共享区,该区域属于系统公有区域,所有被赋予目录权限的系统内用户均可管理/编辑/读取
DATA_MART数据集市,与共享区性质相同,区别在于该区域目录下的应用内,只能创建数据集,供其他区域使用
APP_MART应用集市-个人空间,即发布区(3.0版本未实现目录功能)
SYSTEM_PORTAL应用集市-团队空间,即发布区(3.0版本未实现目录功能)
SUBJECT_AREA主题域,它是数据集市里管理指标的区域

目录/应用授权说明

状态值意义
read查看者:可查看目录/应用及目录下的资源
read|write编辑者:拥有目录的编辑者权限时,可在目录下创建、查看、修改目录/应用
admin|read|write管理者:除拥有编辑者权限外,还可管理目录/应用为其他用户赋予/删除权限
admin|read\租户使用者:平台方授权资源给租户时的角色,可管理目录/应用为租户内其他用户赋予权限

目录权限说明

  • 四个公用目录区:DATA_MART,PUBLIC_AREA,SYSTEM_PORTAL,SUBJECT_AREA存在超管用户,超管用户用有该区域内所有资源的所有权限,其角色分别为:DATA_MART(系统管理+数据管理) ,PUBLIC_AREA(系统管理+数据管理),SYSTEM_PORTAL(系统管理+数据分析),SUBJECT_AREA(系统管理+指标管理)
  • 普通用户的权限范围:若用户拥有某目录的某项权限,则同时拥有该目录下子目录与资源的对应权限,以最大权限为准

接口说明

1、创建目录

  • 创建者需要同时拥有数据管理员系统管理员角色 或 拥有上层任意父目录的编辑者权限
  • 区域根目录由系统默认生成,因此用户创建的目录 parent_id 不可为空

请求URL

http
POST /api/folders HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
titleSTRING目录名称
parentIdBIGINT父目录id

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT每种目录的共同结构见目录结构说明

接口示例1: 创建目录

http
POST /api/folders HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "title": "test",
  "parentId": 1
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "parentId": 1,
    "title": "test",
    "createdBy": 1,
    "createdAt": "2019-12-08 23:35:54",
    "updatedBy": 1,
    "updatedAt": "2019-12-08 23:35:54",
    "area": "PUBLIC_AREA"
  }
}

2、修改(移动)目录

  • 修改者需要同时拥有数据管理员系统管理员角色 或 拥有上层任意父目录的编辑者权限
  • 移动目录需遵循以下规则:

    1、区域根目录不可移动 2、目录不可跨区域移动 3、移动目录需要用户同时拥有被移动目录和目标目录的编辑者权限 4、若移动目录需要保留权限配置,则用户需拥有目标目录的管理者权限

请求URL

http
PUT /api/folders/{folderId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

Request Body 参数
字段类型是否必须说明
titleSTRING目录名称
parentIdBIGINT父目录id(移动操作时表示目标目录id)
keepAuthConfigBOOL是否保留权限配置(默认为true)

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT每种目录的共同结构见目录结构说明

接口示例1: 修改/移动目录

http
PUT /api/folders/{folderId} HTTP/1.1
Content-Type: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

// Request Body:
{
  "title": "test",
  "parentId": 3,
  "keepAuthConfig":false
}
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2,
    "parentId": 3,
    "title": "test",
    "createdBy": 1,
    "createdAt": "2019-12-08 23:35:54",
    "updatedBy": 1,
    "updatedAt": "2019-12-08 23:35:54",
    "area": "PUBLIC_AREA"
  }
}

3、删除目录

  • 修改者需要同时拥有数据管理员系统管理员角色 或 拥有上层任意父目录的编辑者权限
  • 区域根目录不可删除
  • 为防止误操作,只能删除空目录(目录下无子目录或应用)

请求URL

http
DELETE /api/folders/{folderId} HTTP/1.1
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT每种目录的共同结构见目录结构说明

接口示例1: 删除目录

http
DELETE /api/folders/{folderId}` HTTP/1.1
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success"
}

4、根据id获取目录

  • 修改者需要同时拥有数据管理员系统管理员角色 或 拥有上层任意父目录的查看者权限
  • 返回值中包含被查询目录下一级的子目录和app(children/apps),以及被查询目录所有父目录的id和title(parents)

请求URL

http
GET /api/folders/{folderId} HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT每种目录的共同结构见目录结构说明

接口示例1: 根据id获取目录

http
GET /api/folders/{folderId}` HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": {
    "id": 3,
    "parentId": 2,
    "title": "b",
    "options": {},
    "createdBy": 1,
    "createdAt": "2019-12-01 21:24:24",
    "updatedBy": 3,
    "updatedAt": "2019-12-04 18:15:18",
    "visible": true,
    "children": [
        {"id":4,"title":"c"},
        {"id":5,"title":"d"}
    ],
    "parents": [
        {"id":1,"title":"root"}
        {"id":2,"title":"a"}
    ]
    "area": "PUBLIC_AREA",
    "apps": [
      {
        "id": 2,
        "title": "app2",
        "cover": "",
        "options": {},
        "createdBy": 1,
        "createdAt": "2019-12-01 21:08:36",
        "updatedBy": 1,
        "updatedAt": "2019-12-01 21:08:36",
        "visible": true,
        "isDelete": false,
        "isPublish": false,
        "hsVersion": 0,
        "publicPublish": false,
        "publish": false
      }
    ],
    "delete": false
  }
}

5、获取目录列表

  • 修改者需要同时拥有数据管理员系统管理员角色 或 拥有上层任意父目录的查看者权限
  • 返回结果为当前用户在指定区域,有权限查看的所有目录的树形结构,并包含各目录下的应用
  • 同时拥有数据管理员系统管理员角色的用户,可看到指定区域下的所有目录信息

请求URL

http
GET /api/folders HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...

请求参数

URL 参数
字段类型是否必须说明
queryAppTreeBOOL是否要查询目录下的应用信息,默认为 true
areaSTRING指定查询区域,默认为 PUBLIC_AREA
targetAppIdLONG查询可见数据源时传递的当前appId
orderBySTRING排序字段,默认为updated_at
orderTypeSTRING排序方式,默认为desc
actionSTRING查询当前用户拥有特定权限的目录,如:read
targetFolderCreatorIdLONG查询特定用户创建的目录,仅在PERSONAL_AREA可用
folderIdLONG查询指定id的目录,及以该目录为树根的目录树

返回对象的格式说明

字段类型说明
versionSTRING当前系统版本哈希值
dataOBJECT每种目录的共同结构见目录结构说明

接口示例1: 获取目录列表

http
GET /api/folders?queryMeta=false&area=PUBLIC_AREA` HTTP/1.1
Accept: application/json
Cookie: csrf=183f1c4...; sid=26ee552d...; _USER_SESSION_ID=f2a01083...
http
HTTP/1.1 200 Ok
Content-Type: application/json

{
  "version": "version@9a5e106#6730f0d",
  "code": 0,
  "msg": "success",
  "data": [
    {
      "id": 1,
      "title": "public_area_root_folder",
      "options": {
        "rootType": "PUBLIC_ROOT_FOLDER"
      },
      "createdAt": "2019-12-01 21:06:15",
      "updatedAt": "2019-12-01 21:06:15",
      "visible": true,
      "area": "PUBLIC_AREA",
      "children": [
        {
          "id": 2,
          "parentId": 1,
          "title": "a",
          "options": {},
          "createdBy": 1,
          "createdAt": "2019-12-01 21:11:41",
          "updatedBy": 1,
          "updatedAt": "2019-12-01 21:11:41",
          "visible": true,
          "area": "PUBLIC_AREA",
          "children": [
            {
              "id": 3,
              "parentId": 2,
              "title": "b",
              "options": {},
              "createdBy": 1,
              "createdAt": "2019-12-01 21:24:24",
              "updatedBy": 3,
              "updatedAt": "2019-12-04 18:15:18",
              "visible": true,
              "area": "PUBLIC_AREA",
              "children": [
                {
                  "id": 5,
                  "parentId": 3,
                  "title": "d",
                  "options": {},
                  "createdBy": 1,
                  "createdAt": "2019-12-01 21:25:23",
                  "updatedBy": 1,
                  "updatedAt": "2019-12-01 21:25:23",
                  "visible": true,
                  "area": "PUBLIC_AREA",
                  "apps": [
                    {
                      "id": 4,
                      "title": "app4",
                      "cover": "",
                      "options": {},
                      "createdBy": 1,
                      "createdAt": "2019-12-01 21:08:46",
                      "updatedBy": 1,
                      "updatedAt": "2019-12-01 21:08:46",
                      "visible": true,
                      "isDelete": false,
                      "isPublish": false,
                      "hsVersion": 0,
                      "folderId": 5,
                      "publicPublish": false,
                      "publish": false
                    }
                  ],
                  "delete": false
                },
                {
                  "id": 6,
                  "parentId": 3,
                  "title": "e",
                  "options": {},
                  "createdBy": 1,
                  "createdAt": "2019-12-01 21:25:30",
                  "updatedBy": 1,
                  "updatedAt": "2019-12-01 21:25:30",
                  "visible": true,
                  "area": "PUBLIC_AREA",
                  "children": [
                    {
                      "id": 16,
                      "parentId": 6,
                      "title": "test3F",
                      "options": {},
                      "createdBy": 3,
                      "createdAt": "2019-12-05 11:43:14",
                      "updatedBy": 3,
                      "updatedAt": "2019-12-05 12:09:48",
                      "visible": true,
                      "area": "PUBLIC_AREA",
                      "delete": false
                    }
                  ],
                  "delete": false
                }
              ],
              "apps": [
                {
                  "id": 2,
                  "title": "app2",
                  "cover": "",
                  "options": {},
                  "createdBy": 1,
                  "createdAt": "2019-12-01 21:08:36",
                  "updatedBy": 1,
                  "updatedAt": "2019-12-01 21:08:36",
                  "visible": true,
                  "isDelete": false,
                  "isPublish": false,
                  "hsVersion": 0,
                  "folderId": 3,
                  "publicPublish": false,
                  "publish": false
                }
              ],
              "delete": false
            },
            {
              "id": 4,
              "parentId": 2,
              "title": "c",
              "options": {},
              "createdBy": 1,
              "createdAt": "2019-12-01 21:24:50",
              "updatedBy": 1,
              "updatedAt": "2019-12-01 21:24:50",
              "visible": true,
              "area": "PUBLIC_AREA",
              "children": [
                {
                  "id": 7,
                  "parentId": 4,
                  "title": "f",
                  "options": {},
                  "createdBy": 1,
                  "createdAt": "2019-12-01 21:25:52",
                  "updatedBy": 3,
                  "updatedAt": "2019-12-04 17:26:14",
                  "visible": true,
                  "area": "PUBLIC_AREA",
                  "children": [
                    {
                      "id": 8,
                      "parentId": 7,
                      "title": "g",
                      "options": {},
                      "createdBy": 1,
                      "createdAt": "2019-12-01 21:26:09",
                      "updatedBy": 1,
                      "updatedAt": "2019-12-01 21:26:09",
                      "visible": true,
                      "area": "PUBLIC_AREA",
                      "children": [
                        {
                          "id": 17,
                          "parentId": 8,
                          "title": "areaT",
                          "options": {},
                          "createdBy": 3,
                          "createdAt": "2019-12-05 14:17:53",
                          "updatedBy": 3,
                          "updatedAt": "2019-12-05 14:19:43",
                          "visible": true,
                          "area": "PUBLIC_AREA",
                          "delete": false
                        }
                      ],
                      "apps": [
                        {
                          "id": 3,
                          "title": "app3",
                          "cover": "",
                          "options": {},
                          "createdBy": 1,
                          "createdAt": "2019-12-01 21:08:41",
                          "updatedBy": 1,
                          "updatedAt": "2019-12-01 21:08:41",
                          "visible": true,
                          "isDelete": false,
                          "isPublish": false,
                          "hsVersion": 0,
                          "folderId": 8,
                          "publicPublish": false,
                          "publish": false
                        }
                      ],
                      "delete": false
                    }
                  ],
                  "delete": false
                }
              ],
              "delete": false
            }
          ],
          "apps": [],
          "delete": false
        }
      ],
      "delete": false
    }
  ]
}

HENGSHI SENSE API 使用手册