package cn.com.countrygarden.bi.main.configurer;

import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


@Configuration
public class WechatConfig {

  @Resource
  private WechatProperties properties;

  @Bean
  public WxMpServiceImpl wxMpConfigStorage(){
    WxMpServiceImpl service=new WxMpServiceImpl();
    //初始化微信服务配置
    final WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
    // 设置微信公众号的appid
    config.setAppId(properties.getAppId());
    // 设置微信公众号的app corpSecret
    config.setSecret(properties.getAppSecret());
    service.setWxMpConfigStorage(config);
    return service;
  }

}
