
package com.tmerclub.cloud.config;

import com.tmerclub.cloud.common.rocketmq.config.RocketMqAdapter;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author xxw
 * @date 2022/8/31 10:14
 */
@RefreshScope
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqAdapter rocketMqAdapter;

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboSkuStatusTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_SKU_STATUS_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboDeleteOrDisabledTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_DELETE_OR_DISABLED);
    }


    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboSpuCountChangeTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_SPU_COUNT_CHANGE);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate couponMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COUPON_UNLOCK_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate levelUpCouponGiveTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.LEVEL_UP_COUPON_GIVE_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate levelDownCouponExpireTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.LEVEL_DOWN_COUPON_EXPIRE_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendActivityOfflineNotifyToShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SEND_ACTIVITY_OFFLINE_NOTIFY_TO_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate distributionNotifyOrderShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.DISTRIBUTION_NOTIFY_ORDER_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendNotifyToUserTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SEND_NOTIFY_TO_USER_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendActivityAuditNotifyToShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SEND_ACTIVITY_AUDIT_NOTIFY_TO_SHOP_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendAddCouponStockTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ADD_COUPON_STOCK_TOPIC);
    }
}
