1
0
mirror of synced 2025-12-26 04:27:56 +08:00

🎨 #3458 【企业微信】家校沟通获取部门列表接口优化,如果部门id为空则获取全量组织架构

This commit is contained in:
giveup
2025-01-21 18:41:11 +08:00
committed by GitHub
parent 704fba4d85
commit 8e5ee97378
4 changed files with 143 additions and 3 deletions

View File

@@ -334,7 +334,7 @@ public interface WxCpSchoolUserService {
* 请求方式GETHTTPS
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/school/department/list?access_token=ACCESS_TOKEN&id=ID
*
* @param id the id
* @param id 部门id。获取指定部门及其下的子部门。 如果不填,默认获取全量组织架构
* @return wx cp department list
* @throws WxErrorException the wx error exception
*/

View File

@@ -16,6 +16,7 @@ import me.chanjar.weixin.cp.bean.school.user.*;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Objects;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.ExternalContact.*;
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.School.*;
@@ -246,7 +247,7 @@ public class WxCpSchoolUserServiceImpl implements WxCpSchoolUserService {
@Override
public WxCpDepartmentList listDepartment(Integer id) throws WxErrorException {
String apiUrl = this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST) + id;
String apiUrl = Objects.isNull(id) ? this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST) : String.format("%s?id=%s", this.cpService.getWxCpConfigStorage().getApiUrl(DEPARTMENT_LIST), id);
String responseContent = this.cpService.get(apiUrl, null);
return WxCpDepartmentList.fromJson(responseContent);
}

View File

@@ -691,7 +691,7 @@ public interface WxCpApiPathConsts {
/**
* The constant DEPARTMENT_LIST.
*/
String DEPARTMENT_LIST = "/cgi-bin/school/department/list?id=";
String DEPARTMENT_LIST = "/cgi-bin/school/department/list";
/**
* The constant GET_PAYMENT_RESULT.