Fecify-角色-详细
接口信息
- 接口地址:
{your-site-url}/api/skill/system-role/info
- 基础 URL:
{your-site-url} 需替换为你自己的独立站 URL 地址,如 https://your-domain.com/admin
- 请求方式:
GET
- Content-Type:
application/json
- 说明: 获取角色的完整权限详情,包括该角色拥有的权限资源列表以及系统全部的权限资源树(服务端后台、B2C 商家端、B2B 商家端)。
认证
请求头中需要携带 skill-access-token:
| Header |
值 |
skill-access-token |
{your-skill-access-token} (请替换为你自己的 token) |
请求参数
请求示例
cURL
curl --location --request GET '{your-site-url}/api/skill/system-role/info?role_id=18' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json'
返回结果
code 为 200 表示成功;code 不为 200 表示失败。
成功响应
{
"code": 200,
"data": {
"all_admin_resources": [
{
"key": "shop",
"sort_order": 20,
"label": "店铺管理",
"child": [
{
"key": "shop",
"label": "店铺列表",
"sort_order": 1,
"child": [
{"key": "view", "label": "查看", "sort_order": 1, "resource": "shop.shop.view"},
{"key": "edit", "label": "管理", "sort_order": 1, "resource": "shop.shop.edit"}
]
}
]
},
{
"key": "system",
"sort_order": 50,
"label": "系统管理",
"child": [
{
"key": "role",
"label": "角色管理",
"sort_order": 1,
"child": [
{"key": "view", "label": "查看", "resource": "system.role.view"},
{"key": "edit", "label": "管理", "resource": "system.role.edit"}
]
}
]
}
],
"all_manager_b2c_resources": [
{
"key": "order",
"sort_order": 1,
"label": {"cn": "订单", "en": "Order"},
"child": [
{
"key": "manage",
"label": {"cn": "待处理订单", "en": "Pending orders"},
"child": [
{"key": "view", "label": {"cn": "查看"}, "resource": "order.manage.view"},
{"key": "edit", "label": {"cn": "管理"}, "resource": "order.manage.edit"}
]
}
]
}
],
"all_manager_b2b_resources": [
{
"key": "customer",
"sort_order": 20,
"label": {"cn": "顾客", "en": "Customer"},
"child": [
{
"key": "b2bcontacts",
"label": {"cn": "顾客询盘"},
"child": [
{"key": "view", "label": {"cn": "查看"}, "resource": "customer.b2bcontacts.view"}
]
}
]
}
],
"current_admin_resources": [
"shop.shop.view", "shop.shop.edit", "system.role.view"
],
"current_manager_b2c_resources": [
"order.manage.view", "order.manage.edit"
],
"current_manager_b2b_resources": [
"customer.b2bcontacts.view"
],
"shop_type": 2,
"current_shop_ids": [347, 346, 345],
"role_id": "18",
"name": "vip"
},
"message": "success"
}
返回字段说明
| 字段 |
类型 |
说明 |
code |
Number |
状态码,200 表示成功 |
message |
String |
执行结果的文字描述 |
data |
Object |
角色完整权限数据 |
data 顶层字段
| 字段 |
类型 |
说明 |
all_admin_resources |
Array |
服务端总后台的全部资源树(权限结构) |
all_manager_b2c_resources |
Array |
B2C 商家端全部资源树 |
all_manager_b2b_resources |
Array |
B2B 商家端全部资源树 |
current_admin_resources |
Array |
当前角色拥有的服务端后台权限(资源标识符列表) |
current_manager_b2c_resources |
Array |
当前角色拥有的 B2C 商家端权限列表 |
current_manager_b2b_resources |
Array |
当前角色拥有的 B2B 商家端权限列表 |
shop_type |
Number |
店铺范围:1 = 所有店铺,2 = 指定店铺 |
current_shop_ids |
Array |
当 shop_type=2 时,指定的店铺 ID 列表 |
role_id |
String |
角色 ID |
name |
String |
角色名称 |
资源树节点结构
每个资源树节点为三层嵌套结构:
| 层级 |
字段 |
说明 |
| 一级 |
key |
模块标识 |
|
sort_order |
排序权重 |
|
label |
模块名称(可能为字符串或多语言对象) |
|
child |
二级菜单列表 |
| 二级 |
key |
菜单标识 |
|
label |
菜单名称 |
|
child |
权限操作列表 |
| 三级 |
key |
操作标识(如 view、edit) |
|
label |
操作名称 |
|
resource |
权限资源标识符,如 shop.shop.view |
权限资源标识符格式
{模块}.{菜单}.{操作},如 order.manage.view、system.role.edit。这些标识符出现在 current_*_resources 数组中,表示该角色拥有此权限。
注意事项
role_id 通过 Fecify-角色-select下拉条 或 Fecify-角色-列表 获取。
all_*_resources 返回的是系统完整的权限树,包含所有可能的权限项。
current_*_resources 是扁平数组,仅包含该角色已授权的资源标识符。
- 编辑角色时,将选中的资源标识符列表提交到 Fecify-角色-更新 或 Fecify-角色-创建。