mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 18:46:10 +08:00 
			
		
		
		
	🎨 #2811 【公众号】用户管理增加可一次性拉取所有用户数据的接口
This commit is contained in:
		| @ -93,6 +93,19 @@ public interface WxMpUserService { | |||||||
|    */ |    */ | ||||||
|   WxMpUserList userList(String nextOpenid) throws WxErrorException; |   WxMpUserList userList(String nextOpenid) throws WxErrorException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * <pre> | ||||||
|  |    * 获取用户列表(全部) | ||||||
|  |    * 公众号可通过本接口来获取帐号的关注者列表, | ||||||
|  |    * 关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。 | ||||||
|  |    * @see #userList(java.lang.String) 的增强,内部进行了多次数据拉取的汇总 | ||||||
|  |    * 详情请见: http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140840&token=&lang=zh_CN | ||||||
|  |    * http请求方式: GET(请使用https协议) | ||||||
|  |    * 接口地址:https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID | ||||||
|  |    * </pre> | ||||||
|  |    */ | ||||||
|  |   WxMpUserList userList() throws WxErrorException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|    * 微信公众号主体变更迁移用户 openid |    * 微信公众号主体变更迁移用户 openid | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ import me.chanjar.weixin.mp.bean.result.WxMpChangeOpenid; | |||||||
| import me.chanjar.weixin.mp.bean.result.WxMpUser; | import me.chanjar.weixin.mp.bean.result.WxMpUser; | ||||||
| import me.chanjar.weixin.mp.bean.result.WxMpUserList; | import me.chanjar.weixin.mp.bean.result.WxMpUserList; | ||||||
| import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | import me.chanjar.weixin.mp.util.json.WxMpGsonBuilder; | ||||||
|  | import org.apache.commons.lang3.StringUtils; | ||||||
|  |  | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| @ -52,6 +53,25 @@ public class WxMpUserServiceImpl implements WxMpUserService { | |||||||
|     return WxMpUserList.fromJson(responseContent); |     return WxMpUserList.fromJson(responseContent); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   @Override | ||||||
|  |   public WxMpUserList userList() throws WxErrorException { | ||||||
|  |     String responseContent = this.wxMpService.get(USER_GET_URL, null); | ||||||
|  |     WxMpUserList mergeList = new WxMpUserList(); | ||||||
|  |  | ||||||
|  |     WxMpUserList wxMpUserList = WxMpUserList.fromJson(responseContent); | ||||||
|  |     mergeList.getOpenids().addAll(wxMpUserList.getOpenids()); | ||||||
|  |     mergeList.setCount(wxMpUserList.getCount()); | ||||||
|  |     mergeList.setTotal(wxMpUserList.getTotal()); | ||||||
|  |  | ||||||
|  |     while (StringUtils.isNotEmpty(wxMpUserList.getNextOpenid())) { | ||||||
|  |       WxMpUserList nextReqUserList = userList(wxMpUserList.getNextOpenid()); | ||||||
|  |       mergeList.getOpenids().addAll(nextReqUserList.getOpenids()); | ||||||
|  |       mergeList.setCount(mergeList.getCount() + nextReqUserList.getCount()); | ||||||
|  |       wxMpUserList = nextReqUserList; | ||||||
|  |     } | ||||||
|  |     return mergeList; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public List<WxMpChangeOpenid> changeOpenid(String fromAppid, List<String> openidList) throws WxErrorException { |   public List<WxMpChangeOpenid> changeOpenid(String fromAppid, List<String> openidList) throws WxErrorException { | ||||||
|     Map<String, Object> map = new HashMap<>(2); |     Map<String, Object> map = new HashMap<>(2); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Cocowwy
					Cocowwy