- 2-3字: 首字+*** (徐***) - 4-6字: 首2字+***+末1字 (嘉兴***司) - 7字+: 首4字+***+末2字 (嘉兴市乍***公司) - 覆盖所有接口: monitoring, targets, vehicles, weekly-detail Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e7efe179b7
commit
9c9d7a3805
@@ -1,5 +1,26 @@
|
||||
import type { AuthUser } from './types.js';
|
||||
|
||||
/** 客户名称脱敏 */
|
||||
export function maskCustomerName(name: string | null): string | null {
|
||||
if (!name) return name;
|
||||
const len = name.length;
|
||||
if (len <= 1) return '*';
|
||||
if (len <= 3) return name[0] + '***';
|
||||
if (len <= 6) return name.slice(0, 2) + '***' + name.slice(-1);
|
||||
return name.slice(0, 4) + '***' + name.slice(-2);
|
||||
}
|
||||
|
||||
/** 对数据列表中的客户名称进行脱敏 */
|
||||
export function maskCustomerNames<T>(items: T[]): T[] {
|
||||
return items.map(v => {
|
||||
const obj = v as any;
|
||||
const copy = { ...obj };
|
||||
if ('customer' in copy && copy.customer) copy.customer = maskCustomerName(copy.customer);
|
||||
if ('customerName' in copy && copy.customerName) copy.customerName = maskCustomerName(copy.customerName);
|
||||
return copy as T;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用权限过滤函数
|
||||
* 适配 CachedVehicle(department, manager, managerId)和 Vehicle(departmentName, customerManager, managerId)
|
||||
|
||||
Reference in New Issue
Block a user