@Test public void testUserId2Openid() throws Exception { Map<String, String> result = this.wxCpService.getUserService().userId2Openid(userId, null); System.out.println(result); assertNotNull(result); }
@Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = "https: JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonElement tmpJsonElement = new JsonParser().parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJsonElement.getAsJsonObject().get("openid") != null) { result.put("openid", tmpJsonElement.getAsJsonObject().get("openid").getAsString()); } if (tmpJsonElement.getAsJsonObject().get("appid") != null) { result.put("appid", tmpJsonElement.getAsJsonObject().get("appid").getAsString()); } return result; }
WxCpUserServiceImpl implements WxCpUserService { @Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = "https: JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonElement tmpJsonElement = new JsonParser().parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJsonElement.getAsJsonObject().get("openid") != null) { result.put("openid", tmpJsonElement.getAsJsonObject().get("openid").getAsString()); } if (tmpJsonElement.getAsJsonObject().get("appid") != null) { result.put("appid", tmpJsonElement.getAsJsonObject().get("appid").getAsString()); } return result; } }
WxCpUserServiceImpl implements WxCpUserService { @Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = "https: JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonElement tmpJsonElement = new JsonParser().parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJsonElement.getAsJsonObject().get("openid") != null) { result.put("openid", tmpJsonElement.getAsJsonObject().get("openid").getAsString()); } if (tmpJsonElement.getAsJsonObject().get("appid") != null) { result.put("appid", tmpJsonElement.getAsJsonObject().get("appid").getAsString()); } return result; } WxCpUserServiceImpl(WxCpService mainService); }
WxCpUserServiceImpl implements WxCpUserService { @Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = "https: JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonElement tmpJsonElement = new JsonParser().parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJsonElement.getAsJsonObject().get("openid") != null) { result.put("openid", tmpJsonElement.getAsJsonObject().get("openid").getAsString()); } if (tmpJsonElement.getAsJsonObject().get("appid") != null) { result.put("appid", tmpJsonElement.getAsJsonObject().get("appid").getAsString()); } return result; } WxCpUserServiceImpl(WxCpService mainService); @Override void authenticate(String userId); @Override void create(WxCpUser user); @Override void update(WxCpUser user); @Override void delete(String... userIds); @Override WxCpUser getById(String userid); @Override List<WxCpUser> listByDepartment(Integer departId, Boolean fetchChild, Integer status); @Override List<WxCpUser> listSimpleByDepartment(Integer departId, Boolean fetchChild, Integer status); @Override WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds); @Override Map<String, String> userId2Openid(String userId, Integer agentId); @Override String openid2UserId(String openid); }
WxCpUserServiceImpl implements WxCpUserService { @Override public Map<String, String> userId2Openid(String userId, Integer agentId) throws WxErrorException { String url = "https: JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userid", userId); if (agentId != null) { jsonObject.addProperty("agentid", agentId); } String responseContent = this.mainService.post(url, jsonObject.toString()); JsonElement tmpJsonElement = new JsonParser().parse(responseContent); Map<String, String> result = Maps.newHashMap(); if (tmpJsonElement.getAsJsonObject().get("openid") != null) { result.put("openid", tmpJsonElement.getAsJsonObject().get("openid").getAsString()); } if (tmpJsonElement.getAsJsonObject().get("appid") != null) { result.put("appid", tmpJsonElement.getAsJsonObject().get("appid").getAsString()); } return result; } WxCpUserServiceImpl(WxCpService mainService); @Override void authenticate(String userId); @Override void create(WxCpUser user); @Override void update(WxCpUser user); @Override void delete(String... userIds); @Override WxCpUser getById(String userid); @Override List<WxCpUser> listByDepartment(Integer departId, Boolean fetchChild, Integer status); @Override List<WxCpUser> listSimpleByDepartment(Integer departId, Boolean fetchChild, Integer status); @Override WxCpInviteResult invite(List<String> userIds, List<String> partyIds, List<String> tagIds); @Override Map<String, String> userId2Openid(String userId, Integer agentId); @Override String openid2UserId(String openid);  }