# B 端应用平台 sdk 文档

Revision Date Author/Owner Description of Charge
1.0.0 20200325 王梦杰 1、node sdk 新增getChangePasswordUri;2、browser sdk 新增changePsw
1.0.1 20200326 王梦杰 1、node sdk 新增cookieDomain配置
1.0.2 20200330 王梦杰 1、node sdk 新增inc.org.getTreeByIdAPI
1.0.3 20200331 孙旭 1、明确 Java Sdk 接口类定义,避免或多 Json 序列化反序列化 2、Java SDK 配置初始化改进 3、 增加 User 缓存,ThreadLocal 添加 User 信息 4.增加 Domain
1.0.4 20200401 孙旭 1、java sdk 新增inc.org.getTreeByIdAPI
1.0.5 20200402 王梦杰 1、incClient.checkAppAuth接口新增loginType参数;2、MOPAR 项目用到的loginType参数说明
1.0.6 20200410 王梦杰 1、b-inc sdk 新增incClient.checkAppAuth配置参数debugmode, 新增incClient.sLogin配置参数notGo
1.0.7 20200413 柳旭 1、b-inc sdk 新增incClient.ReactPrivateRoute,React 版登陆验证组件
1.0.8 20200414 王梦杰 1、b-inc sdk 移除incClient.checkAppAuth配置参数debugmode到构造函数的参数中
1.0.9 20200428 王梦杰 1、b-inc sdk 新增incClient.checkAppAuth配置参数classic
1.0.10 20200710 王梦杰 1、b-inc sdk、node-inc sdk 新增env配置参数
1.1.0 20200715 王梦杰 1、集成 sdk 涉及的接口规范
1.1.1 20200727 朱文诚 1、接口入参出参修改:(/api/auth/getUser、 /api/user/listWithPaging、/api/user/save、/api/user/update、/api/user/get、/api/log/listWithPaging、 /api/org/getTreeById)
1.1.2 20200812 朱文诚 1、增加 inc.user.renew 2、修改 inc.user.list api 说明
1.1.3 20200814 朱文诚 1、用户详情接口修改
1.1.4 20200820 朱文诚 1、新增获取组织机构接口(非树形结构)
1.1.5 20200824 朱文诚 1、userList roles 字段结构更改
1.1.6 20200824 朱文诚 1、增加 inc.user.getUsersById 获取多个用户详情接口 ;2、增加获取当前登录用户租户信息
1.1.7 20200826 王梦杰 转移“用户管理”模块接口道Center API
1.1.8 20210610 王梦杰 node-inc sdk新增base参数
1.1.9 20210720 覃略 1、接口出参描述调整:(/api/auth/list、/api/user/listWithPaging)
1.1.10 20210908 覃略 1、node sdk 新增接口(/api/auth/getUserDataPerm) 2、browser sdk 新增 inc.getUserDataPerm
1.1.11 20220621 王梦杰 b-inc sdk新增审计上报API

[TOC]

# 前言

incubator sdk 旨在使应用开发者能较为方便的接入B端账号认证,虽然SDK提供了“用户管理”、“组织机构管理”相关的接口,但受限于sdk的更新和分发过程,更建议开发者使用Center API的方式调用

# @incubator/node-inc

node 端 inc sdk

# 使用

import Inc from "@incubator/node-inc";

const inc = new Inc({
  env: "test",
  appId: "12345678",
  appSecret: "fdsfdsdscdn2123321",
  incServer: "http://127.0.0.1:8080",
  cookieDomain: "inc.com",
  base: "/cms",
});
1
2
3
4
5
6
7
8
9
10

参数详解

字段 类型 是否必填 含义
env String 0 子应用环境,可按环境配置应用地址
appId String 1 子应用 APPID
appSecret String 1 子应用 APPSECRET
incServer String 1 inc 服务地址
cookieDomain String 0 设置 cookie 时,自定义 domain 配置
base String 0 如果服务部署在域名子路径下,需要配置,值为子路径

# inc.oAuth.getSSOUri(appId, referer):String

