refactor(services): 重构服务文件结构,将服务按功能分类到不同目录
- 将服务文件按功能分类到core、ai、analytics、security等目录 - 修复logger导入路径问题,统一使用相对路径 - 更新相关文件的导入路径引用 - 添加新的批量操作组件导出文件 - 修复dashboard页面中的类型错误 - 添加dotenv依赖到package.json
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { http } from './http';
|
||||
/**
|
||||
* [MOCK] 黑名单管理数据源
|
||||
* AI注意: 这是Mock实现,不是真实业务逻辑
|
||||
@@ -254,50 +255,38 @@ class ApiBlacklistDataSource implements IBlacklistDataSource {
|
||||
private baseUrl = '/api/blacklist';
|
||||
|
||||
async fetchBlacklist(params?: { type?: string; status?: string; search?: string }): Promise<BlacklistRecord[]> {
|
||||
const response = await fetch(`${this.baseUrl}?${new URLSearchParams(params as any)}`);
|
||||
if (!response.ok) throw new Error('Failed to fetch blacklist');
|
||||
return response.json();
|
||||
const response = await http.post(`${this.baseUrl}?${new URLSearchParams(params as any)}`);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async addBlacklist(data: Partial<BlacklistRecord>): Promise<BlacklistRecord> {
|
||||
const response = await fetch(this.baseUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to add blacklist record');
|
||||
return response.json();
|
||||
const response = await http.post(this.baseUrl, data);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async updateBlacklist(id: string, data: Partial<BlacklistRecord>): Promise<BlacklistRecord> {
|
||||
const response = await fetch(`${this.baseUrl}/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to update blacklist record');
|
||||
return response.json();
|
||||
const response = await http.put(`${this.baseUrl}/${id}`, data);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async removeBlacklist(id: string): Promise<void> {
|
||||
const response = await fetch(`${this.baseUrl}/${id}`, { method: 'DELETE' });
|
||||
if (!response.ok) throw new Error('Failed to remove blacklist record');
|
||||
const response = await http.delete(`${this.baseUrl}/${id}`);
|
||||
|
||||
}
|
||||
|
||||
async fetchRiskAssessments(params?: { status?: string; riskLevel?: string }): Promise<RiskAssessment[]> {
|
||||
const response = await fetch(`${this.baseUrl}/risk-assessments?${new URLSearchParams(params as any)}`);
|
||||
if (!response.ok) throw new Error('Failed to fetch risk assessments');
|
||||
return response.json();
|
||||
const response = await http.get(`${this.baseUrl}/risk-assessments?${new URLSearchParams(params as any)}`);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async reviewRiskAssessment(id: string, action: 'APPROVE' | 'REJECT', reason?: string): Promise<RiskAssessment> {
|
||||
const response = await fetch(`${this.baseUrl}/risk-assessments/${id}/review`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ action, reason }),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to review risk assessment');
|
||||
return response.json();
|
||||
const response = await http.post(`${this.baseUrl}/risk-assessments/${id}/review`, { action, reason });
|
||||
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user