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(系统管理+指标管理)
  • 普通用户的权限范围:若用户拥有某目录的某项权限,则同时拥有该目录下子目录与资源的对应权限,以最大权限为准

接口说明

创建目录

  • 创建者需要同时拥有数据管理员系统管理员角色 或 拥有上层任意父目录的编辑者权限
  • 区域根目录由系统默认生成,因此用户创建的目录 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"
  }
}

修改(移动)目录

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

    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"
  }
}

删除目录

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

请求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"
}

根据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
  }
}

获取目录列表

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

请求URL

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

请求参数

URL 参数
字段类型是否必须说明
areaSTRING指定查询区域,默认为 PUBLIC_AREA
targetAppIdLONG查询可见数据源时传递的当前appId
orderBySTRING排序字段,默认为updated_at
orderTypeSTRING排序方式,默认为desc
actionSTRING查询当前用户拥有特定权限的目录,如:read
targetFolderCreatorIdLONG查询特定用户创建的目录,仅在PERSONAL_AREA可用
needDetailsLONG是否需要查询目录的详细信息
queryAppTreeBOOL是否要查询目录下的应用信息,默认为 true
needAppChildrenLONG是否需要查询应用内的子对象:仪表盘,容器,图表,数据集,默认为 truequeryAppTree = true 时生效)
queryDatasetLONG是否需要返回应用内的数据集,默认为 truequeryAppTree != falseneedAppChildren = true 时生效)
queryDashboardLONG是否需要返回应用内的仪表盘,默认为 truequeryAppTree != falseneedAppChildren = true 时生效)
queryChartLONG是否需要返回应用内的图表,默认为 falsequeryAppTree != falseneedAppChildren = truequeryDashboard = true 时生效)
onlyAppsLONG是否仅返回应用信息以及应用下子对象的列表,默认为 falsequeryAppTree = true 时生效)

返回对象的格式说明

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

接口示例1: 仅获取应用信息列表

http
GET /api/folders?area=PERSONAL_AREA&queryAppTree=true&queryChart=true&needDetails=false&needAppChildren=true&queryDataset=true&queryDashboard=true&onlyApps=true 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": "5.3-SNAPSHOT@@git.commit.id.abbrev@#993daa9",
    "code": 0,
    "msg": "success",
    "data": [
        {
            "id": 89,
            "title": "分析应用20240403120002",
            "createdBy": 2,
            "folderId": 0,
            "area": "PERSONAL_AREA",
            "type": "ANALYTIC_APP",
            "isCollaborated": false,
            "dashboardHash": [
                {
                    "id": 1
                }
            ],
            "action": "read|admin|write",
            "authRole": "ADMINISTRATOR",
            "dashboardList": [
                {
                    "id": 1,
                    "title": "新建仪表盘20240403120019",
                    "appId": 89,
                    "charts": [
                        {
                            "id": 2,
                            "title": "新建探索",
                            "appId": 89
                        }
                    ]
                }
            ],
            "datasetList": [
                {
                    "id": 1,
                    "title": "china_map_area",
                    "appId": 89
                }
            ],
            "refreshEntityGroup": "APP_REFRESH",
            "refreshExecDetail": {
                "jobClass": "com.hengshi.nangaparbat.schedulejob.AppDatasetRefreshJob",
                "jobParams": {
                    "app": 89
                },
                "retryTimes": 1
            },
            "execDetail": {
                "jobClass": "com.hengshi.nangaparbat.schedulejob.AppEmailJob",
                "jobParams": {
                    "app": 89
                },
                "retryTimes": 1
            },
            "entityGroup": "APP_EMAIL",
            "entityKey": "89"
        }
    ],
    "chartDataStartTimeMillis": 0
}

接口示例2: 获取目录与应用