子应用获取 sso 登录的跳转地址,appId 为 center 系统分配的 appId,referer 为当前页面 url,登录成功后跳回

# inc.oAuth.parseTk(body):Promise

解析 jwt,获取 token body 参数和返回值参考:api-auth-parsetk

# inc.oAuth.getUser(token):Promise

获取当前登录用户的信息 返回值参考:api-auth-getuser

# inc.oAuth.getUserDataPerm(token):Promise

获取当前登录用户数据权限信息 返回值参考:api-auth-getuserdataperm

# inc.oAuth.isLogin(token):Promise

获取当前用户的登录状态 返回值参考:api-auth-islogin

# inc.oAuth.logout(token):Promise

当前用户退出登录 返回值参考:api-auth-logout

# inc.oAuth.getChangePasswordUri(token):Promise

获取修改密码的 url 返回值参考:api-auth-get-change-password-uri

# inc.oAuth.checkApi(body):Promise

校验 apiPath 是否具有权限,配合 koa 中间件使用 body 参数和返回值参考:api-auth-check-api-by-token

app.use(async (ctx, next) => {
  const path = ctx.request.path;
  const token = ctx.request.token || ctx.session.token;
  const res = await inc.oAuth.checkApi({ apiPath: path, token }, ctx);
  if (res && res.data) {
    await next();
  } else {
    throw new IncError(ErrorCode.API_AUTH_ERROR, "api request not allowed");
  }
});
1
2
3
4
5
6
7
8
9
10

# inc.oAuth.poxyCenterRoutes(router):any

注: 提供给 koa 框架使用

子应用导入默认请求 center 的路由(参数 router 为 koa-router 实例对象)

# inc.oAuth.authMiddleware(app):void

注: koa 中间件

子应用对需要登录的接口做中间件拦截

# inc.oAuth.apiAuthMiddleware(app):void

注: koa 中间件

子应用 api 请求权限中间件拦截

# inc.opLog.save(body, ctx.session.token):Promise

body 参数和返回值参考:api-log-save

# inc.opLog.listWithPaging(body, ctx.session.token):Promise

body 参数和返回值参考:api-log-list-with-paging

# @incubator/b-inc

浏览器端 inc sdk

# 使用

import Inc from "@incubator/b-inc";

const incClient = new Inc({
  env: "test",
  server: "",
  debug: false,
  mode: "history",
});
1
2
3
4
5
6
7
8

参数详解

字段 类型 是否必填 含义
env String 0 子应用环境,可按环境配置应用地址
server String 1 应用所在的服务地址, 传空表示当前域名
debug Boolean 0 调试模式,tk 获取成功后,跳转到 refer 指定的 url,默认为 false
mode String 0 vue-router 路由模式(hash/history),默认为 history

# incClient.LOGIN_REQUIRE_CODE

incubator 框架下,登录态失效的错误码

# incClient.checkCenterAuth()

vue-router 的 beforeEach hook,用在账号权限系统(center 系统)中,应用开发者不使用

# incClient.checkAppAuth(opt)

vue-router 的 beforeEach hook,应用开发者使用 参数说明:

字段 类型 是否必填 含义
opt.loginRedirect String 0 登录之后的跳转页面(vue router path,如:/main)
opt.loginPage String 0 检查到没有登录态,先跳转的页面。适配 mopar 多账号切换需求(vue router path,如:/login)
opt.classic boolean 0 直接通过 script 标签引入 sdk 的传统 js 应用校验登录,如果为 true,上面配置均失效
router.beforeEach(
  incClient.checkAppAuth({
    loginRedirect: "/main",
  })
);
1
2
3
4
5

# incClient.login()

跳转到登录页面

# incClient.logout(token, rurl)

退出登录,并跳转到登录页面

  • rurl:退出登录跳转到指定页面,默认到登录页

# incClient.getUser():Promise

获取登录用户的用户信息

# incClient.getUserDataPerm():Promise

获取登录用户的数据权限信息

# incClient.changePsw()

获取修改密码的页面 uri,并跳转过去

