fix: 1. 接入入口模块的管理接口,优化样式。
2. 将查看文档评查结果详情对接接口,采用接口的方式进行查询。
This commit is contained in:
@@ -2,6 +2,7 @@ import { postgrestGet, type PostgrestParams, postgrestPut, postgrestPost } from
|
||||
import {getDocumentWithNoUserId} from "~/api/files/documents";
|
||||
import dayjs from "dayjs";
|
||||
import { getUserSession } from "~/api/login/auth.server";
|
||||
import { apiRequest } from "../axios-client";
|
||||
// import { formatDate } from "~/utils";
|
||||
|
||||
/**
|
||||
@@ -959,3 +960,97 @@ export async function confirmReviewResults(documentId: string, request: Request)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 🆕 从后端API获取评查点数据(新版本)
|
||||
* @param fileId 评查文件ID
|
||||
* @param request Remix请求对象,用于获取用户会话
|
||||
* @returns 评查点结果列表和统计数据
|
||||
*
|
||||
* 🔥 接口文档: auth_doc/review_points_api_frontend.md
|
||||
* 📍 API地址: GET /api/v3/review-points/{document_id}
|
||||
*
|
||||
* ✅ 优势:
|
||||
* - 单次API调用替代原7次请求
|
||||
* - 后端统一处理权限验证
|
||||
* - 数据格式与原方法完全一致
|
||||
*/
|
||||
export async function getReviewPoints_fromApi(fileId: string, request: Request) {
|
||||
try {
|
||||
// 获取用户会话信息(用于JWT认证)
|
||||
const { userInfo, frontendJWT } = await getUserSession(request);
|
||||
|
||||
// const test_jwt = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo1LCJ1c2VybmFtZSI6ImFkbWluIiwidXNlcl9yb2xlIjoicHJvdmluY2lhbF9hZG1pbiIsImV4cCI6MTc2NDE2NTI2MCwiaWF0IjoxNzY0MTQzNjYwLCJpc3N1ZWRfdGltZSI6IjIwMjUtMTEtMjYgMTU6NTQ6MjAiLCJhdWQiOiJkb2NyZXZpZXctZnJvbnRlbmQiLCJzdWIiOiIwMDAiLCJuaWNrX25hbWUiOiJhZG1pbiIsIm91X2lkIjoiMDAwIiwib3VfbmFtZSI6InRlc3QiLCJpc19sZWFkZXIiOnRydWUsImFyZWEiOiJcdTY4ODVcdTVkZGUifQ.VRuMvMh98CMeoWDhX1gVczg6DzBNbWwFK9g4kkKqPpc'
|
||||
if (!userInfo?.user_id) {
|
||||
console.error("用户身份验证失败");
|
||||
return { error: '用户身份验证失败', status: 401 };
|
||||
}
|
||||
|
||||
// console.log(`📡 [getReviewPoints_fromApi] 调用后端API获取文档 ${fileId} 的评查点数据`);
|
||||
// console.log(`🔑 [getReviewPoints_fromApi] 使用JWT Token (前10位): ${frontendJWT}`);
|
||||
|
||||
// 🔑 调用后端API(服务端环境需要手动传递Authorization header)
|
||||
const response = await apiRequest<{
|
||||
data: ReviewPointResult[];
|
||||
stats: StatsData;
|
||||
reviewInfo: {
|
||||
reviewTime: string;
|
||||
reviewModel: string;
|
||||
ruleGroup: string;
|
||||
result: string;
|
||||
issueCount: number;
|
||||
};
|
||||
document: unknown;
|
||||
comparison_document: unknown;
|
||||
scoring_proposals: ScoringProposal[];
|
||||
}>(
|
||||
`/api/v3/review-points/${fileId}`,
|
||||
{
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${frontendJWT}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// 处理错误响应
|
||||
if (response.error) {
|
||||
console.error('❌ [getReviewPoints_fromApi] API调用失败:', response.error);
|
||||
return { error: response.error, status: response.status || 500 };
|
||||
}
|
||||
|
||||
// 成功响应
|
||||
if (response.data) {
|
||||
// console.log('✅ [getReviewPoints_fromApi] API调用成功,返回数据结构:', JSON.stringify({
|
||||
// // 评查点数量: response.data.data?.length || 0,
|
||||
// // 统计信息: response.data.stats,
|
||||
// // 评查信息: response.data.reviewInfo,
|
||||
// 有文档数据: response.data.document,
|
||||
// // 有比对数据: !!response.data.comparison_document,
|
||||
// // 评分提案数量: response.data.scoring_proposals?.length || 0
|
||||
// }));
|
||||
|
||||
// 返回数据格式与原方法完全一致
|
||||
return {
|
||||
data: response.data.data,
|
||||
stats: response.data.stats,
|
||||
reviewInfo: response.data.reviewInfo,
|
||||
document: response.data.document,
|
||||
comparison_document: response.data.comparison_document,
|
||||
scoring_proposals: response.data.scoring_proposals
|
||||
};
|
||||
}
|
||||
|
||||
// 数据为空
|
||||
console.error('❌ [getReviewPoints_fromApi] API响应数据为空');
|
||||
return { error: 'API响应数据为空', status: 500 };
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ [getReviewPoints_fromApi] 调用失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '获取评查点数据失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1204,8 +1204,6 @@ export async function getEvaluationPointGroups(
|
||||
...(token ? { headers: { 'Authorization': `Bearer ${token}` } } : {})
|
||||
});
|
||||
|
||||
// 🔍 调试:打印完整响应
|
||||
console.log('📦 getEvaluationPointGroups 完整响应:', JSON.stringify(response, null, 2));
|
||||
|
||||
if (response.error) {
|
||||
console.error('❌ getEvaluationPointGroups 错误:', response.error);
|
||||
@@ -1213,8 +1211,6 @@ export async function getEvaluationPointGroups(
|
||||
}
|
||||
|
||||
if (response.data) {
|
||||
console.log('📊 response.data:', response.data);
|
||||
console.log('📊 response.data.data:', response.data.data);
|
||||
|
||||
if (!response.data.data) {
|
||||
console.error('❌ response.data.data 不存在!完整 response.data:', response.data);
|
||||
@@ -1222,7 +1218,6 @@ export async function getEvaluationPointGroups(
|
||||
}
|
||||
|
||||
const ruleGroups = response.data.data.map(convertApiGroupToRuleGroup);
|
||||
console.log('✅ 转换后的 ruleGroups:', ruleGroups);
|
||||
return {
|
||||
data: ruleGroups,
|
||||
totalCount: response.data.total
|
||||
@@ -1415,7 +1410,6 @@ export async function createEvaluationPointGroup(
|
||||
|
||||
if (response.data) {
|
||||
const ruleGroup = convertApiGroupToRuleGroup(response.data);
|
||||
console.log('✅ createEvaluationPointGroup 成功:', ruleGroup);
|
||||
return { data: ruleGroup };
|
||||
}
|
||||
|
||||
@@ -1477,7 +1471,6 @@ export async function updateEvaluationPointGroup(
|
||||
|
||||
if (response.data) {
|
||||
const ruleGroup = convertApiGroupToRuleGroup(response.data);
|
||||
console.log('✅ updateEvaluationPointGroup 成功:', ruleGroup);
|
||||
return { data: ruleGroup };
|
||||
}
|
||||
|
||||
@@ -1520,7 +1513,6 @@ export async function deleteEvaluationPointGroup(
|
||||
}
|
||||
|
||||
if (response.data) {
|
||||
console.log('✅ deleteEvaluationPointGroup 成功:', response.data);
|
||||
return {
|
||||
success: response.data.success,
|
||||
message: response.data.message,
|
||||
@@ -1579,7 +1571,6 @@ export async function batchUpdateEvaluationPointGroupStatus(
|
||||
}
|
||||
|
||||
if (response.data) {
|
||||
console.log('✅ batchUpdateEvaluationPointGroupStatus 成功:', response.data);
|
||||
return {
|
||||
success: response.data.success,
|
||||
updated_count: response.data.updated_count,
|
||||
@@ -1635,7 +1626,6 @@ export async function batchDeleteEvaluationPointGroups(
|
||||
}
|
||||
|
||||
if (response.data) {
|
||||
console.log('✅ batchDeleteEvaluationPointGroups 成功:', response.data);
|
||||
return {
|
||||
success: response.data.success,
|
||||
deleted_groups: response.data.deleted_groups,
|
||||
|
||||
Reference in New Issue
Block a user