给所有请求都加上jwt,隐藏生成jwt的secret(放到.env中),隐藏app-secret(放在pm2运行配置文件中,后续直接读取环境配置即可)

This commit is contained in:
2025-10-17 15:28:22 +08:00
parent 9ec6d30573
commit 59706b70d0
70 changed files with 2279 additions and 688 deletions
+12 -10
View File
@@ -94,9 +94,11 @@ function buildTypeFilter(reviewType: string | null): string {
/**
* 获取主页数据
* @param reviewType 从客户端传入的 reviewType 值
* @param userId 用户ID
* @param token JWT token
* @returns 主页数据
*/
export async function getHomeData(reviewType?: string | null,userId?: string | number): Promise<HomeStatistics> {
export async function getHomeData(reviewType?: string | null,userId?: string | number, token?: string): Promise<HomeStatistics> {
try {
// 获取当前日期和时间相关值
const startOfToday = dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss');
@@ -170,7 +172,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
}
const todayPendingCount = await handleApiResponse<{ count: number }[]>(
postgrestGet('documents', todayPendingParams),
postgrestGet('documents', { ...todayPendingParams, token }),
'获取今日待审核文件数量失败',
[]
);
@@ -201,7 +203,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
}
const thisMonthReviewedCount = await handleApiResponse<{ count: number }[]>(
postgrestGet('documents', thisMonthReviewedParams),
postgrestGet('documents', { ...thisMonthReviewedParams, token }),
'获取本月已审核文件数量失败',
[]
);
@@ -237,7 +239,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
}
const lastMonthReviewedCount = await handleApiResponse<{ count: number }[]>(
postgrestGet('documents', lastMonthReviewedParams),
postgrestGet('documents', { ...lastMonthReviewedParams, token }),
'获取上月已审核文件数量失败',
[]
);
@@ -283,7 +285,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
}
const thisMonthTotalCount = await handleApiResponse<{ count: number }[]>(
postgrestGet('documents', thisMonthTotalParams),
postgrestGet('documents', { ...thisMonthTotalParams, token }),
'获取本月审核通过数量失败',
[]
);
@@ -323,7 +325,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
}
const lastMonthTotalCount = await handleApiResponse<{ count: number }[]>(
postgrestGet('documents', lastMonthTotalParams),
postgrestGet('documents', { ...lastMonthTotalParams, token }),
'获取上月审核通过数量失败',
[]
);
@@ -373,7 +375,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
end_time: endOfThisMonth,
type_val: typeToQuery,
userid: parseInt(userId as string)
}),
}, token),
'获取合同本月问题数据失败',
[]
);
@@ -388,7 +390,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
end_time: endOfLastMonth,
type_val: typeToQuery,
userid: parseInt(userId as string)
}),
}, token),
'获取上月问题数据失败',
[]
);
@@ -406,7 +408,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
end_time: endOfThisMonth,
type_val: typeToQuery,
userid: parseInt(userId as string)
}),
}, token),
'获取本月许可卷宗类型2问题数据失败',
[]
);
@@ -422,7 +424,7 @@ export async function getHomeData(reviewType?: string | null,userId?: string | n
end_time: endOfLastMonth,
type_val: typeToQuery,
userid: parseInt(userId as string)
}),
}, token),
'获取上月许可卷宗类型2问题数据失败',
[]
);