调整细节&新增小视频消息

This commit is contained in:
jinyu
2015-04-08 18:28:32 +08:00
parent 78e3757029
commit 624ccff953
17 changed files with 137 additions and 83 deletions
@@ -16,12 +16,14 @@ import com.foxinmy.weixin4j.type.MessageType;
* @see
*/
public abstract class AbstractActionMapping implements ActionMapping {
protected final static String DECOLLATOR = ":";
protected String getMappingKey(String xmlMsg) throws DocumentException {
Document doc = DocumentHelper.parseText(xmlMsg);
String msgType = doc.selectSingleNode("/xml/MsgType").getStringValue();
if (msgType.equalsIgnoreCase(MessageType.event.name())) {
msgType += "_"
msgType += DECOLLATOR
+ doc.selectSingleNode("/xml/Event").getStringValue();
}
return msgType.toLowerCase();
@@ -27,7 +27,8 @@ public class AnnotationActionMapping extends AbstractActionMapping {
actionMap = new HashMap<String, WeixinAction>();
Set<Class<?>> weixinActions = ClassUtil.getClasses(actionPackage);
for (Class<?> clazz : weixinActions) {
ActionAnnotation action = clazz.getAnnotation(ActionAnnotation.class);
ActionAnnotation action = clazz
.getAnnotation(ActionAnnotation.class);
if (action == null) {
continue;
}
@@ -41,9 +42,8 @@ public class AnnotationActionMapping extends AbstractActionMapping {
EventType[] eventTypes = action.eventType();
if (eventTypes != null && eventTypes.length > 0) {
for (EventType e : eventTypes) {
actionMap.put(
(msgType.name() + "_" + e.name()).toLowerCase(),
weixinAction);
actionMap.put((msgType.name() + DECOLLATOR + e.name())
.toLowerCase(), weixinAction);
}
continue;
}
@@ -198,7 +198,6 @@ public class HttpRequest {
.getFirstHeader(HttpHeaders.CONTENT_TYPE);
Header disposition = httpResponse
.getFirstHeader("Content-disposition");
System.err.println(response.getAsString());
// json
if (contentType.getValue().contains(
ContentType.APPLICATION_JSON.getMimeType())
@@ -43,10 +43,10 @@ public class BaseMsg implements Serializable {
*/
@XStreamAlias("MsgId")
private long msgId;
@XStreamAlias("AgentID")
/**
* 企业号独有的应用ID
*/
@XStreamAlias("AgentID")
private String agentId;
public BaseMsg() {
@@ -41,6 +41,12 @@ public enum MessageType {
* @see com.foxinmy.weixin4j.msg.VideoMessage
*/
video(VideoMessage.class),
/**
* 小视频消息
*
* @see com.foxinmy.weixin4j.msg.VideoMessage
*/
shortvideo(VideoMessage.class),
/**
* 位置消息
*
@@ -178,7 +178,7 @@ public class MessageUtil {
* @see <a
* href="http://mp.weixin.qq.com/wiki/10/79502792eef98d6e0c6e1739da387346.html">普通消息</a>
* @see <a
* href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html">事件触发</a>
* href="http://mp.weixin.qq.com/wiki/2/5baf56ce4947d35003b86a9805634b1e.html">事件消息</a>
* @see com.foxinmy.weixin4j.type.MessageType
* @see com.feican.weixin.msg.BaeMessage
* @see com.foxinmy.weixin4j.msg.TextMessage