Files
Edu/apps/admin-portal/src/mocks/fixtures.ts
SpecialX 7cf9aec20e feat(admin-portal): 完成参考项目差距闭环 - 4 批次补齐 + Vitest 测试
差距分析闭环(workline §7-§8):
- P0:审计子模块 3 页 + 学校组织 7 页
- P1:系统设置 4 Card + 公告管理 + 邀请码管理
- P2:文件管理 + AI 配置
- P6:5 测试文件 / 69 用例全过

共享基础设施:
- permissions +11 权限点 +14 路由
- view-models +20 接口
- i18n +100 key
- graphql-client +25 operation
- fixtures/handlers +15 mock +20 handler

质量:typecheck + lint 零错误,vitest 69/69 通过,arch.db 已更新
2026-07-13 13:05:29 +08:00

1635 lines
38 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Mock 数据库(开发期 fixtures
*
* 仲裁 ARB-004 §4MSW 拦截所有 GraphQL/HTTP 请求返回 mock 数据
* 所有数据符合 src/types/view-models.ts 类型定义
*/
import type {
UserViewModel,
RoleViewModel,
PermissionViewModel,
ViewportConfigViewModel,
OrganizationNode,
AdminClassViewModel,
AdminTeacherViewModel,
AdminStudentViewModel,
AuditLogViewModel,
AdminDashboardViewModel,
SystemSettingsViewModel,
CurrentUser,
SchoolViewModel,
GradeViewModel,
GradeInsightsViewModel,
DepartmentViewModel,
AcademicYearViewModel,
AuditOverviewStats,
AuditTrendPoint,
DataChangeLogViewModel,
LoginLogViewModel,
AnnouncementViewModel,
InvitationCodeViewModel,
FileViewModel,
FileStats,
AiProviderViewModel,
AiUsageViewModel,
SecurityPolicy,
FileUploadConfig,
NotificationConfig,
BrandConfig,
} from "@/types/view-models";
export const mockCurrentUser: CurrentUser = {
id: "u-admin-001",
email: "admin@edu.test",
name: "系统管理员",
roles: ["system_admin"],
permissions: [
"ADMIN_DASHBOARD_VIEW",
"ADMIN_SYSTEM_MANAGE",
"ADMIN_AUDIT_READ",
"ADMIN_CLASS_READ",
"ADMIN_CLASS_MANAGE",
"ADMIN_TEACHER_READ",
"ADMIN_TEACHER_MANAGE",
"ADMIN_STUDENT_READ",
"ADMIN_STUDENT_MANAGE",
"ADMIN_ORG_MANAGE",
"ADMIN_SCHOOL_READ",
"ADMIN_SCHOOL_MANAGE",
"ADMIN_MONITORING_VIEW",
"IAM_USER_READ",
"IAM_USER_CREATE",
"IAM_USER_UPDATE",
"IAM_USER_DELETE",
"IAM_ROLE_READ",
"IAM_ROLE_CREATE",
"IAM_ROLE_UPDATE",
"IAM_ROLE_DELETE",
"IAM_PERMISSION_READ",
"IAM_VIEWPORT_READ",
"IAM_VIEWPORT_UPDATE",
],
dataScope: "ALL",
schoolId: null,
schoolName: "Edu 实验学校",
};
export const mockPermissions: PermissionViewModel[] = [
{
id: "p-001",
code: "ADMIN_DASHBOARD_VIEW",
name: "仪表盘查看",
description: "查看管理仪表盘",
resource: "admin.dashboard",
action: "view",
isSystem: true,
},
{
id: "p-002",
code: "ADMIN_SYSTEM_MANAGE",
name: "系统设置",
description: "管理系统设置",
resource: "admin.system",
action: "manage",
isSystem: true,
},
{
id: "p-003",
code: "ADMIN_AUDIT_READ",
name: "审计日志查看",
description: "查看审计日志",
resource: "admin.audit",
action: "read",
isSystem: true,
},
{
id: "p-004",
code: "ADMIN_CLASS_MANAGE",
name: "班级管理",
description: "管理班级",
resource: "admin.class",
action: "manage",
isSystem: true,
},
{
id: "p-005",
code: "ADMIN_CLASS_READ",
name: "班级查看",
description: "查看班级",
resource: "admin.class",
action: "read",
isSystem: true,
},
{
id: "p-006",
code: "ADMIN_TEACHER_MANAGE",
name: "教师管理",
description: "管理教师",
resource: "admin.teacher",
action: "manage",
isSystem: true,
},
{
id: "p-007",
code: "ADMIN_TEACHER_READ",
name: "教师查看",
description: "查看教师",
resource: "admin.teacher",
action: "read",
isSystem: true,
},
{
id: "p-008",
code: "ADMIN_STUDENT_MANAGE",
name: "学生管理",
description: "管理学生",
resource: "admin.student",
action: "manage",
isSystem: true,
},
{
id: "p-009",
code: "ADMIN_STUDENT_READ",
name: "学生查看",
description: "查看学生",
resource: "admin.student",
action: "read",
isSystem: true,
},
{
id: "p-010",
code: "ADMIN_ORG_MANAGE",
name: "组织管理",
description: "管理组织架构",
resource: "admin.org",
action: "manage",
isSystem: true,
},
{
id: "p-011",
code: "ADMIN_SCHOOL_MANAGE",
name: "学校管理",
description: "管理学校",
resource: "admin.school",
action: "manage",
isSystem: true,
},
{
id: "p-012",
code: "ADMIN_SCHOOL_READ",
name: "学校查看",
description: "查看学校",
resource: "admin.school",
action: "read",
isSystem: true,
},
{
id: "p-013",
code: "ADMIN_MONITORING_VIEW",
name: "监控查看",
description: "查看系统监控",
resource: "admin.monitoring",
action: "view",
isSystem: true,
},
{
id: "p-101",
code: "IAM_USER_READ",
name: "用户查看",
description: "查看用户",
resource: "iam.user",
action: "read",
isSystem: true,
},
{
id: "p-102",
code: "IAM_USER_CREATE",
name: "用户创建",
description: "创建用户",
resource: "iam.user",
action: "create",
isSystem: true,
},
{
id: "p-103",
code: "IAM_USER_UPDATE",
name: "用户更新",
description: "更新用户",
resource: "iam.user",
action: "update",
isSystem: true,
},
{
id: "p-104",
code: "IAM_USER_DELETE",
name: "用户删除",
description: "删除用户",
resource: "iam.user",
action: "delete",
isSystem: true,
},
{
id: "p-105",
code: "IAM_ROLE_READ",
name: "角色查看",
description: "查看角色",
resource: "iam.role",
action: "read",
isSystem: true,
},
{
id: "p-106",
code: "IAM_ROLE_CREATE",
name: "角色创建",
description: "创建角色",
resource: "iam.role",
action: "create",
isSystem: true,
},
{
id: "p-107",
code: "IAM_ROLE_UPDATE",
name: "角色更新",
description: "更新角色",
resource: "iam.role",
action: "update",
isSystem: true,
},
{
id: "p-108",
code: "IAM_ROLE_DELETE",
name: "角色删除",
description: "删除角色",
resource: "iam.role",
action: "delete",
isSystem: true,
},
{
id: "p-109",
code: "IAM_PERMISSION_READ",
name: "权限查看",
description: "查看权限点",
resource: "iam.permission",
action: "read",
isSystem: true,
},
{
id: "p-110",
code: "IAM_VIEWPORT_READ",
name: "视口查看",
description: "查看视口",
resource: "iam.viewport",
action: "read",
isSystem: true,
},
{
id: "p-111",
code: "IAM_VIEWPORT_UPDATE",
name: "视口更新",
description: "更新视口",
resource: "iam.viewport",
action: "update",
isSystem: true,
},
];
export const mockRoles: RoleViewModel[] = [
{
id: "r-001",
name: "系统管理员",
code: "system_admin",
description: "拥有所有权限",
permissions: mockPermissions,
userCount: 2,
dataScope: "ALL",
isSystem: true,
createdAt: 1704067200000,
updatedAt: 1706745600000,
},
{
id: "r-002",
name: "学校管理员",
code: "school_admin",
description: "管理本校资源",
permissions: mockPermissions.filter((p) =>
[
"ADMIN_DASHBOARD_VIEW",
"ADMIN_CLASS_MANAGE",
"ADMIN_TEACHER_READ",
"ADMIN_STUDENT_READ",
"ADMIN_ORG_MANAGE",
"ADMIN_SCHOOL_READ",
"ADMIN_AUDIT_READ",
].includes(p.code),
),
userCount: 5,
dataScope: "SCHOOL",
isSystem: true,
createdAt: 1704067200000,
updatedAt: 1706745600000,
},
{
id: "r-003",
name: "年级组长",
code: "grade_leader",
description: "管理本年级",
permissions: mockPermissions.filter((p) =>
[
"ADMIN_DASHBOARD_VIEW",
"ADMIN_CLASS_READ",
"ADMIN_TEACHER_READ",
"ADMIN_STUDENT_READ",
].includes(p.code),
),
userCount: 8,
dataScope: "GRADE",
isSystem: false,
createdAt: 1704153600000,
updatedAt: 1706832000000,
},
{
id: "r-004",
name: "班主任",
code: "head_teacher",
description: "管理本班级",
permissions: mockPermissions.filter((p) =>
["ADMIN_DASHBOARD_VIEW", "ADMIN_STUDENT_READ"].includes(p.code),
),
userCount: 24,
dataScope: "CLASS",
isSystem: false,
createdAt: 1704240000000,
updatedAt: 1706918400000,
},
];
export const mockUsers: UserViewModel[] = [
{
id: "u-001",
email: "admin@edu.test",
name: "系统管理员",
roles: [mockRoles[0]!],
status: "active",
dataScope: "ALL",
organizationId: null,
schoolName: "Edu 实验学校",
lastLoginAt: 1706918400000,
createdAt: 1704067200000,
updatedAt: 1706745600000,
},
{
id: "u-002",
email: "principal@edu.test",
name: "张校长",
roles: [mockRoles[1]!],
status: "active",
dataScope: "SCHOOL",
organizationId: "org-school-001",
schoolName: "Edu 实验学校",
lastLoginAt: 1706832000000,
createdAt: 1704153600000,
updatedAt: 1706832000000,
},
{
id: "u-003",
email: "gradeleader@edu.test",
name: "李组长",
roles: [mockRoles[2]!],
status: "active",
dataScope: "GRADE",
organizationId: "org-grade-001",
schoolName: "Edu 实验学校",
lastLoginAt: 1706745600000,
createdAt: 1704240000000,
updatedAt: 1706745600000,
},
{
id: "u-004",
email: "teacher1@edu.test",
name: "王老师",
roles: [mockRoles[3]!],
status: "active",
dataScope: "CLASS",
organizationId: "org-class-001",
schoolName: "Edu 实验学校",
lastLoginAt: 1706688000000,
createdAt: 1704326400000,
updatedAt: 1706688000000,
},
{
id: "u-005",
email: "teacher2@edu.test",
name: "赵老师",
roles: [mockRoles[3]!],
status: "disabled",
dataScope: "CLASS",
organizationId: "org-class-002",
schoolName: "Edu 实验学校",
lastLoginAt: 1704326400000,
createdAt: 1704412800000,
updatedAt: 1706601600000,
},
{
id: "u-006",
email: "teacher3@edu.test",
name: "钱老师",
roles: [mockRoles[2]!, mockRoles[3]!],
status: "locked",
dataScope: "GRADE",
organizationId: "org-grade-002",
schoolName: "Edu 实验学校",
lastLoginAt: 1706515200000,
createdAt: 1704499200000,
updatedAt: 1706515200000,
},
];
export const mockViewports: ViewportConfigViewModel[] = [
{
id: "v-001",
key: "dashboard",
label: "工作台",
route: "/dashboard",
icon: "home",
sortOrder: 1,
requiredPermission: null,
scope: "teacher",
isVisible: true,
},
{
id: "v-002",
key: "classes",
label: "我的班级",
route: "/classes",
icon: "users",
sortOrder: 2,
requiredPermission: "TEACHER_CLASS_READ",
scope: "teacher",
isVisible: true,
},
{
id: "v-003",
key: "exams",
label: "考试管理",
route: "/exams",
icon: "file-text",
sortOrder: 3,
requiredPermission: "TEACHER_EXAM_READ",
scope: "teacher",
isVisible: true,
},
{
id: "v-004",
key: "homework",
label: "作业管理",
route: "/homework",
icon: "book",
sortOrder: 4,
requiredPermission: "TEACHER_HOMEWORK_READ",
scope: "teacher",
isVisible: true,
},
{
id: "v-005",
key: "students",
label: "学生中心",
route: "/students",
icon: "user",
sortOrder: 5,
requiredPermission: "STUDENT_READ",
scope: "student",
isVisible: true,
},
{
id: "v-006",
key: "parent",
label: "家长视口",
route: "/parent",
icon: "heart",
sortOrder: 6,
requiredPermission: "PARENT_VIEW",
scope: "parent",
isVisible: true,
},
{
id: "v-007",
key: "admin",
label: "管理端",
route: "/admin",
icon: "settings",
sortOrder: 7,
requiredPermission: "ADMIN_DASHBOARD_VIEW",
scope: "admin",
isVisible: true,
},
];
export const mockOrganization: OrganizationNode[] = [
{
id: "org-school-001",
name: "Edu 实验学校",
type: "school",
parentId: null,
childrenCount: 3,
sortOrder: 1,
},
{
id: "org-grade-001",
name: "一年级",
type: "grade",
parentId: "org-school-001",
childrenCount: 4,
sortOrder: 1,
},
{
id: "org-grade-002",
name: "二年级",
type: "grade",
parentId: "org-school-001",
childrenCount: 4,
sortOrder: 2,
},
{
id: "org-grade-003",
name: "三年级",
type: "grade",
parentId: "org-school-001",
childrenCount: 3,
sortOrder: 3,
},
{
id: "org-class-001",
name: "一年级一班",
type: "class",
parentId: "org-grade-001",
childrenCount: 0,
sortOrder: 1,
},
{
id: "org-class-002",
name: "一年级二班",
type: "class",
parentId: "org-grade-001",
childrenCount: 0,
sortOrder: 2,
},
{
id: "org-class-003",
name: "一年级三班",
type: "class",
parentId: "org-grade-001",
childrenCount: 0,
sortOrder: 3,
},
{
id: "org-class-004",
name: "一年级四班",
type: "class",
parentId: "org-grade-001",
childrenCount: 0,
sortOrder: 4,
},
{
id: "org-class-005",
name: "二年级一班",
type: "class",
parentId: "org-grade-002",
childrenCount: 0,
sortOrder: 1,
},
{
id: "org-class-006",
name: "二年级二班",
type: "class",
parentId: "org-grade-002",
childrenCount: 0,
sortOrder: 2,
},
{
id: "org-class-007",
name: "二年级三班",
type: "class",
parentId: "org-grade-002",
childrenCount: 0,
sortOrder: 3,
},
{
id: "org-class-008",
name: "二年级四班",
type: "class",
parentId: "org-grade-002",
childrenCount: 0,
sortOrder: 4,
},
];
export const mockClasses: AdminClassViewModel[] = [
{
id: "c-001",
name: "一年级一班",
gradeName: "一年级",
schoolName: "Edu 实验学校",
headTeacherName: "王老师",
studentCount: 36,
createdAt: 1704067200000,
},
{
id: "c-002",
name: "一年级二班",
gradeName: "一年级",
schoolName: "Edu 实验学校",
headTeacherName: "赵老师",
studentCount: 35,
createdAt: 1704067200000,
},
{
id: "c-003",
name: "一年级三班",
gradeName: "一年级",
schoolName: "Edu 实验学校",
headTeacherName: "钱老师",
studentCount: 34,
createdAt: 1704067200000,
},
{
id: "c-004",
name: "二年级一班",
gradeName: "二年级",
schoolName: "Edu 实验学校",
headTeacherName: "孙老师",
studentCount: 38,
createdAt: 1704067200000,
},
{
id: "c-005",
name: "二年级二班",
gradeName: "二年级",
schoolName: "Edu 实验学校",
headTeacherName: "周老师",
studentCount: 37,
createdAt: 1704067200000,
},
{
id: "c-006",
name: "三年级一班",
gradeName: "三年级",
schoolName: "Edu 实验学校",
headTeacherName: "吴老师",
studentCount: 33,
createdAt: 1704067200000,
},
];
export const mockTeachers: AdminTeacherViewModel[] = [
{
id: "t-001",
email: "teacher1@edu.test",
name: "王老师",
schoolName: "Edu 实验学校",
subjects: ["语文", "阅读"],
classCount: 1,
status: "active",
lastLoginAt: 1706688000000,
},
{
id: "t-002",
email: "teacher2@edu.test",
name: "赵老师",
schoolName: "Edu 实验学校",
subjects: ["数学"],
classCount: 1,
status: "disabled",
lastLoginAt: 1704326400000,
},
{
id: "t-003",
email: "teacher3@edu.test",
name: "钱老师",
schoolName: "Edu 实验学校",
subjects: ["英语"],
classCount: 2,
status: "locked",
lastLoginAt: 1706515200000,
},
{
id: "t-004",
email: "teacher4@edu.test",
name: "孙老师",
schoolName: "Edu 实验学校",
subjects: ["物理", "科学"],
classCount: 1,
status: "active",
lastLoginAt: 1706601600000,
},
{
id: "t-005",
email: "teacher5@edu.test",
name: "周老师",
schoolName: "Edu 实验学校",
subjects: ["化学"],
classCount: 1,
status: "active",
lastLoginAt: 1706688000000,
},
{
id: "t-006",
email: "teacher6@edu.test",
name: "吴老师",
schoolName: "Edu 实验学校",
subjects: ["生物"],
classCount: 1,
status: "active",
lastLoginAt: 1706745600000,
},
];
export const mockStudents: AdminStudentViewModel[] = [
{
id: "s-001",
email: "student1@edu.test",
name: "小明",
className: "一年级一班",
gradeName: "一年级",
schoolName: "Edu 实验学校",
guardianName: "大明",
guardianPhone: "13800000001",
status: "active",
},
{
id: "s-002",
email: "student2@edu.test",
name: "小红",
className: "一年级一班",
gradeName: "一年级",
schoolName: "Edu 实验学校",
guardianName: "大红",
guardianPhone: "13800000002",
status: "active",
},
{
id: "s-003",
email: "student3@edu.test",
name: "小华",
className: "一年级二班",
gradeName: "一年级",
schoolName: "Edu 实验学校",
guardianName: "大华",
guardianPhone: "13800000003",
status: "active",
},
{
id: "s-004",
email: "student4@edu.test",
name: "小芳",
className: "二年级一班",
gradeName: "二年级",
schoolName: "Edu 实验学校",
guardianName: "大芳",
guardianPhone: "13800000004",
status: "disabled",
},
{
id: "s-005",
email: "student5@edu.test",
name: "小军",
className: "三年级一班",
gradeName: "三年级",
schoolName: "Edu 实验学校",
guardianName: "大军",
guardianPhone: "13800000005",
status: "active",
},
];
export const mockAuditLogs: AuditLogViewModel[] = [
{
id: "al-001",
eventId: "evt-001",
occurredAt: 1706918400000,
actorUserId: "u-001",
actorName: "系统管理员",
action: "USER_LOGIN",
resourceType: "iam.user",
resourceId: "u-001",
ip: "192.168.1.100",
userAgent: "Mozilla/5.0",
beforeState: null,
afterState: null,
traceId: "trace-001",
},
{
id: "al-002",
eventId: "evt-002",
occurredAt: 1706832000000,
actorUserId: "u-001",
actorName: "系统管理员",
action: "USER_CREATE",
resourceType: "iam.user",
resourceId: "u-006",
ip: "192.168.1.100",
userAgent: "Mozilla/5.0",
beforeState: null,
afterState: '{"email":"teacher3@edu.test","name":"钱老师"}',
traceId: "trace-002",
},
{
id: "al-003",
eventId: "evt-003",
occurredAt: 1706745600000,
actorUserId: "u-002",
actorName: "张校长",
action: "ROLE_UPDATE",
resourceType: "iam.role",
resourceId: "r-002",
ip: "192.168.1.101",
userAgent: "Mozilla/5.0",
beforeState: '{"permissions":["ADMIN_DASHBOARD_VIEW"]}',
afterState: '{"permissions":["ADMIN_DASHBOARD_VIEW","ADMIN_CLASS_MANAGE"]}',
traceId: "trace-003",
},
{
id: "al-004",
eventId: "evt-004",
occurredAt: 1706688000000,
actorUserId: "u-001",
actorName: "系统管理员",
action: "USER_TOGGLE_STATUS",
resourceType: "iam.user",
resourceId: "u-005",
ip: "192.168.1.100",
userAgent: "Mozilla/5.0",
beforeState: '{"status":"active"}',
afterState: '{"status":"disabled"}',
traceId: "trace-004",
},
{
id: "al-005",
eventId: "evt-005",
occurredAt: 1706601600000,
actorUserId: "system",
actorName: "系统",
action: "ABNORMAL_LOGIN_BLOCKED",
resourceType: "iam.user",
resourceId: "u-006",
ip: "10.0.0.99",
userAgent: "curl/7.68",
beforeState: null,
afterState: null,
traceId: "trace-005",
},
];
export const mockDashboard: AdminDashboardViewModel = {
totalTeachers: 6,
totalStudents: 213,
totalClasses: 6,
totalSchools: 1,
schoolAvgScore: 85.6,
activeUsersToday: 28,
auditEventsToday: 12,
trend: [
{ date: "2026-07-04", teachers: 4, students: 198, avgScore: 84.2 },
{ date: "2026-07-05", teachers: 5, students: 205, avgScore: 84.8 },
{ date: "2026-07-06", teachers: 5, students: 210, avgScore: 85.1 },
{ date: "2026-07-07", teachers: 6, students: 211, avgScore: 85.3 },
{ date: "2026-07-08", teachers: 6, students: 213, avgScore: 85.6 },
{ date: "2026-07-09", teachers: 6, students: 213, avgScore: 85.5 },
{ date: "2026-07-10", teachers: 6, students: 213, avgScore: 85.6 },
],
serviceHealth: [
{ serviceName: "api-gateway", status: "healthy", latencyMs: 12 },
{ serviceName: "iam", status: "healthy", latencyMs: 28 },
{ serviceName: "teacher-bff", status: "healthy", latencyMs: 45 },
{ serviceName: "classes", status: "healthy", latencyMs: 35 },
{ serviceName: "core-edu", status: "healthy", latencyMs: 52 },
{ serviceName: "msg", status: "degraded", latencyMs: 280 },
{ serviceName: "data-ana", status: "healthy", latencyMs: 120 },
],
};
export const mockSystemSettings: SystemSettingsViewModel = {
schoolName: "Edu 实验学校",
schoolCode: "EDU-001",
academicYear: "2025-2026",
semester: "second",
contactEmail: "contact@edu.test",
contactPhone: "010-88888888",
address: "北京市海淀区中关村大街 1 号",
timezone: "Asia/Shanghai",
locale: "zh-CN",
};
/** 生成简单 ID */
export function genId(prefix: string): string {
return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
}
// ─── 学校组织管理细化 ──────────────────────────────────────────────
export const mockSchools: SchoolViewModel[] = [
{
id: "sch-001",
name: "Edu 实验学校",
code: "EDU-001",
address: "北京市海淀区中关村大街 1 号",
contactPhone: "010-88888888",
contactEmail: "contact@edu.test",
principalName: "张校长",
gradeCount: 6,
classCount: 24,
studentCount: 1200,
teacherCount: 80,
createdAt: Date.now() - 86400000 * 365,
},
{
id: "sch-002",
name: "Edu 附属中学",
code: "EDU-002",
address: "北京市西城区西长安街 2 号",
contactPhone: "010-66666666",
contactEmail: "fz@edu.test",
principalName: "李校长",
gradeCount: 3,
classCount: 18,
studentCount: 900,
teacherCount: 60,
createdAt: Date.now() - 86400000 * 300,
},
];
export const mockGrades: GradeViewModel[] = [
{
id: "grd-001",
name: "一年级",
schoolId: "sch-001",
schoolName: "Edu 实验学校",
directorName: "王主任",
classCount: 4,
studentCount: 200,
sortOrder: 1,
createdAt: Date.now() - 86400000 * 300,
},
{
id: "grd-002",
name: "二年级",
schoolId: "sch-001",
schoolName: "Edu 实验学校",
directorName: "刘主任",
classCount: 4,
studentCount: 210,
sortOrder: 2,
createdAt: Date.now() - 86400000 * 300,
},
{
id: "grd-003",
name: "三年级",
schoolId: "sch-001",
schoolName: "Edu 实验学校",
directorName: "陈主任",
classCount: 4,
studentCount: 195,
sortOrder: 3,
createdAt: Date.now() - 86400000 * 300,
},
{
id: "grd-004",
name: "初一",
schoolId: "sch-002",
schoolName: "Edu 附属中学",
directorName: "赵主任",
classCount: 6,
studentCount: 300,
sortOrder: 1,
createdAt: Date.now() - 86400000 * 250,
},
];
export const mockGradeInsights: GradeInsightsViewModel = {
gradeId: "grd-001",
gradeName: "一年级",
schoolWideSummary: {
totalStudents: 1200,
totalClasses: 24,
avgScore: 82.5,
passingRate: 0.95,
},
homeworkTimeline: [
{
homeworkId: "hw-001",
title: "数学练习一",
className: "一班",
avgScore: 85,
submittedCount: 48,
totalCount: 50,
dueDate: "2026-07-10",
},
{
homeworkId: "hw-002",
title: "语文阅读",
className: "二班",
avgScore: 78,
submittedCount: 45,
totalCount: 50,
dueDate: "2026-07-11",
},
{
homeworkId: "hw-003",
title: "英语听力",
className: "三班",
avgScore: 82,
submittedCount: 50,
totalCount: 50,
dueDate: "2026-07-12",
},
{
homeworkId: "hw-004",
title: "数学练习二",
className: "四班",
avgScore: 88,
submittedCount: 47,
totalCount: 50,
dueDate: "2026-07-13",
},
],
classRankings: [
{
classId: "cls-001",
className: "一班",
avgScore: 85.2,
rank: 1,
delta: 2.1,
},
{
classId: "cls-002",
className: "四班",
avgScore: 83.8,
rank: 2,
delta: -0.5,
},
{
classId: "cls-003",
className: "二班",
avgScore: 81.5,
rank: 3,
delta: 1.3,
},
{
classId: "cls-004",
className: "三班",
avgScore: 79.6,
rank: 4,
delta: -1.2,
},
],
};
export const mockDepartments: DepartmentViewModel[] = [
{
id: "dept-001",
name: "数学教研组",
schoolId: "sch-001",
schoolName: "Edu 实验学校",
leaderName: "王老师",
memberCount: 12,
subject: "数学",
createdAt: Date.now() - 86400000 * 200,
},
{
id: "dept-002",
name: "语文教研组",
schoolId: "sch-001",
schoolName: "Edu 实验学校",
leaderName: "李老师",
memberCount: 10,
subject: "语文",
createdAt: Date.now() - 86400000 * 200,
},
{
id: "dept-003",
name: "英语教研组",
schoolId: "sch-001",
schoolName: "Edu 实验学校",
leaderName: "张老师",
memberCount: 8,
subject: "英语",
createdAt: Date.now() - 86400000 * 200,
},
{
id: "dept-004",
name: "理科教研组",
schoolId: "sch-002",
schoolName: "Edu 附属中学",
leaderName: "赵老师",
memberCount: 15,
subject: "物理",
createdAt: Date.now() - 86400000 * 180,
},
];
export const mockAcademicYears: AcademicYearViewModel[] = [
{
id: "ay-001",
name: "2025-2026学年",
startDate: "2025-09-01",
endDate: "2026-07-15",
firstSemesterStart: "2025-09-01",
firstSemesterEnd: "2026-01-15",
secondSemesterStart: "2026-02-15",
secondSemesterEnd: "2026-07-15",
isCurrent: true,
createdAt: Date.now() - 86400000 * 300,
},
{
id: "ay-002",
name: "2024-2025学年",
startDate: "2024-09-01",
endDate: "2025-07-15",
firstSemesterStart: "2024-09-01",
firstSemesterEnd: "2025-01-15",
secondSemesterStart: "2025-02-15",
secondSemesterEnd: "2025-07-15",
isCurrent: false,
createdAt: Date.now() - 86400000 * 665,
},
];
// ─── 审计日志子模块 ─────────────────────────────────────────────────
export const mockAuditOverviewStats: AuditOverviewStats = {
totalEvents: 15420,
todayEvents: 86,
uniqueActors: 142,
failedActions: 23,
topActions: [
{ action: "USER_LOGIN", count: 3200 },
{ action: "USER_CREATE", count: 156 },
{ action: "USER_UPDATE", count: 892 },
{ action: "ROLE_UPDATE", count: 45 },
{ action: "SYSTEM_SETTINGS_UPDATE", count: 12 },
],
topResources: [
{ resource: "user", count: 4200 },
{ resource: "role", count: 380 },
{ resource: "viewport", count: 120 },
{ resource: "system_settings", count: 45 },
],
};
export const mockAuditTrend: AuditTrendPoint[] = Array.from(
{ length: 7 },
(_, i) => {
const d = new Date();
d.setDate(d.getDate() - (6 - i));
return {
date: d.toISOString().slice(0, 10),
count: Math.floor(50 + Math.random() * 50),
action: "USER_LOGIN",
};
},
);
export const mockDataChangeLogs: DataChangeLogViewModel[] = [
{
id: "dcl-001",
occurredAt: Date.now() - 3600000,
actorUserId: "u-admin-001",
actorName: "系统管理员",
tableName: "users",
action: "create",
recordId: "u-006",
beforeState: null,
afterState: '{"email":"new@edu.test","name":"新用户"}',
ip: "192.168.1.1",
},
{
id: "dcl-002",
occurredAt: Date.now() - 7200000,
actorUserId: "u-admin-001",
actorName: "系统管理员",
tableName: "roles",
action: "update",
recordId: "r-002",
beforeState: '{"name":"教师"}',
afterState: '{"name":"教师","permissions":["READ","WRITE"]}',
ip: "192.168.1.1",
},
{
id: "dcl-003",
occurredAt: Date.now() - 10800000,
actorUserId: "u-admin-001",
actorName: "系统管理员",
tableName: "users",
action: "delete",
recordId: "u-005",
beforeState: '{"email":"old@edu.test"}',
afterState: null,
ip: "192.168.1.1",
},
{
id: "dcl-004",
occurredAt: Date.now() - 14400000,
actorUserId: "u-admin-001",
actorName: "系统管理员",
tableName: "viewports",
action: "update",
recordId: "v-001",
beforeState: '{"sortOrder":1}',
afterState: '{"sortOrder":2}',
ip: "192.168.1.1",
},
{
id: "dcl-005",
occurredAt: Date.now() - 18000000,
actorUserId: "u-admin-001",
actorName: "系统管理员",
tableName: "system_settings",
action: "update",
recordId: "settings",
beforeState: '{"schoolName":"旧名称"}',
afterState: '{"schoolName":"Edu 实验学校"}',
ip: "192.168.1.1",
},
];
export const mockLoginLogs: LoginLogViewModel[] = [
{
id: "ll-001",
occurredAt: Date.now() - 1800000,
userId: "u-admin-001",
userName: "系统管理员",
action: "signin",
status: "success",
ip: "192.168.1.1",
userAgent: "Chrome/126.0",
failureReason: null,
},
{
id: "ll-002",
occurredAt: Date.now() - 3600000,
userId: "u-002",
userName: "王老师",
action: "signin",
status: "success",
ip: "10.0.0.5",
userAgent: "Firefox/127.0",
failureReason: null,
},
{
id: "ll-003",
occurredAt: Date.now() - 5400000,
userId: "unknown",
userName: "unknown",
action: "signin",
status: "failure",
ip: "203.0.113.5",
userAgent: "curl/8.0",
failureReason: "密码错误",
},
{
id: "ll-004",
occurredAt: Date.now() - 7200000,
userId: "u-003",
userName: "李老师",
action: "signout",
status: "success",
ip: "10.0.0.8",
userAgent: "Chrome/126.0",
failureReason: null,
},
{
id: "ll-005",
occurredAt: Date.now() - 9000000,
userId: "u-006",
userName: "新用户",
action: "signup",
status: "success",
ip: "10.0.0.12",
userAgent: "Safari/17.0",
failureReason: null,
},
{
id: "ll-006",
occurredAt: Date.now() - 10800000,
userId: "unknown",
userName: "unknown",
action: "signin",
status: "failure",
ip: "198.51.100.1",
userAgent: "bot/1.0",
failureReason: "账户锁定",
},
];
// ─── 公告管理 ───────────────────────────────────────────────────────
export const mockAnnouncements: AnnouncementViewModel[] = [
{
id: "ann-001",
title: "2026年春季学期开学通知",
content:
"各位师生2026年春季学期将于2月15日正式开学请提前做好准备工作。",
status: "published",
audience: ["all"],
authorName: "系统管理员",
isPinned: true,
readCount: 1150,
totalCount: 1200,
publishedAt: Date.now() - 86400000 * 3,
createdAt: Date.now() - 86400000 * 5,
updatedAt: Date.now() - 86400000 * 3,
},
{
id: "ann-002",
title: "期中考试安排",
content: "期中考试将于第10周进行具体安排另行通知。",
status: "published",
audience: ["teachers", "students"],
authorName: "系统管理员",
isPinned: false,
readCount: 800,
totalCount: 1280,
publishedAt: Date.now() - 86400000 * 2,
createdAt: Date.now() - 86400000 * 4,
updatedAt: Date.now() - 86400000 * 2,
},
{
id: "ann-003",
title: "家长会通知(草稿)",
content: "定于下周六召开家长会,具体时间待定。",
status: "draft",
audience: ["parents"],
authorName: "系统管理员",
isPinned: false,
readCount: 0,
totalCount: 0,
publishedAt: null,
createdAt: Date.now() - 86400000,
updatedAt: Date.now() - 86400000,
},
{
id: "ann-004",
title: "寒假放假通知",
content: "寒假时间为1月16日至2月14日。",
status: "archived",
audience: ["all"],
authorName: "系统管理员",
isPinned: false,
readCount: 1190,
totalCount: 1200,
publishedAt: Date.now() - 86400000 * 30,
createdAt: Date.now() - 86400000 * 32,
updatedAt: Date.now() - 86400000 * 25,
},
];
// ─── 邀请码管理 ─────────────────────────────────────────────────────
export const mockInvitationCodes: InvitationCodeViewModel[] = [
{
id: "ic-001",
code: "AB3D7F9H",
status: "unused",
roleId: "r-001",
roleName: "教师",
classId: null,
className: null,
email: null,
batchId: "bat-001",
usedBy: null,
usedByName: null,
usedAt: null,
createdAt: Date.now() - 86400000,
expiresAt: Date.now() + 86400000 * 30,
},
{
id: "ic-002",
code: "JC5K8M2P",
status: "unused",
roleId: "r-002",
roleName: "学生",
classId: "cls-001",
className: "一年级一班",
email: null,
batchId: "bat-001",
usedBy: null,
usedByName: null,
usedAt: null,
createdAt: Date.now() - 86400000,
expiresAt: Date.now() + 86400000 * 30,
},
{
id: "ic-003",
code: "QR7S4T6V",
status: "used",
roleId: "r-003",
roleName: "家长",
classId: null,
className: null,
email: "parent@edu.test",
batchId: "bat-001",
usedBy: "u-007",
usedByName: "张家长",
usedAt: Date.now() - 3600000,
createdAt: Date.now() - 86400000,
expiresAt: Date.now() + 86400000 * 30,
},
{
id: "ic-004",
code: "WX9Y2Z4B",
status: "expired",
roleId: null,
roleName: null,
classId: null,
className: null,
email: null,
batchId: "bat-000",
usedBy: null,
usedByName: null,
usedAt: null,
createdAt: Date.now() - 86400000 * 60,
expiresAt: Date.now() - 86400000 * 30,
},
];
// ─── 文件管理 ───────────────────────────────────────────────────────
export const mockFiles: FileViewModel[] = [
{
id: "file-001",
filename: "期中考试试卷.pdf",
mimeType: "application/pdf",
size: 1024000,
url: "/files/exam-mid.pdf",
entityType: "exam",
entityId: "exam-001",
uploadedByName: "王老师",
createdAt: Date.now() - 86400000 * 3,
},
{
id: "file-002",
filename: "数学课件.pptx",
mimeType:
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
size: 5120000,
url: "/files/math.pptx",
entityType: "lesson_plan",
entityId: "lp-001",
uploadedByName: "李老师",
createdAt: Date.now() - 86400000 * 2,
},
{
id: "file-003",
filename: "学生头像.jpg",
mimeType: "image/jpeg",
size: 256000,
url: "/files/avatar.jpg",
entityType: "user_avatar",
entityId: "u-005",
uploadedByName: "系统管理员",
createdAt: Date.now() - 86400000,
},
{
id: "file-004",
filename: "开学通知.docx",
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
size: 89000,
url: "/files/notice.docx",
entityType: "announcement",
entityId: "ann-001",
uploadedByName: "系统管理员",
createdAt: Date.now() - 86400000 * 5,
},
{
id: "file-005",
filename: "成绩统计.xlsx",
mimeType:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
size: 348000,
url: "/files/grades.xlsx",
entityType: "homework",
entityId: "hw-001",
uploadedByName: "王老师",
createdAt: Date.now() - 86400000 * 7,
},
];
export const mockFileStats: FileStats = {
totalFiles: 348,
totalSize: 2840000000,
byMimeType: [
{ mimeType: "application/pdf", count: 85, size: 95000000 },
{ mimeType: "image/jpeg", count: 120, size: 340000000 },
{
mimeType:
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
count: 45,
size: 12000000,
},
{
mimeType:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
count: 30,
size: 8900000,
},
{ mimeType: "video/mp4", count: 12, size: 2300000000 },
],
byEntityType: [
{ entityType: "exam", count: 85 },
{ entityType: "lesson_plan", count: 60 },
{ entityType: "user_avatar", count: 120 },
{ entityType: "announcement", count: 25 },
{ entityType: "homework", count: 58 },
],
};
// ─── AI 配置 ─────────────────────────────────────────────────────────
export const mockAiProviders: AiProviderViewModel[] = [
{
id: "aip-001",
name: "OpenAI",
type: "openai",
isPublic: true,
isActive: true,
model: "gpt-4o",
apiBase: "https://api.openai.com/v1",
createdBy: "系统管理员",
createdAt: Date.now() - 86400000 * 30,
},
{
id: "aip-002",
name: "通义千问",
type: "qwen",
isPublic: true,
isActive: true,
model: "qwen-max",
apiBase: "https://dashscope.aliyuncs.com/api/v1",
createdBy: "系统管理员",
createdAt: Date.now() - 86400000 * 20,
},
{
id: "aip-003",
name: "个人 DeepSeek",
type: "deepseek",
isPublic: false,
isActive: false,
model: "deepseek-chat",
apiBase: "https://api.deepseek.com/v1",
createdBy: "王老师",
createdAt: Date.now() - 86400000 * 10,
},
];
export const mockAiUsage: AiUsageViewModel = {
totalRequests: 12580,
totalTokens: 4520000,
totalCost: 68.5,
byProvider: [
{ providerName: "OpenAI", requests: 8200, tokens: 3200000, cost: 52.3 },
{ providerName: "通义千问", requests: 3380, tokens: 1100000, cost: 12.8 },
{
providerName: "个人 DeepSeek",
requests: 1000,
tokens: 220000,
cost: 3.4,
},
],
byDay: Array.from({ length: 7 }, (_, i) => {
const d = new Date();
d.setDate(d.getDate() - (6 - i));
return {
date: d.toISOString().slice(0, 10),
requests: Math.floor(800 + Math.random() * 400),
tokens: Math.floor(300000 + Math.random() * 200000),
};
}),
};
// ─── 增强系统设置 ───────────────────────────────────────────────────
export const mockSecurityPolicy: SecurityPolicy = {
passwordMinLength: 8,
passwordRequireSpecial: true,
passwordRequireUppercase: true,
sessionTimeoutMinutes: 30,
forcePasswordChange: false,
};
export const mockFileUploadConfig: FileUploadConfig = {
maxFileSize: 50,
allowedTypes: ["pdf", "jpg", "jpeg", "png", "docx", "xlsx", "pptx", "mp4"],
};
export const mockNotificationConfig: NotificationConfig = {
notifyNewUser: true,
notifyScheduleChange: true,
notifyAnnouncement: false,
};
export const mockBrandConfig: BrandConfig = {
logoUrl: "/logo.png",
primaryColor: "#1a56db",
schoolMotto: "博学笃行,求实创新",
};