复制角色
查看文档来源信息
- 来源目录:
addons/sys_base/docs - 来源文件:
接口文档/72-复制角色.md
详细说明
用于在当前模块内创建一个新的正式角色副本,并按最终态规则复制源角色的应用绑定、可管理角色范围、正式页面/动作授权与默认页。
接口信息
| 项目 | 内容 |
|---|---|
| 请求方式 | POST |
| 请求路径 | /sys_base/platform/authority/copyAuthority |
| 来源文件 | 接口文档/72-复制角色.md |
请求头
| 请求头 | 示例值 | 说明 |
|---|---|---|
Content-Type | application/json | 请求体格式。 |
x-token | <登录令牌> | 登录令牌。 |
app-id | mid-admin | 当前应用 ID。 |
addons-type | sys_base | 当前模块标识。 |
入参
| 参数名 | 类型 | 是否必填 | 示例值 | 参数说明 |
|---|---|---|---|---|
sourceAuthorityId | number | 是 | 12 | 源角色 ID |
targetAuthorityId | number | 是 | 112 | 新角色 ID |
targetAuthorityName | string | 是 | 运营经理-副本 | 新角色名称 |
targetAuthorityFlag | string | 是 | ops_manager_copy | 新角色业务标识 |
copyAppBindings | boolean | 否 | true | 是否沿用源角色应用绑定 |
copyManageableScope | boolean | 否 | true | 是否沿用源角色可管理角色范围 |
copyGrantedActions | boolean | 否 | true | 是否沿用源角色正式页面/动作授权 |
copyDefaultPage | boolean | 否 | true | 是否沿用源角色默认页;要求 copyGrantedActions=true |
参数说明
sourceAuthorityId:被复制的源角色 ID。targetAuthorityId:新角色 ID,必须是未使用的正式角色 ID。targetAuthorityName:新角色名称。targetAuthorityFlag:新角色业务标识。copyAppBindings:为true时复制sys_authority_app中的正式应用绑定。copyManageableScope:为true时复制源角色可管理角色范围,但仍按当前操作者上下文校验是否允许下发。copyGrantedActions:为true时按正式页面码、动作码复制授权,不复制 partial 状态的历史残留。copyDefaultPage:为true时尝试复制源角色默认页;若默认页不在正式页面授权范围内,则后端会跳过并返回 warning。
请求示例
json
{
"sourceAuthorityId": 12,
"targetAuthorityId": 112,
"targetAuthorityName": "运营经理-副本",
"targetAuthorityFlag": "ops_manager_copy",
"copyAppBindings": true,
"copyManageableScope": true,
"copyGrantedActions": true,
"copyDefaultPage": true
}响应输出
json
{
"code": 1000,
"msg": "复制角色成功",
"data": {
"authority": {
"authorityId": 112,
"authorityName": "运营经理-副本",
"addonsType": "sys_base"
},
"copiedAppCount": 3,
"copiedManageableAuthorityCount": 2,
"copiedPageCount": 6,
"copiedActionCount": 14,
"defaultPageCode": "system.role.manage",
"warnings": []
}
}字段说明
| 字段名 | 类型 | 示例值 | 字段说明 |
|---|---|---|---|
code | number | 1000 | 业务状态码 |
msg | string | 复制角色成功 | 返回消息 |
data.authority | object | {...} | 新创建角色的正式信息 |
data.copiedAppCount | number | 3 | 复制的应用绑定数量 |
data.copiedManageableAuthorityCount | number | 2 | 复制的可管理角色数量 |
data.copiedPageCount | number | 6 | 复制的正式页面数量 |
data.copiedActionCount | number | 14 | 复制的正式动作数量 |
data.defaultPageCode | string | system.role.manage | 实际沿用的默认页页面码 |
data.warnings | array | [] | 复制过程中被跳过或自动调整的提示信息 |
curl 示例
bash
curl --location --request POST 'http://127.0.0.1:8100/sys_base/platform/authority/copyAuthority' \
--header 'Content-Type: application/json' \
--header 'x-token: <登录令牌>' \
--header 'app-id: mid-admin' \
--header 'addons-type: sys_base' \
--data-raw '{
"sourceAuthorityId": 12,
"targetAuthorityId": 112,
"targetAuthorityName": "运营经理-副本",
"targetAuthorityFlag": "ops_manager_copy",
"copyAppBindings": true,
"copyManageableScope": true,
"copyGrantedActions": true,
"copyDefaultPage": true
}'