持续优化代码
This commit is contained in:
@@ -311,7 +311,7 @@ public class WeixinProxy {
|
||||
* 查询部门列表(以部门的order字段从小到大排列)
|
||||
*
|
||||
* @param partyId
|
||||
* 部门ID。获取指定部门ID下的子部门
|
||||
* 部门ID。获取指定部门ID下的子部门 传入0表示获取全部子部门
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E5.88.97.E8.A1.A8">获取部门列表</a>
|
||||
|
||||
@@ -87,7 +87,7 @@ public class PartyApi extends QyApi {
|
||||
* 查询部门列表(以部门的order字段从小到大排列)
|
||||
*
|
||||
* @param partId
|
||||
* 部门ID。获取指定部门ID下的子部门
|
||||
* 部门ID。获取指定部门ID下的子部门 传入0表示获取全部子部门
|
||||
* @see com.foxinmy.weixin4j.qy.model.Party
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E9%83%A8%E9%97%A8#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E5.88.97.E8.A1.A8">获取部门列表</a>
|
||||
@@ -96,6 +96,9 @@ public class PartyApi extends QyApi {
|
||||
*/
|
||||
public List<Party> listParty(int partId) throws WeixinException {
|
||||
String department_list_uri = getRequestUri("department_list_uri");
|
||||
if (partId > 0) {
|
||||
department_list_uri += String.format("&id=%d", partId);
|
||||
}
|
||||
Token token = tokenHolder.getToken();
|
||||
WeixinResponse response = weixinClient.post(String.format(
|
||||
department_list_uri, token.getAccessToken()));
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.foxinmy.weixin4j.qy.api;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.TypeReference;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.weixin.JsonResult;
|
||||
import com.foxinmy.weixin4j.http.weixin.WeixinResponse;
|
||||
@@ -198,8 +197,10 @@ public class SuiteApi extends QyApi {
|
||||
WeixinResponse response = weixinClient.post(
|
||||
String.format(suite_get_authinfo_uri,
|
||||
suiteTokenHolder.getAccessToken()), obj.toJSONString());
|
||||
return response.getAsObject(new TypeReference<OUserInfo>() {
|
||||
});
|
||||
obj = response.getAsJson();
|
||||
obj.put("corp_info", obj.remove("auth_corp_info"));
|
||||
obj.put("user_info", obj.remove("auth_user_info"));
|
||||
return JSON.toJavaObject(obj, OUserInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PartyTest extends TokenTest {
|
||||
|
||||
@Test
|
||||
public void list() throws WeixinException {
|
||||
List<Party> list = partyApi.listParty(1);
|
||||
List<Party> list = partyApi.listParty(0);
|
||||
Assert.assertFalse(list.isEmpty());
|
||||
System.out.println(list);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user