version upgrade to 1.7.0
This commit is contained in:
parent
0b0f9bb31d
commit
7f2f1d8f64
@ -714,3 +714,7 @@
|
|||||||
+ 优化PayOldApi
|
+ 优化PayOldApi
|
||||||
|
|
||||||
+ weixin4j-mp:新增接口调用次数清零接口
|
+ weixin4j-mp:新增接口调用次数清零接口
|
||||||
|
|
||||||
|
* 2016-06-20
|
||||||
|
|
||||||
|
+ version upgrade to 1.7.0
|
||||||
3
pom.xml
3
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>weixin4j</name>
|
<name>weixin4j</name>
|
||||||
<url>https://github.com/foxinmy/weixin4j</url>
|
<url>https://github.com/foxinmy/weixin4j</url>
|
||||||
@ -50,6 +50,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.6</maven.compiler.source>
|
<maven.compiler.source>1.6</maven.compiler.source>
|
||||||
<maven.compiler.target>1.6</maven.compiler.target>
|
<maven.compiler.target>1.6</maven.compiler.target>
|
||||||
|
<fastjson.version>1.2.3</fastjson.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>weixin4j-base</artifactId>
|
<artifactId>weixin4j-base</artifactId>
|
||||||
<name>weixin4j-base</name>
|
<name>weixin4j-base</name>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import com.foxinmy.weixin4j.tuple.MpArticle;
|
|
||||||
import com.foxinmy.weixin4j.type.ButtonType;
|
import com.foxinmy.weixin4j.type.ButtonType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,10 +48,10 @@ public class Button implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String content;
|
private String content;
|
||||||
/**
|
/**
|
||||||
* 图文列表 只有在公众平台设置的菜单才有
|
* 扩展属性,比如在公众平台设置菜单时的图文列表
|
||||||
*/
|
*/
|
||||||
@JSONField(serialize = false, deserialize = false)
|
@JSONField(serialize = false, deserialize = false)
|
||||||
private List<MpArticle> articles;
|
private Object extra;
|
||||||
/**
|
/**
|
||||||
* 二级菜单数组,个数应为1~5个
|
* 二级菜单数组,个数应为1~5个
|
||||||
*/
|
*/
|
||||||
@ -117,17 +116,17 @@ public class Button implements Serializable {
|
|||||||
this.content = content;
|
this.content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MpArticle> getArticles() {
|
public Object getExtra() {
|
||||||
return articles;
|
return extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <font color="red">创建菜单设置无效</font>
|
* 扩展只读属性,设置无效
|
||||||
*
|
*
|
||||||
* @param articles
|
* @param extra
|
||||||
*/
|
*/
|
||||||
public void setArticles(List<MpArticle> articles) {
|
public void setExtra(Object extra) {
|
||||||
this.articles = articles;
|
this.extra = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Button> getSubs() {
|
public List<Button> getSubs() {
|
||||||
@ -146,6 +145,6 @@ public class Button implements Serializable {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Button [name=" + name + ", type=" + type + ", content="
|
return "Button [name=" + name + ", type=" + type + ", content="
|
||||||
+ content + ", articles=" + articles + ", subs=" + subs + "]";
|
+ content + ", extra=" + extra + ", subs=" + subs + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -951,5 +951,5 @@ public class WeixinPayProxy {
|
|||||||
return customsApi.queryCustomsOrder(idQuery, customsCity);
|
return customsApi.queryCustomsOrder(idQuery, customsCity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String VERSION = "1.6.9";
|
public final static String VERSION = "1.7.0";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>weixin4j-example</artifactId>
|
<artifactId>weixin4j-example</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
@ -47,13 +47,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j-mp</artifactId>
|
<artifactId>weixin4j-mp</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 微信企业号 -->
|
<!-- 微信企业号 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j-qy</artifactId>
|
<artifactId>weixin4j-qy</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 微信被动消息(回调模式) -->
|
<!-- 微信被动消息(回调模式) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package com.foxinmy.weixin4j.example.server;
|
package com.foxinmy.weixin4j.example.server;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.exception.WeixinException;
|
import com.foxinmy.weixin4j.exception.WeixinException;
|
||||||
@ -41,12 +42,12 @@ public class Weixin4jServerStartupWithoutThread {
|
|||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public static void main(String[] args) throws WeixinException {
|
public static void main(String[] args) throws WeixinException {
|
||||||
// 单独服务启动
|
// 单独服务启动
|
||||||
//new WeixinServerBootstrap(aesToken)
|
// new WeixinServerBootstrap(aesToken)
|
||||||
//.handlerPackagesToScan(handlerPackage)
|
// .handlerPackagesToScan(handlerPackage)
|
||||||
//.addHandler(DebugMessageHandler.global).openAlwaysResponse()
|
// .addHandler(DebugMessageHandler.global).openAlwaysResponse()
|
||||||
//.startup(port);
|
// .startup(port);
|
||||||
// spring容器启动
|
// spring容器启动
|
||||||
new ClassPathXmlApplicationContext(
|
ApplicationContext app = new ClassPathXmlApplicationContext(
|
||||||
new String[] { "classpath:/spring-bean.xml" });
|
new String[] { "classpath:/spring-bean.xml" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>weixin4j-mp</artifactId>
|
<artifactId>weixin4j-mp</artifactId>
|
||||||
<name>weixin4j-mp</name>
|
<name>weixin4j-mp</name>
|
||||||
|
|||||||
@ -1806,5 +1806,5 @@ public class WeixinProxy {
|
|||||||
return tagApi.getUserTags(openId);
|
return tagApi.getUserTags(openId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String VERSION = "1.6.9";
|
public final static String VERSION = "1.7.0";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,6 @@ import com.foxinmy.weixin4j.mp.model.SemResult;
|
|||||||
import com.foxinmy.weixin4j.token.TokenManager;
|
import com.foxinmy.weixin4j.token.TokenManager;
|
||||||
import com.foxinmy.weixin4j.tuple.MpArticle;
|
import com.foxinmy.weixin4j.tuple.MpArticle;
|
||||||
import com.foxinmy.weixin4j.type.ButtonType;
|
import com.foxinmy.weixin4j.type.ButtonType;
|
||||||
import com.foxinmy.weixin4j.util.ReflectionUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 辅助相关API
|
* 辅助相关API
|
||||||
@ -142,6 +141,7 @@ public class HelperApi extends MpApi {
|
|||||||
private static final class ButtonExtraProcessor implements ExtraProcessor {
|
private static final class ButtonExtraProcessor implements ExtraProcessor {
|
||||||
private static ButtonExtraProcessor global = new ButtonExtraProcessor();
|
private static ButtonExtraProcessor global = new ButtonExtraProcessor();
|
||||||
private static final String KEY = "news_info";
|
private static final String KEY = "news_info";
|
||||||
|
|
||||||
private ButtonExtraProcessor() {
|
private ButtonExtraProcessor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,11 +160,7 @@ public class HelperApi extends MpApi {
|
|||||||
article.remove("source_url"));
|
article.remove("source_url"));
|
||||||
newsList.add(JSON.toJavaObject(article, MpArticle.class));
|
newsList.add(JSON.toJavaObject(article, MpArticle.class));
|
||||||
}
|
}
|
||||||
if (ReflectionUtil.getAccessibleField(object, "articles") != null) {
|
JSONPath.set(object, "$.extar", newsList);
|
||||||
JSONPath.set(object, "$.articles", newsList);
|
|
||||||
} else {
|
|
||||||
JSONPath.set(object, "$.content", newsList);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
JSONPath.set(object, "$.content", value);
|
JSONPath.set(object, "$.content", value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.mp.card;
|
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.mp.type.CardType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券
|
|
||||||
*
|
|
||||||
* @className CardCoupon
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2016年4月4日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public interface CardCoupon {
|
|
||||||
/**
|
|
||||||
* 卡券类型
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public CardType getCardType();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券基本信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public CouponBaseInfo getBaseInfo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券高级信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public CouponAdvancedInfo getAdvancedInfo();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券详细信息
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public CouponDetailInfo getDetailInfo();
|
|
||||||
}
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.mp.card;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券构造器
|
|
||||||
*
|
|
||||||
* @className CardCouponBuilder
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2016年6月1日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public class CardCouponBuilder {
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.mp.card;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券高级信息
|
|
||||||
*
|
|
||||||
* @className CouponAdvancedInfo
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2016年6月1日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public class CouponAdvancedInfo implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3626615706377721404L;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.mp.card;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券基本信息
|
|
||||||
*
|
|
||||||
* @className CouponBaseInfo
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2016年6月1日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public class CouponBaseInfo implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -5725424121330101716L;
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.mp.card;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 卡券详情信息
|
|
||||||
*
|
|
||||||
* @className CouponDetailInfo
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2016年6月1日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public interface CouponDetailInfo extends Serializable {
|
|
||||||
public JSONObject toContent();
|
|
||||||
}
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.mp.card;
|
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.mp.type.CardType;
|
|
||||||
|
|
||||||
public class GrouponCoupon implements CardCoupon {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CardType getCardType() {
|
|
||||||
return CardType.GROUPON;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CouponBaseInfo getBaseInfo() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CouponAdvancedInfo getAdvancedInfo() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CouponDetailInfo getDetailInfo() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>weixin4j-qy</artifactId>
|
<artifactId>weixin4j-qy</artifactId>
|
||||||
<name>weixin4j-qy</name>
|
<name>weixin4j-qy</name>
|
||||||
|
|||||||
@ -1353,5 +1353,5 @@ public class WeixinProxy {
|
|||||||
return chatApi.sendChatMessage(message);
|
return chatApi.sendChatMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String VERSION = "1.6.9";
|
public final static String VERSION = "1.7.0";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -235,5 +235,5 @@ public class WeixinSuiteProxy {
|
|||||||
suite(suiteId).getSuiteTokenManager());
|
suite(suiteId).getSuiteTokenManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static String VERSION = "1.6.9";
|
public final static String VERSION = "1.7.0";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>com.foxinmy</groupId>
|
<groupId>com.foxinmy</groupId>
|
||||||
<artifactId>weixin4j</artifactId>
|
<artifactId>weixin4j</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>weixin4j-server</artifactId>
|
<artifactId>weixin4j-server</artifactId>
|
||||||
<version>1.1.8</version>
|
<version>1.1.8</version>
|
||||||
@ -18,6 +18,11 @@
|
|||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>4.0.23.Final</version>
|
<version>4.0.23.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>${fastjson.version}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
|||||||
@ -1,202 +0,0 @@
|
|||||||
package com.foxinmy.weixin4j.dispatcher;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.foxinmy.weixin4j.message.ImageMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.LinkMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.LocationMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.TextMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.VideoMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.VoiceMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.event.LocationEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.event.MenuEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.event.MenuLocationEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.event.MenuPhotoEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.message.event.MenuScanEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.KfCloseEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.KfCreateEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.KfSwitchEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.MassEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.TemplatesendjobfinishMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.VerifyExpireEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.mp.event.VerifyFailEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.qy.event.BatchjobresultMessage;
|
|
||||||
import com.foxinmy.weixin4j.qy.event.EnterAgentEventMessage;
|
|
||||||
import com.foxinmy.weixin4j.request.WeixinMessage;
|
|
||||||
import com.foxinmy.weixin4j.type.AccountType;
|
|
||||||
import com.foxinmy.weixin4j.type.EventType;
|
|
||||||
import com.foxinmy.weixin4j.type.MessageType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认MessageMatcher实现(可以改进)
|
|
||||||
*
|
|
||||||
* @className DefaultMessageMatcher
|
|
||||||
* @author jinyu(foxinmy@gmail.com)
|
|
||||||
* @date 2015年6月10日
|
|
||||||
* @since JDK 1.6
|
|
||||||
* @see
|
|
||||||
*/
|
|
||||||
public class DefaultMessageMatcher implements WeixinMessageMatcher {
|
|
||||||
|
|
||||||
private final Map<WeixinMessageKey, Class<? extends WeixinMessage>> messageClassMap;
|
|
||||||
|
|
||||||
public DefaultMessageMatcher() {
|
|
||||||
messageClassMap = new HashMap<WeixinMessageKey, Class<? extends WeixinMessage>>();
|
|
||||||
initMessageClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initMessageClass() {
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
/******************** 普通消息 ********************/
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
initGeneralMessageClass();
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
/******************** 事件消息 ********************/
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
initEventMessageClass();
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
/***************** 公众平台事件消息 *****************/
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
initMpEventMessageClass();
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
/****************** 企业号事件消息 ******************/
|
|
||||||
// /////////////////////////////////////////////////
|
|
||||||
initQyEventMessageClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initGeneralMessageClass() {
|
|
||||||
for (AccountType accountType : AccountType.values()) {
|
|
||||||
messageClassMap.put(new WeixinMessageKey(MessageType.text.name(),
|
|
||||||
null, accountType), TextMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(MessageType.image.name(),
|
|
||||||
null, accountType), ImageMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(MessageType.voice.name(),
|
|
||||||
null, accountType), VoiceMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(MessageType.video.name(),
|
|
||||||
null, accountType), VideoMessage.class);
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(MessageType.shortvideo.name(), null,
|
|
||||||
accountType), VideoMessage.class);
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(MessageType.location.name(), null,
|
|
||||||
accountType), LocationMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(MessageType.link.name(),
|
|
||||||
null, accountType), LinkMessage.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initEventMessageClass() {
|
|
||||||
String messageType = MessageType.event.name();
|
|
||||||
EventType[] eventTypes = new EventType[] { EventType.subscribe,
|
|
||||||
EventType.unsubscribe };
|
|
||||||
for (EventType eventType : eventTypes) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
AccountType.MP),
|
|
||||||
com.foxinmy.weixin4j.mp.event.ScribeEventMessage.class);
|
|
||||||
}
|
|
||||||
for (EventType eventType : eventTypes) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
AccountType.QY),
|
|
||||||
com.foxinmy.weixin4j.qy.event.ScribeEventMessage.class);
|
|
||||||
}
|
|
||||||
for (AccountType accountType : AccountType.values()) {
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.location.name(), accountType),
|
|
||||||
LocationEventMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.location_select.name(), accountType),
|
|
||||||
MenuLocationEventMessage.class);
|
|
||||||
for (EventType eventType : new EventType[] { EventType.click,
|
|
||||||
EventType.view }) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
accountType), MenuEventMessage.class);
|
|
||||||
}
|
|
||||||
for (EventType eventType : new EventType[] {
|
|
||||||
EventType.scancode_push, EventType.scancode_waitmsg }) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
accountType), MenuScanEventMessage.class);
|
|
||||||
}
|
|
||||||
for (EventType eventType : new EventType[] {
|
|
||||||
EventType.pic_sysphoto, EventType.pic_photo_or_album,
|
|
||||||
EventType.pic_weixin }) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
accountType), MenuPhotoEventMessage.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initMpEventMessageClass() {
|
|
||||||
String messageType = MessageType.event.name();
|
|
||||||
AccountType accountType = AccountType.MP;
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, EventType.scan.name(),
|
|
||||||
accountType),
|
|
||||||
com.foxinmy.weixin4j.mp.event.ScanEventMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.masssendjobfinish.name(), accountType),
|
|
||||||
MassEventMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.templatesendjobfinish.name(), accountType),
|
|
||||||
TemplatesendjobfinishMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.kf_create_session.name(), accountType),
|
|
||||||
KfCreateEventMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.kf_close_session.name(), accountType),
|
|
||||||
KfCloseEventMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.kf_switch_session.name(), accountType),
|
|
||||||
KfSwitchEventMessage.class);
|
|
||||||
EventType[] eventTypes = new EventType[] {
|
|
||||||
EventType.qualification_verify_success,
|
|
||||||
EventType.naming_verify_success, EventType.annual_renew,
|
|
||||||
EventType.verify_expired };
|
|
||||||
for (EventType eventType : eventTypes) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
accountType), VerifyExpireEventMessage.class);
|
|
||||||
}
|
|
||||||
eventTypes = new EventType[] { EventType.qualification_verify_success,
|
|
||||||
EventType.naming_verify_fail };
|
|
||||||
for (EventType eventType : eventTypes) {
|
|
||||||
messageClassMap.put(
|
|
||||||
new WeixinMessageKey(messageType, eventType.name(),
|
|
||||||
accountType), VerifyFailEventMessage.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initQyEventMessageClass() {
|
|
||||||
String messageType = MessageType.event.name();
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.batch_job_result.name(), AccountType.QY),
|
|
||||||
BatchjobresultMessage.class);
|
|
||||||
messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
EventType.enter_agent.name(), AccountType.QY),
|
|
||||||
EnterAgentEventMessage.class);
|
|
||||||
//messageClassMap.put(new WeixinMessageKey(messageType,
|
|
||||||
// EventType.suite.name(), AccountType.QY),
|
|
||||||
//SuiteMessage.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<? extends WeixinMessage> match(WeixinMessageKey messageKey) {
|
|
||||||
return messageClassMap.get(messageKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void regist(WeixinMessageKey messageKey,
|
|
||||||
Class<? extends WeixinMessage> messageClass) {
|
|
||||||
Class<?> clazz = match(messageKey);
|
|
||||||
if (clazz != null) {
|
|
||||||
throw new IllegalArgumentException("duplicate messagekey '"
|
|
||||||
+ messageKey + "' define for " + clazz);
|
|
||||||
}
|
|
||||||
messageClassMap.put(messageKey, messageClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user