# incClient.sLogin(notGo):Promise

子应用跳转到登录页面,如果notGo参数为true,则不跳转,返回一个Promise供业务自行处理 示例:

incClient.sLogin(); // 跳转到登录页
incClient.sLogin(true).then((url) => console.log(url)); // 返回登录页跳转地址
1
2

# incClient.filterAsyncRoutes(asyncRoutes, permIds, homeRoute?)

通过原路由、权限值、默认 home 路由生成新路由

# incClient.sLogout(token, rurl)

子应用退出登录,并跳转到登录页面

  • rurl:退出登录跳转到指定页面,默认到登录页

# incClient.audit(params)

审计操作上报

params<Object>参数说明:

字段 类型 是否必填 含义
params.eventCode String 1 事件code
params.eventName String 1 事件名
params.operatorType String 1 操作类型,(1:只读,2:只写)
params.operatorDesc String 0 操作详情

# incClient.ReactPrivateRoute()

返回一个带有权限验证,登陆等功能的 React 组件,此组件功能类似incClient.checkAppAuth(opt)方法,参数exactpathcomponentreact-router-domRoute组件的参数一致,可参考react-router-dom (opens new window)文档,同时支持loginRedirectloginPage参数

参数说明:

字段 类型 是否必填 含义
exact Boolean 0 path 是否严格匹配
path String 1 目标路由的 URL
component String 1 目标路由匹配时展示的组件
react Object 1 React 实例
route Object 1 react-router-dom 中的 Route 组件
redirect Object 1 react-router-dom 中的 Redirect 组件
loginRedirect String 0 登录之后的跳转页面(如:/main)
loginPage String 0 检查到没有登录态,先跳转的页面。适配 mopar 多账号切换需求(如:/login)

import React from 'react'
import { Route, Redirect } from 'react-router-dom'
import Inc from '@incubator/b-inc'

const incClient = new Inc({ server: '' })
const PrivateRoute = incClient.ReactPrivateRoute()

<PrivateRoute
  exact
  path="/"
  loginRedirect="/"
  component={UserList}
  react={React}
  route={Route}
  redirect={Redirect}
/>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# @incubator/java-inc

Java 端 inc sdk

:sdk jar 包未分发到在线 maven 仓库,请自行点此下载 (opens new window)

# 使用

# 0. 框架 Java springboot 框架

# 1. pom.xml 文件引入 inc-access-sdk

<dependency>
  <groupId>com.iov.tencent</groupId>
  <artifactId>inc-access-sdk</artifactId>
  <!--按需填写对应jar的版本号-->
  <version>2.0-SNAPSHOT</version>
</dependency>
1
2
3
4
5
6

# 2. 启动类添加 com.iov.tencent.inc.access 包,初始化配置

  1. 启动文件 需配置, ComponentScan 扫描 "com.iov.tencent.inc.access", 案例如下:

@ComponentScan({"com.tencent.iov.test", "com.iov.tencent.inc.access"})
public class IncTestApplication {
    SpringApplication.run(IncTestApplication.class, args);
	}
}
1
2
3
4
5
6
  1. 在配置文件(如application.yml)增加配置信息
inc-config:
  appId: 111 #Center系统的appId
  appSecret: 111 #Center系统的appSecret
  incServer:  #Center系统的请求地址
  sessionKey : "inc-test" # session key 前缀
  sessionTime : 300 # 登陆session有效期,单位s
  cookieDomain: "127.0.0.1" # cookie domain
  redis:
    database: 0  # redis 数据库
    host: 127.0.0.1 # redis 数据库HOST
    port: 6379  # redis 数据库PORT
    password: 123456 # redis 数据库password
    maxActive: 80  # redis 数据库连接池参数 -- 最大活跃连接
    maxWait: -1 # redis 数据库连接池参数 -- 获取连接 等待时间
    maxIdle: 80 # redis 数据库连接池参数 -- 最大连接
    minIdle: 20 # redis 数据库连接池参数 -- 最小连接
    timeout: 20000 # redis 数据库连接池参数 -- 超时参数


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# 3. 拦截器使用(sdk 提供, 可选, 默认集成 1. apiPath 和 token 做校验 2. 登陆态校验 )

