me.chanjar.weixin.qidian.solon.config.WxQidianServiceAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weixin-java-qidian-solon-plugin Show documentation
Show all versions of weixin-java-qidian-solon-plugin Show documentation
wxjava,腾讯企点 Java SDK Solon Plugin
package me.chanjar.weixin.qidian.solon.config;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Condition;
import org.noear.solon.annotation.Configuration;
import me.chanjar.weixin.qidian.solon.enums.HttpClientType;
import me.chanjar.weixin.qidian.solon.properties.WxQidianProperties;
import me.chanjar.weixin.qidian.api.WxQidianService;
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceHttpClientImpl;
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceImpl;
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceJoddHttpImpl;
import me.chanjar.weixin.qidian.api.impl.WxQidianServiceOkHttpImpl;
import me.chanjar.weixin.qidian.config.WxQidianConfigStorage;
/**
* 腾讯企点相关服务自动注册.
*
* @author alegria
*/
@Configuration
public class WxQidianServiceAutoConfiguration {
@Bean
@Condition(onMissingBean = WxQidianService.class)
public WxQidianService wxQidianService(WxQidianConfigStorage configStorage, WxQidianProperties wxQidianProperties) {
HttpClientType httpClientType = wxQidianProperties.getConfigStorage().getHttpClientType();
WxQidianService wxQidianService;
switch (httpClientType) {
case OkHttp:
wxQidianService = newWxQidianServiceOkHttpImpl();
break;
case JoddHttp:
wxQidianService = newWxQidianServiceJoddHttpImpl();
break;
case HttpClient:
wxQidianService = newWxQidianServiceHttpClientImpl();
break;
default:
wxQidianService = newWxQidianServiceImpl();
break;
}
wxQidianService.setWxMpConfigStorage(configStorage);
return wxQidianService;
}
private WxQidianService newWxQidianServiceImpl() {
return new WxQidianServiceImpl();
}
private WxQidianService newWxQidianServiceHttpClientImpl() {
return new WxQidianServiceHttpClientImpl();
}
private WxQidianService newWxQidianServiceOkHttpImpl() {
return new WxQidianServiceOkHttpImpl();
}
private WxQidianService newWxQidianServiceJoddHttpImpl() {
return new WxQidianServiceJoddHttpImpl();
}
}