import { randomUUID } from "node:crypto"; const FIRST_NAMES = ["Alex", "Sam", "Taylor", "Jordan", "Morgan", "Casey", "Riley", "Avery"]; const LAST_NAMES = ["Li", "Wang", "Zhang", "Chen", "Liu", "Yang", "Zhao", "Huang"]; const DISPLAY_NAMES = ["张三", "李四", "王五", "赵六", "孙七", "周八", "吴九", "郑十"]; const ORG_NAMES = [ "上海浦东支行", "北京西城支行", "深圳南山支行", "杭州西湖支行", "广州天河支行", "成都高新支行", "南京鼓楼支行", "武汉光谷支行" ]; export function buildMockUser(): { id: string; name: string; email: string; age: number; createdAt: string } { const firstName = pick(FIRST_NAMES); const lastName = pick(LAST_NAMES); const age = randomInt(18, 60); const createdAt = new Date(Date.now() - randomInt(0, 90) * 24 * 60 * 60 * 1000).toISOString(); const name = `${firstName} ${lastName}`; const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@example.com`; return { id: randomUUID(), name, email, age, createdAt }; } export function buildNameList( count: number, offset = 0 ): Array<{ userNo: string; displayName: string; orgId: number; orgName: string; days: number; isParty: string; userStatus: number }> { const list: Array<{ userNo: string; displayName: string; orgId: number; orgName: string; days: number; isParty: string; userStatus: number }> = []; const base = DISPLAY_NAMES; const baseLen = base.length || 1; const orgBase = ORG_NAMES; const orgLen = orgBase.length || 1; for (let i = 0; i < count; i += 1) { const index = offset + i; const dn = base[index % baseLen]; const userNo = String(index + 1).padStart(6, "0"); const orgId = 500000 + (index % 100000); const orgName = orgBase[index % orgLen]; list.push({ userNo, displayName: `${dn}${index + 1}`, orgId, orgName, days: 1, isParty: String(index % 2), userStatus: 1 }); } return list; } export function buildYearTrend(year: number): Array<{ label: string; value: number | string }> { const result: Array<{ label: string; value: number | string }> = []; let current = new Date(Date.UTC(year, 0, 1)); while (current.getUTCFullYear() === year) { const y = current.getUTCFullYear(); const m = String(current.getUTCMonth() + 1).padStart(2, "0"); const d = String(current.getUTCDate()).padStart(2, "0"); const label = `${y}-${m}-${d}`; const value = Math.random() > 0.9 ? "_" : randomInt(0, 100000000000); result.push({ label, value }); current.setUTCDate(current.getUTCDate() + 1); } return result; } function pick(items: T[]): T { return items[Math.floor(Math.random() * items.length)]; } function randomInt(minInclusive: number, maxInclusive: number): number { const min = Math.ceil(minInclusive); const max = Math.floor(maxInclusive); return Math.floor(Math.random() * (max - min + 1)) + min; }