添加jwt验证,添加交叉评查首页加载对接接口,评查任务文档列表对接接口,意见列表对接接口
This commit is contained in:
@@ -396,6 +396,56 @@ export async function getDocument(id: string, userId: string): Promise<{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取单个文档详情
|
||||
* @param id 文档ID
|
||||
* @returns 文档详情
|
||||
*/
|
||||
export async function getDocumentWithNoUserId(id: string): Promise<{
|
||||
data?: DocumentUI;
|
||||
error?: string;
|
||||
status?: number;
|
||||
}> {
|
||||
try {
|
||||
if (!id) {
|
||||
return { error: '文档ID不能为空', status: 400 };
|
||||
}
|
||||
|
||||
const response = await postgrestGet<Document[]>(
|
||||
'documents',
|
||||
{
|
||||
filter: {
|
||||
'id': `eq.${id}`,
|
||||
},
|
||||
limit: 1
|
||||
}
|
||||
);
|
||||
|
||||
if (response.error) {
|
||||
return { error: response.error, status: response.status };
|
||||
}
|
||||
|
||||
const extractedData = extractApiData<Document[]>(response.data);
|
||||
if (!extractedData || extractedData.length === 0) {
|
||||
return { error: '文档不存在', status: 404 };
|
||||
}
|
||||
|
||||
// console.log('extractedData', extractedData);
|
||||
const documentUI = await convertToUIDocument(extractedData[0]);
|
||||
|
||||
return { data: documentUI };
|
||||
} catch (error) {
|
||||
console.error('获取文档详情失败:', error);
|
||||
return {
|
||||
error: error instanceof Error ? error.message : '获取文档详情失败',
|
||||
status: 500
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件下载链接
|
||||
* @param filePath 文件路径
|
||||
|
||||
@@ -133,6 +133,7 @@ export async function uploadFileToBinary(file: File): Promise<ArrayBuffer> {
|
||||
* @param isTestDocument 是否为测试文档
|
||||
* @param documentId 关联的文档ID(用于合同附件上传)
|
||||
* @param isReupload 是否为重新上传
|
||||
* @param jwtToken JWT token
|
||||
* @returns 上传结果
|
||||
*/
|
||||
export async function uploadDocumentToServer(
|
||||
@@ -145,7 +146,8 @@ export async function uploadDocumentToServer(
|
||||
remark?: string | null,
|
||||
isTestDocument: boolean = false,
|
||||
documentId?: number | null,
|
||||
isReupload: boolean = false
|
||||
isReupload: boolean = false,
|
||||
jwtToken?: string
|
||||
): Promise<{data: FileUploadResponse; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
// console.log('【调试】开始上传文档:', { fileName, fileSize: binaryData.byteLength });
|
||||
@@ -185,7 +187,8 @@ export async function uploadDocumentToServer(
|
||||
const response = await fetch(uploadUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-File-Name': encodeURIComponent(fileName)
|
||||
'X-File-Name': encodeURIComponent(fileName),
|
||||
'Authorization': `Bearer ${jwtToken || ''}`
|
||||
},
|
||||
body: formData
|
||||
});
|
||||
@@ -242,11 +245,20 @@ export async function uploadDocumentToServer(
|
||||
|
||||
/**
|
||||
* 获取当天的文档列表
|
||||
* @param userInfo 用户信息(必需)
|
||||
* @param reviewType 审核类型(可选)
|
||||
* @returns 文档列表
|
||||
*/
|
||||
export async function getTodayDocuments(reviewType?: string): Promise<{data: Document[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
export async function getTodayDocuments(userInfo?: { user_id?: number; [key: string]: unknown }, reviewType?: string): Promise<{data: Document[]; error?: never} | {data?: never; error: string; status?: number}> {
|
||||
try {
|
||||
// 检查用户信息是否存在
|
||||
if (!userInfo?.user_id) {
|
||||
return {
|
||||
error: '没有找到用户信息,请刷新重试',
|
||||
status: 401
|
||||
};
|
||||
}
|
||||
|
||||
const today = dayjs().startOf('day').format('YYYY-MM-DD');
|
||||
// console.log('查询当天文档,日期范围:', today);
|
||||
|
||||
@@ -276,10 +288,12 @@ export async function getTodayDocuments(reviewType?: string): Promise<{data: Doc
|
||||
order: 'created_at.desc',
|
||||
filter: {
|
||||
'created_at': `gte.${today}`,
|
||||
'type_id': 'eq.1'
|
||||
'type_id': 'eq.1',
|
||||
'user_id': `eq.${userInfo.user_id}`
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 查询contract_structure_comparison表中的数据
|
||||
// const comparisonParams: PostgrestParams = {
|
||||
// select: `
|
||||
@@ -391,7 +405,8 @@ export async function getTodayDocuments(reviewType?: string): Promise<{data: Doc
|
||||
`,
|
||||
order: 'created_at.desc',
|
||||
filter: {
|
||||
'created_at': `gte.${today}`
|
||||
'created_at': `gte.${today}`,
|
||||
'user_id': `eq.${userInfo.user_id}`
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user