系统集成 API

登录 API

登录

支持两种登录,一是传入用户名和密码,二是传入用户登录 token

url: $platformUrl/login
method: post
request header
    Accept: application/json 
    content-type: application/x-www-form-urlencoded
request body(form)
    username: ""            //用户名
    password: ""            //密码
    token: ""            //用户登录 token
response cookie
    user_session: ""        //后续调用平台接口时需要使用
response status: 200成功,其它失败

用户登录 token 的获取方法参考《第三方自动登录并打开页面》中的获取用户 token

注销

说明:此接口调用前不需要登录集成用户

url: $platformUrl/logout
method: get
request cookie:
    user_session: ""        //登录得到的 user_session
response status: 200成功,其它失败

获取用户信息

说明:此接口调用前不需要登录集成用户

url: $platformUrl/entry/uaa/userinfo
method: get
request cookie:
    user_session: $token    //平台打开外部系统时给的 token
response body(application/json)
    {
        "user_id":"",    //用户标识
        "username":"",    //登录名
        "name":""    //中文名
        "phone_number":"",
        "email":""
    }
response status: 200成功,其它失败

验证 token

使用“获取用户信息”模拟,如果能获取到用户信息,表示 token 有效,否则无效。

获取 token

根据用户名和凭证令牌 credenntialToken(企业门户的环境变量 uaa_credential_token)获取用户登录的 token

url:$platformUrl/entry/uaa/sso/token?username=账号&credentialToken=xxx
method: get
response:用户 token 字符串

组织 API

获取组织增量

说明:此接口调用前必须登录集成用户

url: $platformUrl/entry/misc/org/getOrgSnapshot?orgDigest=$orgDigest
method: get
request cookie:
    user_session: $user_session        //集成用户登录获取获取的 user_session
request field:
    orgDigest: 外部服务当前组织镜像的 md5;  当 orgDigest 为空或给定的 orgDigest 不存在时,将会返回组织最新的全量数据
response body(application/json)
    {
        "success": true,        //状态, 取值范围 true, false
        "msg": "",             //错误消息
        "type": "delta"    ,        //数据格式, 取值范围: 增量(delta), 全量(all),
        "orgDigest": "",        //当前组织镜像的 md5
        "data":{
            //增量数据修改时,添加一个 state 表示修改状态,取值范围:new,update,delete,            //全量时没有 state
            "users": [{
                //参考数据结构中的“用户”
                state: "new"
            }],
            "orgs": [{
                //参考数据结构中的“组织”
                state: "new"
            }]
        }
    }
response status: 200表示成功,其它表示失败

导入组织

说明:此接口调用前必须登录集成用户

uaa 提供一个api:postOrgs,实现组织和人员的增删改,参考《组织权限 API》中维护组织和用户

导入组织图片

说明:此接口调用前必须登录集成用户

url: $platformUrl/entry/misc/org/importOrgImg
method: post
request cookie:
    user_session: $user_session        //集成用户登录获取获取的 user_session
request body(multipart/form-data)
    file: zip格式的压缩文件
response body(application/json)
    {
        "success": true,        //状态, 取值范围 true, false
        "msg": ""             //错误消息
    }
response status: 200表示成功,其它表示失败

说明:

  • 压缩文件格式:zip格式
  • 压缩文件示例:
├─xx.zip
│  ├─users(表名作目录名)
│  │  ├─config.json(配置文件)
│  │  ├─signature(字段名作目录名)
│  │  │  ├─system.jpg
│  │  │  └─dev1.jpg

config.json 文件内容如下

{"lookupColumnName": "username"}

以上压缩包的含义是:更新 users 表中的 signature 字段,使用 users 表中的 username 字段作为查找条件,生成的 sql 类似:

update users set signature=${图片上传后生成的地址} where username=${不带后缀的图片名}

除此之外,在 config.json 中还可以加 lookupColumnValue 指定一个查询的 sql, 这个 sql 必须返回一个字段,有且只有一个?参数,生成的语句类似:

update users set signature=${图片上传后生成的地址} where username in (${lookupColumnValue使用不带后缀的图片名替换其中的?})
  • 代码调用案例:
String path = System.getProperty("user.dir") + "/test/res.zip";
OkHttpClient client = new OkHttpClient();
File file = new File(path);
RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"), file);
RequestBody body = new MultipartBuilder().type(MultipartBuilder.FORM)
                    .addFormDataPart("file", file.getName(), fileBody)
                    .build();
String url = "/xxxx/entry/misc/org/importOrgImg";
Request request = new Request.Builder().url(url).post(body).build();
Call call = client.newCall(request);
Response response = call.execute();

任务 API

创建任务

参考《任务 API》中的新建外部任务

更新任务

参考《任务 API》中的更新任务

其它 API

服务注册

说明:此接口调用前必须登录集成用户

url: $platformUrl/entry/manager/services
method: post
request cookie:
    user_session: $user_session      //集成用户登录后获取的 user_session
request body(application/json)
    {
        "type": "external",      //服务类型,取值范围:外部服务 external
        "label": "",          //服务名称
        "address": "",            //服务接入地址, 
        "apisecret": ""          //外部服务 apisecret,平台调用外部服务时将会使用
    }
response status: 200表示成功,其它失败

results matching ""

    No results matching ""