{
  "module": {
    "module": "OpenAPI 接口",
    "moduleKey": "openapi"
  },
  "api": {
    "title": "账户权限校验",
    "method": "POST",
    "path": "/openapi/permissions/check",
    "description": "根据访问令牌校验账户在指定系统下拥有的资源与权限。资源列表以树状结构返回，方便前端渲染菜单等场景。支持通过 X-Site header 切换站点。",
    "requestParams": {
      "headers": [
        {
          "name": "Authorization",
          "type": "string",
          "required": true,
          "description": "访问令牌，支持系统用户与客户端用户，格式为 Bearer TOKEN"
        },
        {
          "name": "X-Site",
          "type": "string",
          "required": false,
          "description": "站点标识。用于切换站点和对应的数据库上下文。如果用户有多个可用站点，可通过此 header 切换。"
        }
      ],
      "body": {
        "systemCode": "string｜必填，要校验的系统编码"
      }
    },
    "responseExample": {
      "success": {
        "code": "0000",
        "message": "权限校验成功",
        "data": {
          "user": {
            "id": "MNFIOHH6QOA3kg0z",
            "code": "USER000001",
            "username": "企业管理员",
            "type": "user"
          },
          "companyName": "靖苒数字",
          "system": {
            "code": "AUTH",
            "name": "权限管理系统"
          },
          "resources": [
            {
              "id": "RES001",
              "code": "RES001",
              "name": "内容管理",
              "title": "内容管理",
              "type": "page",
              "url": "/content",
              "parentId": null,
              "orderNum": 1,
              "children": [
                {
                  "id": "RES002",
                  "code": "RES002",
                  "name": "文章管理",
                  "title": "文章管理",
                  "type": "page",
                  "url": "/content/articles",
                  "parentId": "RES001",
                  "orderNum": 1,
                  "children": []
                },
                {
                  "id": "RES003",
                  "code": "RES003",
                  "name": "分类管理",
                  "title": "分类管理",
                  "type": "page",
                  "url": "/content/categories",
                  "parentId": "RES001",
                  "orderNum": 2,
                  "children": []
                }
              ]
            }
          ],
          "resourcesByType": {
            "page": [
              {
                "id": "RES001",
                "code": "RES001",
                "name": "内容管理",
                "title": "内容管理",
                "type": "page",
                "url": "/content",
                "parentId": null,
                "orderNum": 1,
                "children": [
                  {
                    "id": "RES002",
                    "code": "RES002",
                    "name": "文章管理",
                    "title": "文章管理",
                    "type": "page",
                    "url": "/content/articles",
                    "parentId": "RES001",
                    "orderNum": 1,
                    "children": []
                  },
                  {
                    "id": "RES003",
                    "code": "RES003",
                    "name": "分类管理",
                    "title": "分类管理",
                    "type": "page",
                    "url": "/content/categories",
                    "parentId": "RES001",
                    "orderNum": 2,
                    "children": []
                  }
                ]
              }
            ],
            "button": [
              {
                "id": "RES004",
                "code": "RES004",
                "name": "新增按钮",
                "title": "新增按钮",
                "type": "button",
                "url": "/api/content/create",
                "parentId": null,
                "orderNum": 1,
                "children": []
              }
            ]
          },
          "site": {
            "id": "site-id",
            "key": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890-ABCDEF12",
            "name": "个人站点",
            "createTime": "2025-01-21T10:00:00.000Z"
          }
        }
      },
      "failure": {
        "code": "1402",
        "message": "系统未开放或已停用",
        "data": null
      }
    },
    "notes": [
      "企业账号会同时合并个人权限与所属组织权限；散客账号仅返回个人权限。",
      "权限列表来自角色继承链，请根据资源类型及 resourceUrls 进行前端路由控制。",
      "resources 字段返回树状结构，每个资源节点包含 children 数组，用于前端渲染菜单树。树状结构按 orderNum 排序。",
      "resourcesByType 字段按资源类型分组返回，每个类型下的资源也是树状结构，方便前端按类型渲染。",
      "支持通过 X-Site header 切换站点，切换后使用对应站点的数据库进行权限查询，返回该站点下的角色和权限。"
    ]
  }
}