package co.yixiang.yshop.module.mp.framework.mp.config;

import co.yixiang.yshop.module.mp.framework.mp.core.DefaultMpServiceFactory;
import co.yixiang.yshop.module.mp.framework.mp.core.MpServiceFactory;
import co.yixiang.yshop.module.mp.service.handler.mp.menu.MenuHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.message.MessageReceiveHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.message.MessageAutoReplyHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.other.KfSessionHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.other.NullHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.other.ScanHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.other.StoreCheckNotifyHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.user.LocationHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.user.SubscribeHandler;
import co.yixiang.yshop.module.mp.service.handler.mp.user.UnsubscribeHandler;
import com.binarywang.spring.starter.wxjava.mp.properties.WxMpProperties;
import me.chanjar.weixin.common.redis.RedisTemplateWxRedisOps;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * 微信公众号的配置类
 *
 * @author yshop
 */
@Configuration
public class MpConfiguration {

    @Bean
    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public RedisTemplateWxRedisOps redisTemplateWxRedisOps(StringRedisTemplate stringRedisTemplate) {
        return new RedisTemplateWxRedisOps(stringRedisTemplate);
    }

    @Bean
    @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
    public MpServiceFactory mpServiceFactory(RedisTemplateWxRedisOps redisTemplateWxRedisOps,
                                             WxMpProperties wxMpProperties,
                                             MessageReceiveHandler messageReceiveHandler,
                                             KfSessionHandler kfSessionHandler,
                                             StoreCheckNotifyHandler storeCheckNotifyHandler,
                                             MenuHandler menuHandler,
                                             NullHandler nullHandler,
                                             SubscribeHandler subscribeHandler,
                                             UnsubscribeHandler unsubscribeHandler,
                                             LocationHandler locationHandler,
                                             ScanHandler scanHandler,
                                             MessageAutoReplyHandler messageAutoReplyHandler) {
        return new DefaultMpServiceFactory(redisTemplateWxRedisOps, wxMpProperties,
                messageReceiveHandler, kfSessionHandler, storeCheckNotifyHandler, menuHandler,
                nullHandler, subscribeHandler, unsubscribeHandler, locationHandler, scanHandler, messageAutoReplyHandler);
    }

}