@Aspect
@Component
public class UserIncAuthAopAspect extends IncBaseAopAspect implements IncAopMethod {

  /**
    * 可以添加不需要 拦截的地址
    */
  public static List<String> permittedUrl = new ArrayList<String>();

  /**
    * 初始化 加载不拦截的Url
    */
  static {
    permittedUrl.add("/v1/test1");
  }
  /**
    * 配置自定义 拦截表达式, 拦截项目的主类, 请参考 AOP PointCut Expression规范
    */
  @Pointcut("execution(public * com.tencent.iov.test.controller.TestController.*(..)) ")
  public void verify() {
  }

  /**
    * 拦截器方法, incAuthFilter 会对 1. apiPath 和 token做校验 2. 登陆态校验
    */
  @Around("verify()")
  public Object myAround(ProceedingJoinPoint joinPoint) throws Throwable {
    return defaultIncAuthFilter(joinPoint, permittedUrl);
  }
  /**
    * 调用结束清理ThreadLocal如果 拦截器Aroud方法使用了 defaultIncAuthFilter,则必须使用 defaultCleanThreadLocal
    */
  @After(value = "verify()")
  public void afterAop() throws Throwable{
    defaultCleanThreadLocal();
  }

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

# 4. session 及用户信息 获取(sdk 提供, parseTk 接口登陆成功会自动 set 到 redis 里)

@Autorired
IncSessionService incSessionService;

// 获取session
incSessionService.getSession();

// 通过 token获取用户信息
incSessionService.getUserFromCache(IncAccessConstParam.TokenPrefix  token)

// ThreadLocal 获取, 只有完成拦截器鉴权才有
IncUserThreadLocal.get()

1
2
3
4
5
6
7
8
9
10
11
12

# 操作记录相关 IncOpLogService

@Autorired
IncOpLogService incOpLogService;
1
2

# saveOpLog(IncSaveOptLogReq requestBody, String token)

body 参数和返回值参考:api-log-save

# listOpLogWithPaging(IncQueryWithPagingReq requestBody, String token)

body 参数和返回值参考:api-log-list-with-paging

# 内部登陆相关 IncInnerService

@Autorired
IncInnerService incInnerService;
1
2

# getSSOUri(String appId, String referer)

子应用获取 sso 登录的跳转地址,appId 为 center 系统分配的 appId,referer 为当前页面 url,登录成功后跳回

# parseTk(Object requestBody)

解析 jwt,获取 token body 参数和返回值参考:api-auth-parsetk

# getUser( String token)

获取当前登录用户的信息 返回值参考:api-auth-getuser

# getUserDataPerm( String token)

获取当前登录用户数据权限 返回值参考:api-auth-getuserdataperm

# isLogin(token)

获取当前用户的登录状态 返回值参考:api-auth-islogin

# logout(token)

当前用户退出登录 返回值参考:api-auth-logout

# authCheckApi(String apiPath, String token)

校验 apiPath 是否具有权限 返回值参考:api-auth-check-api-by-token

# sdk 提供登陆管理模块 api ,引入 sdk 自动集成

  • /api/auth/getUser: 获取当前登录用户的信息
  • /api/auth/getUserDataPerm: 获取当前登录用户数据权限
  • /api/auth/parseTk: 解析 jwt,获取 token
  • /api/auth/islogin: 获取当前用户的登录状态
  • /api/auth/logout: 当前用户退出登录
  • /api/auth/getSSO: 子应用获取 sso 登录的跳转地址,appId 为 center 系统分配的 appId,referer 为当前页面 url,登录成功后跳回
  • /api/auth/checkApiByToken: 校验 token 是否有权限调用 api

上述接口请参考 接口规范

# 接口规范

# api-auth-parsetk

请求

Path: /api/auth/parseTk

requestBody:字段说明

字段 类型 必选 含义 备注
tk String 1 jwt 串

样例

{
  "tk": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbiI6IjM3NWQxYTkyLThhMzQtNGJkMi04ZDU1LWY4ZjdjOTFlNGM3MiIsImlhdCI6MTU4NDkzNjg5OSwiZXhwIjozMTY5ODczODU4fQ.8ofBfo2pU7es-hl2gZsh3qP7RE8ElU3oOixsgFuZ5eQ"
}
1
2
3

响应

字段说明

字段 类型 含义 备注
token String 解析之后的 token

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": {
    "token": "375d1a92-8a34-4bd2-8d55-f8f7c91e4c72"
  }
}
1
2
3
4
5
6
7

