优化打手注册和列表筛选

This commit is contained in:
yml2213
2026-08-20 09:52:51 +08:00
parent f1575aec85
commit 12ca943170
14 changed files with 99 additions and 35 deletions
@@ -284,6 +284,8 @@ export type ListInput = {
/** 后台待办跳转时按工单主键精确定位 */
workOrderId?: number
keyword?: string
/** 打手类型筛选:internal 内部打手 / external 外部打手 */
workerType?: string
workerId?: number
categoryId?: number
workerSharingId?: number
@@ -462,8 +462,9 @@ export async function listWorkerUsers({
pageSize = 20,
status = '',
keyword = '',
workerType = '',
}: ListInput = {}): Promise<{ items: WorkerUserRow[]; total: number }> {
const { whereClause, params } = buildWorkerUserWhere({ status, keyword })
const { whereClause, params } = buildWorkerUserWhere({ status, keyword, workerType })
const totalResult = await query<{ total: number }>(
`SELECT COUNT(*)::int AS total FROM worker_users wu ${whereClause}`,
params,
@@ -1174,7 +1175,8 @@ async function getWorkerFinanceRequestByIdWithClient(
function buildWorkerUserWhere({
status = '',
keyword = '',
}: Pick<ListInput, 'status' | 'keyword'>) {
workerType = '',
}: Pick<ListInput, 'status' | 'keyword' | 'workerType'>) {
const filters: string[] = []
const params: unknown[] = []
if (status) {
@@ -1187,6 +1189,10 @@ function buildWorkerUserWhere({
`(wu.username ILIKE $${params.length} OR wu.display_name ILIKE $${params.length} OR wu.phone ILIKE $${params.length})`,
)
}
if (workerType) {
params.push(workerType)
filters.push(`wu.worker_type = $${params.length}`)
}
return {
whereClause: filters.length > 0 ? `WHERE ${filters.join(' AND ')}` : '',
params,