/**
 * 下游 gRPC 服务返回的 DTO 类型定义。
 *
 * 这些接口对齐 proto message 字段（camelCase，proto-loader keepCase: false）。
 * 字段类型保持 proto 原始语义（如 Grade.score 为 string），
 * 由 response-mapper（P4.6）负责 proto → GraphQL 类型转换。
 */

// ============ iam DTOs ============

export interface UserInfoDto {
  id: string;
  email: string;
  name: string;
  roles: string[];
  permissions: string[];
}

/**
 * 家长绑定的孩子信息。
 *
 * 注意：iam.proto 尚未定义 Child message（I6 裁决，ai06 待补），
 * 此接口为 parent-bff 消费侧预期结构，GetChildrenByParent RPC 就绪后对齐。
 */
export interface ChildDto {
  id: string;
  name: string;
  grade: string;
  classId: string;
  className: string;
  gradeId: string;
}

export interface ViewportDto {
  key: string;
  label: string;
  route: string;
  icon?: string;
  sortOrder: string;
  requiredPermission?: string;
}

// ============ core-edu DTOs ============

export interface GradeDto {
  id: string;
  studentId: string;
  examId: string;
  homeworkId: string;
  /** proto: string（ISSUE-008），response-mapper 转 Float */
  score: string;
  feedback: string;
  gradedBy: string;
  createdAt: string;
  updatedAt: string;
}

export interface HomeworkDto {
  id: string;
  classId: string;
  title: string;
  description: string;
  dueDate: string;
  status: string;
  createdBy: string;
  createdAt: string;
  updatedAt: string;
}

export interface ExamDto {
  id: string;
  classId: string;
  title: string;
  description: string;
  examDate: string;
  duration: string;
  totalScore: string;
  status: string;
  createdBy: string;
  createdAt: string;
  updatedAt: string;
}

/**
 * 班级信息。
 *
 * 注意：core_edu.proto 尚未定义 ClassService（ISSUE-008 待仲裁），
 * 此接口为 parent-bff 消费侧预期结构。
 */
export interface ClassInfoDto {
  id: string;
  name: string;
  gradeId: string;
}

// ============ data-ana DTOs ============

export interface WeakPointDto {
  knowledgePointId: string;
  title: string;
  mastery: number;
}

export interface StudentWeaknessDto {
  studentId: string;
  weakPoints: WeakPointDto[];
}

export interface TrendPointDto {
  /** proto: int64（epoch ms），response-mapper 转 DateTime */
  date: number;
  score: number;
}

export interface LearningTrendDto {
  studentId: string;
  points: TrendPointDto[];
}

export interface StudentScoreDto {
  studentId: string;
  score: number;
  grade: string;
}

export interface ClassPerformanceDto {
  classId: string;
  averageScore: number;
  passRate: number;
  scores: StudentScoreDto[];
}

// ============ msg DTOs ============

/**
 * 通知 DTO（对齐 msg.proto Notification message）。
 *
 * 注意：msg.proto 当前 Notification 缺 child_id 字段（ISSUE-007），
 * 此处 childId 为 parent-bff 消费侧预期结构，proto 补全后对齐。
 */
export interface NotificationDto {
  id: string;
  userId: string;
  type: string;
  title: string;
  content: string;
  channel: string;
  isRead: boolean;
  childId?: string;
  createdAt: number;
}

export interface NotificationPreferencesDto {
  parentId: string;
  channels: string[];
  eventTypes: {
    gradeReleased: boolean;
    homeworkGraded: boolean;
    examPublished: boolean;
    attendanceAlert: boolean;
    schoolAnnouncement: boolean;
  };
}
