| | |
| | | return getCheckinData(startTime, endTime, useridList); |
| | | } |
| | | |
| | | public WorkWXUserDetail getUserDetail(String userid) throws IOException { |
| | | String accessToken = getContactAccessToken(); |
| | | String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s", |
| | | accessToken, userid); |
| | | |
| | | Request request = new Request.Builder() |
| | | .url(url) |
| | | .get() |
| | | .build(); |
| | | |
| | | try (Response response = client.newCall(request).execute()) { |
| | | if (!response.isSuccessful()) { |
| | | log.error("获取用户详情失败,HTTP状态码: {}", response.code()); |
| | | throw new IOException("获取用户详情失败: " + response.message()); |
| | | } |
| | | |
| | | String responseBody = response.body().string(); |
| | | log.info("获取用户详情响应: {}", responseBody); |
| | | |
| | | WorkWXUserDetailResponse userDetailResponse = objectMapper.readValue(responseBody, WorkWXUserDetailResponse.class); |
| | | |
| | | if (userDetailResponse.getErrcode() != 0) { |
| | | log.error("获取用户详情失败,错误码: {}, 错误信息: {}", |
| | | userDetailResponse.getErrcode(), userDetailResponse.getErrmsg()); |
| | | throw new IOException("获取用户详情失败: " + userDetailResponse.getErrmsg()); |
| | | } |
| | | |
| | | log.info("成功获取用户 {} 的详情", userid); |
| | | return userDetailResponse; |
| | | } |
| | | } |
| | | |
| | | public List<CheckinData> getCheckinData(long startTime, long endTime, List<String> useridList) throws IOException { |
| | | String accessToken = getAccessToken(); |
| | | String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/checkin/getcheckindata?access_token=%s", accessToken); |
| | |
| | | } |
| | | |
| | | @Data |
| | | public static class WorkWXUserDetail { |
| | | private Integer errcode; |
| | | private String errmsg; |
| | | private String userid; |
| | | private String name; |
| | | private String mobile; |
| | | private String position; |
| | | } |
| | | |
| | | @Data |
| | | private static class WorkWXUserDetailResponse extends WorkWXUserDetail { |
| | | } |
| | | |
| | | @Data |
| | | private static class WorkWXCheckinResponse { |
| | | private Integer errcode; |
| | | private String errmsg; |