{
  "openapi": "3.0.3",
  "info": {
    "title": "OpenAPI 接口 - 账户权限校验",
    "version": "1.0.0",
    "description": "OpenAPI 接口相关接口文档"
  },
  "paths": {
    "/openapi/permissions/check": {
      "post": {
        "summary": "账户权限校验",
        "description": "根据访问令牌校验账户在指定系统下拥有的资源与权限。资源列表以树状结构返回，方便前端渲染菜单等场景。支持通过 X-Site header 切换站点。",
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "访问令牌，支持系统用户与客户端用户，格式为 Bearer TOKEN",
            "example": "Bearer {token}"
          },
          {
            "name": "X-Site",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "站点标识。用于切换站点和对应的数据库上下文。如果用户有多个可用站点，可通过此 header 切换。"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "systemCode": {
                    "type": "string",
                    "description": "string｜必填，要校验的系统编码"
                  }
                },
                "required": [
                  "systemCode"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功响应",
            "content": {
              "application/json": {
                "example": {
                  "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}