Skip to content

Commit c7c76d2

Browse files
committed
fix:增加了敏感列被动扫描功能,并用二级缓存进行短暂存储,避免频繁调用AI
敏感列扫描外观修复,缓存刷新逻辑修复 修复主动扫描的逻辑 修改部分扫描逻辑
1 parent 0018c48 commit c7c76d2

File tree

14 files changed

+1543
-17
lines changed

14 files changed

+1543
-17
lines changed

src/common/network/sensitiveColumn.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,70 @@ export async function startScanning(
4242
return ret?.data?.taskId;
4343
}
4444

45+
// 新增单表扫描API
46+
export async function scanSingleTableAsync(
47+
projectId: number,
48+
params: {
49+
databaseId: number;
50+
tableName: string;
51+
scanningMode?: string;
52+
},
53+
): Promise<string> {
54+
// 导入login store来检查organizationId
55+
const login = require('@/store/login').default;
56+
console.log('发起单表扫描请求:', { projectId, params });
57+
console.log('当前organizationId:', login?.organizationId);
58+
console.log('当前用户信息:', login?.user);
59+
60+
try {
61+
const ret = await request.post(
62+
`/api/v2/collaboration/projects/${projectId}/sensitiveColumns/scanSingleTableAsync`,
63+
{
64+
data: {
65+
...params,
66+
},
67+
params: {
68+
currentOrganizationId: login?.organizationId,
69+
},
70+
},
71+
);
72+
console.log('单表扫描请求响应:', ret);
73+
// 后端直接返回taskId在data字段中,而不是data.taskId
74+
const taskId = ret?.data?.taskId || ret?.data;
75+
if (!taskId) {
76+
console.error('单表扫描请求返回的taskId为空:', ret);
77+
}
78+
return taskId;
79+
} catch (error) {
80+
console.error('单表扫描请求失败:', error);
81+
throw error;
82+
}
83+
}
84+
85+
// 获取单表扫描结果
86+
export async function getSingleTableScanResult(projectId: number, taskId: string): Promise<any> {
87+
// 导入login store来检查organizationId
88+
const login = require('@/store/login').default;
89+
console.log('获取单表扫描结果:', { projectId, taskId });
90+
console.log('当前organizationId:', login?.organizationId);
91+
92+
try {
93+
const ret = await request.get(
94+
`/api/v2/collaboration/projects/${projectId}/sensitiveColumns/singleTableScan/${taskId}/result`,
95+
{
96+
params: {
97+
currentOrganizationId: login?.organizationId,
98+
},
99+
},
100+
);
101+
console.log('单表扫描结果响应:', ret);
102+
return ret?.data;
103+
} catch (error) {
104+
console.error('获取单表扫描结果失败:', error);
105+
throw error;
106+
}
107+
}
108+
45109
export async function setEnabled(
46110
projectId: number,
47111
id: number,
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.indicator {
2+
display: inline-flex;
3+
align-items: center;
4+
cursor: pointer;
5+
padding: 2px 6px;
6+
border-radius: 3px;
7+
transition: all 0.15s ease;
8+
font-size: 12px;
9+
10+
&:hover {
11+
background-color: rgba(0, 0, 0, 0.04);
12+
transform: none;
13+
}
14+
}
15+
16+
.tooltipContent {
17+
max-width: 300px;
18+
background: #fff;
19+
color: #000;
20+
border-radius: 6px;
21+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
22+
border: 1px solid #e8e8e8;
23+
padding: 12px;
24+
25+
.tooltipTitle {
26+
font-weight: 500;
27+
margin-bottom: 8px;
28+
color: #000;
29+
}
30+
31+
.tooltipItem {
32+
margin-bottom: 4px;
33+
color: #333;
34+
35+
&:last-child {
36+
margin-bottom: 0;
37+
}
38+
}
39+
40+
.tooltipDetails {
41+
margin-top: 12px;
42+
padding-top: 8px;
43+
border-top: 1px solid #e8e8e8;
44+
45+
.tooltipSubtitle {
46+
font-weight: 500;
47+
margin-bottom: 6px;
48+
color: #333;
49+
font-size: 12px;
50+
}
51+
52+
.tooltipDetailItem {
53+
margin-bottom: 4px;
54+
font-size: 12px;
55+
color: #666;
56+
57+
&:last-child {
58+
margin-bottom: 0;
59+
}
60+
}
61+
}
62+
}
63+
64+
.summary {
65+
margin-top: 8px;
66+
padding-top: 8px;
67+
border-top: 1px solid #f0f0f0;
68+
font-size: 12px;
69+
color: #666;
70+
text-align: center;
71+
}
72+
73+
.scanInfo {
74+
margin-top: 4px;
75+
font-size: 11px;
76+
color: #999;
77+
font-style: italic;
78+
}
79+
80+
// Tooltip 全局样式覆盖
81+
:global(.ant-tooltip-inner) {
82+
.tooltipContent {
83+
background: #fff !important;
84+
border-radius: 6px !important;
85+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
86+
border: 1px solid #e8e8e8 !important;
87+
padding: 12px !important;
88+
}
89+
}
90+
91+
// 响应式调整
92+
@media (max-width: 768px) {
93+
.tooltipContent {
94+
max-width: 250px;
95+
}
96+
}

0 commit comments

Comments
 (0)