案例推荐-发起推送 调用用户中心接口更改

This commit is contained in:
joshen@zcwytd.com
2023-09-12 10:32:04 +08:00
parent 0bfc7dd661
commit bac127a22b
5 changed files with 25 additions and 12 deletions

View File

@@ -34,10 +34,14 @@ public class ThirdApi {
@Value("${statApi.userdynamicList}")
private String userdynamicListUrl;
@Value("${audience.getOrgUsers}")
private String searchOrgUsersUrl;
public List<UserInfoListVo> getAllUserList(UserListParam userListParam, String token) {
log.info("获取用户:url:{}|params:{}|token:{}", searchUserListUrl, JSONUtil.toJsonStr(userListParam), token);
String resp = Optional.ofNullable(HttpRequest.post(searchUserListUrl).body(JSONUtil.toJsonStr(userListParam)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
log.info("获取用户:url:{}", searchOrgUsersUrl);
log.info("获取用户:params:{}", JSONUtil.toJsonStr(userListParam));
String resp = Optional.ofNullable(HttpRequest.post(searchOrgUsersUrl).body(JSONUtil.toJsonStr(userListParam)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
UserInfoListRootBean userInfoListRootBean1 = JSONUtil.toBean(resp, UserInfoListRootBean.class);
log.info("userInfoListRootBean1 = " + userInfoListRootBean1);
List<UserInfoListVo> list = userInfoListRootBean1.getResult().getList();
@@ -53,14 +57,14 @@ public class ThirdApi {
private void getAllUserList(UserListParam userListParam, String token, List<UserInfoListVo> userInfoLists) {
log.info("获取用户2");
String resp = Optional.ofNullable(HttpRequest.post(searchUserListUrl).body(JSONUtil.toJsonStr(userListParam)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
String resp = Optional.ofNullable(HttpRequest.post(searchOrgUsersUrl).body(JSONUtil.toJsonStr(userListParam)).header("token", token).execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
log.info("获取用户返回值2 {}",resp);
Opt.ofBlankAble(resp).map(t -> JSONUtil.toBean(t, UserInfoListRootBean.class).success()).map(UserInfoListRootBean::getResult).map(UserInfoListRootBean.ResultData::getList).stream().flatMap(Collection::stream).forEach(userInfoLists::add);
}
private void nextPage(UserListParam userListParam, String token, List<UserInfoListVo> userInfoLists, UserInfoListRootBean.ResultData t) {
log.info("获取用户--" + userListParam.getPageNo());
log.info("nextPage 获取用户--" + userListParam.getPageNo());
if (t.getTotalPage() > userListParam.getPageNo()) {
REQUEST_TASK.submit(() -> IntStream.range(userListParam.getPageNo(), t.getTotalPage()).parallel().forEach(i -> getAllUserList(userListParam.withPageNo(i + 1), token, userInfoLists))).join();
}