feat: 1. 完善起草合同页面的逻辑交互,对接minio的接口操作
This commit is contained in:
@@ -158,7 +158,7 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
limit: 1,
|
||||
token: frontendJWT
|
||||
};
|
||||
const contractStructureComparisonResponse = await postgrestGet('contract_structure_comparison', contractStructureComparisonParams);
|
||||
const contractStructureComparisonResponse = await postgrestGet('/api/postgrest/proxy/contract_structure_comparison', contractStructureComparisonParams);
|
||||
// console.log('contract_structure_comparison', contractStructureComparisonResponse)
|
||||
|
||||
if (contractStructureComparisonResponse.error) {
|
||||
@@ -201,7 +201,7 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
},
|
||||
token: frontendJWT
|
||||
};
|
||||
const evaluationResultsResponse = await postgrestGet('evaluation_results', evaluationResultsParams);
|
||||
const evaluationResultsResponse = await postgrestGet('/api/postgrest/proxy/evaluation_results', evaluationResultsParams);
|
||||
|
||||
// console.log('evaluationResultsResponse-------', evaluationResultsResponse,);
|
||||
if (evaluationResultsResponse.error) {
|
||||
@@ -230,7 +230,7 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
},
|
||||
token: frontendJWT
|
||||
};
|
||||
const evaluationPointsResponse = await postgrestGet('evaluation_points', evaluationPointsParams);
|
||||
const evaluationPointsResponse = await postgrestGet('/api/postgrest/proxy/evaluation_points', evaluationPointsParams);
|
||||
|
||||
if (evaluationPointsResponse.error) {
|
||||
return { error: evaluationPointsResponse.error, status: evaluationPointsResponse.status };
|
||||
@@ -257,7 +257,7 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
},
|
||||
token: frontendJWT
|
||||
};
|
||||
const groupsResponse = await postgrestGet('evaluation_point_groups', groupsParams);
|
||||
const groupsResponse = await postgrestGet('/api/postgrest/proxy/evaluation_point_groups', groupsParams);
|
||||
|
||||
if (groupsResponse.error) {
|
||||
return { error: groupsResponse.error, status: groupsResponse.status };
|
||||
@@ -281,7 +281,7 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
},
|
||||
token: frontendJWT
|
||||
};
|
||||
const manualReviewPointsResponse = await postgrestGet('audit_status', manualReviewPointsParams);
|
||||
const manualReviewPointsResponse = await postgrestGet('/api/postgrest/proxy/audit_status', manualReviewPointsParams);
|
||||
if (manualReviewPointsResponse.error) {
|
||||
return { error: manualReviewPointsResponse.error, status: manualReviewPointsResponse.status };
|
||||
}
|
||||
@@ -336,7 +336,7 @@ export async function getReviewPoints(fileId: string, request: Request) {
|
||||
},
|
||||
token: frontendJWT
|
||||
};
|
||||
const scoringProposalsResponse = await postgrestGet('cross_scoring_proposals', scoringProposalsParams);
|
||||
const scoringProposalsResponse = await postgrestGet('/api/postgrest/proxy/cross_scoring_proposals', scoringProposalsParams);
|
||||
|
||||
if (scoringProposalsResponse.error) {
|
||||
return { error: scoringProposalsResponse.error, status: scoringProposalsResponse.status };
|
||||
@@ -776,12 +776,13 @@ export async function updateReviewResult(
|
||||
}
|
||||
|
||||
// 首先获取当前评查结果数据
|
||||
const currentResultResponse = await postgrestGet('evaluation_results', {
|
||||
const currentResultResponse = await postgrestGet('/api/postgrest/proxy/evaluation_results', {
|
||||
select: '*',
|
||||
filter: { id: `eq.${resultId}` },
|
||||
token: frontendJWT
|
||||
});
|
||||
|
||||
console.log('/api/postgrest/proxy/evaluation_results',currentResultResponse.error)
|
||||
if (currentResultResponse.error) {
|
||||
return { error: currentResultResponse.error, status: currentResultResponse.status };
|
||||
}
|
||||
@@ -812,7 +813,7 @@ export async function updateReviewResult(
|
||||
|
||||
// 调用 API 更新评查点结果数据
|
||||
const resultResponse = await postgrestPut<unknown, typeof updatedData>(
|
||||
'evaluation_results',
|
||||
'/api/postgrest/proxy/evaluation_results',
|
||||
updatedData,
|
||||
{ id: resultId },
|
||||
frontendJWT
|
||||
@@ -831,7 +832,7 @@ export async function updateReviewResult(
|
||||
if (editAuditStatusId && editAuditStatusId !== '') {
|
||||
// 更新现有审核状态记录
|
||||
const auditStatusResponse = await postgrestPut(
|
||||
'audit_status',
|
||||
'/api/postgrest/proxy/audit_status',
|
||||
{
|
||||
edit_audit_status: editAuditStatusValue,
|
||||
// 重新审核时不更新message
|
||||
@@ -864,7 +865,7 @@ export async function updateReviewResult(
|
||||
};
|
||||
|
||||
// 使用postgrestPost创建新记录
|
||||
const postResponse = await postgrestPost('audit_status', newAuditStatus, frontendJWT);
|
||||
const postResponse = await postgrestPost('/api/postgrest/proxy/audit_status', newAuditStatus, frontendJWT);
|
||||
|
||||
if (postResponse.error) {
|
||||
return { error: postResponse.error, status: postResponse.status || 500 };
|
||||
@@ -938,7 +939,7 @@ export async function confirmReviewResults(documentId: string, request: Request)
|
||||
|
||||
// 调用API更新文档审核状态
|
||||
const response = await postgrestPut<{ id: string }, typeof updateDocumentParams>(
|
||||
'documents',
|
||||
'/api/postgrest/proxy/documents',
|
||||
updateDocumentParams,
|
||||
{
|
||||
id: documentId,
|
||||
|
||||
@@ -88,122 +88,6 @@ export interface RuleGroupQueryParams {
|
||||
token?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评查点分组列表(支持分页、筛选、排序)
|
||||
* @deprecated 使用 getEvaluationPointGroups 代替(FastAPI v3)
|
||||
* @param params 查询参数
|
||||
* @returns 评查点分组列表和总数
|
||||
*/
|
||||
export async function getRuleGroups_legacy(
|
||||
params?: RuleGroupQueryParams
|
||||
): Promise<{data: RuleGroup[]; totalCount?: number; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
const {
|
||||
page = 1,
|
||||
pageSize = 50,
|
||||
name,
|
||||
code,
|
||||
is_enabled,
|
||||
pid = '0', // 默认获取一级分组
|
||||
orderBy = 'created_at',
|
||||
order = 'desc',
|
||||
token
|
||||
} = params || {};
|
||||
|
||||
// 构建筛选条件
|
||||
const filter: Record<string, string> = {};
|
||||
|
||||
// 父级ID筛选 (pid=null或'0'表示一级分组)
|
||||
if (pid === null || pid === '0') {
|
||||
filter['pid'] = 'eq.0';
|
||||
} else if (pid) {
|
||||
filter['pid'] = `eq.${pid}`;
|
||||
}
|
||||
|
||||
// 名称模糊搜索
|
||||
if (name) {
|
||||
filter['name'] = `ilike.*${name}*`;
|
||||
}
|
||||
|
||||
// 编码模糊搜索
|
||||
if (code) {
|
||||
filter['code'] = `ilike.*${code}*`;
|
||||
}
|
||||
|
||||
// 状态筛选
|
||||
if (is_enabled !== undefined) {
|
||||
filter['is_enabled'] = `eq.${is_enabled}`;
|
||||
}
|
||||
|
||||
const postgrestParams: PostgrestParams = {
|
||||
select: `
|
||||
id,
|
||||
pid,
|
||||
name,
|
||||
code,
|
||||
description,
|
||||
is_enabled,
|
||||
created_at
|
||||
`,
|
||||
filter,
|
||||
order: `${orderBy}.${order}`, // PostgREST order format: field.direction
|
||||
limit: pageSize,
|
||||
offset: (page - 1) * pageSize,
|
||||
token
|
||||
};
|
||||
|
||||
const response = await postgrestGet<{code: number; msg: string; data: Array<{
|
||||
id: number;
|
||||
pid: number;
|
||||
name: string;
|
||||
code?: string;
|
||||
description?: string;
|
||||
is_enabled: boolean;
|
||||
created_at?: string;
|
||||
}>}>('evaluation_point_groups', postgrestParams);
|
||||
|
||||
if (response.error) {
|
||||
return { error: response.error, status: response.status };
|
||||
}
|
||||
|
||||
// 处理响应数据
|
||||
let groups: RuleGroup[] = [];
|
||||
if (response.data && 'code' in response.data && response.data.data) {
|
||||
groups = response.data.data.map(group => ({
|
||||
id: group.id.toString(),
|
||||
pid: group.pid.toString(),
|
||||
name: group.name,
|
||||
code: group.code,
|
||||
description: group.description,
|
||||
is_enabled: group.is_enabled,
|
||||
createdAt: group.created_at ? formatDate(group.created_at) : undefined
|
||||
}));
|
||||
} else if (Array.isArray(response.data)) {
|
||||
groups = response.data.map(group => ({
|
||||
id: group.id.toString(),
|
||||
pid: group.pid.toString(),
|
||||
name: group.name,
|
||||
code: group.code,
|
||||
description: group.description,
|
||||
is_enabled: group.is_enabled,
|
||||
createdAt: group.created_at ? formatDate(group.created_at) : undefined
|
||||
}));
|
||||
}
|
||||
|
||||
// 注意:由于当前 PostgREST 客户端不支持 count 参数,totalCount 返回当前页的记录数
|
||||
// 后续可优化为单独查询获取准确的总数
|
||||
return {
|
||||
data: groups,
|
||||
totalCount: groups.length
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取评查点分组列表失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '获取评查点分组列表失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定分组的子分组(包含评查点数量统计)
|
||||
@@ -241,204 +125,6 @@ export async function getChildGroups(parentId: string, token?: string): Promise<
|
||||
|
||||
|
||||
|
||||
|
||||
// ==================== 批量操作接口 ====================
|
||||
|
||||
/**
|
||||
* 批量更新分组状态(启用/禁用)
|
||||
* @deprecated 使用 batchUpdateEvaluationPointGroupStatus 代替(FastAPI v3)
|
||||
* @param ids 分组ID列表
|
||||
* @param is_enabled 目标状态
|
||||
* @param token JWT token (可选)
|
||||
* @returns 更新结果
|
||||
*/
|
||||
export async function batchUpdateRuleGroupStatus_legacy(
|
||||
ids: string[],
|
||||
is_enabled: boolean,
|
||||
token?: string
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
updated_count: number;
|
||||
failed_ids: string[];
|
||||
errors?: Array<{ id: string; error: string }>;
|
||||
}> {
|
||||
try {
|
||||
// ========== 1. 参数验证 ==========
|
||||
|
||||
if (!Array.isArray(ids) || ids.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
updated_count: 0,
|
||||
failed_ids: [],
|
||||
errors: [{ id: 'validation', error: 'ID列表不能为空' }]
|
||||
};
|
||||
}
|
||||
|
||||
// 验证每个ID的有效性
|
||||
const invalidIds = ids.filter(id => !id || id.trim() === '');
|
||||
if (invalidIds.length > 0) {
|
||||
return {
|
||||
success: false,
|
||||
updated_count: 0,
|
||||
failed_ids: ids,
|
||||
errors: [{ id: 'validation', error: '存在无效的分组ID' }]
|
||||
};
|
||||
}
|
||||
|
||||
// ========== 2. 逐个更新(确保每个分组都能被正确处理) ==========
|
||||
|
||||
const failedIds: string[] = [];
|
||||
const errors: Array<{ id: string; error: string }> = [];
|
||||
let updatedCount = 0;
|
||||
|
||||
for (const id of ids) {
|
||||
try {
|
||||
// 验证分组是否存在
|
||||
const groupResponse = await getRuleGroup(id, token);
|
||||
if (groupResponse.error || !groupResponse.data) {
|
||||
failedIds.push(id);
|
||||
errors.push({ id, error: '分组不存在或无法访问' });
|
||||
continue;
|
||||
}
|
||||
|
||||
// 执行更新
|
||||
const updateResponse = await postgrestPut<ApiResponse<RuleGroup> | RuleGroup, Partial<ApiRuleGroup>>(
|
||||
'evaluation_point_groups',
|
||||
{ is_enabled },
|
||||
{ id },
|
||||
token
|
||||
);
|
||||
|
||||
if (updateResponse.error) {
|
||||
failedIds.push(id);
|
||||
errors.push({ id, error: updateResponse.error });
|
||||
} else {
|
||||
updatedCount++;
|
||||
}
|
||||
} catch (error) {
|
||||
failedIds.push(id);
|
||||
errors.push({
|
||||
id,
|
||||
error: error instanceof Error ? error.message : '更新失败'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 3. 返回结果 ==========
|
||||
|
||||
return {
|
||||
success: failedIds.length === 0,
|
||||
updated_count: updatedCount,
|
||||
failed_ids: failedIds,
|
||||
errors: errors.length > 0 ? errors : undefined
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('批量更新分组状态失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
updated_count: 0,
|
||||
failed_ids: ids,
|
||||
errors: [{
|
||||
id: 'batch',
|
||||
error: error instanceof Error ? error.message : '批量更新失败'
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除分组(安全的阻止删除策略)
|
||||
* @deprecated 使用 batchDeleteEvaluationPointGroups 代替(FastAPI v3)
|
||||
* @param ids 分组ID列表
|
||||
* @param token JWT token (可选)
|
||||
* @returns 删除结果
|
||||
*/
|
||||
export async function batchDeleteRuleGroups_legacy(
|
||||
ids: string[],
|
||||
token?: string
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
deleted_count: number;
|
||||
failed_ids: string[];
|
||||
errors?: Array<{ id: string; error: string; details?: { hasChildren?: boolean; hasPoints?: boolean } }>;
|
||||
}> {
|
||||
try {
|
||||
// ========== 1. 参数验证 ==========
|
||||
|
||||
if (!Array.isArray(ids) || ids.length === 0) {
|
||||
return {
|
||||
success: false,
|
||||
deleted_count: 0,
|
||||
failed_ids: [],
|
||||
errors: [{ id: 'validation', error: 'ID列表不能为空' }]
|
||||
};
|
||||
}
|
||||
|
||||
// 验证每个ID的有效性
|
||||
const invalidIds = ids.filter(id => !id || id.trim() === '');
|
||||
if (invalidIds.length > 0) {
|
||||
return {
|
||||
success: false,
|
||||
deleted_count: 0,
|
||||
failed_ids: ids,
|
||||
errors: [{ id: 'validation', error: '存在无效的分组ID' }]
|
||||
};
|
||||
}
|
||||
|
||||
// ========== 2. 逐个删除(使用安全的阻止删除策略) ==========
|
||||
|
||||
const failedIds: string[] = [];
|
||||
const errors: Array<{ id: string; error: string; details?: { hasChildren?: boolean; hasPoints?: boolean } }> = [];
|
||||
let deletedCount = 0;
|
||||
|
||||
for (const id of ids) {
|
||||
try {
|
||||
const deleteResult = await deleteRuleGroup(id, token);
|
||||
|
||||
if (!deleteResult.success) {
|
||||
failedIds.push(id);
|
||||
errors.push({
|
||||
id,
|
||||
error: deleteResult.error || '删除失败',
|
||||
details: deleteResult.details ? {
|
||||
hasChildren: deleteResult.details.hasChildren,
|
||||
hasPoints: deleteResult.details.hasPoints
|
||||
} : undefined
|
||||
});
|
||||
} else {
|
||||
deletedCount++;
|
||||
}
|
||||
} catch (error) {
|
||||
failedIds.push(id);
|
||||
errors.push({
|
||||
id,
|
||||
error: error instanceof Error ? error.message : '删除失败'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ========== 3. 返回结果 ==========
|
||||
|
||||
return {
|
||||
success: failedIds.length === 0,
|
||||
deleted_count: deletedCount,
|
||||
failed_ids: failedIds,
|
||||
errors: errors.length > 0 ? errors : undefined
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('批量删除分组失败:', error);
|
||||
return {
|
||||
success: false,
|
||||
deleted_count: 0,
|
||||
failed_ids: ids,
|
||||
errors: [{
|
||||
id: 'batch',
|
||||
error: error instanceof Error ? error.message : '批量删除失败'
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================
|
||||
// FastAPI v3 接口函数(新版)
|
||||
// ========================================
|
||||
|
||||
@@ -136,7 +136,7 @@ export async function updateDocumentAuditStatus(id: string, auditStatus: number,
|
||||
});
|
||||
|
||||
const response = await postgrestPut<Document, Partial<Document>>(
|
||||
'documents',
|
||||
'/api/postgrest/proxy/documents',
|
||||
{ audit_status: auditStatus },
|
||||
{
|
||||
id: parseInt(id),
|
||||
|
||||
@@ -364,7 +364,7 @@ export async function getRule(id: string, token?: string): Promise<{data: Rule;
|
||||
};
|
||||
|
||||
// 获取评查点详情 - 使用正确的PostgREST格式
|
||||
const response = await postgrestGet<{code: number; msg: string; data: ApiRule} | ApiRule[]>('evaluation_points', postgrestParams);
|
||||
const response = await postgrestGet<{code: number; msg: string; data: ApiRule} | ApiRule[]>('/api/postgrest/proxy/evaluation_points', postgrestParams);
|
||||
|
||||
// 检查是否有错误响应
|
||||
if (response.error) {
|
||||
@@ -401,7 +401,7 @@ export async function getRule(id: string, token?: string): Promise<{data: Rule;
|
||||
};
|
||||
|
||||
// 查询评查点分组
|
||||
const groupResponse = await postgrestGet<{code: number; msg: string; data: {id: number; name: string}[]}>('evaluation_point_groups', groupParams);
|
||||
const groupResponse = await postgrestGet<{code: number; msg: string; data: {id: number; name: string}[]}>('/api/postgrest/proxy/evaluation_point_groups', groupParams);
|
||||
|
||||
if (groupResponse.data?.data && groupResponse.data.data.length > 0) {
|
||||
// 将分组信息添加到评查点数据中
|
||||
@@ -480,7 +480,7 @@ export async function createRule(ruleData: Omit<Rule, 'id' | 'createdAt' | 'upda
|
||||
}
|
||||
|
||||
// 检查分组是否存在
|
||||
const groupResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; name: string; pid: number}> }>('evaluation_point_groups', {
|
||||
const groupResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; name: string; pid: number}> }>('/api/postgrest/proxy/evaluation_point_groups', {
|
||||
filter: { 'id': `eq.${ruleData.groupId}` },
|
||||
select: 'id,name,pid',
|
||||
token
|
||||
@@ -524,7 +524,7 @@ export async function createRule(ruleData: Omit<Rule, 'id' | 'createdAt' | 'upda
|
||||
};
|
||||
|
||||
// 使用postgrestPost创建评查点
|
||||
const response = await postgrestPost<{code: number; msg: string; data: ApiRule}, typeof apiRuleData>('evaluation_points', apiRuleData, token);
|
||||
const response = await postgrestPost<{code: number; msg: string; data: ApiRule}, typeof apiRuleData>('/api/postgrest/proxy/evaluation_points', apiRuleData, token);
|
||||
|
||||
// 检查是否有错误响应
|
||||
if (response.error) {
|
||||
@@ -599,7 +599,7 @@ export async function updateRule(id: string, ruleData: Partial<Omit<Rule, 'id' |
|
||||
|
||||
// 4. 验证分组ID有效性(如果提供)
|
||||
if (ruleData.groupId !== undefined) {
|
||||
const groupResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; name: string; pid: number}> }>('evaluation_point_groups', {
|
||||
const groupResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; name: string; pid: number}> }>('/api/postgrest/proxy/evaluation_point_groups', {
|
||||
filter: { 'id': `eq.${ruleData.groupId}` },
|
||||
select: 'id,name,pid',
|
||||
token
|
||||
@@ -645,7 +645,7 @@ export async function updateRule(id: string, ruleData: Partial<Omit<Rule, 'id' |
|
||||
}
|
||||
|
||||
// 使用postgrestPut更新评查点 - 使用正确的PostgREST格式
|
||||
const response = await postgrestPut<{code: number; msg: string; data: ApiRule} | ApiRule[], typeof apiRuleData>('evaluation_points', apiRuleData, { id: parseInt(id) }, token);
|
||||
const response = await postgrestPut<{code: number; msg: string; data: ApiRule} | ApiRule[], typeof apiRuleData>('/api/postgrest/proxy/evaluation_points', apiRuleData, { id: parseInt(id) }, token);
|
||||
|
||||
// 检查是否有错误响应
|
||||
if (response.error) {
|
||||
@@ -816,7 +816,7 @@ export async function getRuleTypes(documentTypeIds?: number[], token?: string):
|
||||
name: string;
|
||||
evaluation_point_groups_ids: number[];
|
||||
}>
|
||||
}>('document_types', documentTypesParams);
|
||||
}>('/api/postgrest/proxy/document_types', documentTypesParams);
|
||||
|
||||
if (documentTypesResponse.error) {
|
||||
return { error: documentTypesResponse.error, status: documentTypesResponse.status };
|
||||
@@ -890,7 +890,7 @@ export async function getRuleTypes(documentTypeIds?: number[], token?: string):
|
||||
description: string;
|
||||
is_enabled: boolean;
|
||||
}>
|
||||
}>('evaluation_point_groups', groupsParams);
|
||||
}>('/api/postgrest/proxy/evaluation_point_groups', groupsParams);
|
||||
|
||||
// 检查是否有错误响应
|
||||
if (response.error) {
|
||||
@@ -975,7 +975,7 @@ export async function getRuleGroupsByType(typeId: string, token?: string): Promi
|
||||
description: string;
|
||||
is_enabled: boolean;
|
||||
}>;
|
||||
}>('evaluation_point_groups', postgrestParams);
|
||||
}>('/api/postgrest/proxy/evaluation_point_groups', postgrestParams);
|
||||
|
||||
// 检查是否有错误响应
|
||||
if (response.error) {
|
||||
@@ -1169,7 +1169,7 @@ export async function getFormattedEvaluationPoint(id: number): Promise<{
|
||||
}
|
||||
};
|
||||
|
||||
const response = await postgrestGet<{code: number; msg: string; data: ApiRule[]} | ApiRule[]>('evaluation_points', postgrestParams);
|
||||
const response = await postgrestGet<{code: number; msg: string; data: ApiRule[]} | ApiRule[]>('/api/postgrest/proxy/evaluation_points', postgrestParams);
|
||||
|
||||
if (response.error) {
|
||||
return {
|
||||
@@ -1238,7 +1238,7 @@ export async function getEvaluationPointGroups(): Promise<{
|
||||
updated_at?: string;
|
||||
};
|
||||
|
||||
const response = await postgrestGet<{code: number; msg: string; data: EvaluationPointGroupType[]} | EvaluationPointGroupType[]>('evaluation_point_groups', postgrestParams);
|
||||
const response = await postgrestGet<{code: number; msg: string; data: EvaluationPointGroupType[]} | EvaluationPointGroupType[]>('/api/postgrest/proxy/evaluation_point_groups', postgrestParams);
|
||||
|
||||
if (response.error) {
|
||||
return {
|
||||
@@ -1480,14 +1480,14 @@ export async function saveEvaluationPoint(evaluationPoint: EvaluationPointInput,
|
||||
if (isEditMode) {
|
||||
// 更新操作
|
||||
response = await postgrestPut<{code: number; msg: string; data: ApiRule} | ApiRule, typeof cleanedData>(
|
||||
`evaluation_points`,
|
||||
`/api/postgrest/proxy/evaluation_points`,
|
||||
cleanedData,
|
||||
{id: cleanedData.id!}
|
||||
);
|
||||
} else {
|
||||
// 创建操作
|
||||
response = await postgrestPost<{code: number; msg: string; data: ApiRule} | ApiRule, typeof cleanedData>(
|
||||
'evaluation_points',
|
||||
'/api/postgrest/proxy/evaluation_points',
|
||||
cleanedData
|
||||
);
|
||||
}
|
||||
@@ -1566,7 +1566,7 @@ export async function getRuleStatistics(token?: string): Promise<{data: RuleStat
|
||||
is_enabled: boolean;
|
||||
risk: string;
|
||||
evaluation_point_groups_id: number | null;
|
||||
}>}>('evaluation_points', postgrestParams);
|
||||
}>}>('/api/postgrest/proxy/evaluation_points', postgrestParams);
|
||||
|
||||
// 检查是否有错误响应
|
||||
if (response.error) {
|
||||
@@ -1628,7 +1628,7 @@ export async function getRuleStatistics(token?: string): Promise<{data: RuleStat
|
||||
token
|
||||
};
|
||||
|
||||
const groupsResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; name: string}>}>('evaluation_point_groups', groupsParams);
|
||||
const groupsResponse = await postgrestGet<{code: number; msg: string; data: Array<{id: number; name: string}>}>('/api/postgrest/proxy/evaluation_point_groups', groupsParams);
|
||||
|
||||
let groups: Array<{id: number; name: string}> = [];
|
||||
if (groupsResponse.data && 'code' in groupsResponse.data && groupsResponse.data.data) {
|
||||
|
||||
Reference in New Issue
Block a user