import { ClassificationRuleEntity } from '../entities/classification-rule.entity';

export const CLASSIFICATION_RULE_REPOSITORY = Symbol('CLASSIFICATION_RULE_REPOSITORY');

/**
 * 用户分类规则仓储接口
 */
export interface ClassificationRuleRepository {
  /**
   * 保存规则
   */
  save(rule: ClassificationRuleEntity): Promise<ClassificationRuleEntity>;

  /**
   * 根据ID查找规则
   */
  findById(id: string): Promise<ClassificationRuleEntity | null>;

  /**
   * 查找所有规则
   */
  findAll(params?: {
    isEnabled?: boolean;
    limit?: number;
    offset?: number;
  }): Promise<ClassificationRuleEntity[]>;

  /**
   * 查找所有启用的规则
   */
  findEnabled(): Promise<ClassificationRuleEntity[]>;

  /**
   * 查找已关联标签的规则
   */
  findLinkedRules(): Promise<RuleWithTag[]>;

  /**
   * 统计规则数量
   */
  count(params?: {
    isEnabled?: boolean;
  }): Promise<number>;

  /**
   * 删除规则
   */
  delete(id: string): Promise<void>;
}

/**
 * 规则及其关联的标签
 */
export interface RuleWithTag {
  rule: ClassificationRuleEntity;
  tagId: string;
  tagCode: string;
}
