feat: add tenant-scoped rule and permission management

This commit is contained in:
wren
2026-05-21 22:03:08 +08:00
parent a2c2bf1969
commit 1f1bccf3b3
193 changed files with 64463 additions and 1771 deletions
@@ -51,6 +51,13 @@ class ReviewPointAuditDTO(BaseModel):
class DocumentController(BaseController):
"""文档控制器。"""
@staticmethod
def _tenant_context(payload: dict[str, Any]) -> dict[str, str | None]:
return {
"TenantCode": payload.get("tenant_code"),
"TenantName": payload.get("tenant_name"),
}
def __init__(self):
super().__init__(prefix="", tags=["文档"])
self.DocumentService: IDocumentService = DocumentServiceImpl()
@@ -62,7 +69,8 @@ class DocumentController(BaseController):
typeId: int | None = Form(None, description="文档类型ID"),
typeCode: str | None = Form(None, description="文档类型编码"),
groupId: int | None = Form(None, description="二级分组ID"),
region: str = Form("default", description="所属地区"),
region: str | None = Form(None, description="所属租户/地区"),
tenant_code: str | None = Form(None, description="租户编码"),
fileRole: str = Form("primary", description="文件角色"),
createdBy: int | None = Form(None, description="上传用户ID"),
autoRun: bool = Form(False, description="是否上传后自动触发评查"),
@@ -81,6 +89,7 @@ class DocumentController(BaseController):
attachment.content_type,
)
)
tenant_context = self._tenant_context(payload)
Data = await self.DocumentService.Upload(
FileName=file.filename or "upload.bin",
FileContent=Content,
@@ -91,6 +100,8 @@ class DocumentController(BaseController):
Region=region,
FileRole=fileRole,
CreatedBy=int(payload["user_id"]),
TenantCode=tenant_code or tenant_context.get("TenantCode"),
TenantName=tenant_context.get("TenantName"),
Attachments=attachmentPayloads,
AutoRun=autoRun,
Speed=speed,
@@ -133,7 +144,8 @@ class DocumentController(BaseController):
typeCode: str | None = None,
type_ids: str | None = Query(None, description="逗号分隔的文档类型ID列表"),
entry_module_id: int | None = Query(None, description="按入口模块ID过滤文档"),
region: str | None = None,
region: str | None = Query(None, description="兼容保留字段:租户展示值/旧地区"),
tenant_code: str | None = Query(None, description="租户编码"),
processingStatus: str | None = None,
resultStatus: str | None = None,
auditStatus: int | None = Query(None, description="按人工审核状态过滤"),
@@ -156,6 +168,7 @@ class DocumentController(BaseController):
TypeIds=typeIdList,
EntryModuleId=entry_module_id,
Region=region,
TenantCode=tenant_code,
ProcessingStatus=processingStatus,
ResultStatus=resultStatus,
AuditStatus=auditStatus,