new I()
Ajax接口类
调用方式:
import Ex from 'ex';
Ex.I.application().then(response => {
})
安全接口带Token,非安全接口不带Token,统一调用 Zero Extension中的特殊接口。
1. 接口列表
函数名 | HTTP方法 | 路径 | 安全 | 说明 |
---|---|---|---|---|
action | POST | /api/form/actions |
是 | 读取表单中的Action专用方法。 |
apis | POST | /api/x-api/search |
是 | 查询引擎查询I_API 表结构中的信息。 |
app | GET | /api/name/:name |
否 | 读取X_APP 中的可公开部分信息。 |
application | GET | /api/app |
是 | 「可读取敏感信息」读取应用程序的基本数据,和app 方法对应。 |
attributes | GET | /api/model/identifier/:identifier |
是 | 读取模型中的属性集。 |
authorize | POST | /oauth/authorize |
否 | OAuth认证流程中申请临时授权码的专用方法。 |
category | GET | /api/:type/category/:code |
是 | 读取唯一分类记录。 |
GET | /api/type/categories/:type |
是 | 读取某一类分类记录。 | |
POST | /api/types/categories |
是 | 读取多类分类数据记录。 | |
company | GET | /api/company/employee/:eid |
是 | 根据员工ID读取员工所属公司信息。 |
control | POST | /api/ui/control |
是 | 读取界面控件配置信息UI_CONTROL 。 |
forest | GET | 无 | 是 | 没有直接对应的API信息,该方法读取X_CATEGORY 并构造多叉树。 |
form | GET | /api/ui/form/:code |
是 | 根据表单编码读取单表单记录UI_FORM 。 |
forms | GET | /api/ui/forms/:identifier |
是 | 根据模型统一标识符,读取和模型相关的所有表单记录。 |
inited | GET | /api/app 和/api/menus |
是 | 应用程序配置的完整初始化流程,登录后读取。 |
jobResume | PUT | /api/job/resume/:key |
是 | 恢复任务。 |
jobs | GET | /api/job/info/by/sigma |
是 | 按sigma读取所有的任务定义信息。 |
jobStart | PUT | /api/job/start/:key |
是 | 启动任务。 |
jobStop | PUT | /api/job/stop/:key |
是 | 停止任务。 |
lists | GET | /api/ui/lists/:identifier |
是 | 按identifier读取所有列表配置信息。 |
login | POST | /oauth/login |
否 | 登录专用接口,用于读取client_secret 和client_id 专用方法。 |
logout | POST | /api/user/logout |
是 | 注销专用接口。 |
menus | GET | /api/menus |
是 | 读取应用相关的配置信息。 |
mission | GET | /api/job/info/mission/:key |
是 | 读取任务的详细信息(包括任务状态、运行状态等)。 |
module | GET | /api/module?entry={entry} |
是 | 根据入口信息读取模块配置数据,对应后端X_MODULE 表。 |
ops | POST | /api/ui/ops |
是 | 读取UI_OP 配置信息,可动态读取,也可静态读取。 |
page | POST | /api/ui/page |
是 | 读取当前页面配置信息。 |
password | POST | /api/user/password |
是 | 更新登录账号密码专用接口。 |
profile | POST | /api/user/profile |
是 | 更新当前登录账号的Profile信息。 |
relation | GET | /api/relation |
是 | 读取关系定义专用接口。 |
relationDelete | POST | /api/ox/relation/delete |
是 | 删除关系专用方法。 |
relationSave | POST | /api/ox/relation/save |
是 | 保存关系专用方法。 |
tabular | GET | /api/:type/tabular/:code |
是 | 读取唯一字典记录。 |
GET | /api/type/tabulars/:type |
是 | 读取某一类字典记录。 | |
POST | /api/types/tabulars |
是 | 读取多类字典数据记录。 | |
todo | PUT | /api/todo/confirm/:key |
是 | 确认待办。 |
PUT | /api/todo/reject/:key |
是 | 拒绝待办。 | |
token | POST | /oauth/token |
否 | 使用授权码交换令牌专用方法。 |
uri | GET | /api/x-api/:key |
是 | 读取Uri配置信息。 |
user | GET | /api/user |
是 | 读取当前登录用户基本信息。 |
2. 特定说明
/api/ox/relation/save
:保存关系专用方法(CMDB专用)。/api/ox/relation/delete
:删除关系专用方法(CMDB专用)。
Methods
(async, static) action(params) → {Promise.<T>}
「接口」Ex.I.action
- 接口:
/api/form/actions
(POST) - 安全:是
{
"control": "控件ID,对应 UI_FORM 中的 CONTROL_ID",
"name": "表单名称",
"op": [],
"remote": "Boolean,是否读取远程配置,默认无值。"
}
该接口会执行分流操作。
- 远程读取:
POST /api/form/actions
,尚未开发该接口后端(开发中)。 - 本地读取:(默认)直接读取参数中op来构造合法的Action信息。
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 读取表单中的action专用方法。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) apis() → {Promise.<T>}
「接口」Ex.I.apis
- 接口:
/api/x-api/search
(POST) - 安全:是
读取当前系统中所有的接口信息,读取时候自动为系统追加查询条件:
{
"criteria": {
"": true
}
}
根据查询引擎规范该条件追加后,会生成AND
操作符来连接所有的params
中存在的条件。
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) app(failure) → {Promise.<T>}
「接口」Ex.I.app
- 接口:
/app/name/:name
(GET) - 安全:否
此接口一般用于初始化过程,调用Ux.ajaxFetch
函数从远程读取应用程序配置,而且这个接口不带安全认证,也无法
读取到appKey
这种敏感信息。该函数可传一个Function的异常回调函数,当访问过程中出错时,执行该函数处理异常流程。
参数中的
:name
参数直接从Ux.Env.APP
中读取,该值配置在环境变量中。
Parameters:
Name | Type | Description |
---|---|---|
failure |
function | 容错专用函数。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) application() → {Promise.<T>}
「接口」Ex.I.application
- 接口:
/api/app
(GET) - 安全:是
带缓存地读取应用程序信息,这个方法会执行校验:
- 系统调用
Ux.isInit()
方法读取应用信息,如果应用信息不存在则直接抛出异常。 - 如果拥有应用信息,并且该应用包含了
appKey
数据,则直接从缓存中读取数据。 - 如果没有包含
appKey
,则只证明执行了第一次初始化,需要再次读取(敏感信息)。
appKey
是用来判断首次初始化和二次初始化的核心字段,而且该接口会使用appKey读取应用配置数据。
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) attributes(identifier) → {Promise.<T>}
「接口」Ex.I.attributes
读取单个模型的属性信息
- 接口:
/api/model/identifier/:identifier
(GET) - 安全:是
根据模型中的统一标识符identifier
读取模型中的属性集
Parameters:
Name | Type | Description |
---|---|---|
identifier |
String | 模型标识符 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) authorize(request) → {Promise.<T>}
「接口」Ex.I.authorize
- 接口:
/oauth/authorize
(POST) - 安全:否
申请临时码专用方法:
{
"client_id": "客户ID",
"client_secret": "客户账号颁布的密钥",
"response_type": "code",
"scope": "应用的域"
}
内部参数
参数名 | 含义 |
---|---|
client_id |
客户端ID,对单个用户而言就是S_USER 表中的用户主键。 |
client_secret |
创建用户账号(或第三方对接应用)时,平台会发放专用密钥(一个随机字符串)。 |
response_type |
默认值code 表示授权码流程,也可使用其他符合OAuth规范的类型。 |
scope |
应用程序域字段数据,该字段存储于X_APP 中用来限定多应用平台中每个应用的单独信息。 |
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | 临时码申请请求。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) category(params) → {Promise.<T>}
「接口」Ex.I.category
- 接口:
- 读唯一:
/api/:type/category/:code
(GET) - 读某一类:
/api/type/categories/:type
(GET) - 读几类:
/api/type/categories
(POST)
- 读唯一:
- 安全:是
读取X_CATEGORY
专用接口(三义性接口),这个方法会分三种方式读取,根据参数判断。
内部参数
参数名 | 含义 |
---|---|
type | 读取的X_CATEGORY 的类型,对应TYPE 字段。 |
code | 读取的X_CATEGORY 的编码,对应CODE 字段。 |
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 当前字典专用请求。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) company() → {Promise.<T>}
「接口」Ex.I.company
- 接口:
/api/company/employee/:eid
(GET) - 安全:是
根据用户数据中存储的员工主键employeeId
读取员工所属公司信息,如果未登录则读取的数据为空。
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) control(params) → {Promise.<T>}
「接口」Ex.I.control
- 接口:
/api/ui/control
(POST) - 安全:是
{
"type": "两种类型",
"control": "控件ID"
}
读取控件配置UI_CONTROL
相关数据。
内部参数
参数名 | 含义 |
---|---|
type | 读取的控件类型信息,目前分为FORM | LIST 三种,不仅读取UI_CONTROL 表,也会读取子表信息。 |
control | 传入需要读取控件的ID值。 |
- type = FORM,读取表单配置数据。
- type = LIST,读取列表配置数据。
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 控件专用请求 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) forest(type, mode) → {Promise.<T>}
「接口」Ex.I.forest
- 接口:
- 读取某一类:
/api/type/categories/:type
(GET) - 判断节点
- 读取某一类:
节点主要包含两种:
- 整棵树:tree =
- 树中某个分支:tree = xxx,
连接模式
- mode = "REPLACE": 抓取的树直接替换当前节点
- mode = "CONNECT": 抓取的树作为当前节点的子节点
Parameters:
Name | Type | Default | Description |
---|---|---|---|
type |
String | 读取某一类 X_CATEGORY 构造森林 |
|
mode |
String |
REPLACE
|
连接模式 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) form(params) → {Promise.<T>}
「接口」Ex.I.form
- 接口:
/api/ui/form/:code
(GET) - 安全:是
读取表单专用配置接口,根据表单的code读取表单配置信息。
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 表单请求,包含表单的 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) forms(identifier) → {Promise.<T>}
「接口」Ex.I.forms
- 接口:
/api/ui/forms/:identifier
(GET) - 安全:是
读取模型下的表单配置信息,这个接口读取和identifier
模型相关的所有表单配置信息。
Parameters:
Name | Type | Description |
---|---|---|
identifier |
String | 模型统一标识符。 |
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) inited() → {Promise.<T>}
「接口」Ex.I.inited
- 接口
- 应用接口:
/api/app
(GET) - 菜单数据:
/api/menus
(GET)
- 应用接口:
- 安全:是
该接口为登录过后的主页调用的专用初始化接口,主要执行两个操作:
- 执行
X_APP
的全配置信息(包括敏感信息,appKey)。 - 执行
X_MENU
的全配置信息(只读取当前菜单)。
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) jobResume(key) → {Promise.<T>}
「接口」Ex.I.jobResume
- 接口:
/api/job/resume/:key
(PUT) - 安全:是
恢复任务专用接口,I_JOB
特定应用。
Parameters:
Name | Type | Description |
---|---|---|
key |
String | 恢复任务的键。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) jobs() → {Promise.<T>}
「接口」Ex.I.jobs
- 接口:
/api/job/info/by/sigma
(GET) - 安全:是
读取当前系统中所有的任务信息(按sigma分类)。
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) jobStart(key) → {Promise.<T>}
「接口」Ex.I.jobStart
- 接口:
/api/job/start/:key
(PUT) - 安全:是
启动任务专用接口
Parameters:
Name | Type | Description |
---|---|---|
key |
String | 启动任务的键。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) jobStop(key) → {Promise.<T>}
「接口」Ex.I.jobStop
- 接口:
/api/job/stop/:key
(PUT) - 安全:是
停止任务专用接口
Parameters:
Name | Type | Description |
---|---|---|
key |
String | 停止任务的键。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) lists(identifier) → {Promise.<T>}
「接口」Ex.I.lists
- 接口:
/api/ui/lists/:identifier
(GET) - 安全:是
读取模型下的所有列表配置信息
Parameters:
Name | Type | Description |
---|---|---|
identifier |
String | 模型统一标识符。 |
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) login(request, options) → {Promise.<T>}
「接口」Ex.I.login
- 接口:
/oauth/login
(POST) - 安全:否
登录入口专用,请求数据如:
{
"username": "登录账号",
"password": "MD5加密过后的密码"
}
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | 登录专用请求。 |
options |
Object | 选项处理 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) logout() → {Promise.<T>}
「接口」Ex.I.logout
- 接口:
/api/user/logout
(POST) - 安全:是
注销登出专用接口
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) menus() → {Promise.<T>}
「接口」Ex.I.menus
- 接口:
/api/menus
(GET) - 安全:是
登录过后根据Ux.isInit()
的应用信息返回当前应用的所有菜单数据,应用数据存储在
X_APP
表中,包含X_SOURCE
的数据源信息,菜单数据存储在X_MENU
表中。
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) mission(key) → {Promise.<T>}
「接口」Ex.I.mission
- 接口:
/api/job/info/mission/:key
(GET) - 安全:是
读取 Mission 相关的 Job任务配置。
Parameters:
Name | Type | Description |
---|---|---|
key |
String | 当前任务的 |
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) module(uri) → {Promise.<T>}
「接口」Ex.I.module
- 接口:
/api/module?entry={entry}
(GET) - 安全:是
根据当前路由路径读取X_MODULE
中的模块配置信息,该模块的配置信息和Cab.json
中绑定
的资源文件合并生成当前模块的所有配置信息。
Parameters:
Name | Type | Description |
---|---|---|
uri |
String | 当前模块的入口信息。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) ops(params) → {Promise.<T>}
「接口」Ex.I.ops
- 接口:
/api/ui/ops
(POST) - 安全:是
读取操作专用配置UI_OP
,入参为:
{
"control": "控件ID",
"identifier": "模型标识符",
"type": "OP"
}
内部参数
参数名 | 含义 |
---|---|
type | 固定值OP,暂定为只读取OP相关信息。 |
control | (动态读取专用)传入需要读取控件的ID值,读取和UI_CONTROL 相关的数据库记录。 |
identifier | (静态读取专用)传入模型标识符,读取静态配置,配置文件在plugin/ui/ops.json 中。 |
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 控件专用请求 |
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) page(params) → {Promise.<T>}
「接口」Ex.I.page
- 接口:
/api/ui/page
(POST) - 安全:是
- 先读取
UI_PAGE
中的页面配置信息。 - 然后读取
UI_LAYOUT
中的模板配置信息。 - 最后根据
pageId
读取UI_CONTROL
中的控件配置信息。
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 页面专用请求 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) password(params) → {Promise.<T>}
「接口」Ex.I.password
- 接口:
/api/user/password
(POST) - 安全:是
更新用户登录密码专用接口
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 更新密码所用的请求。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) profile(params) → {Promise.<T>}
「接口」Ex.I.profile
- 接口:
/api/user/profile
(POST) - 安全:是
更新登录用户的Profile详细信息。
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 更新账号专用请求。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) relation() → {Promise.<T>}
「接口」Ex.I.relation
- 接口:
/api/relation
(GET) - 安全:是
读取关系定义专用接口
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) relationDelete(keys) → {Promise.<T>}
「接口」Ex.I.relationDelete
- 接口:
/api/ox/relation/remove
(POST) - 安全:是
删除关系专用接口
Parameters:
Name | Type | Description |
---|---|---|
keys |
Array | 将要被删除的关系的 key 集合 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) relationSave(relations) → {Promise.<T>}
「接口」Ex.I.relationSave
- 接口:
/api/ox/relation/save
(POST) - 安全:是
存储关系专用
Parameters:
Name | Type | Description |
---|---|---|
relations |
Array | 存储关系专用 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) tabular(params) → {Promise.<T>}
「接口」Ex.I.tabular
- 接口:
- 读唯一:
/api/:type/tabular/:code
(GET) - 读某一类:
/api/type/tabulars/:type
(GET) - 读几类:
/api/type/tabulars
(POST)
- 读唯一:
- 安全:是
读取X_TABULAR
专用接口(三义性接口),这个方法分三种方式读取,根据参数判断。
内部参数
参数名 | 含义 |
---|---|
type | 读取的X_TABULAR 的类型,对应TYPE 字段。 |
code | 读取的X_TABULAR 的编码,对应CODE 字段。 |
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | 当前字典专用请求。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) todo(params, confirmed) → {Promise.<T>}
「接口」Ex.I.token
- 接口:
- 确认:
/api/todo/confirm/:key
(PUT) - 拒绝:
/api/todo/reject/:key
(PUT)
- 确认:
- 安全:是
Todo待办的确认和拒绝专用接口。
Parameters:
Name | Type | Default | Description |
---|---|---|---|
params |
Object | 待办专用请求 |
|
confirmed |
boolean |
true
|
确认待办还是拒绝待办 |
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) token(request) → {Promise.<T>}
「接口」Ex.I.token
- 接口:
/oauth/token
(POST) - 安全:否
请求格式
{
"client_id": "客户ID",
"code": "临时验证码"
}
使用临时授权码交换令牌专用方法。
Parameters:
Name | Type | Description |
---|---|---|
request |
Object | 交换令牌专用请求。 |
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) uri(key) → {Promise.<T>}
「接口」Ex.I.uri
- 接口:
/api/x-api/:key
(GET) - 安全:是
读取具体 uri 配置。
Parameters:
Name | Type | Description |
---|---|---|
key |
String | 当前任务的 |
Returns:
返回Promise
- Type
- Promise.<T>
(async, static) user() → {Promise.<T>}
「接口」Ex.I.user
- 接口:
/api/user
(GET) - 安全:是
读取当前登录用户的基本信息。
Returns:
返回Promise。
- Type
- Promise.<T>
(async, static) visitor(params) → {Promise.<T>}
「接口」Ex.I.visitor
- 接口:
/ui/visitor/:identifier/:page
(POST) - 安全:是
{
"identifier": "路径参数,模型标识符",
"page": "页面ID",
"view": "「位置1」视图信息",
"position": "「位置2」位置信息",
"type": "类型选择,FORM / LIST",
"alias": "「位置3」别名信息"
}
位置信息计算规则:view / position / alias
- view:视图信息,直接从 $myView 中提取。
- position:位置信息,直接从 $myView 中提取。
- alias:别名处理,同样用来计算 alias。
内部参数
参数名 | 含义 |
---|---|
type | 读取控件的专用类型,主要包含FORM | LIST 两种。 |
identifier | 模型标识符。 |
page | 页面专用ID。 |
view/position/alias | 专用位置计算信息。 |
Parameters:
Name | Type | Description |
---|---|---|
params |
Object | params 参数信息 |
Returns:
返回Promise
- Type
- Promise.<T>