Files
leaudit-platform-backend/fastapi_modules/fastapi_leaudit/services/ruleService.py
T

113 lines
3.0 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, CurrentUserId: int | None = None) -> list[RuleSetVO]:
"""列出所有规则集。"""
...
@abstractmethod
async def GetVersions(self, RuleType: str, CurrentUserId: int | None = None) -> list[RuleVersionVO]:
"""获取规则集的所有版本。"""
...
@abstractmethod
async def GetContent(self, VersionId: int, CurrentUserId: int | None = None) -> 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,
CurrentUserId: int | None = None,
) -> RuleVersionVO:
"""创建规则版本。"""
...
@abstractmethod
async def Publish(
self,
RuleType: str,
VersionId: int,
OperatorUserId: int | None = None,
CurrentUserId: int | None = None,
) -> RuleVersionVO:
"""发布指定版本。"""
...
@abstractmethod
async def Rollback(
self,
RuleType: str,
VersionId: int,
OperatorUserId: int | None = None,
CurrentUserId: int | None = None,
) -> RuleVersionVO:
"""回滚到指定历史版本。"""
...
@abstractmethod
async def ListBindings(
self,
RuleType: str | None = None,
Region: str | None = None,
CurrentUserId: int | None = None,
) -> list[RuleBindingVO]:
"""列出规则类型绑定;Region 仅保留兼容入参,不再作为新链路边界。"""
...
@abstractmethod
async def CreateBinding(
self,
DocTypeId: int,
RuleSetId: int,
Region: str = "公共",
BindingMode: str = "explicit",
Priority: int = 0,
DocTypeCode: str | None = None,
Note: str | None = None,
CurrentUserId: int | None = None,
) -> RuleBindingVO:
"""创建规则类型绑定;新链路按二级分组生效,Region 仅兼容保留。"""
...
@abstractmethod
async def UpdateBinding(
self,
BindingId: int,
IsActive: bool | None = None,
Priority: int | None = None,
BindingMode: str | None = None,
Note: str | None = None,
CurrentUserId: int | None = None,
) -> RuleBindingVO:
"""更新规则类型绑定。"""
...
@abstractmethod
async def DeleteBinding(self, BindingId: int, CurrentUserId: int | None = None) -> None:
"""删除规则类型绑定。"""
...