feat: update audit platform workspace
This commit is contained in:
@@ -62,6 +62,7 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
Page: int,
|
||||
PageSize: int,
|
||||
CurrentUserId: int,
|
||||
EntryModuleId: int | None = None,
|
||||
) -> EvaluationPointGroupListVO:
|
||||
async with GetAsyncSession() as session:
|
||||
await self._ensure_ready(session)
|
||||
@@ -97,6 +98,10 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
if Pid is not None:
|
||||
filters.append("COALESCE(g.pid, 0) = :pid")
|
||||
params["pid"] = self._normalize_pid(Pid)
|
||||
if EntryModuleId is not None:
|
||||
await self._assert_entry_module_access(session, EntryModuleId, current_user)
|
||||
filters.append("COALESCE(g.entry_module_id, parent.entry_module_id, dt.entry_module_id) = :entry_module_id")
|
||||
params["entry_module_id"] = int(EntryModuleId)
|
||||
|
||||
where_clause = " AND ".join(filters)
|
||||
total = int(
|
||||
@@ -149,7 +154,13 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
page_size=PageSize,
|
||||
)
|
||||
|
||||
async def ListAllGroups(self, IncludeDisabled: bool, WithRuleCount: bool, CurrentUserId: int) -> list[EvaluationPointGroupVO]:
|
||||
async def ListAllGroups(
|
||||
self,
|
||||
IncludeDisabled: bool,
|
||||
WithRuleCount: bool,
|
||||
CurrentUserId: int,
|
||||
EntryModuleId: int | None = None,
|
||||
) -> list[EvaluationPointGroupVO]:
|
||||
async with GetAsyncSession() as session:
|
||||
await self._ensure_ready(session)
|
||||
current_user = await self._get_current_user_context(session, CurrentUserId)
|
||||
@@ -166,6 +177,10 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
)
|
||||
if not IncludeDisabled:
|
||||
filters.append("g.is_enabled = TRUE")
|
||||
if EntryModuleId is not None:
|
||||
await self._assert_entry_module_access(session, EntryModuleId, current_user)
|
||||
filters.append("COALESCE(g.entry_module_id, parent.entry_module_id, dt.entry_module_id) = :entry_module_id")
|
||||
params["entry_module_id"] = int(EntryModuleId)
|
||||
rows = (
|
||||
await session.execute(
|
||||
text(
|
||||
@@ -233,6 +248,7 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
IncludeDisabled=IncludeDisabled,
|
||||
WithRuleCount=WithRuleCount,
|
||||
CurrentUserId=CurrentUserId,
|
||||
EntryModuleId=None,
|
||||
)
|
||||
result: list[EvaluationPointGroupVO] = []
|
||||
for root in roots:
|
||||
@@ -262,6 +278,7 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
Page=Page,
|
||||
PageSize=PageSize,
|
||||
CurrentUserId=CurrentUserId,
|
||||
EntryModuleId=None,
|
||||
)
|
||||
|
||||
async def CreateGroup(self, Body: EvaluationPointGroupCreateDTO, CurrentUserId: int) -> EvaluationPointGroupVO:
|
||||
@@ -760,7 +777,7 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
row = (
|
||||
await session.execute(
|
||||
text(
|
||||
"""
|
||||
f"""
|
||||
SELECT
|
||||
rgb.id,
|
||||
rgb.group_id,
|
||||
@@ -798,30 +815,43 @@ class EvaluationPointGroupServiceImpl(IEvaluationPointGroupService):
|
||||
group_ids = [int(item) for item in group_ids if item]
|
||||
if not group_ids:
|
||||
return {}
|
||||
params: dict[str, Any] = {"group_ids": group_ids}
|
||||
tenant_filter = ""
|
||||
if current_user is not None and not current_user.get("is_global"):
|
||||
visible_tenant_codes = ["PUBLIC", "PROVINCIAL"]
|
||||
tenant_code = normalize_scoped_tenant_code(str(current_user.get("tenant_code") or ""), default="")
|
||||
if tenant_code:
|
||||
visible_tenant_codes.append(tenant_code)
|
||||
tenant_filter = """
|
||||
AND COALESCE(NULLIF(BTRIM(tenant_code), ''), 'PROVINCIAL') IN :visible_tenant_codes
|
||||
"""
|
||||
params["visible_tenant_codes"] = sorted(set(visible_tenant_codes))
|
||||
query = text(
|
||||
f"""
|
||||
SELECT
|
||||
id,
|
||||
group_id,
|
||||
rule_set_id,
|
||||
rule_type_binding_id,
|
||||
COALESCE(NULLIF(BTRIM(tenant_code), ''), 'PROVINCIAL') AS tenant_code,
|
||||
COALESCE(NULLIF(BTRIM(scope_type), ''), 'PROVINCIAL') AS scope_type,
|
||||
tenant_name_snapshot,
|
||||
priority,
|
||||
is_active,
|
||||
note,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM leaudit_rule_group_bindings
|
||||
WHERE group_id IN :group_ids
|
||||
AND deleted_at IS NULL
|
||||
{tenant_filter}
|
||||
ORDER BY priority DESC, id ASC
|
||||
"""
|
||||
).bindparams(bindparam("group_ids", expanding=True))
|
||||
if "visible_tenant_codes" in params:
|
||||
query = query.bindparams(bindparam("visible_tenant_codes", expanding=True))
|
||||
rows = (
|
||||
await session.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT
|
||||
id,
|
||||
group_id,
|
||||
rule_set_id,
|
||||
rule_type_binding_id,
|
||||
COALESCE(NULLIF(BTRIM(tenant_code), ''), 'PROVINCIAL') AS tenant_code,
|
||||
COALESCE(NULLIF(BTRIM(scope_type), ''), 'PROVINCIAL') AS scope_type,
|
||||
tenant_name_snapshot,
|
||||
priority,
|
||||
is_active,
|
||||
note,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM leaudit_rule_group_bindings
|
||||
WHERE group_id IN :group_ids AND deleted_at IS NULL
|
||||
ORDER BY priority DESC, id ASC
|
||||
"""
|
||||
).bindparams(bindparam("group_ids", expanding=True)),
|
||||
{"group_ids": group_ids},
|
||||
)
|
||||
await session.execute(query, params)
|
||||
).mappings().all()
|
||||
result: dict[int, list[RuleGroupBindingVO]] = {}
|
||||
for row in rows:
|
||||
|
||||
Reference in New Issue
Block a user