SuperAPI AI Directory

ziniao-role

General & other

View repository

Updated 10-16 09:45

About this skill

Role Management

CRITICAL — Before starting, you MUST first use the Read tool to read ../ziniao-shared/SKILL.md

Manage roles (permission groups) in Ziniao ERP. Roles determine which features employees can see and which stores they can operate. When creating an employee, you need to pass in --role-id, which can be obtained through role list .

Shortcuts

Command Description
role list Query all roles
role detail --id View role details (including permission list)
role create --name --identity-id --permission-ids Create role
role update --id --name --identity-id --permission-ids Modify role (full submission required; fields not passed may be cleared)
role assign --role-id --staff-id Assign roles to employees (--staff-id supports batch)
role staff-roles --staff-id View the list of roles assigned to an employee
role permissions --identity-id View available permission items for a specified identity

Core Scenarios

View roles and permissions

# 查询所有角色(先获取 role-id)
ziniao-cli role list --format table

# 查看某角色详情
ziniao-cli role detail --id 123

# 查看系统支持的全部权限项(创建角色前先查)
ziniao-cli role permissions --identity-id 2

Create and modify roles

# 创建角色(权限使用权限 ID,多个权限用逗号分隔)
ziniao-cli role create --name "店铺运营" --identity-id 2 --permission-ids "100,101" --desc "负责日常店铺操作"

# 修改角色(需全量提交,建议先 role detail 查看当前值)
ziniao-cli role update --id 123 --name "高级运营" --identity-id 2 --permission-ids "100,101,102"

Assign roles to employees

# 将角色分配给单个员工
ziniao-cli role assign --role-id 123 --staff-id 456

# 批量分配给多人
ziniao-cli role assign --role-id 123 --staff-id "456,789,101"

# 查看某员工已分配的角色
ziniao-cli role staff-roles --staff-id 456 --format table

Typical workflow: create a role and assign it in batch

# 1. 查看系统已有角色,避免重复创建
ziniao-cli role list --format table

# 2. 查看普通成员可用权限项
ziniao-cli role permissions --identity-id 2 --jq '.[] | .id'

# 3. 创建新角色
ziniao-cli role create --name "跨境运营" --identity-id 2 --permission-ids "100,101,102"

# 4. 获取新角色 ID(从上一步输出的 data.id 取)
# 5. 批量分配给员工
ziniao-cli role assign --role-id <new-id> --staff-id "201,202,203"

General API Coverage

ziniao-cli api /superbrowser/rest/v1/erp/per/role/list
ziniao-cli api /superbrowser/rest/v1/erp/per/role/detail --data '{"roleId":"xxx"}'
ziniao-cli api /superbrowser/rest/v1/erp/per/role/add --data '{"roleName":"xxx","identityId":2,"permissionIds":[100,101]}'
ziniao-cli api /superbrowser/rest/v1/erp/per/role/edit --data '{"roleId":"xxx","roleName":"yyy","identityId":2,"permissionIds":[100,101]}'
ziniao-cli api /superbrowser/rest/v1/erp/staff/change/role --data '{"roleId":"xxx","staffIds":["yyy"]}'
ziniao-cli api /superbrowser/rest/v1/erp/staff/role/list --data '{"staffId":"yyy"}'
ziniao-cli api /superbrowser/rest/v1/erp/per/permission/list --data '{"identityId":2}'