添加jwt验证,添加交叉评查首页加载对接接口,评查任务文档列表对接接口,意见列表对接接口
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { postgrestGet, type PostgrestParams, postgrestPut, postgrestPost } from "../postgrest-client";
|
||||
import {getDocument} from "~/api/files/documents";
|
||||
import {getDocumentWithNoUserId} from "~/api/files/documents";
|
||||
import dayjs from "dayjs";
|
||||
import { getUserSession } from "~/api/login/auth.server";
|
||||
// import { formatDate } from "~/utils";
|
||||
|
||||
/**
|
||||
@@ -125,11 +126,22 @@ interface ScoringProposal {
|
||||
/**
|
||||
* 获取当前评查文件的所有评查点结果
|
||||
* @param fileId 评查文件ID
|
||||
* @param request Remix请求对象,用于获取用户会话
|
||||
* @returns 评查点结果列表和统计数据
|
||||
*/
|
||||
export async function getReviewPoints(fileId: string, userId: string) {
|
||||
export async function getReviewPoints(fileId: string, request: Request) {
|
||||
// 获取用户会话信息
|
||||
const { userInfo } = await getUserSession(request);
|
||||
|
||||
if (!userInfo?.user_id) {
|
||||
console.error("用户身份验证失败");
|
||||
return { error: '用户身份验证失败', status: 401 };
|
||||
}
|
||||
|
||||
// const userId = userInfo.user_id.toString();
|
||||
|
||||
// 首先先获取这个文档的数据
|
||||
const documentData = await getDocument(fileId);
|
||||
const documentData = await getDocumentWithNoUserId(fileId);
|
||||
if (documentData.error) {
|
||||
console.error("获取文档数据错误:", documentData.error);
|
||||
return Response.json({ error: documentData.error }, { status: documentData.status || 500 });
|
||||
@@ -722,14 +734,31 @@ export async function getReviewPoints(fileId: string, userId: string) {
|
||||
* @param editAuditStatusId 审核状态ID
|
||||
* @param result 评查结果 (true/false)
|
||||
* @param message 评查意见
|
||||
* @param request Remix请求对象,用于获取用户会话
|
||||
* @returns 更新后的评查结果
|
||||
*/
|
||||
export async function updateReviewResult(resultId: string, editAuditStatusId: string | number, result: string, message: string): Promise<{
|
||||
export async function updateReviewResult(
|
||||
resultId: string,
|
||||
editAuditStatusId: string | number,
|
||||
result: string,
|
||||
message: string,
|
||||
request: Request
|
||||
): Promise<{
|
||||
data?: unknown;
|
||||
error?: string;
|
||||
status?: number;
|
||||
}> {
|
||||
try {
|
||||
// 获取用户会话信息
|
||||
const { userInfo } = await getUserSession(request);
|
||||
|
||||
if (!userInfo?.user_id) {
|
||||
console.error("用户身份验证失败");
|
||||
return { error: '用户身份验证失败', status: 401 };
|
||||
}
|
||||
|
||||
const userId = userInfo.user_id;
|
||||
|
||||
if (!resultId) {
|
||||
return { error: '评查结果ID不能为空', status: 400 };
|
||||
}
|
||||
@@ -794,7 +823,10 @@ export async function updateReviewResult(resultId: string, editAuditStatusId: st
|
||||
// 重新审核时不更新message
|
||||
...(isReview ? {} : { message })
|
||||
},
|
||||
{ id: editAuditStatusId }
|
||||
{
|
||||
id: editAuditStatusId,
|
||||
user_id: userId // 添加用户ID条件,确保只能更新自己的记录
|
||||
}
|
||||
);
|
||||
|
||||
if (auditStatusResponse.error) {
|
||||
@@ -812,7 +844,8 @@ export async function updateReviewResult(resultId: string, editAuditStatusId: st
|
||||
evaluation_point_id: evaluationPointId,
|
||||
evaluation_result_id: resultId,
|
||||
edit_audit_status: editAuditStatusValue,
|
||||
message: isReview ? '' : message
|
||||
message: isReview ? '' : message,
|
||||
user_id: userId // 添加用户ID
|
||||
};
|
||||
|
||||
// 使用postgrestPost创建新记录
|
||||
@@ -842,14 +875,25 @@ export async function updateReviewResult(resultId: string, editAuditStatusId: st
|
||||
/**
|
||||
* 确认评查结果并更新文档审核状态 只更新文档的审核状态为通过
|
||||
* @param documentId 文档ID
|
||||
* @param request Remix请求对象,用于获取用户会话
|
||||
* @returns 更新结果
|
||||
*/
|
||||
export async function confirmReviewResults(documentId: string): Promise<{
|
||||
export async function confirmReviewResults(documentId: string, request: Request): Promise<{
|
||||
data?: { auditStatus: number; };
|
||||
error?: string;
|
||||
status?: number;
|
||||
}> {
|
||||
try {
|
||||
// 获取用户会话信息
|
||||
const { userInfo } = await getUserSession(request);
|
||||
|
||||
if (!userInfo?.user_id) {
|
||||
console.error("用户身份验证失败");
|
||||
return { error: '用户身份验证失败', status: 401 };
|
||||
}
|
||||
|
||||
const userId = userInfo.user_id;
|
||||
|
||||
if (!documentId) {
|
||||
return { error: '文档ID不能为空', status: 400 };
|
||||
}
|
||||
@@ -881,7 +925,10 @@ export async function confirmReviewResults(documentId: string): Promise<{
|
||||
const response = await postgrestPut<{ id: string }, typeof updateDocumentParams>(
|
||||
'documents',
|
||||
updateDocumentParams,
|
||||
{ id: documentId }
|
||||
{
|
||||
id: documentId,
|
||||
user_id: userId // 添加用户ID条件,确保只能更新自己的文档
|
||||
}
|
||||
);
|
||||
|
||||
if (response.error) {
|
||||
|
||||
Reference in New Issue
Block a user