集成网络检测和获取 IP 地址的 API ,这个代码还需要优化加入 Request 的拦截器
This commit is contained in:
parent
485a6da98a
commit
48560e611f
|
@ -4,6 +4,7 @@ import com.ossez.wechat.common.config.ConfigStorage;
|
|||
import com.ossez.wechat.demo.common.enums.HttpClientCategory;
|
||||
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
|
||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
@ -34,4 +35,13 @@ public class WeChatConfiguration {
|
|||
weChatOfficialAccountService.setWxMpConfigStorage(configStorage);
|
||||
return weChatOfficialAccountService;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public WeChatPlatformService weChatPlatformService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
||||
WeChatPlatformService weChatPlatformService = new WeChatPlatformService();
|
||||
|
||||
weChatPlatformService.setWeChatOfficialAccountService(weChatOfficialAccountService);
|
||||
return weChatPlatformService;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package com.ossez.wechat.demo.controller;
|
|||
import com.ossez.wechat.common.exception.WxErrorException;
|
||||
|
||||
import com.ossez.wechat.demo.data.repository.redis.StudentRepository;
|
||||
import com.ossez.wechat.demo.model.entity.Student;
|
||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -23,11 +23,13 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class WeChatController {
|
||||
|
||||
private final WeChatOfficialAccountService weChatOfficialAccountService;
|
||||
private final WeChatPlatformService weChatPlatformService;
|
||||
private final StudentRepository studentRepository;
|
||||
|
||||
@Autowired
|
||||
public WeChatController(WeChatOfficialAccountService weChatOfficialAccountService, StudentRepository studentRepository) {
|
||||
public WeChatController(WeChatOfficialAccountService weChatOfficialAccountService, WeChatPlatformService weChatPlatformService, StudentRepository studentRepository) {
|
||||
this.weChatOfficialAccountService = weChatOfficialAccountService;
|
||||
this.weChatPlatformService = weChatPlatformService;
|
||||
this.studentRepository = studentRepository;
|
||||
}
|
||||
|
||||
|
@ -48,7 +50,14 @@ public class WeChatController {
|
|||
@ResponseBody
|
||||
public String getDomainIPs() throws WxErrorException {
|
||||
log.debug("Get access token from WeChat");
|
||||
return weChatOfficialAccountService.getDomainIPs();
|
||||
return weChatPlatformService.getDomainIPs();
|
||||
}
|
||||
|
||||
@GetMapping("/network_check")
|
||||
@ResponseBody
|
||||
public String checkNetwork() throws WxErrorException {
|
||||
log.debug("Get access token from WeChat");
|
||||
return weChatPlatformService.checkNetwork();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue