吸收数字员工管理端技能版本权限预览

This commit is contained in:
baiyanyun
2026-06-13 16:28:17 +08:00
parent b9f49d2c0e
commit 4fdc95da75
7 changed files with 111 additions and 3 deletions

View File

@@ -102,6 +102,16 @@ public class DigitalEmployeeAdminWorkbenchRowDto {
private String memoryKey;
@JsonProperty("skill_id")
private String skillId;
@JsonProperty("skill_version")
private String skillVersion;
@JsonProperty("install_status")
private String installStatus;
@JsonProperty("permission_scope")
private String permissionScope;
@JsonProperty("policy_source")
private String policySource;
@JsonProperty("policy_status")
private String policyStatus;
@JsonProperty("tool_name")
private String toolName;
@JsonProperty("server_id")

View File

@@ -1093,6 +1093,11 @@ public class DigitalEmployeeSyncApplicationServiceImpl implements DigitalEmploye
.memoryId(firstString(businessView.get("memory_id"), businessView.get("memoryId"), payload.get("memory_id"), payload.get("memoryId"), "memory".equals(record.getEntityType()) ? record.getEntityId() : null))
.memoryKey(firstString(businessView.get("memory_key"), businessView.get("memoryKey"), businessView.get("key"), payload.get("memory_key"), payload.get("memoryKey"), payload.get("key")))
.skillId(firstString(businessView.get("skill_id"), businessView.get("skillId"), payload.get("skill_id"), payload.get("skillId")))
.skillVersion(firstString(businessView.get("skill_version"), businessView.get("skillVersion"), businessView.get("version"), payload.get("skill_version"), payload.get("skillVersion"), payload.get("version")))
.installStatus(firstString(businessView.get("install_status"), businessView.get("installStatus"), payload.get("install_status"), payload.get("installStatus")))
.permissionScope(firstString(businessView.get("permission_scope"), businessView.get("permissionScope"), payload.get("permission_scope"), payload.get("permissionScope")))
.policySource(firstString(businessView.get("policy_source"), businessView.get("policySource"), businessView.get("source"), payload.get("policy_source"), payload.get("policySource"), payload.get("source")))
.policyStatus(firstString(businessView.get("policy_status"), businessView.get("policyStatus"), payload.get("policy_status"), payload.get("policyStatus")))
.toolName(firstString(businessView.get("tool_name"), businessView.get("toolName"), payload.get("tool_name"), payload.get("toolName")))
.serverId(firstString(businessView.get("server_id"), businessView.get("serverId"), payload.get("server_id"), payload.get("serverId")))
.policyKind(firstString(businessView.get("policy_kind"), businessView.get("policyKind"), payload.get("policy_kind"), payload.get("policyKind")))
@@ -1236,11 +1241,17 @@ public class DigitalEmployeeSyncApplicationServiceImpl implements DigitalEmploye
String kind = firstString(row.getKind());
return StringUtils.equals(category, "skill")
|| StringUtils.equals(category, "skill_call_audit")
|| StringUtils.equals(category, "skill_catalog")
|| StringUtils.equals(category, "skill_policy")
|| startsWithAny(kind, "skill_call_")
|| startsWithAny(kind, "skill_catalog", "skill_policy")
|| StringUtils.equals(category, "tool_call_audit")
|| StringUtils.equals(category, "sandbox_audit")
|| StringUtils.equals(category, "token_cost")
|| StringUtils.isNotBlank(row.getSkillId())
|| StringUtils.isNotBlank(row.getSkillVersion())
|| StringUtils.isNotBlank(row.getInstallStatus())
|| StringUtils.isNotBlank(row.getPermissionScope())
|| StringUtils.isNotBlank(row.getToolName())
|| StringUtils.isNotBlank(row.getServerId());
}

View File

@@ -461,6 +461,67 @@ class DigitalEmployeeSyncApplicationServiceImplTest {
assertThat(result.getRecords().get(2).getBusinessView()).containsEntry("total_tokens", 180);
}
@Test
void queryAdminWorkbenchSkillAuditsReturnsVersionPermissionAndPolicyRowsOnly() {
when(repository.queryBusinessRecords(eq(101L), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(1L), eq(20L)))
.thenReturn(page(List.of(
record("outbox-skill-catalog", "event", "event-skill-catalog-1", 101L, new Date(10_000),
Map.of(
"entity_type", "event",
"category", "skill_catalog",
"kind", "skill_catalog_snapshot",
"status", "enabled",
"title", "Browser skill installed",
"summary", "浏览器技能已安装",
"skill_id", "skill-web",
"skill_version", "1.2.3",
"install_status", "installed",
"permission_scope", "browser.open,browser.screenshot",
"policy_source", "local"
),
Map.of("id", "event-skill-catalog-1", "kind", "skill_catalog_snapshot")),
record("outbox-skill-policy", "event", "event-skill-policy-1", 101L, new Date(11_000),
Map.of(
"entity_type", "event",
"category", "skill_policy",
"kind", "skill_policy_snapshot",
"status", "remote_disabled",
"title", "Browser skill policy",
"skill_id", "skill-web",
"skill_version", "1.2.3",
"policy_source", "remote",
"policy_status", "disabled",
"permission_scope", "browser.open"
),
Map.of("id", "event-skill-policy-1", "kind", "skill_policy_snapshot")),
record("outbox-notification", "notification", "notification-1", 101L, new Date(12_000),
Map.of("entity_type", "notification", "title", "普通通知", "status", "unread"),
Map.of("id", "notification-1", "status", "unread")),
record("outbox-approval", "approval", "approval-1", 101L, new Date(13_000),
Map.of("entity_type", "approval", "title", "审批", "status", "pending"),
Map.of("id", "approval-1", "status", "pending")),
record("outbox-route", "event", "event-route-1", 101L, new Date(14_000),
Map.of("entity_type", "event", "kind", "route_decision_blocked", "title", "路由阻断", "status", "blocked"),
Map.of("id", "event-route-1", "kind", "route_decision_blocked"))
)));
DigitalEmployeeAdminWorkbenchPageDto result = service.queryAdminWorkbench(
"skill_audits", null, null, null, null, null, null, null, null, null, null, null, 1L, 20L
);
assertThat(result.getTotal()).isEqualTo(2);
assertThat(result.getRecords()).extracting(DigitalEmployeeAdminWorkbenchRowDto::getEntityId)
.containsExactly("event-skill-catalog-1", "event-skill-policy-1");
assertThat(result.getRecords().get(0).getView()).isEqualTo("skill_audits");
assertThat(result.getRecords().get(0).getSkillId()).isEqualTo("skill-web");
assertThat(result.getRecords().get(0).getSkillVersion()).isEqualTo("1.2.3");
assertThat(result.getRecords().get(0).getInstallStatus()).isEqualTo("installed");
assertThat(result.getRecords().get(0).getPermissionScope()).isEqualTo("browser.open,browser.screenshot");
assertThat(result.getRecords().get(0).getPolicySource()).isEqualTo("local");
assertThat(result.getRecords().get(1).getPolicySource()).isEqualTo("remote");
assertThat(result.getRecords().get(1).getPolicyStatus()).isEqualTo("disabled");
}
@Test
void queryAdminWorkbenchPolicyCenterReturnsPolicySnapshotRowsOnly() {
when(repository.queryBusinessRecords(eq(101L), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(null), eq(1L), eq(20L)))