public User getUser(Long uid, int retryCount){ User info = new User(); int ret = userClient.getUser(uid, info); if (RetCode.RET_SUCCESS == ret) { return info; }
public OrgInfo getOrg(Long orgId, int retryCount){ OrgInfo info = new OrgInfo(); int ret = orgClient.getOrg(orgId, info); if (RetCode.RET_SUCCESS == ret) { return info; }
public User getUser(Long uid){ return RetryUtil.invoke(() -> { User info = new User(); int ret = userClient.getUser(uid, info); if (RetCode.RET_SUCCESS == ret) { return info; } returnnull; }, Objects::isNull, // 重试条件为调用返回结果为null 5, // 等待5毫秒 3, // 重试3次 () -> new ApiException("获取用户信息失败")); // 超出重试次数抛出异常 }
public OrgInfo getOrg(Long orgId){ return RetryUtil.invoke(() -> { OrgInfo info = new OrgInfo(); int ret = orgClient.getOrg(orgId, info); if (RetCode.RET_SUCCESS == ret) { return info; } returnnull; }, Objects::isNull, 5, 3, () -> new ApiException("获取企业信息失败")); }