mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	issue #79 增加批量获取用户详情的接口
This commit is contained in:
		| @ -197,7 +197,25 @@ public interface WxCpService { | ||||
|   void departDelete(Integer departId) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 获取部门成员(详情) | ||||
|    * | ||||
|    * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98.28.E8.AF.A6.E6.83.85.29 | ||||
|    * </pre> | ||||
|    * @param departId    必填。部门id | ||||
|    * @param fetchChild  非必填。1/0:是否递归获取子部门下面的成员 | ||||
|    * @param status      非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加 | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    */ | ||||
|   List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 获取部门成员 | ||||
|    * | ||||
|    * http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param departId   必填。部门id | ||||
|    * @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员 | ||||
|  | ||||
| @ -226,6 +226,28 @@ public class WxCpServiceImpl implements WxCpService { | ||||
|     return WxCpUser.fromJson(responseContent); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException { | ||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/list?department_id=" + departId; | ||||
|     String params = ""; | ||||
|     if (fetchChild != null) { | ||||
|       params += "&fetch_child=" + (fetchChild ? "1" : "0"); | ||||
|     } | ||||
|     if (status != null) { | ||||
|       params += "&status=" + status; | ||||
|     } else { | ||||
|       params += "&status=0"; | ||||
|     } | ||||
|  | ||||
|     String responseContent = get(url, params); | ||||
|     JsonElement tmpJsonElement = Streams.parse(new JsonReader(new StringReader(responseContent))); | ||||
|     return WxCpGsonBuilder.INSTANCE.create() | ||||
|         .fromJson( | ||||
|             tmpJsonElement.getAsJsonObject().get("userlist"), | ||||
|             new TypeToken<List<WxCpUser>>() { }.getType() | ||||
|         ); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException { | ||||
|     String url = "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?department_id=" + departId; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Daniel Qian
					Daniel Qian