import { DomainEvent } from './domain-event.base'
import { RoleType } from '@/domain/enums'

// 月度考核通过事件
export class MonthlyAssessmentPassedEvent extends DomainEvent {
  readonly eventType = 'assessment.monthly.passed'
  readonly aggregateId: string
  readonly payload: {
    assessmentId: string
    userId: string
    roleType: RoleType
    month: string
    cumulativeCompleted: number
    cumulativeTarget: number
  }

  constructor(data: {
    assessmentId: string
    userId: string
    roleType: RoleType
    month: string
    cumulativeCompleted: number
    cumulativeTarget: number
  }) {
    super()
    this.aggregateId = data.assessmentId
    this.payload = data
  }
}

// 月度考核未达标事件
export class MonthlyAssessmentFailedEvent extends DomainEvent {
  readonly eventType = 'assessment.monthly.failed'
  readonly aggregateId: string
  readonly payload: {
    assessmentId: string
    userId: string
    roleType: RoleType
    month: string
    cumulativeCompleted: number
    cumulativeTarget: number
    reason: string
  }

  constructor(data: {
    assessmentId: string
    userId: string
    roleType: RoleType
    month: string
    cumulativeCompleted: number
    cumulativeTarget: number
    reason: string
  }) {
    super()
    this.aggregateId = data.assessmentId
    this.payload = data
  }
}

// 单月豁免授予事件
export class MonthlyBypassGrantedEvent extends DomainEvent {
  readonly eventType = 'assessment.monthly.bypass_granted'
  readonly aggregateId: string
  readonly payload: {
    assessmentId: string
    userId: string
    roleType: RoleType
    month: string
    grantedBy: string
  }

  constructor(data: {
    assessmentId: string
    userId: string
    roleType: RoleType
    month: string
    grantedBy: string
  }) {
    super()
    this.aggregateId = data.assessmentId
    this.payload = data
  }
}

// 获得第一名事件
export class FirstPlaceAchievedEvent extends DomainEvent {
  readonly eventType = 'assessment.ranking.first_place'
  readonly aggregateId: string
  readonly payload: {
    assessmentId: string
    userId: string
    roleType: RoleType
    regionCode: string
    month: string
  }

  constructor(data: {
    assessmentId: string
    userId: string
    roleType: RoleType
    regionCode: string
    month: string
  }) {
    super()
    this.aggregateId = data.assessmentId
    this.payload = data
  }
}
