package com.icloud.server.scala.engine.service

import com.icloud.server.scala.engine.contect.Context
import com.icloud.server.scala.engine.filter.{AbstractFilter, AmountRiskFilter, RandomFilter, RealmNameFilter, RedisFilter, RiskFilter, TimeFilter, TodayRiskFilter, WeightFilter}
import org.springframework.stereotype.Service

import javax.annotation.{PostConstruct, Resource}
import scala.beans.BeanProperty

@Service
class PayFilterService {

  @Resource
  @BeanProperty var realmnamefilter: RealmNameFilter = _
  @Resource
  @BeanProperty var redisfilter: RedisFilter = _
  @Resource
  @BeanProperty var weightfilter: WeightFilter = _
  @Resource
  @BeanProperty var randomfilter: RandomFilter = _
  @Resource
  @BeanProperty var timefilter: TimeFilter = _

  @Resource
  @BeanProperty var riskfilter: RiskFilter = _
  @Resource
  @BeanProperty var todayriskfilter: TodayRiskFilter = _
  @Resource
  @BeanProperty var amountriskfilter: AmountRiskFilter = _

  @BeanProperty var filters: List[AbstractFilter] = null
  @PostConstruct
  def init = {
    filters = List(realmnamefilter, riskfilter,amountriskfilter,todayriskfilter,timefilter,redisfilter, weightfilter, randomfilter)
  }


  def filter(context: Context, goodspaye: Goodspaye): Goodspaye = {
    var ret = goodspaye
    for (f <- filters) {
      ret = f.filter(context, ret)
    }
    ret
  }

}
