tjx
2025-11-26 04b8f2ff696b53cd3f4b4bcf7d11dc3a62a4a65a
src/main/java/com/gs/xky/service/WorkWXService.java
@@ -180,6 +180,38 @@
        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);
@@ -288,6 +320,20 @@
    }
    @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;