package org.sky.resource.rule.builder;

import org.sky.core.literule.annotation.RuleEngineComponent;
import org.sky.core.literule.builder.LiteRule;
import org.sky.core.literule.builder.RuleBuilder;
import org.sky.core.literule.builder.chain.RuleChain;
import org.sky.resource.rule.constant.SmsRuleConstant;

/**
 * Sms规则链构建器
 *
 */
@RuleEngineComponent(id = SmsRuleConstant.SMS_CHAIN_ID)
public class SmsRuleBuilder implements RuleBuilder {
	@Override
	public RuleChain build() {
		// 创建SMS构建条件判断规则链
		RuleChain smsBuildRuleChain = LiteRule.SWITCH(SmsRuleConstant.SMS_BUILD_RULE).TO(
			SmsRuleConstant.ALI_SMS_RULE,
			SmsRuleConstant.QINIU_SMS_RULE,
			SmsRuleConstant.TENCENT_SMS_RULE,
			SmsRuleConstant.YUNPIAN_SMS_RULE,
			SmsRuleConstant.CACHE_SMS_RULE
		).build();

		// 创建完整规则链
		return LiteRule.THEN(SmsRuleConstant.PRE_SMS_RULE)
			.THEN(smsBuildRuleChain)
			.THEN(SmsRuleConstant.FINALLY_SMS_RULE)
			.build();
	}
}
