weixin4j-qy: 管理成员新增头像参数
This commit is contained in:
parent
bc937b4095
commit
25998e2605
@ -356,3 +356,5 @@
|
||||
* 2015-06-26
|
||||
|
||||
+ 将微信支付模块移到base工程
|
||||
|
||||
+ **weixin4j-qy**: 管理成员新增头像参数
|
||||
@ -65,3 +65,7 @@
|
||||
* 2015-06-24
|
||||
|
||||
+ 新增userid与openid互换接口
|
||||
|
||||
* 2015-06-26
|
||||
|
||||
+ 管理成员新增头像参数
|
||||
@ -392,6 +392,24 @@ public class WeixinProxy {
|
||||
return userApi.createUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @param avatar
|
||||
* 头像文件
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.9B.E5.BB.BA.E6.88.90.E5.91.98">创建成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult createUser(User user, File avatar) throws WeixinException {
|
||||
return userApi.createUser(user, avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户(如果非必须的字段未指定 则不更新该字段之前的设置值)
|
||||
*
|
||||
@ -408,6 +426,24 @@ public class WeixinProxy {
|
||||
return userApi.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户(如果非必须的字段未指定 则不更新该字段之前的设置值)
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @param avatar
|
||||
* 头像文件
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">更新成员说明</a>
|
||||
* @see com.foxinmy.weixin4j.qy.api.UserApi
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult updateUser(User user, File avatar) throws WeixinException {
|
||||
return userApi.updateUser(user, avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成员
|
||||
*
|
||||
@ -852,8 +888,8 @@ public class WeixinProxy {
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E8.8E.B7.E5.8F.96.E5.BC.82.E6.AD.A5.E4.BB.BB.E5.8A.A1.E7.BB.93.E6.9E.9C">获取异步任务执行结果</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public BatchResult getresult(String jobId) throws WeixinException {
|
||||
return batchApi.getresult(jobId);
|
||||
public BatchResult getBatchResult(String jobId) throws WeixinException {
|
||||
return batchApi.getBatchResult(jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -161,7 +161,7 @@ public class BatchApi extends QyApi {
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E5%BC%82%E6%AD%A5%E4%BB%BB%E5%8A%A1%E6%8E%A5%E5%8F%A3#.E8.8E.B7.E5.8F.96.E5.BC.82.E6.AD.A5.E4.BB.BB.E5.8A.A1.E7.BB.93.E6.9E.9C">获取异步任务执行结果</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public BatchResult getresult(String jobId) throws WeixinException {
|
||||
public BatchResult getBatchResult(String jobId) throws WeixinException {
|
||||
Token token = tokenHolder.getToken();
|
||||
String batch_getresult_uri = getRequestUri("batch_getresult_uri");
|
||||
WeixinResponse response = weixinClient.get(String.format(batch_getresult_uri,
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.foxinmy.weixin4j.qy.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -28,10 +30,12 @@ import com.foxinmy.weixin4j.token.TokenHolder;
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98">管理成员说明</a>
|
||||
*/
|
||||
public class UserApi extends QyApi {
|
||||
private final MediaApi mediaApi;
|
||||
private final TokenHolder tokenHolder;
|
||||
|
||||
public UserApi(TokenHolder tokenHolder) {
|
||||
this.tokenHolder = tokenHolder;
|
||||
this.mediaApi = new MediaApi(tokenHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,7 +51,25 @@ public class UserApi extends QyApi {
|
||||
*/
|
||||
public JsonResult createUser(User user) throws WeixinException {
|
||||
String user_create_uri = getRequestUri("user_create_uri");
|
||||
return excute(user_create_uri, user);
|
||||
return excute(user_create_uri, user, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建成员
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @param avatar
|
||||
* 头像文件
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E5.88.9B.E5.BB.BA.E6.88.90.E5.91.98">创建成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult createUser(User user, File avatar) throws WeixinException {
|
||||
String user_create_uri = getRequestUri("user_create_uri");
|
||||
return excute(user_create_uri, user, avatar);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,10 +85,29 @@ public class UserApi extends QyApi {
|
||||
*/
|
||||
public JsonResult updateUser(User user) throws WeixinException {
|
||||
String user_update_uri = getRequestUri("user_update_uri");
|
||||
return excute(user_update_uri, user);
|
||||
return excute(user_update_uri, user, null);
|
||||
}
|
||||
|
||||
private JsonResult excute(String uri, User user) throws WeixinException {
|
||||
/**
|
||||
* 更新用户(如果非必须的字段未指定 则不更新该字段之前的设置值)
|
||||
*
|
||||
* @param user
|
||||
* 成员对象
|
||||
* @param avatar
|
||||
* 头像文件
|
||||
* @see com.foxinmy.weixin4j.qy.model.User
|
||||
* @see <a
|
||||
* href="http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%88%90%E5%91%98#.E6.9B.B4.E6.96.B0.E6.88.90.E5.91.98">更新成员说明</a>
|
||||
* @return 处理结果
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public JsonResult updateUser(User user, File avatar) throws WeixinException {
|
||||
String user_update_uri = getRequestUri("user_update_uri");
|
||||
return excute(user_update_uri, user, avatar);
|
||||
}
|
||||
|
||||
private JsonResult excute(String uri, User user, File avatar)
|
||||
throws WeixinException {
|
||||
JSONObject obj = (JSONObject) JSON.toJSON(user);
|
||||
Object extattr = obj.remove("extattr");
|
||||
if (extattr != null) {
|
||||
@ -74,6 +115,13 @@ public class UserApi extends QyApi {
|
||||
attrs.put("attrs", extattr);
|
||||
obj.put("extattr", attrs);
|
||||
}
|
||||
if (avatar != null) {
|
||||
try {
|
||||
obj.put("avatar_mediaid", mediaApi.uploadMedia(avatar));
|
||||
} catch (IOException e) {
|
||||
throw new WeixinException(e);
|
||||
}
|
||||
}
|
||||
Token token = tokenHolder.getToken();
|
||||
WeixinResponse response = weixinClient.post(
|
||||
String.format(uri, token.getAccessToken()), obj.toJSONString());
|
||||
|
||||
@ -55,7 +55,7 @@ public class BatchTest extends TokenTest {
|
||||
@Test
|
||||
public void getresult() throws WeixinException {
|
||||
BatchResult result = batchApi
|
||||
.getresult("PVucPBfEapLnvQZ1ru2Vdw3Dbl-jXs3AEQdS24cqmI0");
|
||||
.getBatchResult("PVucPBfEapLnvQZ1ru2Vdw3Dbl-jXs3AEQdS24cqmI0");
|
||||
System.err.println(result);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user