package com.kym.miniapp.config;

import lombok.Data;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author skyline
 * @description 微信
 * @date 2023-07-22 23:09
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "wechat.mp")
public class WxMpConfig {
    private String appid;
    private String secret;
    private String token;
    private String aeskey;


    @Bean
    public WxMpService wxMpService() {
        WxMpService service = new WxMpServiceImpl();
        WxMpDefaultConfigImpl configStorage = new WxMpDefaultConfigImpl();

        configStorage.setAppId(appid);
        configStorage.setSecret(secret);
        configStorage.setToken(token);
        configStorage.setAesKey(aeskey);
        service.addConfigStorage("MP", configStorage);
        return service;
    }

}
