
package com.tmerclub.cloud.search.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 tmerclub
 * @date 2021/3/30
 */
@RefreshScope
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqAdapter rocketMqAdapter;

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

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

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

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

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

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