Files
wren c776af598a refactor: region from document, not app config
- Add region column to leaudit_documents + LeauditDocument model
- AuditServiceImpl: read region from document.region, not APP_REGION
- RuleServiceImpl: ListBindings/CreateBinding accept Region parameter
- RuleBindingCreateDTO: add region field
- RuleController: pass region from query param/DTO to service
- APP_REGION removed from binding queries; region flows from document

Region is now per-document: each document carries its region at upload
time, and rules are matched to the document's region at run time.
2026-04-28 14:19:29 +08:00

103 lines
2.5 KiB
Python

"""规则服务接口。"""
from abc import ABC, abstractmethod
from fastapi_modules.fastapi_leaudit.domian.vo.ruleVo import (
RuleBindingVO,
RuleContentVO,
RuleSetVO,
RuleValidationVO,
RuleVersionVO,
)
class IRuleService(ABC):
"""规则服务接口。"""
@abstractmethod
async def ListSets(self) -> list[RuleSetVO]:
"""列出所有规则集。"""
...
@abstractmethod
async def GetVersions(self, RuleType: str) -> list[RuleVersionVO]:
"""获取规则集的所有版本。"""
...
@abstractmethod
async def GetContent(self, VersionId: int) -> RuleContentVO:
"""获取指定版本的规则正文。"""
...
@abstractmethod
async def Validate(self, RuleType: str, YamlText: str) -> RuleValidationVO:
"""校验规则 YAML。"""
...
@abstractmethod
async def CreateVersion(
self,
RuleType: str,
YamlText: str,
ChangeNote: str | None = None,
EditorUserId: int | None = None,
) -> RuleVersionVO:
"""创建规则版本。"""
...
@abstractmethod
async def Publish(
self,
RuleType: str,
VersionId: int,
OperatorUserId: int | None = None,
) -> RuleVersionVO:
"""发布指定版本。"""
...
@abstractmethod
async def Rollback(
self,
RuleType: str,
VersionId: int,
OperatorUserId: int | None = None,
) -> RuleVersionVO:
"""回滚到指定历史版本。"""
...
@abstractmethod
async def ListBindings(self, RuleType: str | None = None, Region: str | None = None) -> list[RuleBindingVO]:
"""列出规则类型绑定。可按规则类型/地区过滤。"""
...
@abstractmethod
async def CreateBinding(
self,
DocTypeId: int,
RuleSetId: int,
Region: str = "default",
BindingMode: str = "explicit",
Priority: int = 0,
DocTypeCode: str | None = None,
Note: str | None = None,
) -> RuleBindingVO:
"""创建规则类型绑定。"""
...
@abstractmethod
async def UpdateBinding(
self,
BindingId: int,
IsActive: bool | None = None,
Priority: int | None = None,
BindingMode: str | None = None,
Note: str | None = None,
) -> RuleBindingVO:
"""更新规则类型绑定。"""
...
@abstractmethod
async def DeleteBinding(self, BindingId: int) -> None:
"""删除规则类型绑定。"""
...