调整路由以符合 RESTful 规范,新增 API Token 撤销功能

This commit is contained in:
2026-01-14 10:13:57 +08:00
parent 9c10dfd496
commit 5160ae78cc
10 changed files with 658 additions and 536 deletions

View File

@@ -283,7 +283,73 @@ paths:
summary: 删除 API Token
tags:
- Admin
/admin/batch/{batch_id}:
/admin/api-tokens/{id}/revoke:
post:
description: 将 API Token 标记为已撤销,使其失效但保留记录
parameters:
- description: Token ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/model.Response'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/model.Response'
security:
- AdminAuth: []
summary: 撤销 API Token
tags:
- Admin
/admin/batches:
get:
description: 分页查询所有文件批次,支持按状态过滤和取件码模糊搜索
parameters:
- description: 页码 (默认 1)
in: query
name: page
type: integer
- description: 每页数量 (默认 20)
in: query
name: page_size
type: integer
- description: 状态 (active/expired/deleted)
in: query
name: status
type: string
- description: 取件码 (模糊搜索)
in: query
name: pickup_code
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/model.Response'
- properties:
data:
$ref: '#/definitions/admin.ListBatchesResponse'
type: object
"401":
description: Unauthorized
schema:
$ref: '#/definitions/model.Response'
security:
- AdminAuth: []
summary: 获取批次列表
tags:
- Admin
/admin/batches/{batch_id}:
delete:
description: 标记批次为已删除,并物理删除关联的存储文件
parameters:
@@ -374,47 +440,6 @@ paths:
summary: 修改批次信息
tags:
- Admin
/admin/batches:
get:
description: 分页查询所有文件批次,支持按状态过滤和取件码模糊搜索
parameters:
- description: 页码 (默认 1)
in: query
name: page
type: integer
- description: 每页数量 (默认 20)
in: query
name: page_size
type: integer
- description: 状态 (active/expired/deleted)
in: query
name: status
type: string
- description: 取件码 (模糊搜索)
in: query
name: pickup_code
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/model.Response'
- properties:
data:
$ref: '#/definitions/admin.ListBatchesResponse'
type: object
"401":
description: Unauthorized
schema:
$ref: '#/definitions/model.Response'
security:
- AdminAuth: []
summary: 获取批次列表
tags:
- Admin
/admin/login:
post:
consumes:
@@ -446,85 +471,7 @@ paths:
summary: 管理员登录
tags:
- Admin
/api/download/batch/{pickup_code}:
get:
description: 根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载
parameters:
- description: 取件码
in: path
name: pickup_code
required: true
type: string
produces:
- application/zip
responses:
"200":
description: OK
schema:
type: file
"404":
description: Not Found
schema:
$ref: '#/definitions/model.Response'
summary: 批量下载文件
tags:
- Public
/api/download/file/{file_id}:
get:
description: 根据文件 ID 下载单个文件
parameters:
- description: 文件 ID
in: path
name: file_id
required: true
type: integer
produces:
- application/octet-stream
responses:
"200":
description: OK
schema:
type: file
"404":
description: Not Found
schema:
$ref: '#/definitions/model.Response'
"410":
description: Gone
schema:
$ref: '#/definitions/model.Response'
summary: 下载单个文件
tags:
- Public
/api/pickup/{pickup_code}:
get:
description: 根据取件码获取文件批次详详情和文件列表
parameters:
- description: 取件码
in: path
name: pickup_code
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/model.Response'
- properties:
data:
$ref: '#/definitions/public.PickupResponse'
type: object
"404":
description: Not Found
schema:
$ref: '#/definitions/model.Response'
summary: 获取批次信息
tags:
- Public
/api/upload:
/api/batches:
post:
consumes:
- multipart/form-data
@@ -574,7 +521,58 @@ paths:
summary: 上传文件
tags:
- Public
/api/upload/text:
/api/batches/{pickup_code}:
get:
description: 根据取件码获取文件批次详详情和文件列表
parameters:
- description: 取件码
in: path
name: pickup_code
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/model.Response'
- properties:
data:
$ref: '#/definitions/public.PickupResponse'
type: object
"404":
description: Not Found
schema:
$ref: '#/definitions/model.Response'
summary: 获取批次信息
tags:
- Public
/api/batches/{pickup_code}/download:
get:
description: 根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载
parameters:
- description: 取件码
in: path
name: pickup_code
required: true
type: string
produces:
- application/zip
responses:
"200":
description: OK
schema:
type: file
"404":
description: Not Found
schema:
$ref: '#/definitions/model.Response'
summary: 批量下载文件
tags:
- Public
/api/batches/text:
post:
consumes:
- application/json
@@ -609,6 +607,33 @@ paths:
summary: 发送长文本
tags:
- Public
/api/files/{file_id}/download:
get:
description: 根据文件 ID 下载单个文件
parameters:
- description: 文件 ID
in: path
name: file_id
required: true
type: integer
produces:
- application/octet-stream
responses:
"200":
description: OK
schema:
type: file
"404":
description: Not Found
schema:
$ref: '#/definitions/model.Response'
"410":
description: Gone
schema:
$ref: '#/definitions/model.Response'
summary: 下载单个文件
tags:
- Public
securityDefinitions:
AdminAuth:
description: Type "Bearer <your-jwt-token>" to authenticate.