feat: 审计链路
Some checks failed
构建并部署前端到测试环境 / build-and-deploy (push) Failing after 59s

This commit is contained in:
luo
2026-08-07 18:33:37 +08:00
parent fa3d7088f9
commit b8b2854aa6
54 changed files with 5448 additions and 12 deletions

View File

@@ -0,0 +1,69 @@
import type { AuditSubjectResourceType } from '@/types/api'
import type { AuditFinanceField, AuditInvestigationTarget } from '@/components/business/audit/types'
interface AuditResourceRouteOptions {
userType?: number
resourceType: AuditSubjectResourceType | string
internalId?: string | number | null
businessIdentifier?: string | null
}
/** 根据当前主体选择平台内部 ID 或主体安全业务标识。 */
export function resolveAuditResourceTarget(
options: AuditResourceRouteOptions
): AuditInvestigationTarget | null {
const { userType, resourceType, internalId, businessIdentifier } = options
const normalizedBusinessIdentifier = businessIdentifier?.trim()
if (userType === 3) {
if (
!normalizedBusinessIdentifier ||
![
'iot_card',
'device',
'asset_allocation_record',
'exchange_order',
'shop',
'enterprise'
].includes(resourceType)
)
return null
return {
mode: 'agent',
resourceType: resourceType as AuditSubjectResourceType,
id: normalizedBusinessIdentifier
}
}
if (userType === 4) {
if (!normalizedBusinessIdentifier || !['iot_card', 'device'].includes(resourceType)) return null
return {
mode: 'enterprise',
resourceType: resourceType as AuditSubjectResourceType,
id: normalizedBusinessIdentifier
}
}
if (
internalId === undefined ||
internalId === null ||
internalId === '' ||
(typeof internalId === 'string' && !internalId.trim()) ||
(typeof internalId === 'number' && (!Number.isFinite(internalId) || internalId <= 0))
)
return null
return { mode: 'resource', resourceType, id: String(internalId).trim() }
}
export function resolveFinanceAuditTarget(
field: AuditFinanceField,
value?: string | number | null
): AuditInvestigationTarget | null {
const normalizedValue = typeof value === 'string' ? value.trim() : value
if (
normalizedValue === undefined ||
normalizedValue === null ||
normalizedValue === '' ||
(typeof normalizedValue === 'number' &&
(!Number.isFinite(normalizedValue) || normalizedValue <= 0))
)
return null
return { mode: 'finance', field, value: normalizedValue }
}