feat: 重构微信小程序登录模块
This commit is contained in:
38
src/main/java/com/youlai/boot/config/WxMaConfig.java
Normal file
38
src/main/java/com/youlai/boot/config/WxMaConfig.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.youlai.boot.config;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import com.youlai.boot.config.property.WxMaProperties;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 微信小程序配置
|
||||
*
|
||||
* @author Ray.Hao
|
||||
* @since 2024/01/01
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(WxMaProperties.class)
|
||||
public class WxMaConfig {
|
||||
|
||||
/**
|
||||
* 微信小程序服务
|
||||
*
|
||||
* @param properties 微信小程序配置属性
|
||||
* @return {@link WxMaService}
|
||||
*/
|
||||
@Bean
|
||||
public WxMaService wxMaService(WxMaProperties properties) {
|
||||
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
|
||||
config.setAppid(properties.getAppid());
|
||||
config.setSecret(properties.getSecret());
|
||||
|
||||
WxMaService service = new WxMaServiceImpl();
|
||||
service.setWxMaConfig(config);
|
||||
return service;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user