{
  "tags": [
    "消息"
  ],
  "description": "分页查询站内消息摘要和当前查询用户的已读状态，按 sort 降序、消息 ID 降序返回。普通用户只可查询展示中的、按当前服务端 receive 条件归属自己的消息；管理员可查询全部消息，也可用 receive 切换为指定接收用户视角。列表响应不包含消息正文 content，正文需通过 GET /v1/messages/{message_id} 获取。",
  "operationId": "user_get_v1_messages",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果使用 HTTP 200 返回。成功响应包含 code、count、data，不含 msg；页码、每页数量、is_show 格式或 receive 权限错误时返回业务错误封装。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "count",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "成功状态码，固定为 0。"
                  },
                  "count": {
                    "type": "integer",
                    "format": "int64",
                    "minimum": 0,
                    "description": "当前权限和筛选条件下、未应用分页前的消息总数。"
                  },
                  "data": {
                    "type": "array",
                    "description": "当前页消息摘要，按 sort 降序、id 降序排列。",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "type",
                        "title",
                        "is_show",
                        "is_red",
                        "is_bold",
                        "url",
                        "is_external",
                        "is_popup",
                        "sort",
                        "create_at2",
                        "update_at2"
                      ],
                      "properties": {
                        "user_package_id": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true,
                          "description": "关联的用户套餐 ID；未关联时为 null。"
                        },
                        "site_id": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true,
                          "description": "关联的网站 ID；未关联时为 null。"
                        },
                        "receive": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true,
                          "description": "消息指定接收用户 ID；null 表示未指定单个接收者。"
                        },
                        "uid": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true,
                          "description": "当前查询用户在 message_read 中的用户 ID；非 null 表示该用户已读此消息，null 表示未读。"
                        },
                        "id": {
                          "type": "integer",
                          "format": "int64",
                          "description": "消息 ID。"
                        },
                        "type": {
                          "type": "string",
                          "nullable": true,
                          "description": "消息类型。"
                        },
                        "title": {
                          "type": "string",
                          "nullable": true,
                          "description": "消息标题。"
                        },
                        "is_show": {
                          "type": "boolean",
                          "nullable": true,
                          "description": "是否在消息列表中展示。"
                        },
                        "is_red": {
                          "type": "boolean",
                          "nullable": true,
                          "description": "是否使用红色强调样式。"
                        },
                        "is_bold": {
                          "type": "boolean",
                          "nullable": true,
                          "description": "是否使用粗体强调样式。"
                        },
                        "url": {
                          "type": "string",
                          "nullable": true,
                          "description": "外部消息跳转地址；非外部消息通常为空字符串。"
                        },
                        "is_external": {
                          "type": "boolean",
                          "nullable": true,
                          "description": "是否为外部链接消息；为 true 时客户端应使用 url，不使用正文。"
                        },
                        "is_popup": {
                          "type": "boolean",
                          "nullable": true,
                          "description": "是否要求客户端以弹窗方式展示。"
                        },
                        "sort": {
                          "type": "integer",
                          "format": "int32",
                          "nullable": true,
                          "description": "排序值，值越大越靠前。"
                        },
                        "create_at2": {
                          "type": "string",
                          "nullable": true,
                          "description": "格式化后的创建时间，格式为 YYYY-MM-DD HH:mm:ss。"
                        },
                        "update_at2": {
                          "type": "string",
                          "nullable": true,
                          "description": "格式化后的更新时间，格式为 YYYY-MM-DD HH:mm:ss。"
                        }
                      },
                      "additionalProperties": false,
                      "description": "消息列表项（不含 content 正文）。"
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "message-19",
                      "message-20",
                      "message-21",
                      "message-33",
                      "login_required"
                    ],
                    "description": "page、limit、is_show 参数错误，receive 需要管理员权限或认证失败的业务错误码。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "具体错误原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "examples": {
            "success": {
              "summary": "查询成功",
              "value": {
                "code": 0,
                "count": 1,
                "data": [
                  {
                    "user_package_id": null,
                    "site_id": null,
                    "receive": 12,
                    "uid": 12,
                    "id": 101,
                    "type": "announcement",
                    "title": "服务通知",
                    "is_show": true,
                    "is_red": false,
                    "is_bold": false,
                    "url": "",
                    "is_external": false,
                    "is_popup": false,
                    "sort": 100,
                    "create_at2": "2026-01-01 12:00:00",
                    "update_at2": "2026-01-01 12:00:00"
                  }
                ]
              }
            }
          },
          "example": {
            "code": 0,
            "count": 1,
            "data": [
              {
                "user_package_id": null,
                "site_id": null,
                "receive": 12,
                "uid": 12,
                "id": 101,
                "type": "announcement",
                "title": "服务通知",
                "is_show": true,
                "is_red": false,
                "is_bold": false,
                "url": "",
                "is_external": false,
                "is_popup": false,
                "sort": 100,
                "create_at2": "2026-01-01 12:00:00",
                "update_at2": "2026-01-01 12:00:00"
              }
            ]
          }
        }
      }
    }
  },
  "x-python-handler": "system.MessageAPI",
  "x-python-route-line": 1046,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "page",
      "in": "query",
      "required": false,
      "description": "页码，默认 1。服务端仅校验为数字，分页偏移为 (page - 1) × limit。",
      "schema": {
        "type": "integer",
        "format": "int32",
        "minimum": 1,
        "default": 1
      }
    },
    {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "每页记录数，默认 10；传 0 时返回全部匹配记录。",
      "schema": {
        "type": "integer",
        "format": "int32",
        "minimum": 0,
        "default": 10
      }
    },
    {
      "name": "type",
      "in": "query",
      "required": false,
      "description": "精确筛选消息类型。当前消息创建接口只允许 announcement；服务端对非 announcement 类型会在普通用户或指定 receive 时额外按接收用户过滤。",
      "schema": {
        "type": "string",
        "example": "announcement"
      }
    },
    {
      "name": "receive",
      "in": "query",
      "required": false,
      "description": "仅管理员可用。指定消息接收用户 ID，并按该用户视角关联已读状态；普通用户传入会被拒绝。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      }
    },
    {
      "name": "is_show",
      "in": "query",
      "required": false,
      "description": "仅管理员有效：精确筛选展示状态，必须为数字。普通用户始终只查询 is_show=1 的消息。",
      "schema": {
        "type": "integer",
        "enum": [
          0,
          1
        ]
      }
    },
    {
      "name": "user_package_id",
      "in": "query",
      "required": false,
      "description": "精确筛选关联的用户套餐 ID。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      }
    },
    {
      "name": "site_id",
      "in": "query",
      "required": false,
      "description": "精确筛选关联的网站 ID。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      }
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "system.MessageAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 1046
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "get",
  "path": "/v1/messages",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "AccessToken": {
      "type": "apiKey",
      "in": "header",
      "name": "access-token",
      "description": "通过登录接口获得的短期访问令牌。"
    },
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "api-key",
      "description": "API Key；必须和 api-secret 同时发送。"
    },
    "ApiSecret": {
      "type": "apiKey",
      "in": "header",
      "name": "api-secret",
      "description": "API Secret；必须和 api-key 同时发送。"
    }
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "查询消息列表与当前用户阅读状态",
    "description": {
      "content": "分页查询站内消息摘要和当前查询用户的已读状态，按 sort 降序、消息 ID 降序返回。普通用户只可查询展示中的、按当前服务端 receive 条件归属自己的消息；管理员可查询全部消息，也可用 receive 切换为指定接收用户视角。列表响应不包含消息正文 content，正文需通过 GET /v1/messages/{message_id} 获取。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "messages"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "页码，默认 1。服务端仅校验为数字，分页偏移为 (page - 1) × limit。",
            "type": "text/plain"
          },
          "key": "page",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "每页记录数，默认 10；传 0 时返回全部匹配记录。",
            "type": "text/plain"
          },
          "key": "limit",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "精确筛选消息类型。当前消息创建接口只允许 announcement；服务端对非 announcement 类型会在普通用户或指定 receive 时额外按接收用户过滤。",
            "type": "text/plain"
          },
          "key": "type",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "仅管理员可用。指定消息接收用户 ID，并按该用户视角关联已读状态；普通用户传入会被拒绝。",
            "type": "text/plain"
          },
          "key": "receive",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "仅管理员有效：精确筛选展示状态，必须为数字。普通用户始终只查询 is_show=1 的消息。",
            "type": "text/plain"
          },
          "key": "is_show",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "精确筛选关联的用户套餐 ID。",
            "type": "text/plain"
          },
          "key": "user_package_id",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "精确筛选关联的网站 ID。",
            "type": "text/plain"
          },
          "key": "site_id",
          "value": ""
        }
      ],
      "variable": []
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET",
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}