140 lines
5.1 KiB
Python
140 lines
5.1 KiB
Python
"""Govdoc 公文模块服务接口。"""
|
|
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any
|
|
|
|
from fastapi import UploadFile
|
|
|
|
|
|
class IGovdocService(ABC):
|
|
"""公文处理与格式审查服务抽象接口。"""
|
|
|
|
# ── 文档 ──────────────────────────────────────────────
|
|
|
|
@abstractmethod
|
|
async def UploadDocument(
|
|
self,
|
|
file: UploadFile,
|
|
typeId: int | None = None,
|
|
region: str | None = None,
|
|
tenantCode: str | None = None,
|
|
autoRun: bool = False,
|
|
speed: str = "normal",
|
|
ruleVersionId: int | None = None,
|
|
createdBy: int | None = None,
|
|
) -> dict[str, Any]:
|
|
"""上传公文文档,创建主档记录,可选自动触发审查。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def ListDocuments(
|
|
self,
|
|
page: int = 1,
|
|
pageSize: int = 20,
|
|
keyword: str | None = None,
|
|
fileExt: str | None = None,
|
|
region: str | None = None,
|
|
tenantCode: str | None = None,
|
|
status: str | None = None,
|
|
resultStatus: str | None = None,
|
|
createdBy: int | None = None,
|
|
dateFrom: str | None = None,
|
|
dateTo: str | None = None,
|
|
userId: int | None = None,
|
|
) -> dict[str, Any]:
|
|
"""获取公文模块文档列表,自动限制 engine_type='govdoc'。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetDocumentDetail(self, documentId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取公文详情:文档基础信息 + 最新 run 摘要 + 报告引用。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def UpdateDocument(self, documentId: int, body: dict[str, Any], userId: int | None = None) -> dict[str, Any]:
|
|
"""修改公文标题、文号、备注等基础信息。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def DeleteDocument(self, documentId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""软删除文档。"""
|
|
...
|
|
|
|
# ── 审查运行 ──────────────────────────────────────────
|
|
|
|
@abstractmethod
|
|
async def CreateRun(
|
|
self,
|
|
documentId: int,
|
|
ruleVersionId: int | None = None,
|
|
speed: str = "normal",
|
|
force: bool = False,
|
|
triggerUserId: int | None = None,
|
|
) -> dict[str, Any]:
|
|
"""对已存在文档发起一次公文审查 run。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRunStatus(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""查询 run 状态、阶段、耗时、错误摘要。"""
|
|
...
|
|
|
|
# ── 结果与报告 ────────────────────────────────────────
|
|
|
|
@abstractmethod
|
|
async def GetRunResult(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取审查结果摘要:summary + checked rules + findings 统计 + entities 摘要。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRunFindings(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取段落级 findings 明细列表。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRunEntities(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取识别出的标题、文号、署名等实体。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRunParagraphs(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取前端文档联动视图所需的段落 HTML。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRunStructure(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取文档结构统计(结构面板数据)。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRunOutline(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取文档大纲树(大纲面板数据)。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetReportHtml(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取 HTML 报告内容或下载地址。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetReportDocx(self, runId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取批注 DOCX 下载地址。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def DownloadOriginal(self, documentId: int, userId: int | None = None) -> dict[str, Any]:
|
|
"""获取原始上传文档下载地址。"""
|
|
...
|
|
|
|
# ── 规则 ──────────────────────────────────────────────
|
|
|
|
@abstractmethod
|
|
async def ListRules(self, rulesPath: str | None = None) -> dict[str, Any]:
|
|
"""获取当前生效规则集摘要。"""
|
|
...
|
|
|
|
@abstractmethod
|
|
async def GetRuleDetail(self, ruleId: str, rulesPath: str | None = None) -> dict[str, Any]:
|
|
"""获取单条规则完整详情(名称、严重度、分类、分组、stages、消息等)。"""
|
|
...
|