For testing and Spring DI, we use new way to approach
This commit is contained in:
parent
48560e611f
commit
f1794ee3ef
1831
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
1831
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
.idea/jarRepositories.xml
generated
10
.idea/jarRepositories.xml
generated
@ -16,6 +16,11 @@
|
|||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="ossez-repo-snapshots" />
|
||||||
|
<option name="name" value="OSSEZ Private Snapshots" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Maven Central repository" />
|
<option name="name" value="Maven Central repository" />
|
||||||
@ -26,5 +31,10 @@
|
|||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="ossez-repo-releases" />
|
||||||
|
<option name="name" value="OSSEZ Private Releases" />
|
||||||
|
<option name="url" value="https://repo.ossez.com/repository/maven-public/" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -1,11 +1,13 @@
|
|||||||
package com.ossez.wechat.demo.config;
|
package com.ossez.wechat.demo.config;
|
||||||
|
|
||||||
import com.ossez.wechat.common.config.ConfigStorage;
|
import com.ossez.wechat.common.config.ConfigStorage;
|
||||||
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
import com.ossez.wechat.demo.common.enums.HttpClientCategory;
|
import com.ossez.wechat.demo.common.enums.HttpClientCategory;
|
||||||
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
|
import com.ossez.wechat.demo.properties.WeChatOfficialAccountProperties;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
|
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
|
import com.ossez.wechat.oa.api.impl.okhttp.WeChatOfficialAccountServiceOkHttp;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -39,7 +41,14 @@ public class WeChatConfiguration {
|
|||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
public WeChatPlatformService weChatPlatformService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
public WeChatPlatformService weChatPlatformService(WeChatOfficialAccountService weChatOfficialAccountService) {
|
||||||
WeChatPlatformService weChatPlatformService = new WeChatPlatformService();
|
String accessToken = StringUtils.EMPTY;
|
||||||
|
try {
|
||||||
|
accessToken = weChatOfficialAccountService.getAccessToken();
|
||||||
|
} catch (WxErrorException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
WeChatPlatformService weChatPlatformService = new WeChatPlatformService(accessToken);
|
||||||
|
|
||||||
weChatPlatformService.setWeChatOfficialAccountService(weChatOfficialAccountService);
|
weChatPlatformService.setWeChatOfficialAccountService(weChatOfficialAccountService);
|
||||||
return weChatPlatformService;
|
return weChatPlatformService;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.ossez.wechat.demo.controller;
|
package com.ossez.wechat.demo.controller;
|
||||||
|
|
||||||
import com.ossez.wechat.common.exception.WxErrorException;
|
import com.ossez.wechat.common.exception.WxErrorException;
|
||||||
|
import com.ossez.wechat.common.model.res.NetworkCheckResponse;
|
||||||
|
import com.ossez.wechat.common.model.res.QueryQuotaResponse;
|
||||||
import com.ossez.wechat.demo.data.repository.redis.StudentRepository;
|
import com.ossez.wechat.demo.data.repository.redis.StudentRepository;
|
||||||
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
import com.ossez.wechat.oa.api.WeChatOfficialAccountService;
|
||||||
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
|
import com.ossez.wechat.oa.api.impl.okhttp.WeChatPlatformService;
|
||||||
@ -46,18 +47,25 @@ public class WeChatController {
|
|||||||
return weChatOfficialAccountService.getAccessToken(true);
|
return weChatOfficialAccountService.getAccessToken(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/api_domain_ip")
|
@GetMapping("/ip")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String getDomainIPs() throws WxErrorException {
|
public String getDomainIPs() throws WxErrorException {
|
||||||
log.debug("Get access token from WeChat");
|
log.debug("Get access token from WeChat");
|
||||||
return weChatPlatformService.getDomainIPs();
|
return weChatPlatformService.getDomainIPs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/network_check")
|
@GetMapping("/networkcheck")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String checkNetwork() throws WxErrorException {
|
public NetworkCheckResponse checkNetwork() throws WxErrorException {
|
||||||
log.debug("Get access token from WeChat");
|
log.debug("Get access token from WeChat");
|
||||||
return weChatPlatformService.checkNetwork();
|
return weChatPlatformService.checkNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/query/quota")
|
||||||
|
@ResponseBody
|
||||||
|
public QueryQuotaResponse queryQuota() throws WxErrorException {
|
||||||
|
log.debug("Get access token from WeChat");
|
||||||
|
return weChatPlatformService.queryQuota();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,8 @@ package com.ossez.wechat.demo;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.Period;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -19,7 +17,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
class DateTest {
|
class DataTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStartAndEndDateTime() {
|
public void testStartAndEndDateTime() {
|
||||||
@ -30,6 +28,17 @@ class DateTest {
|
|||||||
Map<Integer, Boolean> map2 = reqIds.stream().collect(Collectors.toMap(Function.identity(), reqs::contains));
|
Map<Integer, Boolean> map2 = reqIds.stream().collect(Collectors.toMap(Function.identity(), reqs::contains));
|
||||||
|
|
||||||
log.debug("Map Size {}",11+20);
|
log.debug("Map Size {}",11+20);
|
||||||
|
|
||||||
|
log.debug("Map Size {}", map2);
|
||||||
|
|
||||||
|
|
||||||
|
List<Integer> shiftIds = Arrays.asList(1, 2);
|
||||||
|
Map<Integer, Boolean> shiftIdMaps = new HashMap<Integer, Boolean>();
|
||||||
|
shiftIdMaps.put(1, Boolean.TRUE);
|
||||||
|
List<Integer> reponse = shiftIds.stream().filter(item -> shiftIdMaps.get(item) == Boolean.TRUE).collect(Collectors.toList());
|
||||||
|
log.debug("Map Size {}", reponse);
|
||||||
|
|
||||||
|
log.debug("Map Size {}",map2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user