export type AnnouncementStatus = "draft" | "published" | "archived"

export type AnnouncementType = "school" | "grade" | "class"

export interface Announcement {
  id: string
  title: string
  content: string
  type: AnnouncementType
  status: AnnouncementStatus
  targetGradeId: string | null
  targetClassId: string | null
  authorId: string
  authorName: string | null
  publishedAt: string | null
  isPinned: boolean
  /** V2-P2-13d: 当前用户是否已读（仅用户端查询时填充） */
  isReadByCurrentUser?: boolean
  /** V2-P2-13d: 已读人数（仅管理端查询时填充） */
  readCount?: number
  createdAt: string
  updatedAt: string
}

export type AnnouncementListItem = Announcement

export type GetAnnouncementsParams = {
  status?: AnnouncementStatus
  type?: AnnouncementType
  page?: number
  pageSize?: number
  /**
   * 受众过滤（用户端使用）：当提供时，仅返回对该受众可见的公告。
   * - school 类型公告：对所有受众可见
   * - grade 类型公告：仅当 targetGradeId 与 audience.gradeId 匹配时可见
   * - class 类型公告：仅当 targetClassId 与 audience.classId 匹配时可见
   * 未提供时（管理端）返回所有公告。
   */
  audience?: {
    gradeId?: string
    classId?: string
  }
}

export interface AnnouncementInsertData {
  id: string
  title: string
  content: string
  type: AnnouncementType
  status: AnnouncementStatus
  targetGradeId: string | null
  targetClassId: string | null
  authorId: string
  publishedAt: Date | null
}

export interface AnnouncementUpdateData {
  title: string
  content: string
  type: AnnouncementType
  status: AnnouncementStatus
  targetGradeId: string | null
  targetClassId: string | null
  publishedAt: Date | null
  updatedAt: Date
}

/** V2-P2-13d: 公告已读回执 */
export interface AnnouncementRead {
  id: string
  announcementId: string
  userId: string
  readAt: string
}
