跳转至

SuperuserController(特权用户管理)

管理企业域下的特权用户(SuperUserVO,含超级管理员 / 域管理员 / 系统管理员 / 开发者):分页查询特权用户列表、新建 / 更新 / 批量删除特权用户,以及通过管理员密钥换取指定 runtime 用户的 accessToken。

  • 类级基址${myapps.context-path.manager:}/api/authtime(完整路径:{manager-context}/api/authtime<相对路径>
  • Tag:特权用户管理模块(控制器源码声明 @Tag(name = "特权用户管理模块")
  • 控制器源码obpm-manager/src/main/java/cn/myapps/manager/authtime/controller/superuser/SuperuserController.java
  • 公共说明
  • 类继承 BaseAuthTimeController,通过其 success(errmsg, data) / error(errcode, errmsg, errors) 返回统一 Resource(字段 errcode/errmsg/data/errors,结构见 ../index.md「统一响应结构」)。
  • 多数端点在 try/catch 内捕获 Exceptione.printStackTrace() 后返回 errcode=500errmsg=e.getMessage()data=null;业务校验失败常用 errcode=40001(注意:本控制器使用 40001,与多数同模块控制器的 4001 不同)。
  • 控制器未声明 @ResponseStatus,HTTP 状态码默认 200。
  • 鉴权说明见 index.md「鉴权说明」(adminToken JWT)。
  • 路径变量:id 为特权用户 id(仅 PUT /superuser/{id} 持有);其余端点 id 由 body 提供。
  • 三员管理(security.mode)开启时,新建 / 更新会以**当前管理员**的 type 强制覆盖请求体的 type,并把请求体的 departments 写入。

1. 查询特权用户列表

分页查询特权用户(SuperUserVO)列表,支持按名称(name)与登录账号(loginno)模糊匹配。开启三员管理(security.mode)时按当前管理员的 type 过滤,仅返回同类型特权用户。返回前将每个 SuperUserVO 投影为精简 JSON(包含 id / name / 登录账号 / 邮箱 / 状态 / 各类管理员标记 / 域 / 软件 / 部门集合等字段)。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/superuser(完整:{manager-context}/api/authtime/superuser
  • 鉴权:是(需管理员 adminToken,详见 index.md「鉴权说明」)
  • Tag:特权用户管理模块

请求参数

参数名 位置 类型 必填 说明
currpage query int 当前页码
pagelines query int 每页条数
name query string 名称模糊匹配关键词
loginno query string 登录账号模糊匹配关键词

请求示例

GET /api/authtime/superuser?currpage=1&pagelines=20&name=admin&loginno= HTTP/1.1

响应

结构:统一 Resource(见 ../index.md「统一响应结构」)。 dataDataPackage<JSONObject>,字段:

字段 类型 说明
linesPerPage int 每页条数
pageCount int 总页数
pageNo int 当前页码
rowCount int 总记录数
datas array\<JSONObject> 特权用户数组(见下)

datas 元素字段:

字段 类型 说明
id string 特权用户 id
name string 名称
loginno string 登录账号
loginpwd string 登录密码(原样返回,调用方注意脱敏)
email string 邮箱
status int 状态
type int 用户类型(SuperUserVO.type
superAdmin boolean 是否超级管理员
domainAdmin boolean 是否域管理员
developer boolean 是否开发者
secret string 管理员密钥(用于换取 accessToken,见端点 5)
applications array 关联软件 id 列表
applicationList array 关联软件对象列表
domains array 关联企业域 id 列表
domainList array 关联企业域对象列表
departments array 关联部门 id 列表(三员管理开启时返回)

成功示例

{
  "errcode": 0,
  "errmsg": "ok",
  "data": {
    "linesPerPage": 20,
    "pageCount": 1,
    "pageNo": 1,
    "rowCount": 1,
    "datas": [
      {
        "id": "__SU001",
        "name": "admin",
        "loginno": "admin",
        "email": "admin@example.com",
        "status": 1,
        "type": 1,
        "superAdmin": true,
        "domainAdmin": false,
        "developer": false,
        "applications": [],
        "domains": []
      }
    ]
  },
  "errors": null
}
失败示例
{ "errcode": 500, "errmsg": "<异常信息>", "data": null, "errors": null }


2. 保存特权用户信息

按特权用户 id 更新特权用户信息。校验用户名称、登录账号不能含特殊字符;密码占位符 666666qqqq 表示沿用原密码(注意:与 UserAuthtimeController 的占位符 888888qqqq 不同)。开启三员管理时,请求体的 typedepartments 会按当前管理员强制覆盖。

  • 接口类型:REST 资源
  • 请求方式PUT
  • 请求路径/superuser/{id}(完整:{manager-context}/api/authtime/superuser/{id}
  • 鉴权:是
  • Tag:特权用户管理模块

请求参数

参数名 位置 类型 必填 说明
id path string 待更新的特权用户 id
jsonObject body JSON 特权用户字段(见下)

请求体

JSON 对象(application/json),字段:

字段 类型 必填 说明
name string 用户名称(不能含特殊字符)
loginno string 登录账号(不能含特殊字符)
password string 登录密码;值为 666666qqqq 时表示沿用原密码
email string 邮箱
status int 状态
issuperadmin string 是否超级管理员(字符串 true/false
isdeveloper string 是否开发者(字符串 true/false
isdomainadmin string 是否域管理员(字符串 true/false
type string 用户类型(三员管理关闭时使用,开启时由当前管理员的 type 覆盖)
domains string[] 关联企业域 id 列表
applications string[] 关联软件 id 列表
departments string[] 关联部门 id 列表(三员管理开启时写入)

请求示例

PUT /api/authtime/superuser/__SU001 HTTP/1.1
Content-Type: application/json

{
  "name": "admin",
  "loginno": "admin",
  "password": "666666qqqq",
  "email": "admin@example.com",
  "status": 1,
  "issuperadmin": "true",
  "isdeveloper": "false",
  "isdomainadmin": "false",
  "type": "1",
  "domains": ["__P1UD2yVWpnFpUedONr"],
  "applications": [],
  "departments": []
}

响应

结构:统一 Resourcedata:字符串 "保存成功"

条件 errcode errmsg data
用户名称含特殊字符 500 用户名称含有特殊字符 null
登录账号含特殊字符 500 用户账号含有特殊字符 null
业务校验异常 500 <异常信息> null
成功 0 ok 保存成功

成功示例

{ "errcode": 0, "errmsg": "ok", "data": "保存成功", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "用户名称含有特殊字符", "data": null, "errors": null }


3. 新建特权用户信息

新建特权用户。校验用户名称、登录账号不能含特殊字符;开启三员管理时,请求体的 typedepartments 会按当前管理员强制覆盖。

  • 接口类型:REST 资源
  • 请求方式POST
  • 请求路径/superuser(完整:{manager-context}/api/authtime/superuser
  • 鉴权:是
  • Tag:特权用户管理模块

请求参数

参数名 位置 类型 必填 说明
jsonObject body JSON 特权用户字段(见下)

请求体

JSON 对象(application/json),字段同「保存特权用户信息」请求体,但 password 为新密码(无占位符语义)。

字段 类型 必填 说明
name string 用户名称(不能含特殊字符)
loginno string 登录账号(不能含特殊字符)
password string 登录密码
email string 邮箱
status int 状态
issuperadmin string 是否超级管理员(字符串 true/false
isdeveloper string 是否开发者(字符串 true/false
isdomainadmin string 是否域管理员(字符串 true/false
type string 用户类型(三员管理关闭时使用)
domains string[] 关联企业域 id 列表
applications string[] 关联软件 id 列表
departments string[] 关联部门 id 列表(三员管理开启时写入)

请求示例

POST /api/authtime/superuser HTTP/1.1
Content-Type: application/json

{
  "name": "管理员2",
  "loginno": "admin2",
  "password": "encoded-password",
  "email": "admin2@example.com",
  "status": 1,
  "issuperadmin": "false",
  "isdeveloper": "false",
  "isdomainadmin": "true",
  "type": "2",
  "domains": ["__P1UD2yVWpnFpUedONr"],
  "applications": [],
  "departments": []
}

响应

结构:统一 Resourcedata:字符串 "保存成功"

条件 errcode errmsg data
用户名称含特殊字符 500 用户名称含有特殊字符 null
登录账号含特殊字符 500 用户账号含有特殊字符 null
业务校验异常 500 <异常信息> null
成功 0 ok 保存成功

成功示例

{ "errcode": 0, "errmsg": "ok", "data": "保存成功", "errors": null }
失败示例
{ "errcode": 500, "errmsg": "用户名称含有特殊字符", "data": null, "errors": null }


4. 删除特权用户

按特权用户 id 数组批量删除特权用户(物理删除,doRemove)。不允许删除当前登录的管理员自己

  • 接口类型:REST 资源
  • 请求方式DELETE
  • 请求路径/superuser(完整:{manager-context}/api/authtime/superuser
  • 鉴权:是
  • Tag:特权用户管理模块

请求参数

参数名 位置 类型 必填 说明
ids body string[] 待删除的特权用户 id 数组

请求体

application/json,字符串数组:

[ "__SU001", "__SU002" ]

请求示例

DELETE /api/authtime/superuser HTTP/1.1
Content-Type: application/json

[ "__SU002" ]

响应

结构:统一 Resourcedata:字符串 "删除成功"

条件 errcode errmsg data
待删列表包含当前管理员自己 40001 选择用户中包含自己,无法进行删除! null
业务校验异常 500 <异常信息> null
成功 0 ok 删除成功

成功示例

{ "errcode": 0, "errmsg": "ok", "data": "删除成功", "errors": null }
失败示例
{ "errcode": 40001, "errmsg": "选择用户中包含自己,无法进行删除!", "data": null, "errors": null }


5. 通过管理员密钥获取用户 accessToken

通过特权用户的 secret(管理员密钥)换取指定 runtime 用户(按登录账号 + 企业域名匹配)的 accessToken(runtime JWT)。用于管理员侧代登录 / 接口转调场景。

  • 接口类型:REST 资源
  • 请求方式GET
  • 请求路径/getAccessToken(完整:{manager-context}/api/authtime/getAccessToken
  • 鉴权:是(仍需 adminToken;本端点不被鉴权白名单豁免)
  • Tag:特权用户管理模块

请求参数

参数名 位置 类型 必填 说明
secret query string 管理员密钥(特权用户的 secret 字段)
userName query string runtime 用户的登录账号
domainName query string 企业域名称

请求示例

GET /api/authtime/getAccessToken?secret=__SECRET__&userName=zhangsan&domainName=default HTTP/1.1

响应

结构:统一 Resourcedata:字符串——runtime 用户的 accessToken(Security.generateToken(userId) 签发的 JWT)。

条件 errcode errmsg data
secret 未匹配到特权用户 40001 管理员不存在,获取accessToken失败 null
runtime 用户不存在(按 userName + domainName) 500 该用户不存在 null
业务校验异常 500 <异常信息> null
成功 0 ok accessToken 字符串

成功示例

{
  "errcode": 0,
  "errmsg": "ok",
  "data": "<runtime-user-accessToken-jwt>",
  "errors": null
}
失败示例
{ "errcode": 40001, "errmsg": "管理员不存在,获取accessToken失败", "data": null, "errors": null }