# api-auth-getuser

请求

Path: /api/auth/getUser

requestBody:字段说明

字段 类型 必选 含义 备注
token String 0 用户 token

样例

{
  "token": "2fa212b5-fadf-42d4-87fa-6c1813f5ac3d"
}
1
2
3

响应

字段说明

字段 类型 含义 备注
user Object<User> 用户详情
User._id String 用户主键
User.token String 用户 token
User.status Enum<String> 账户状态 ENABLE/DISABLE
User.gender Enum<String> 性别 M/F/U
User.name String 用户名
User.isInitial Enum<String> 是否为初始化账户 Y/N
User.mobile String 手机号
User.email String 邮箱
User.id String 用户 ID
User.extra String 用户附带信息
User.userName String 真实姓名
User.roles Array<ObjectId> 角色主键 Id 数组
User.birthday Date 生日
User.org Array<ObjectId> 所属组织机构信息 org 主键 id 数组
User.orgName Array<String> 所属组织机构名称
User.orgCode Array<String> 所属组织机构 code 信息
User.roleNames Array<String> 所属角色名称集合
User.roleType Enum<String> 角色类型 0/1/2/3/4(超级管理员/租户管理员/应用管理员/普通角色/机构管理员)
User.permIdList Array<String> 所拥有权限值集合
User.permApiList Array<String> 所拥有 api 接口集合
User.manageOrgs Array<ObjectId> 管理机构 id 集合
User.mainTenant ObjectId 主租户 id
User.tenant Array<ObjectId> 所属租户 id 集合
User.created_at Date 创建时间
User.loginTime Date 登陆时间
User.avatar String 头像地址
User.tenantList Array 租户详情集合
tenantList.isAdmin Boolean 是否是租户管理员
tenantList.manageOrgs Array <ObjectId> 管理的机构
tenantList.orgs Array 机构完整路径集合
tenantList.roles Array <ObjectId> 角色 id 集合
tenantList.tenantId ObjectId 租户 id
User.permList Array 权限详情
permList.apis string api
permList.extra string 附带信息
permList._id string<ObjectId> 权限主键
permList.appId string 所属应用

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": {
    "user": {
      "token": "1622c2a6-a0b2-446c-b325-630653f880d3",
      "userName": null,
      "isInitial": "N",
      "roles": [],
      "email": "userTesta04@qq.com",
      "avatar": null,
      "mobile": null,
      "status": "ENABLE",
      "birthday": null,
      "gender": "U",
      "manageOrgs": [
        {
          "status": "1",
          "rootId": "5f03e4c70868e338b0581516",
          "orgType": "1",
          "associationRole": "5f06b1adb0598f5fe4e0505f",
          "fullPath": ["5f03e4c70868e338b0581516"],
          "_id": "5f06b1adb0598f5fe4e0505d",
          "name": "测试机构2",
          "code": "12321321321"
        }
      ],
      "mainTenant": "5f03e4c70868e338b0581516",
      "tenant": ["5f03e4c70868e338b0581516"],
      "org": ["5f06b1adb0598f5fe4e0505d"],
      "extra": "{}",
      "loginTime": "2020-08-14T09:36:57.329Z",
      "_id": "5f154e8e267b3e36b8c11441",
      "name": "userTesta04",
      "id": "144115205301731476",
      "created_at": "2020-07-20T07:58:06.437Z",
      "tenantList": [
        {
          "tenantId": "5f03e4c70868e338b0581516",
          "orgs": [
            {
              "status": "1",
              "rootId": "5f03e4c70868e338b0581516",
              "orgType": "1",
              "associationRole": "5f06b1adb0598f5fe4e0505f",
              "fullPath": ["5f03e4c70868e338b0581516"],
              "_id": "5f06b1adb0598f5fe4e0505d",
              "name": "测试机构2",
              "code": "12321321321"
            }
          ],
          "isAdmin": false,
          "fullOrgs": [
            ["5f03e4c70868e338b0581516", "5f06b1adb0598f5fe4e0505d"]
          ],
          "manageOrgs": [
            {
              "status": "1",
              "rootId": "5f03e4c70868e338b0581516",
              "orgType": "1",
              "associationRole": "5f06b1adb0598f5fe4e0505f",
              "fullPath": ["5f03e4c70868e338b0581516"],
              "_id": "5f06b1adb0598f5fe4e0505d",
              "name": "测试机构2",
              "code": "12321321321"
            }
          ],
          "roles": []
        }
      ],
      "orgCode": ["12321321321"],
      "orgName": ["测试机构2"],
      "roleType": "4",
      "roleNames": [],
      "permApiList": ["/api/user/get", "/api/org/getTreeById"],
      "permIdList": ["/role", "/role/user-edit"],
      "permList": [
        {
          "apis": [],
          "extra": "{}",
          "_id": "5f34fd286b67f80f888f5c4b",
          "appId": "5f153b0f64f07527fc1c23d7"
        },
        {
          "apis": [],
          "extra": "{}",
          "_id": "300000000000000000000000",
          "permId": "/role",
          "appId": "5f153b0f64f07527fc1c23d7"
        }
      ]
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

# api-auth-getuserdataperm

请求

Path: /api/auth/getUserDataPerm

requestBody:字段说明

字段 类型 必选 含义 备注
token String 0 用户 token

样例

{
  "token": "2fa212b5-fadf-42d4-87fa-6c1813f5ac3d"
}
1
2
3

响应

字段说明

字段 类型 含义 备注
data.list Array 数据权限列表
list.permissionId string 数据权限主键
list.permissionName string 数据权限名称
list._id string<ObjectId> 权限id
list.api string api路径

样例

{
   "code": 0,
   "msg": "SUCCESS",
   "data": {
     "list": [
         {
         "_id": "612bbe43b54aaa6c01522317",
          "permissionId": "84",
          "permissionName": "规则aaaa",
          "api": "/test/aaaaaaaaaa"
         },
        {
        "_id": "612bbe30b54aaa6c01522315",
        "permissionId": "83",
        "permissionName": "规则aaa",
        "api": "/test/aaaaaaaaaa"
        }
        ]
      }
    }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

# api-auth-islogin

请求

Path: /api/auth/islogin

requestBody:字段说明

字段 类型 必选 含义 备注
token String 0 用户 token

样例

{
  "token": "2fa212b5-fadf-42d4-87fa-6c1813f5ac3d"
}
1
2
3

响应

字段说明

字段 类型 含义 备注
data Boolean 是否登录 true/false

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": true
}
1
2
3
4
5

