{
  "tags": [
    "任务"
  ],
  "description": "分页查询当前登录用户创建的任务申请及其关联执行任务状态，按任务申请 ID 倒序返回。可按任务类型、两个业务索引字段和创建时间筛选，limit=0 时返回全部匹配记录。注意：当 type 精确传 backup 时，服务端使用独立查询条件，不再按当前用户 ID 限制结果；该行为按当前 Python 主控实现保留。",
  "operationId": "user_get_v1_jobs",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果使用 HTTP 200 返回。成功响应包含 code、count、data，不含 msg；分页参数、type 格式不正确或登录失效时返回统一业务错误封装。",
      "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": "当前页任务申请记录，按 job.id 倒序排列。",
                    "items": {
                      "type": "object",
                      "required": [
                        "id",
                        "uid",
                        "type",
                        "data",
                        "create_at",
                        "task_id",
                        "create_at2"
                      ],
                      "properties": {
                        "enable": {
                          "type": "integer",
                          "nullable": true,
                          "description": "关联 task 的启用标记；没有关联执行任务时为 null。"
                        },
                        "id": {
                          "type": "integer",
                          "format": "int64",
                          "description": "任务申请（job）ID。"
                        },
                        "uid": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true,
                          "description": "创建该任务申请的用户 ID。"
                        },
                        "type": {
                          "type": "string",
                          "nullable": true,
                          "description": "任务类型，例如 clean_url、clean_dir、pre_cache_url、cancel_task、unlock_ip、clean_white_ip 或 down_http_access_log。"
                        },
                        "key1": {
                          "type": "string",
                          "nullable": true,
                          "description": "任务业务索引字段 1，具体含义取决于任务类型。"
                        },
                        "key2": {
                          "type": "string",
                          "nullable": true,
                          "description": "任务业务索引字段 2，具体含义取决于任务类型。"
                        },
                        "data": {
                          "type": "string",
                          "nullable": true,
                          "description": "创建任务时保存的 JSON 文本；接口不解析该字段，具体键由任务类型决定。"
                        },
                        "create_at": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "数据库返回的任务申请创建时间。"
                        },
                        "task_id": {
                          "type": "integer",
                          "format": "int64",
                          "nullable": true,
                          "description": "关联 task 的 ID。"
                        },
                        "create_at2": {
                          "type": "string",
                          "nullable": true,
                          "description": "格式化后的任务申请创建时间，格式为 YYYY-MM-DD HH:mm:ss。"
                        },
                        "end_at": {
                          "type": "string",
                          "format": "date-time",
                          "nullable": true,
                          "description": "关联 task 的结束时间；任务未结束或无关联任务时为 null。"
                        },
                        "state": {
                          "type": "string",
                          "nullable": true,
                          "description": "关联 task 的执行状态，例如 pending、running、success 或 failed；无关联任务时为 null。"
                        },
                        "ret": {
                          "type": "string",
                          "nullable": true,
                          "description": "关联 task 的返回内容或错误信息；无返回内容时为 null。"
                        },
                        "progress": {
                          "type": "string",
                          "nullable": true,
                          "description": "关联 task 的进度文本；无进度信息时为 null。"
                        }
                      },
                      "additionalProperties": false,
                      "description": "任务申请及其关联执行任务状态。"
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "job-21",
                      "job-22",
                      "job-41",
                      "login_required"
                    ],
                    "description": "page 或 limit 格式错误、type 含非法字符或认证失败的业务错误码。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "具体错误原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "examples": {
            "success": {
              "summary": "查询成功",
              "value": {
                "code": 0,
                "count": 1,
                "data": [
                  {
                    "enable": 1,
                    "id": 1201,
                    "uid": 12,
                    "type": "clean_url",
                    "key1": "www.example.invalid",
                    "key2": "https://www.example.invalid/index.html",
                    "data": "{\"url\": \"https://www.example.invalid/index.html\"}",
                    "create_at": "2026-01-02T08:00:00",
                    "task_id": 9876,
                    "create_at2": "2026-01-02 08:00:00",
                    "end_at": null,
                    "state": "pending",
                    "ret": null,
                    "progress": null
                  }
                ]
              }
            }
          },
          "example": {
            "code": 0,
            "count": 1,
            "data": [
              {
                "enable": 1,
                "id": 1201,
                "uid": 12,
                "type": "clean_url",
                "key1": "www.example.invalid",
                "key2": "https://www.example.invalid/index.html",
                "data": "{\"url\": \"https://www.example.invalid/index.html\"}",
                "create_at": "2026-01-02T08:00:00",
                "task_id": 9876,
                "create_at2": "2026-01-02 08:00:00",
                "end_at": null,
                "state": "pending",
                "ret": null,
                "progress": null
              }
            ]
          }
        }
      }
    }
  },
  "x-python-handler": "system.JobAPI",
  "x-python-route-line": 660,
  "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 时不附加 SQL limit，返回全部匹配记录。",
      "schema": {
        "type": "integer",
        "format": "int32",
        "minimum": 0,
        "default": 10
      }
    },
    {
      "name": "type",
      "in": "query",
      "required": false,
      "description": "任务类型筛选。可用逗号分隔多个仅含字母、数字、下划线或连字符的类型，例如 clean_url,unlock_ip；精确值 backup 使用特殊查询逻辑，不按当前用户 ID 过滤。",
      "schema": {
        "type": "string",
        "example": "clean_url,pre_cache_url"
      }
    },
    {
      "name": "key1",
      "in": "query",
      "required": false,
      "description": "精确筛选任务申请的 key1 字段。该字段由创建任务时的具体业务类型写入，例如缓存任务的域名。",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "key2",
      "in": "query",
      "required": false,
      "description": "精确筛选任务申请的 key2 字段。该字段由创建任务时的具体业务类型写入，例如缓存任务的 URL。",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "start",
      "in": "query",
      "required": false,
      "description": "创建时间下限，筛选 create_at 大于或等于该值。服务端直接将值交给数据库比较，不在接口层校验格式。",
      "schema": {
        "type": "string",
        "example": "2026-01-01 00:00:00"
      }
    },
    {
      "name": "end",
      "in": "query",
      "required": false,
      "description": "创建时间上限（不含），筛选 create_at 小于该值。服务端直接将值交给数据库比较，不在接口层校验格式。",
      "schema": {
        "type": "string",
        "example": "2026-01-02 00:00:00"
      }
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "system.JobAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 660
    },
    {
      "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/jobs",
  "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": "分页查询当前登录用户创建的任务申请及其关联执行任务状态，按任务申请 ID 倒序返回。可按任务类型、两个业务索引字段和创建时间筛选，limit=0 时返回全部匹配记录。注意：当 type 精确传 backup 时，服务端使用独立查询条件，不再按当前用户 ID 限制结果；该行为按当前 Python 主控实现保留。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "jobs"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "页码，默认 1。服务端仅校验为数字，分页偏移为 (page - 1) × limit。",
            "type": "text/plain"
          },
          "key": "page",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "每页记录数，默认 10。传字符串 0 时不附加 SQL limit，返回全部匹配记录。",
            "type": "text/plain"
          },
          "key": "limit",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "任务类型筛选。可用逗号分隔多个仅含字母、数字、下划线或连字符的类型，例如 clean_url,unlock_ip；精确值 backup 使用特殊查询逻辑，不按当前用户 ID 过滤。",
            "type": "text/plain"
          },
          "key": "type",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "精确筛选任务申请的 key1 字段。该字段由创建任务时的具体业务类型写入，例如缓存任务的域名。",
            "type": "text/plain"
          },
          "key": "key1",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "精确筛选任务申请的 key2 字段。该字段由创建任务时的具体业务类型写入，例如缓存任务的 URL。",
            "type": "text/plain"
          },
          "key": "key2",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "创建时间下限，筛选 create_at 大于或等于该值。服务端直接将值交给数据库比较，不在接口层校验格式。",
            "type": "text/plain"
          },
          "key": "start",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "创建时间上限（不含），筛选 create_at 小于该值。服务端直接将值交给数据库比较，不在接口层校验格式。",
            "type": "text/plain"
          },
          "key": "end",
          "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"
        }
      ]
    }
  }
}