refactor: remove document legacy binding reads
This commit is contained in:
@@ -1186,7 +1186,6 @@ class DocumentServiceImpl(IDocumentService):
|
||||
if not current:
|
||||
raise LeauditException(StatusCodeEnum.HTTP_404_NOT_FOUND, "文档类型不存在")
|
||||
await Session.execute(text("UPDATE leaudit_document_types SET deleted_at = NOW() WHERE id = :id"), {"id": Id})
|
||||
await Session.execute(text("UPDATE leaudit_rule_type_bindings SET deleted_at = NOW() WHERE doc_type_id = :id AND deleted_at IS NULL"), {"id": Id})
|
||||
await Session.commit()
|
||||
|
||||
async def ListDocumentTypeRoots(self, EntryModuleId: int | None = None) -> list[DocumentTypeRootItemVO]:
|
||||
@@ -1362,27 +1361,6 @@ class DocumentServiceImpl(IDocumentService):
|
||||
if normalizedRuleSetId not in current:
|
||||
current.append(normalizedRuleSetId)
|
||||
|
||||
# 兼容历史数据:若某些文档类型尚未完成分组绑定迁移,再回退读取旧绑定表。
|
||||
missingDocTypeIds = [docTypeId for docTypeId, ruleSetIds in bindingsMap.items() if len(ruleSetIds) == 0]
|
||||
if missingDocTypeIds:
|
||||
legacyBindingRows = (
|
||||
await Session.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT doc_type_id, rule_set_id
|
||||
FROM leaudit_rule_type_bindings
|
||||
WHERE doc_type_id = ANY(:ids) AND deleted_at IS NULL AND is_active = true
|
||||
ORDER BY priority DESC
|
||||
"""
|
||||
),
|
||||
{"ids": missingDocTypeIds},
|
||||
)
|
||||
).fetchall()
|
||||
for docTypeId, ruleSetId in legacyBindingRows:
|
||||
current = bindingsMap.setdefault(int(docTypeId), [])
|
||||
normalizedRuleSetId = int(ruleSetId)
|
||||
if normalizedRuleSetId not in current:
|
||||
current.append(normalizedRuleSetId)
|
||||
return rows, bindingsMap
|
||||
|
||||
async def _queryDocumentTypeRoots(self, Session, Ids: list[int] | None = None, EntryModuleId: int | None = None):
|
||||
|
||||
Reference in New Issue
Block a user