企业号:增加用户进入应用的callback事件&增加批量获取用户详情的接口
This commit is contained in:
parent
96b3080c2d
commit
3f4c174580
@ -198,6 +198,12 @@ netty的代码没有放到maven中心仓库,也没什么意义,因为最终需
|
||||
|
||||
+ change the version to 1.1
|
||||
|
||||
* 2014-12-28
|
||||
|
||||
+ **weixin4j-qy**:增加用户进入应用的callback事件
|
||||
|
||||
+ **weixin4j-qy**:增加批量获取用户详情的接口
|
||||
|
||||
接下来
|
||||
------
|
||||
* 微信小店
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>weixin4j</name>
|
||||
<url>https://github.com/foxinmy/weixin4j</url>
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-base</artifactId>
|
||||
<name>weixin4j-base</name>
|
||||
|
||||
@ -34,7 +34,7 @@ public class BaseMsg implements Serializable {
|
||||
}
|
||||
|
||||
public BaseMsg(String msgType) {
|
||||
this(msgType, null, null);
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public BaseMsg(String toUserName, String fromUserName) {
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
package com.foxinmy.weixin4j.msg.event;
|
||||
|
||||
import com.foxinmy.weixin4j.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 用户进入应用的事件推送(企业号)本事件只有在应用的回调模式中打开上报开关时上报
|
||||
*
|
||||
* @className EnterAgentEventMessage
|
||||
* @author jy
|
||||
* @date 2014年12月28日
|
||||
* @since JDK 1.7
|
||||
* @see<a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E4%BA%8B%E4%BB%B6#.E7.94.A8.E6.88.B7.E8.BF.9B.E5.85.A5.E5.BA.94.E7.94.A8.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81"
|
||||
* >用户进入应用的事件推送</a>
|
||||
*/
|
||||
public class EnterAgentEventMessage extends EventMessage {
|
||||
|
||||
private static final long serialVersionUID = 7675732524832500820L;
|
||||
|
||||
public EnterAgentEventMessage() {
|
||||
super(EventType.enter_agent);
|
||||
}
|
||||
|
||||
@XStreamAlias("EventKey")
|
||||
private String eventKey; // 事件KEY值,与自定义菜单接口中KEY值对应
|
||||
|
||||
public String getEventKey() {
|
||||
return eventKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EnterAgentEventMessage [eventKey=" + eventKey + ", "
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ import com.foxinmy.weixin4j.type.EventType;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
/**
|
||||
* 模板消息事件推送
|
||||
* 模板消息事件推送(公众平台)
|
||||
*
|
||||
* @className TemplatesendjobfinishMessage
|
||||
* @author jy
|
||||
|
||||
@ -37,6 +37,7 @@ public class MenuEventMessage extends EventMessage {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "eventKey=" + eventKey + ", " + super.toString();
|
||||
return "MenuEventMessage [eventKey=" + eventKey + ", "
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ import com.foxinmy.weixin4j.msg.model.Base;
|
||||
import com.foxinmy.weixin4j.msg.model.News;
|
||||
import com.foxinmy.weixin4j.msg.model.Responseable;
|
||||
import com.foxinmy.weixin4j.util.ClassUtil;
|
||||
import com.foxinmy.weixin4j.xml.TextConverter;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
||||
@ -107,10 +108,7 @@ public class ResponseMessage extends BaseMsg {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResponseMessage [" + box.toString() + ", attach=" + attach
|
||||
+ ", getToUserName()=" + getToUserName()
|
||||
+ ", getFromUserName()=" + getFromUserName()
|
||||
+ ", getCreateTime()=" + getCreateTime() + ", getMsgType()="
|
||||
+ getMsgType() + "]";
|
||||
return "ResponseMessage [ " + super.toString() + ", attach=" + attach
|
||||
+ ", box=" + box + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.foxinmy.weixin4j.type;
|
||||
|
||||
import com.foxinmy.weixin4j.msg.event.EnterAgentEventMessage;
|
||||
import com.foxinmy.weixin4j.msg.event.EventMessage;
|
||||
import com.foxinmy.weixin4j.msg.event.LocationEventMessage;
|
||||
import com.foxinmy.weixin4j.msg.event.MassEventMessage;
|
||||
@ -31,7 +32,7 @@ public enum EventType {
|
||||
MenuLocationEventMessage.class), click(MenuEventMessage.class), location(
|
||||
LocationEventMessage.class),masssendjobfinish(
|
||||
MassEventMessage.class), templatesendjobfinish(
|
||||
TemplatesendjobfinishMessage.class);
|
||||
TemplatesendjobfinishMessage.class),enter_agent(EnterAgentEventMessage.class);
|
||||
|
||||
private Class<? extends EventMessage> eventClass;
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.foxinmy.weixin4j.response;
|
||||
package com.foxinmy.weixin4j.xml;
|
||||
|
||||
import com.foxinmy.weixin4j.msg.model.Text;
|
||||
import com.thoughtworks.xstream.converters.SingleValueConverter;
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<name>weixin4j-mp</name>
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp-api</artifactId>
|
||||
<name>weixin4j-mp-api</name>
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-mp</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-mp-server</artifactId>
|
||||
<name>weixin4j-mp-server</name>
|
||||
|
||||
@ -88,3 +88,9 @@ weixin4j-qy
|
||||
* 2014-11-24
|
||||
|
||||
+ **weixin4j-qy-server**: 新增netty服务与消息分发
|
||||
|
||||
* 2014-12-28
|
||||
|
||||
+ **weixin4j-qy**:增加用户进入应用的callback事件
|
||||
|
||||
+ **weixin4j-qy**:增加批量获取用户详情的接口
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-qy</artifactId>
|
||||
<name>weixin4j-qy</name>
|
||||
|
||||
@ -57,3 +57,7 @@ weixin.properties说明
|
||||
+ 新增`用户管理`接口
|
||||
|
||||
+ 新增`标签管理`接口
|
||||
|
||||
* 2014-12-28
|
||||
|
||||
+ 增加`批量获取用户详情`的接口
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-qy</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-qy-api</artifactId>
|
||||
<name>weixin4j-qy-api</name>
|
||||
|
||||
@ -185,6 +185,8 @@ public class WeixinProxy {
|
||||
* 是否递归获取子部门下面的成员 非必须
|
||||
* @param userStatus
|
||||
* 成员状态 status可叠加 非必须
|
||||
* @param findDetail
|
||||
* 是否获取详细信息
|
||||
* @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#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98">获取部门成员说明</a>
|
||||
@ -193,8 +195,8 @@ public class WeixinProxy {
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<User> listUser(int departId, boolean fetchChild,
|
||||
UserStatus userStatus) throws WeixinException {
|
||||
return userApi.listUser(departId, fetchChild, userStatus);
|
||||
UserStatus userStatus, boolean findDetail) throws WeixinException {
|
||||
return userApi.listUser(departId, fetchChild, userStatus, findDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,7 +246,8 @@ public class WeixinProxy {
|
||||
/**
|
||||
* 更新标签(管理组必须是指定标签的创建者)
|
||||
*
|
||||
* @param tag 标签信息
|
||||
* @param tag
|
||||
* 标签信息
|
||||
* @see <a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E7%AE%A1%E7%90%86%E6%A0%87%E7%AD%BE#.E6.9B.B4.E6.96.B0.E6.A0.87.E7.AD.BE.E5.90.8D.E5.AD.97"
|
||||
* >更新标签说明</a>
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package com.foxinmy.weixin4j.qy.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.JsonResult;
|
||||
@ -132,6 +134,8 @@ public class UserApi extends QyApi {
|
||||
* 是否递归获取子部门下面的成员 非必须
|
||||
* @param userStatus
|
||||
* 成员状态 status可叠加 非必须
|
||||
* @param findDetail
|
||||
* 是否获取详细信息
|
||||
* @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#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98">获取部门成员说明</a>
|
||||
@ -139,15 +143,31 @@ public class UserApi extends QyApi {
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<User> listUser(int departId, boolean fetchChild,
|
||||
UserStatus userStatus) throws WeixinException {
|
||||
String user_list_uri = getRequestUri("user_list_uri");
|
||||
UserStatus userStatus, boolean findDetail) throws WeixinException {
|
||||
String user_list_uri = findDetail ? getRequestUri("user_list_uri")
|
||||
: getRequestUri("user_slist_uri");
|
||||
Token token = tokenHolder.getToken();
|
||||
Response response = request.post(String.format(user_list_uri,
|
||||
token.getAccessToken(), departId, fetchChild ? 1 : 0,
|
||||
userStatus.getVal()));
|
||||
return JSON.parseArray(response.getAsJson().getString("userlist"),
|
||||
List<User> list = null;
|
||||
if (findDetail) {
|
||||
JSONArray arrays = response.getAsJson().getJSONArray("userlist");
|
||||
list = new ArrayList<User>(arrays.size());
|
||||
for (int i = 0; i < arrays.size(); i++) {
|
||||
JSONObject obj = arrays.getJSONObject(i);
|
||||
Object attrs = obj.getJSONObject("extattr").remove("attrs");
|
||||
if (attrs != null) {
|
||||
obj.put("extattr", attrs);
|
||||
}
|
||||
list.add(JSON.toJavaObject(obj, User.class));
|
||||
}
|
||||
} else {
|
||||
list = JSON.parseArray(response.getAsJson().getString("userlist"),
|
||||
User.class);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下所有状态成员(不进行递归)
|
||||
@ -159,7 +179,7 @@ public class UserApi extends QyApi {
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public List<User> listUser(int departId) throws WeixinException {
|
||||
return listUser(departId, false, UserStatus.BOTH);
|
||||
return listUser(departId, false, UserStatus.BOTH, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,9 @@ user_get_uri={api_base_url}/user/get?access_token=%s&userid=%s
|
||||
# code\u83b7\u53d6\u6210\u5458\u4fe1\u606f
|
||||
user_getid_uri={api_base_url}/getuserinfo?access_token=%s&code=%s&agentid=%d
|
||||
# \u83b7\u53d6\u90e8\u95e8\u6210\u5458
|
||||
user_list_uri={api_base_url}/user/simplelist?access_token=%s&department_id=%d&fetch_child=%d&status=%d
|
||||
user_slist_uri={api_base_url}/user/simplelist?access_token=%s&department_id=%d&fetch_child=%d&status=%d
|
||||
# \u83b7\u53d6\u90e8\u95e8\u6210\u5458(\u8be6\u60c5)
|
||||
user_list_uri={api_base_url}/user/list?access_token=%s&department_id=%d&fetch_child=%d&status=%d
|
||||
# \u5220\u9664\u6210\u5458
|
||||
user_delete_uri={api_base_url}/user/delete?access_token=%s&userid=%s
|
||||
# \u6210\u5458\u4e8c\u6b21\u9a8c\u8bc1\u6210\u529f\u65f6\u8c03\u7528
|
||||
|
||||
@ -10,6 +10,7 @@ import com.foxinmy.weixin4j.exception.WeixinException;
|
||||
import com.foxinmy.weixin4j.http.JsonResult;
|
||||
import com.foxinmy.weixin4j.qy.api.UserApi;
|
||||
import com.foxinmy.weixin4j.qy.model.User;
|
||||
import com.foxinmy.weixin4j.qy.type.UserStatus;
|
||||
|
||||
/**
|
||||
* 部门API测试
|
||||
@ -57,7 +58,10 @@ public class UserTest extends TokenTest {
|
||||
|
||||
@Test
|
||||
public void list() throws WeixinException {
|
||||
List<User> userList = userApi.listUser(1);
|
||||
List<User> userList = userApi.listUser(1, true, UserStatus.BOTH, true);
|
||||
Assert.assertFalse(userList.isEmpty());
|
||||
System.out.println(userList);
|
||||
userList = userApi.listUser(1);
|
||||
Assert.assertFalse(userList.isEmpty());
|
||||
System.out.println(userList);
|
||||
}
|
||||
|
||||
@ -52,3 +52,7 @@ weixin4j-qy-server
|
||||
* 2014-11-24
|
||||
|
||||
+ 新增netty服务与消息分发
|
||||
|
||||
* 2014-12-28
|
||||
|
||||
+ 增加用户进入应用的callback事件
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>com.foxinmy</groupId>
|
||||
<artifactId>weixin4j-qy</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>weixin4j-qy-server</artifactId>
|
||||
<name>weixin4j-qy-server</name>
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package com.foxinmy.weixin4j.qy.action.event;
|
||||
|
||||
import com.foxinmy.weixin4j.action.DebugAction;
|
||||
import com.foxinmy.weixin4j.action.mapping.ActionAnnotation;
|
||||
import com.foxinmy.weixin4j.msg.event.EnterAgentEventMessage;
|
||||
import com.foxinmy.weixin4j.type.EventType;
|
||||
import com.foxinmy.weixin4j.type.MessageType;
|
||||
|
||||
/**
|
||||
* 用户进入应用的事件推送
|
||||
*
|
||||
* @className
|
||||
* @author jy
|
||||
* @date 2014年12月28日
|
||||
* @since JDK 1.7
|
||||
* @see com.foxinmy.weixin4j.msg.event.EnterAgentEventMessage
|
||||
* @see<a href=
|
||||
* "http://qydev.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E4%BA%8B%E4%BB%B6#.E7.94.A8.E6.88.B7.E8.BF.9B.E5.85.A5.E5.BA.94.E7.94.A8.E7.9A.84.E4.BA.8B.E4.BB.B6.E6.8E.A8.E9.80.81"
|
||||
* >用户进入应用的事件推送</a>
|
||||
*/
|
||||
@ActionAnnotation(msgType = MessageType.event, eventType = { EventType.enter_agent })
|
||||
public class EnterAgentAction extends DebugAction<EnterAgentEventMessage> {
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user