# api-auth-logout

请求

Path: /api/auth/logout

requestBody:字段说明

字段 类型 必选 含义 备注
token String 0 用户 token

样例

{
  "token": "2fa212b5-fadf-42d4-87fa-6c1813f5ac3d"
}
1
2
3

响应

字段说明

字段 类型 含义 备注
data String 登出后跳转的 url

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": "http://111.230.207.102/oauth/authorize?state=NTk1MTMyNDAzMjQ5&nonce=NjE2NzgyMTQzNzMw&scope=set_email%20get_email%20set_profile%20get_profile%20set_phone%20get_phone%20logout%20delete_user%20%2F.*&response_type=code&appid=1&client_id=2575043885&redirect_uri=http%3A%2F%2F9.134.67.38%3A8081"
}
1
2
3
4
5

# api-auth-get-change-password-uri

请求

Path: /api/auth/getChangePasswordUri

requestBody:字段说明

字段 类型 必选 含义 备注

样例

{}
1

响应

字段说明

字段 类型 含义 备注
data String 修改密码的页面 uri

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": "http://111.230.207.102/static/portal.html?action=change_password&sdkappid=1&url=http%3A%2F%2F111.230.207.102%2Foauth%2Fauthorize%3Fstate%3DMTAwODUyOTY1NTU2Mg%253D%253D%26nonce%3DNTk3NjE2MzY4Mzk0%26scope%3Dset_email%2520user_import%2520reset_password%2520get_user_info%2520get_email%2520set_profile%2520get_profile%2520set_phone%2520get_phone%2520set_username%2520get_username%2520logout%2520delete_user%2520%252F.*%26response_type%3Dcode%26appid%3D1%26client_id%3D2575043885%26redirect_uri%3Dhttp%253A%252F%252F9.134.67.38%253A8081%26title%3DB%25E7%25AB%25AF%25E8%2584%259A%25E6%2589%258B%25E6%259E%25B6%25E6%25BC%2594%25E7%25A4%25BA%25E5%25B9%25B3%25E5%258F%25B0"
}
1
2
3
4
5

