mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-08-20 00:44:25 +08:00
🆕 #2708【企业微信】增加家校沟通-部门管理接口支持
This commit is contained in:
parent
1fbd22efac
commit
a807063f4c
@ -182,6 +182,7 @@
|
||||
1. [007gzs](https://github.com/007gzs)
|
||||
1. [Silloy](https://github.com/silloy)
|
||||
1. [mgcnrx11](https://github.com/mgcnrx11)
|
||||
1. [0katekate0 (Wang_Wong)](https://github.com/0katekate0)
|
||||
1. [yuanqixun](https://github.com/yuanqixun)
|
||||
1. [kakotor](https://github.com/kakotor)
|
||||
1. [aimilin6688 (Jonk)](https://github.com/aimilin6688)
|
||||
|
5
pom.xml
5
pom.xml
@ -97,6 +97,11 @@
|
||||
<email>xiaohe@53jy.net</email>
|
||||
<url>https://github.com/xiaohe-53</url>
|
||||
</developer>
|
||||
<developer>
|
||||
<name>Wang_Wong</name>
|
||||
<email>wangkaikate@163.com</email>
|
||||
<url>https://github.com/0katekate0</url>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
|
@ -3,8 +3,7 @@ package me.chanjar.weixin.cp.api;
|
||||
import lombok.NonNull;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.school.user.WxCpCreateParentRequest;
|
||||
import me.chanjar.weixin.cp.bean.school.user.WxCpUpdateParentRequest;
|
||||
import me.chanjar.weixin.cp.bean.school.user.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -101,4 +100,62 @@ public interface WxCpSchoolUserService {
|
||||
*/
|
||||
WxCpBaseResp setArchSyncMode(@NonNull Integer archSyncMode) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/create?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param request 请求参数对象
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpCreateDepartment createDepartment(@NonNull WxCpCreateDepartmentRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 更新部门
|
||||
* <p>
|
||||
* 请求方式:POST(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/update?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpBaseResp updateDepartment(@NonNull WxCpUpdateDepartmentRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/delete?access_token=ACCESS_TOKEN&id=ID
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpBaseResp deleteDepartment(Integer id) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
* 请求方式:GET(HTTPS)
|
||||
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/school/department/list?access_token=ACCESS_TOKEN&id=ID
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpDepartmentList listDepartment(Integer id) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 修改自动升年级的配置
|
||||
* 请求方式: POST(HTTPS)
|
||||
* 请求地址: https://qyapi.weixin.qq.com/cgi-bin/school/set_upgrade_info?access_token=ACCESS_TOKEN
|
||||
*
|
||||
* @param upgradeTime
|
||||
* @param upgradeSwitch
|
||||
* @return
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException;
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.WxCpSchoolUserService;
|
||||
import me.chanjar.weixin.cp.api.WxCpService;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.school.user.WxCpCreateParentRequest;
|
||||
import me.chanjar.weixin.cp.bean.school.user.WxCpUpdateParentRequest;
|
||||
import me.chanjar.weixin.cp.bean.school.user.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
@ -105,4 +104,46 @@ public class WxCpSchoolUserServiceImpl implements WxCpSchoolUserService {
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpCreateDepartment createDepartment(@NonNull WxCpCreateDepartmentRequest request) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_CREATE);
|
||||
String responseContent = this.cpService.post(apiUrl, request.toJson());
|
||||
return WxCpCreateDepartment.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp updateDepartment(@NonNull WxCpUpdateDepartmentRequest request) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_UPDATE);
|
||||
String responseContent = this.cpService.post(apiUrl, request.toJson());
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp deleteDepartment(Integer id) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_DELETE) + id;
|
||||
String responseContent = this.cpService.get(apiUrl, null);
|
||||
return WxCpBaseResp.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpDepartmentList listDepartment(Integer id) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST) + id;
|
||||
String responseContent = this.cpService.get(apiUrl, null);
|
||||
return WxCpDepartmentList.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpSetUpgradeInfo setUpgradeInfo(Long upgradeTime, Integer upgradeSwitch) throws WxErrorException {
|
||||
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(SET_UPGRADE_INFO);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
if (upgradeTime != null) {
|
||||
jsonObject.addProperty("upgrade_time", upgradeTime);
|
||||
}
|
||||
if (upgradeSwitch != null) {
|
||||
jsonObject.addProperty("upgrade_switch", upgradeSwitch);
|
||||
}
|
||||
String responseContent = this.cpService.post(apiUrl, jsonObject.toString());
|
||||
return WxCpSetUpgradeInfo.fromJson(responseContent);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.cp.bean.school.user;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 创建部门返回结果.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
*/
|
||||
@Data
|
||||
public class WxCpCreateDepartment extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
@SerializedName("id")
|
||||
private Integer id;
|
||||
|
||||
public static WxCpCreateDepartment fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpCreateDepartment.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
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.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建部门请求.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
* @date 2022-06-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpCreateDepartmentRequest implements Serializable {
|
||||
private static final long serialVersionUID = -4960239394895754138L;
|
||||
|
||||
@SerializedName("parentid")
|
||||
private Integer parentId;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("id")
|
||||
private Integer id;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("register_year")
|
||||
private Integer registerYear;
|
||||
|
||||
@SerializedName("standard_grade")
|
||||
private Integer standardGrade;
|
||||
|
||||
@SerializedName("order")
|
||||
private Integer order;
|
||||
|
||||
@SerializedName("department_admins")
|
||||
private List<DepartmentAdmin> departmentAdmins;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class DepartmentAdmin implements Serializable {
|
||||
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("subject")
|
||||
private String subject;
|
||||
|
||||
public static DepartmentAdmin fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, DepartmentAdmin.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpCreateDepartmentRequest fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpCreateDepartmentRequest.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package me.chanjar.weixin.cp.bean.school.user;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
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
|
||||
*/
|
||||
@Data
|
||||
public class WxCpDepartmentList extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
@SerializedName("departments")
|
||||
private List<Department> departments;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class Department implements Serializable{
|
||||
@SerializedName("parentid")
|
||||
private Integer parentId;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("id")
|
||||
private Integer id;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("register_year")
|
||||
private Integer registerYear;
|
||||
|
||||
@SerializedName("standard_grade")
|
||||
private Integer standardGrade;
|
||||
|
||||
@SerializedName("order")
|
||||
private Integer order;
|
||||
|
||||
@SerializedName("is_graduated")
|
||||
private Integer isGraduated;
|
||||
|
||||
@SerializedName("open_group_chat")
|
||||
private Integer openGroupChat;
|
||||
|
||||
@SerializedName("group_chat_id")
|
||||
private String groupChatId;
|
||||
|
||||
@SerializedName("department_admins")
|
||||
private List<DepartmentAdmin> departmentAdmins;
|
||||
|
||||
public static Department fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, Department.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class DepartmentAdmin implements Serializable {
|
||||
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("subject")
|
||||
private String subject;
|
||||
|
||||
public static DepartmentAdmin fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, DepartmentAdmin.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpDepartmentList fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpDepartmentList.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.cp.bean.school.user;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 修改自动升年级的配置 返回结果.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
*/
|
||||
@Data
|
||||
public class WxCpSetUpgradeInfo extends WxCpBaseResp implements Serializable {
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
@SerializedName("next_upgrade_time")
|
||||
private Long nextUpgradeTime;
|
||||
|
||||
public static WxCpSetUpgradeInfo fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpSetUpgradeInfo.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
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.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 更新部门请求.
|
||||
*
|
||||
* @author Wang_Wong
|
||||
* @date 2022-06-22
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class WxCpUpdateDepartmentRequest implements Serializable {
|
||||
private static final long serialVersionUID = -4960239394895754138L;
|
||||
|
||||
@SerializedName("parentid")
|
||||
private Integer parentId;
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
|
||||
@SerializedName("id")
|
||||
private Integer id;
|
||||
|
||||
@SerializedName("new_id")
|
||||
private Integer newId;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("register_year")
|
||||
private Integer registerYear;
|
||||
|
||||
@SerializedName("standard_grade")
|
||||
private Integer standardGrade;
|
||||
|
||||
@SerializedName("order")
|
||||
private Integer order;
|
||||
|
||||
@SerializedName("department_admins")
|
||||
private List<DepartmentAdmin> departmentAdmins;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class DepartmentAdmin implements Serializable {
|
||||
|
||||
@SerializedName("userid")
|
||||
private String userId;
|
||||
|
||||
@SerializedName("op")
|
||||
private Integer op;
|
||||
|
||||
@SerializedName("type")
|
||||
private Integer type;
|
||||
|
||||
@SerializedName("subject")
|
||||
private String subject;
|
||||
|
||||
public static DepartmentAdmin fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, DepartmentAdmin.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static WxCpUpdateDepartmentRequest fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpUpdateDepartmentRequest.class);
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -190,6 +190,12 @@ public interface WxCpApiPathConsts {
|
||||
String UPDATE_PARENT = "/cgi-bin/school/user/update_parent";
|
||||
String DELETE_PARENT = "/cgi-bin/school/user/delete_parent?userid=";
|
||||
String SET_ARCH_SYNC_MODE = "/cgi-bin/school/set_arch_sync_mode";
|
||||
String SET_UPGRADE_INFO = "/cgi-bin/school/set_upgrade_info";
|
||||
|
||||
String DEPARTMENT_CREATE = "/cgi-bin/school/department/create";
|
||||
String DEPARTMENT_UPDATE = "/cgi-bin/school/department/update";
|
||||
String DEPARTMENT_DELETE = "/cgi-bin/school/department/delete?id=";
|
||||
String DEPARTMENT_LIST = "/cgi-bin/school/department/list?id=";
|
||||
|
||||
String GET_PAYMENT_RESULT = "/cgi-bin/school/get_payment_result";
|
||||
String GET_TRADE = "/cgi-bin/school/get_trade";
|
||||
|
@ -6,8 +6,7 @@ import lombok.var;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.school.user.WxCpCreateParentRequest;
|
||||
import me.chanjar.weixin.cp.bean.school.user.WxCpUpdateParentRequest;
|
||||
import me.chanjar.weixin.cp.bean.school.user.*;
|
||||
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
|
||||
import me.chanjar.weixin.cp.demo.WxCpDemoInMemoryConfigStorage;
|
||||
import org.testng.annotations.Test;
|
||||
@ -44,6 +43,72 @@ public class WxCpSchoolUserTest {
|
||||
list.add(3);
|
||||
log.info("list:{}", list.toString());
|
||||
|
||||
final String userId = "WangKai";
|
||||
|
||||
|
||||
/**
|
||||
* 修改自动升年级的配置
|
||||
* https://developer.work.weixin.qq.com/document/path/92949
|
||||
*/
|
||||
WxCpSetUpgradeInfo wxCpSetUpgradeInfo = cpService.getSchoolUserService().setUpgradeInfo(1594090969L, 2);
|
||||
log.info("wxCpSetUpgradeInfo:{}", wxCpSetUpgradeInfo.toJson());
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
* https://developer.work.weixin.qq.com/document/path/92343
|
||||
*/
|
||||
String str5 = "{\"errcode\":0,\"errmsg\":\"ok\",\"departments\":[{\"name\":\"一年级\",\"parentid\":1,\"id\":2,\"type\":2,\"register_year\":2018,\"standard_grade\":1,\"order\":1,\"department_admins\":[{\"userid\":\"zhangsan\",\"type\":1},{\"userid\":\"lisi\",\"type\":2}],\"is_graduated\":0},{\"name\":\"一年级一班\",\"parentid\":1,\"id\":3,\"type\":1,\"department_admins\":[{\"userid\":\"zhangsan\",\"type\":3,\"subject\":\"语文\"},{\"userid\":\"lisi\",\"type\":4,\"subject\":\"数学\"}],\"open_group_chat\":1,\"group_chat_id\":\"group_chat_id\"}]}";
|
||||
WxCpDepartmentList wxCpDepartmentList = WxCpDepartmentList.fromJson(str5);
|
||||
log.info("wxCpDepartmentList:{}", wxCpDepartmentList.toJson());
|
||||
|
||||
WxCpDepartmentList departmentList = cpService.getSchoolUserService().listDepartment(7);
|
||||
log.info("departmentList:{}", departmentList.toJson());
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* https://developer.work.weixin.qq.com/document/path/92342
|
||||
*/
|
||||
WxCpBaseResp deleteDepartment = cpService.getSchoolUserService().deleteDepartment(7);
|
||||
log.info("deleteDepartment:{}", deleteDepartment.toJson());
|
||||
|
||||
/**
|
||||
* 更新部门
|
||||
* https://developer.work.weixin.qq.com/document/path/92341
|
||||
*/
|
||||
String str4 = "{\"name\":\"一年级\",\"parentid\":5,\"id\":2,\"register_year\":2018,\"standard_grade\":1,\"order\":1,\"new_id\":100,\"department_admins\":[{\"op\":0,\"userid\":\"zhangsan\",\"type\":3,\"subject\":\"语文\"},{\"op\":1,\"userid\":\"lisi\",\"type\":4,\"subject\":\"数学\"}]}";
|
||||
WxCpUpdateDepartmentRequest wxCpUpdateDepartmentRequest = WxCpUpdateDepartmentRequest.fromJson(str4);
|
||||
log.info("wxCpUpdateParentRequest:{}", wxCpUpdateDepartmentRequest.toJson());
|
||||
|
||||
WxCpBaseResp updateDepartment = cpService.getSchoolUserService().updateDepartment(wxCpUpdateDepartmentRequest);
|
||||
log.info("updateDepartment:{}", updateDepartment.toJson());
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
* https://developer.work.weixin.qq.com/document/path/92340
|
||||
*/
|
||||
String str3 = "{\"name\":\"一年级\",\"parentid\":5,\"id\":2,\"type\":1,\"register_year\":2018,\"standard_grade\":1,\"order\":1,\"department_admins\":[{\"userid\":\"zhangsan\",\"type\":4,\"subject\":\"语文\"},{\"userid\":\"lisi\",\"type\":3,\"subject\":\"数学\"}]}";
|
||||
WxCpCreateDepartmentRequest wxCpCreateDepartmentRequest = WxCpCreateDepartmentRequest.fromJson(str3);
|
||||
log.info("wxCpCreateDepartmentRequest:{}", wxCpCreateDepartmentRequest.toJson());
|
||||
|
||||
WxCpCreateDepartmentRequest createDepartmentRequest = new WxCpCreateDepartmentRequest();
|
||||
createDepartmentRequest.setParentId(5);
|
||||
createDepartmentRequest.setName("一年级");
|
||||
createDepartmentRequest.setId(2);
|
||||
createDepartmentRequest.setType(1);
|
||||
createDepartmentRequest.setRegisterYear(2018);
|
||||
createDepartmentRequest.setStandardGrade(1);
|
||||
createDepartmentRequest.setOrder(1);
|
||||
|
||||
var departmentAdmin = new WxCpCreateDepartmentRequest.DepartmentAdmin();
|
||||
departmentAdmin.setUserId(userId);
|
||||
departmentAdmin.setType(4);
|
||||
departmentAdmin.setSubject("英语");
|
||||
List<WxCpCreateDepartmentRequest.DepartmentAdmin> createDepartList = Lists.newArrayList();
|
||||
createDepartList.add(departmentAdmin);
|
||||
|
||||
createDepartmentRequest.setDepartmentAdmins(createDepartList);
|
||||
WxCpCreateDepartment createDepartment = cpService.getSchoolUserService().createDepartment(createDepartmentRequest);
|
||||
log.info("createDepartment:{}", createDepartment.toJson());
|
||||
|
||||
/**
|
||||
* 更新家长
|
||||
|
Loading…
Reference in New Issue
Block a user