package com.hfkj.config;

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

/**
 * @serviceName  .java
 * @author Sum1Dream
 * @version 1.0.0
 * @Description //TODO
 * @createTime 16:24 2022/9/2
 **/
@Configuration
public class WxMpConfig {

    /**
     * 微信客户端配置存储
     *
     * @return
     */
    @Bean
    public WxMpConfigStorage wxMpConfigStorage() {
        WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();
        // 公众号appId
        configStorage.setAppId(CommonSysConst.getSysConfig().getWechatMpAppid());
        // 公众号appSecret
        configStorage.setSecret(CommonSysConst.getSysConfig().getWechatMpSecret());
        return configStorage;
    }

    /**
     * @Author Sum1Dream
     * @Name wxMpService
     * @Description //TODO
     * @Date 16:24 2022/9/2
     * @Param []
     * @Return WxMpService
     */
    @Bean
    public WxMpService wxMpService() {
        WxMpService wxMpService = new WxMpServiceImpl();
        wxMpService.setWxMpConfigStorage(wxMpConfigStorage());
        return wxMpService;
    }
}
