权限-角色更新
接口信息
- 接口地址:
{your-site-url}/api/skill/system-user/update-role
- 基础 URL:
{your-site-url} 需替换为你自己的独立站 URL 地址,如 https://your-domain.com/apimanager666
- 请求方式:
POST
- Content-Type:
application/json
- 说明: 此接口用于更新已有角色的名称和权限资源。这是一个全量更新接口,需要传入角色的 ID 以及完整的名称和资源列表
认证
请求头中需要携带 skill-access-token:
| Header |
值 |
skill-access-token |
{your-skill-access-token} (请替换为你自己的 token) |
请求参数 (JSON Body)
| 字段 |
类型 |
必填 |
说明 |
id |
string/int |
✅ 必填 |
角色 ID |
name |
string |
✅ 必填 |
角色名称 |
resources |
Array[string] |
✅ 必填 |
分配给该角色的权限资源标识数组(完整列表,会覆盖原有资源)。资源标识从 权限-资源树信息 返回的资源树中叶子节点的 resource 字段获取 |
请求示例
cURL
curl --location --request POST '{your-site-url}/api/skill/system-user/update-role' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "54",
"name": "test role",
"resources": [
"customer.manage.view",
"customer.manage.edit",
"customer.contacts.view",
"customer.contacts.edit",
"shop.theme.view",
"shop.theme.edit",
"shop.menu.view",
"shop.menu.edit",
"shop.page.view",
"shop.page.edit",
"shop.urlrewrite.view",
"shop.urlrewrite.edit",
"shop.createshop.view",
"shop.createshop.edit"
]
}'
返回结果
code 为 200 表示调用成功;code 不为 200 表示调用失败。
成功响应
{
"code": 200,
"data": {
"id": 54,
"shop_id": 15,
"name": "test role",
"resources": [
"customer.manage.view",
"customer.manage.edit",
"customer.contacts.view",
"customer.contacts.edit",
"shop.theme.view",
"shop.theme.edit",
"shop.menu.view",
"shop.menu.edit",
"shop.page.view",
"shop.page.edit",
"shop.urlrewrite.view",
"shop.urlrewrite.edit",
"shop.createshop.view",
"shop.createshop.edit"
],
"created_at": "2026-05-31 09:44:17",
"updated_at": "2026-05-31 09:44:17"
},
"message": "success"
}
返回字段说明
| 字段 |
类型 |
说明 |
code |
Number |
状态码,200 表示成功 |
message |
String |
执行结果的文字描述 |
data |
Object |
更新后的角色信息 |
data 字段
| 字段 |
类型 |
说明 |
id |
int |
角色 ID |
shop_id |
int |
店铺 ID |
name |
string |
角色名称 |
resources |
Array[string] |
该角色拥有的权限资源标识数组 |
created_at |
string |
创建时间 |
updated_at |
string |
更新时间 |
注意事项
- 所有字段均为必填
- 这是一个全量更新接口,提交的
resources 会完全覆盖原有权限资源,而非追加
resources 的值来源于 权限-资源树信息 返回的资源树中叶子节点的 resource 字段