1. 合并 files-page 与 pdf-admin 为统一文件管理页 /api/files-page:
- 新增 GET /api/admin/files/with-pdf 接口,以 uploaded_files 为基础,
用 pdf_jobs.source_file_id / output_file_id 内存匹配,为关联文件标注
转换状态、用户软删标记与角色(源epub/产物PDF)
- PdfJobOut 补 source_file_id / output_file_id 字段
- file_browser 新增 PDF 任务列(状态徽标/软删标记/硬删任务按钮)
- 删除 /api/pdf-admin 路由及 static/pdf_admin.* 三个文件
2. 新增导航页 /api/index,卡片式收集所有页面入口;
各子页(upload/whiteboard/system_status/files-page)脚注加返回导航链接
3. 更新 docs/routes.md、docs/configuration.md 同步说明
测试: pytest tests/test_pdf_service.py 7 passed; 手动校验各页面路由与合并接口响应
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""PDF 转换接口 DTO。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from datetime import datetime
|
||
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
class PdfJobOut(BaseModel):
|
||
"""任务对外视图(用户与管理页共用,user_deleted 仅管理页关注)。"""
|
||
|
||
id: int
|
||
source_file_id: int = Field(..., description="原始 epub 文件的 uploaded_file.id")
|
||
source_filename: str = Field(..., description="原始上传文件名")
|
||
source_size: int = Field(..., description="原始文件字节数")
|
||
output_file_id: int | None = Field(None, description="产物 PDF 的 uploaded_file.id,转换完成前为 null")
|
||
status: str = Field(..., description="pending / converting / done / failed")
|
||
progress: int = Field(0, description="转换进度 0-100")
|
||
error_message: str = Field("", description="失败原因")
|
||
user_deleted: bool = Field(False, description="用户是否已软删(管理页用)")
|
||
deleted_at: datetime | None = Field(None, description="用户软删时间(管理页用)")
|
||
created_at: datetime
|
||
updated_at: datetime
|
||
|
||
model_config = {"from_attributes": True}
|
||
|
||
|
||
class PdfJobListResponse(BaseModel):
|
||
"""任务列表响应。"""
|
||
|
||
total: int
|
||
items: list[PdfJobOut]
|
||
|
||
|
||
class PdfSubmitResponse(BaseModel):
|
||
"""提交转换任务的响应。"""
|
||
|
||
job: PdfJobOut = Field(..., description="新建的任务")
|
||
set_cookie: bool = Field(
|
||
False, description="true=本次请求未带 cookie,响应已下发新 cookie"
|
||
)
|
||
|
||
|
||
class DeleteResult(BaseModel):
|
||
deleted: bool
|