http
GET /api/folders?area=PERSONAL_AREA&queryAppTree=true&queryChart=true&needAppChildren=true&onlyApps=false 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": "5.3-SNAPSHOT@@git.commit.id.abbrev@#993daa9",
    "code": 0,
    "msg": "success",
    "data": [
        {
            "id": 0,
            "title": "personal_area_root_folder",
            "area": "PERSONAL_AREA",
            "children": [
                {
                    "id": 47,
                    "parentId": 0,
                    "title": "仪表盘复制",
                    "createdBy": 2,
                    "area": "PERSONAL_AREA",
                    "idPath": [
                        0
                    ],
                    "children": [],
                    "apps": [
                        {
                            "id": 330,
                            "title": "查询应用 -个人区",
                            "createdBy": 2,
                            "folderId": 47,
                            "area": "PERSONAL_AREA",
                            "type": "QUERY_APP",
                            "isCollaborated": false,
                            "dashboardHash": [
                                {
                                    "id": 6
                                },
                                {
                                    "id": 5
                                },
                                {
                                    "id": 2
                                }
                            ],
                            "action": "read|admin|write",
                            "authRole": "ADMINISTRATOR",
                            "dashboardList": [
                                {
                                    "id": 6,
                                    "title": "页面C(1)",
                                    "appId": 330
                                }
                            ],
                            "datasetList": [],
                            "refreshEntityGroup": "APP_REFRESH",
                            "refreshExecDetail": {
                                "jobClass": "com.hengshi.nangaparbat.schedulejob.AppDatasetRefreshJob",
                                "jobParams": {
                                    "app": 330
                                },
                                "retryTimes": 1
                            },
                            "execDetail": {
                                "jobClass": "com.hengshi.nangaparbat.schedulejob.AppEmailJob",
                                "jobParams": {
                                    "app": 330
                                },
                                "retryTimes": 1
                            },
                            "entityGroup": "APP_EMAIL",
                            "entityKey": "330"
                        }
                    ]
                }
            ],
            "action": "read|admin|write",
            "authRole": "ADMINISTRATOR",
            "isCollaborated": false
        }
    ],
    "chartDataStartTimeMillis": 0
}

接口示例3: 仅获取目录信息

http
GET /api/folders?area=PERSONAL_AREA&queryAppTree=false&queryChart=true&needAppChildren=true 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": "5.3-SNAPSHOT@@git.commit.id.abbrev@#993daa9",
    "code": 0,
    "msg": "success",
    "data": [
        {
            "id": 0,
            "title": "personal_area_root_folder",
            "area": "PERSONAL_AREA",
            "children": [
                {
                    "id": 31,
                    "parentId": 0,
                    "title": "json array",
                    "createdBy": 2,
                    "area": "PERSONAL_AREA",
                    "idPath": [
                        0
                    ],
                    "children": [
                        {
                            "id": 34,
                            "parentId": 31,
                            "title": "array folder1",
                            "createdBy": 2,
                            "area": "PERSONAL_AREA",
                            "idPath": [
                                0,
                                31
                            ],
                            "children": [
                                {
                                    "id": 35,
                                    "parentId": 34,
                                    "title": "array folder2",
                                    "createdBy": 2,
                                    "area": "PERSONAL_AREA",
                                    "idPath": [
                                        0,
                                        31,
                                        34
                                    ],
                                    "children": [],
                                    "apps": [],
                                    "action": "read|admin|write",
                                    "authRole": "ADMINISTRATOR",
                                    "isCollaborated": true
                                }
                            ],
                            "apps": [],
                            "action": "read|admin|write",
                            "authRole": "ADMINISTRATOR",
                            "isCollaborated": true
                        }
                    ],
                    "apps": [],
                    "action": "read|admin|write",
                    "authRole": "ADMINISTRATOR",
                    "isCollaborated": false
                },
                {
                    "id": 26,
                    "parentId": 0,
                    "title": "性能测试",
                    "createdBy": 2,
                    "area": "PERSONAL_AREA",
                    "idPath": [
                        0
                    ],
                    "children": [],
                    "apps": [],
                    "action": "read|admin|write",
                    "authRole": "ADMINISTRATOR",
                    "isCollaborated": false
                },
                {
                    "id": 19,
                    "parentId": 0,
                    "title": "外面1",
                    "createdBy": 2,
                    "area": "PERSONAL_AREA",
                    "idPath": [
                        0
                    ],
                    "children": [
                        {
                            "id": 20,
                            "parentId": 19,
                            "title": "外面2",
                            "createdBy": 2,
                            "area": "PERSONAL_AREA",
                            "idPath": [
                                0,
                                19
                            ],
                            "children": [],
                            "apps": [],
                            "action": "read|admin|write",
                            "authRole": "ADMINISTRATOR",
                            "isCollaborated": true
                        }
                    ],
                    "apps": [],
                    "action": "read|admin|write",
                    "authRole": "ADMINISTRATOR",
                    "isCollaborated": false
                }
            ],
            "apps": [],
            "action": "read|admin|write",
            "authRole": "ADMINISTRATOR",
            "isCollaborated": false
        }
    ],
    "chartDataStartTimeMillis": 0
}

HENGSHI SENSE API 使用手册