Fecify-角色-创建

接口信息

  • 接口地址: {your-site-url}/api/skill/system-role/create
  • 基础 URL: {your-site-url} 需替换为你自己的独立站 URL 地址,如 https://your-domain.com/admin
  • 请求方式: POST
  • Content-Type: application/json
  • 说明: 创建新角色,指定角色名称和三大权限范围(服务端后台、B2C 商家端、B2B 商家端)的资源标识符列表。

认证

请求头中需要携带 skill-access-token

Header
skill-access-token {your-skill-access-token} (请替换为你自己的 token)

请求参数

字段 类型 必填 说明
name String 角色名称
admin_resources Array 服务端后台权限资源标识符列表,从 Fecify-角色-详细all_admin_resources 中选取
shop_type Number 店铺范围:1 = 所有店铺,2 = 指定店铺
shop_ids Array 店铺 ID 列表,shop_type=2 时必填
manager_b2c_resources Array B2C 商家端权限资源标识符列表,从 Fecify-角色-详细all_manager_b2c_resources 中选取
manager_b2b_resources Array B2B 商家端权限资源标识符列表,从 Fecify-角色-详细all_manager_b2b_resources 中选取

请求示例

cURL

curl --location --request POST '{your-site-url}/api/skill/system-role/create' \
--header 'skill-access-token: {your-skill-access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "vip22",
    "admin_resources": ["shop.shop.view", "system.role.view"],
    "shop_type": 2,
    "shop_ids": [347, 346, 345],
    "manager_b2c_resources": ["order.manage.view"],
    "manager_b2b_resources": ["customer.manage.view"]
}'

返回结果

code200 表示成功;code 不为 200 表示失败。

成功响应

{
    "code": 200,
    "data": {
        "name": "vip22",
        "admin_resources": ["shop.shop.view", "system.role.view"],
        "shop_type": 2,
        "shop_ids": [347, 346, 345],
        "manager_b2c_resources": ["order.manage.view"],
        "manager_b2b_resources": ["customer.manage.view"],
        "created_at": "2026-07-22 11:26:00",
        "updated_at": "2026-07-22 11:26:00",
        "id": 19
    },
    "message": "success"
}

返回字段说明

字段 类型 说明
code Number 状态码,200 表示成功
message String 执行结果的文字描述
data Object 创建后的角色信息,含自动分配的 id

注意事项

  1. 权限资源标识符的合法值来自 Fecify-角色-详细 返回的 all_*_resources 资源树中各节点的 resource 字段。
  2. shop_type=2 时必须传入 shop_ids 指定店铺范围。
  3. 创建后可通过 Fecify-角色-列表 查看,通过 Fecify-角色-更新 修改。

results matching ""

    No results matching ""