import { NotificationEntity, NotificationType } from '../entities/notification.entity';

export const NOTIFICATION_REPOSITORY = Symbol('NOTIFICATION_REPOSITORY');

/**
 * 通知仓储接口
 */
export interface NotificationRepository {
  /**
   * 保存通知
   */
  save(notification: NotificationEntity): Promise<NotificationEntity>;

  /**
   * 根据ID查找通知
   */
  findById(id: string): Promise<NotificationEntity | null>;

  /**
   * 查找所有已发布且有效的通知
   */
  findActiveNotifications(params?: {
    type?: NotificationType;
    limit?: number;
    offset?: number;
  }): Promise<NotificationEntity[]>;

  /**
   * 获取用户的通知列表（带已读状态）
   */
  findNotificationsForUser(params: {
    userSerialNum: string;
    type?: NotificationType;
    limit?: number;
    offset?: number;
  }): Promise<NotificationWithReadStatus[]>;

  /**
   * 获取用户未读通知数量
   */
  countUnreadForUser(userSerialNum: string): Promise<number>;

  /**
   * 标记通知为已读
   */
  markAsRead(notificationId: string, userSerialNum: string): Promise<void>;

  /**
   * 标记所有通知为已读
   */
  markAllAsRead(userSerialNum: string): Promise<void>;

  /**
   * 删除通知
   */
  delete(id: string): Promise<void>;

  /**
   * 查找所有通知（管理后台用）
   */
  findAll(params?: {
    type?: NotificationType;
    isEnabled?: boolean;
    limit?: number;
    offset?: number;
  }): Promise<NotificationEntity[]>;

  /**
   * 统计通知数量
   */
  count(params?: {
    type?: NotificationType;
    isEnabled?: boolean;
  }): Promise<number>;
}

/**
 * 带已读状态的通知
 */
export interface NotificationWithReadStatus {
  notification: NotificationEntity;
  isRead: boolean;
  readAt: Date | null;
}