# api-auth-check-api-by-token

请求

Path: /api/auth/checkApiByToken

requestBody:字段说明

字段 类型 必选 含义 备注
token String 1 token
apiPath String 1 api 路径

样例

{
  "token": "375d1a92-8a34-4bd2-8d55-f8f7c91e4c72",
  "apiPath": "/api/auth/getUser"
}
1
2
3
4

响应

字段说明

字段 类型 含义 备注
data Boolean 是否通过校验 true/false

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": true
}
1
2
3
4
5

# api-log-save

请求

Path: /api/log/save

requestBody:字段说明

字段 类型 必选 含义 备注
userId String 1 操作人用户 Id
op String 1 操作类型
detail String 1 操作详情 格式为 json 序列化串

样例

{
  "userId": "9691781286819106",
  "op": "remove user",
  "detail": "{\"a\":\"1\"}"
}
1
2
3
4
5

响应

字段说明

字段 类型 含义 备注

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": {}
}
1
2
3
4
5

# api-log-list-with-paging

请求

Path: /api/log/listWithPaging

requestBody:字段说明

字段 类型 必选 含义 备注
page Number 0 页码 默认为 1
pageSize Number 0 每页条数 默认为 10
filterText String 0 关键词搜索 支持对'op', 'detail' 模糊搜索

样例

{
  "filterText": "admin",
  "page": "1",
  "pageSize": "1"
}
1
2
3
4
5

响应

注:只说明data部分

字段 类型 含义 备注
page Number 当前页码
count Number 总条数
list Array<Log>> 用户列表
Log.op String 操作类型
Log.detail String 操作详情
Log.created_at Date 创建时间
Log._id String 日志主键 Id
Log.user Object<User> 操作人详情
User.name String 操作人名称
User.userName String 操作人真实姓名
User.id String 操作人 Id
User.extra String 操作人额外详情
User._id String 操作人主键 Id

样例

{
  "code": 0,
  "msg": "SUCCESS",
  "data": {
    "page": 1,
    "count": 1,
    "list": [
      {
        "_id": "5e79c2ae53c0a9003c92f47f",
        "op": "user",
        "detail": "{\"msg\":\"update user\",\"params\":{\"gender\":\"M\",\"userName\":\"1232132123\",\"birthday\":null,\"org\":[\"5e71cb291f4bd7003c8417de\"],\"roles\":[\"5e4f533363ede00043e1bf3a\"],\"status\":\"ENABLE\"},\"userId\":\"144115205374725511\"}",
        "user": {
            "_id": "5e4f524263ede00043e1bef4",
            "name": "UNKNOW",
            "id": "144115205374725106",
            "userName": ""
        },
          "extra":'{"otherName":"ads"}'
        }
      }
    ]
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
lastUpdate: 6/21/2022, 8:15:04 PM