feat: 全局客户名称脱敏(首尾保留+中间三个*)
ci/woodpecker/push/woodpecker Pipeline was successful

- 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:
kkfluous
2026-04-02 20:23:24 +08:00
co-authored by Claude Opus 4.6
parent e7efe179b7
commit 9c9d7a3805
4 changed files with 30 additions and 11 deletions
+21
View File
@@ -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;
});
}
/**
* 通用权限过滤函数
* 适配 CachedVehicledepartment, manager, managerId)和 VehicledepartmentName, customerManager, managerId