🆕 #2746 【企业微信】 增加读取学生或家长所有接口支持
This commit is contained in:
@@ -158,6 +158,40 @@ public interface WxCpSchoolUserService {
|
||||
*/
|
||||
WxCpBatchResultList batchUpdateParent(@NonNull WxCpBatchUpdateParentRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 读取学生或家长
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/get?access_token=ACCESS_TOKEN&userid=USERID
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpUserResult getUser(@NonNull String userId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取部门成员详情
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID&fetch_child=FETCH_CHILD
|
||||
*
|
||||
* @param departmentId 获取的部门id
|
||||
* @param fetchChild 1/0:是否递归获取子部门下面的成员
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpUserListResult getUserList(@NonNull Integer departmentId, Integer fetchChild) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取部门家长详情
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/user/list_parent?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID
|
||||
*
|
||||
* @param departmentId 获取的部门id
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpListParentResult getUserListParent(@NonNull Integer departmentId) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 更新家长
|
||||
* 请求方式:POST(HTTPS)
|
||||
|
||||
@@ -142,6 +142,27 @@ public class WxCpSchoolUserServiceImpl implements WxCpSchoolUserService {
|
||||
return WxCpBatchResultList.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpUserResult getUser(@NonNull String userId) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER) + userId;
|
||||
String responseContent = this.cpService.get(apiUrl, null);
|
||||
return WxCpUserResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpUserListResult getUserList(@NonNull Integer departmentId, Integer fetchChild) throws WxErrorException {
|
||||
String apiUrl = String.format(this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_LIST), departmentId, fetchChild);
|
||||
String responseContent = this.cpService.get(apiUrl, null);
|
||||
return WxCpUserListResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpListParentResult getUserListParent(@NonNull Integer departmentId) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(GET_USER_LIST_PARENT) + departmentId;
|
||||
String responseContent = this.cpService.get(apiUrl, null);
|
||||
return WxCpListParentResult.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp updateParent(@NonNull WxCpUpdateParentRequest request) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(UPDATE_PARENT);
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.io.Serializable;
|
||||
* <pre>
|
||||
* 使用user_ticket获取成员详情接口返回类.
|
||||
* Created by BinaryWang on 2018/4/22.
|
||||
* 官方文档:https://developer.work.weixin.qq.com/document/path/91122
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package me.chanjar.weixin.cp.bean.school.user;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取部门家长详情返回结果.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
* @date 2022-07-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpListParentResult extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754138L;
|
||||
|
||||
@SerializedName("parents")
|
||||
private List<Parent> parents;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Parent implements Serializable {
|
||||
|
||||
@SerializedName("parent_userid")
|
||||
private String parentUserId;
|
||||
|
||||
@SerializedName("mobile")
|
||||
private String mobile;
|
||||
|
||||
@SerializedName("external_userid")
|
||||
private String externalUserId;
|
||||
|
||||
@SerializedName("is_subscribe")
|
||||
private Integer isSubscribe;
|
||||
|
||||
@SerializedName("children")
|
||||
private List<Children> children;
|
||||
|
||||
public static Parent fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Parent.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Children implements Serializable {
|
||||
|
||||
@SerializedName("student_userid")
|
||||
private String studentUserId;
|
||||
|
||||
@SerializedName("relation")
|
||||
private String relation;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
public static Children fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Children.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpListParentResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpListParentResult.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package me.chanjar.weixin.cp.bean.school.user;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取部门成员详情返回结果.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
* @date 2022-07-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpUserListResult extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754138L;
|
||||
|
||||
@SerializedName("students")
|
||||
private List<Student> students;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Parent implements Serializable {
|
||||
|
||||
@SerializedName("parent_userid")
|
||||
private String parentUserId;
|
||||
|
||||
@SerializedName("relation")
|
||||
private String relation;
|
||||
|
||||
@SerializedName("mobile")
|
||||
private String mobile;
|
||||
|
||||
@SerializedName("external_userid")
|
||||
private String externalUserId;
|
||||
|
||||
@SerializedName("is_subscribe")
|
||||
private Integer isSubscribe;
|
||||
|
||||
public static Parent fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Parent.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Student implements Serializable {
|
||||
|
||||
@SerializedName("student_userid")
|
||||
private String studentUserId;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("department")
|
||||
private List<Integer> department;
|
||||
|
||||
@SerializedName("parents")
|
||||
private List<Parent> parents;
|
||||
|
||||
public static Student fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Student.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpUserListResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUserListResult.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package me.chanjar.weixin.cp.bean.school.user;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 读取学生或家长返回结果.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
* @date 2022-07-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpUserResult extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -4960239393895754138L;
|
||||
|
||||
@SerializedName("student")
|
||||
private Student student;
|
||||
|
||||
@SerializedName("parent")
|
||||
private Parent parent;
|
||||
|
||||
@SerializedName("user_type")
|
||||
private Integer userType;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Parent implements Serializable {
|
||||
|
||||
@SerializedName("parent_userid")
|
||||
private String parentUserId;
|
||||
|
||||
@SerializedName("relation")
|
||||
private String relation;
|
||||
|
||||
@SerializedName("mobile")
|
||||
private String mobile;
|
||||
|
||||
@SerializedName("external_userid")
|
||||
private String externalUserId;
|
||||
|
||||
@SerializedName("is_subscribe")
|
||||
private Integer isSubscribe;
|
||||
|
||||
@SerializedName("children")
|
||||
private List<Children> children;
|
||||
|
||||
public static Parent fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Parent.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Student implements Serializable {
|
||||
|
||||
@SerializedName("student_userid")
|
||||
private String studentUserId;
|
||||
|
||||
@SerializedName("department")
|
||||
private List<Integer> department;
|
||||
|
||||
@SerializedName("parents")
|
||||
private List<Parent> parents;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
public static Student fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Student.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class Children implements Serializable {
|
||||
|
||||
@SerializedName("student_userid")
|
||||
private String studentUserId;
|
||||
|
||||
@SerializedName("relation")
|
||||
private String relation;
|
||||
|
||||
public static Children fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Children.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpUserResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUserResult.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -206,6 +206,9 @@ public interface WxCpApiPathConsts {
|
||||
String CREATE_PARENT = "/cgi-bin/school/user/create_parent";
|
||||
String UPDATE_PARENT = "/cgi-bin/school/user/update_parent";
|
||||
String DELETE_PARENT = "/cgi-bin/school/user/delete_parent?userid=";
|
||||
String GET_USER = "/cgi-bin/school/user/get?userid=";
|
||||
String GET_USER_LIST = "/cgi-bin/school/user/list?department_id=%s&fetch_child=%d";
|
||||
String GET_USER_LIST_PARENT = "/cgi-bin/school/user/list_parent?department_id=";
|
||||
String SET_ARCH_SYNC_MODE = "/cgi-bin/school/set_arch_sync_mode";
|
||||
String SET_UPGRADE_INFO = "/cgi-bin/school/set_upgrade_info";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user