Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chanjarster committed Oct 22, 2014
2 parents f759d2c + 46e66d3 commit c23293f
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public interface WxCpService {
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
* </pre>
*
* @param mediaType 媒体类型, 请看{@link WxCpConsts}
* @param fileType 文件类型,请看{@link WxCpConsts}
* @param mediaType 媒体类型, 请看{@link WxConsts}
* @param fileType 文件类型,请看{@link WxConsts}
* @param inputStream 输入流
* @throws WxErrorException
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ public String getMsgType() {
/**
* <pre>
* 请使用
* {@link me.chanjar.weixin.cp.api.WxCpConsts#CUSTOM_MSG_TEXT}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#CUSTOM_MSG_IMAGE}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#CUSTOM_MSG_VOICE}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#CUSTOM_MSG_MUSIC}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#CUSTOM_MSG_VIDEO}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#CUSTOM_MSG_NEWS}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VOICE}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_MUSIC}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#CUSTOM_MSG_NEWS}
* </pre>
* @param msgType
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ public void setCreateTime(Long createTime) {
/**
* <pre>
* 当接受用户消息时,可能会获得以下值:
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_LOCATION}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_LINK}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_EVENT}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LOCATION}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_LINK}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_EVENT}
* </pre>
*
* @return
Expand All @@ -208,11 +208,11 @@ public String getMsgType() {
/**
* <pre>
* 当发送消息的时候使用:
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.cp.api.WxCpConsts#XML_MSG_NEWS}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_TEXT}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_IMAGE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VOICE}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_VIDEO}
* {@link me.chanjar.weixin.common.api.WxConsts#XML_MSG_NEWS}
* </pre>
*
* @param msgType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package me.chanjar.weixin.cp.bean;

import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.MediaIdMarshaller;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import me.chanjar.weixin.cp.api.WxCpConsts;
import me.chanjar.weixin.common.util.xml.MediaIdMarshaller;

@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage {
Expand All @@ -18,7 +18,7 @@ public class WxCpXmlOutImageMessage extends WxCpXmlOutMessage {
private String mediaId;

public WxCpXmlOutImageMessage() {
this.msgType = WxCpConsts.XML_MSG_IMAGE;
this.msgType = WxConsts.XML_MSG_IMAGE;
}

public String getMediaId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package me.chanjar.weixin.cp.bean;

import java.util.ArrayList;
import java.util.List;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import me.chanjar.weixin.cp.api.WxCpConsts;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;
import java.util.ArrayList;
import java.util.List;

@XmlRootElement(name = "xml")
@XmlAccessorType(XmlAccessType.FIELD)
Expand All @@ -25,7 +20,7 @@ public class WxCpXmlOutMewsMessage extends WxCpXmlOutMessage {
protected final List<Item> articles = new ArrayList<Item>();

public WxCpXmlOutMewsMessage() {
this.msgType = WxCpConsts.XML_MSG_NEWS;
this.msgType = WxConsts.XML_MSG_NEWS;
}

public int getArticleCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import me.chanjar.weixin.cp.api.WxCpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;

@XmlRootElement(name = "xml")
Expand All @@ -18,7 +18,7 @@ public class WxCpXmlOutTextMessage extends WxCpXmlOutMessage {
private String content;

public WxCpXmlOutTextMessage() {
this.msgType = WxCpConsts.XML_MSG_TEXT;
this.msgType = WxConsts.XML_MSG_TEXT;
}

public String getContent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import me.chanjar.weixin.cp.api.WxCpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.AdapterCDATA;

@XmlRootElement(name = "xml")
Expand All @@ -17,7 +17,7 @@ public class WxCpXmlOutVideoMessage extends WxCpXmlOutMessage {
protected final Video video = new Video();

public WxCpXmlOutVideoMessage() {
this.msgType = WxCpConsts.XML_MSG_VIDEO;
this.msgType = WxConsts.XML_MSG_VIDEO;
}

public String getMediaId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import me.chanjar.weixin.cp.api.WxCpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.common.util.xml.MediaIdMarshaller;

@XmlRootElement(name = "xml")
Expand All @@ -18,7 +18,7 @@ public class WxCpXmlOutVoiceMessage extends WxCpXmlOutMessage {
private String mediaId;

public WxCpXmlOutVoiceMessage() {
this.msgType = WxCpConsts.XML_MSG_VOICE;
this.msgType = WxConsts.XML_MSG_VOICE;
}

public String getMediaId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.lang.reflect.Type;

import me.chanjar.weixin.cp.api.WxCpConsts;
import me.chanjar.weixin.common.api.WxConsts;
import me.chanjar.weixin.cp.bean.WxCpMessage;

import com.google.gson.JsonArray;
Expand Down Expand Up @@ -41,31 +41,31 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat
if (StringUtils.isNotBlank(message.getToTag())) {
messageJson.addProperty("totag", message.getToUser());
}
if (WxCpConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_TEXT.equals(message.getMsgType())) {
JsonObject text = new JsonObject();
text.addProperty("content", message.getContent());
messageJson.add("text", text);
}

if (WxCpConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_IMAGE.equals(message.getMsgType())) {
JsonObject image = new JsonObject();
image.addProperty("media_id", message.getMediaId());
messageJson.add("image", image);
}

if (WxCpConsts.CUSTOM_MSG_FILE.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_FILE.equals(message.getMsgType())) {
JsonObject image = new JsonObject();
image.addProperty("media_id", message.getMediaId());
messageJson.add("file", image);
}

if (WxCpConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_VOICE.equals(message.getMsgType())) {
JsonObject voice = new JsonObject();
voice.addProperty("media_id", message.getMediaId());
messageJson.add("voice", voice);
}

if (WxCpConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_VIDEO.equals(message.getMsgType())) {
JsonObject video = new JsonObject();
video.addProperty("media_id", message.getMediaId());
video.addProperty("thumb_media_id", message.getThumbMediaId());
Expand All @@ -74,7 +74,7 @@ public JsonElement serialize(WxCpMessage message, Type typeOfSrc, JsonSerializat
messageJson.add("video", video);
}

if (WxCpConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) {
if (WxConsts.CUSTOM_MSG_NEWS.equals(message.getMsgType())) {
JsonArray articleJsonArray = new JsonArray();
for (WxCpMessage.WxArticle article : message.getArticles()) {
JsonObject articleJson = new JsonObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public void testUploadMedia(String mediaType, String fileType, String fileName)
@DataProvider
public Object[][] uploadMedia() {
return new Object[][] {
new Object[] { WxCpConsts.MEDIA_IMAGE, WxCpConsts.FILE_JPG, "mm.jpeg" },
new Object[] { WxCpConsts.MEDIA_VOICE, WxCpConsts.FILE_MP3, "mm.mp3" },
new Object[] { WxCpConsts.MEDIA_VIDEO, WxCpConsts.FILE_MP4, "mm.mp4" },
new Object[] { WxCpConsts.MEDIA_FILE, WxCpConsts.FILE_JPG, "mm.jpeg" }
new Object[] { WxConsts.MEDIA_IMAGE, WxConsts.FILE_JPG, "mm.jpeg" },
new Object[] { WxConsts.MEDIA_VOICE, WxConsts.FILE_MP3, "mm.mp3" },
new Object[] { WxConsts.MEDIA_VIDEO, WxConsts.FILE_MP4, "mm.mp4" },
new Object[] { WxConsts.MEDIA_FILE, WxConsts.FILE_JPG, "mm.jpeg" }
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void testSendCustomMessage() throws WxErrorException {
ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage = (ApiTestModule.WxXmlCpInMemoryConfigStorage) wxService.wxCpConfigStorage;
WxCpMessage message1 = new WxCpMessage();
message1.setAgentId(configStorage.getAgentId());
message1.setMsgType(WxCpConsts.CUSTOM_MSG_TEXT);
message1.setMsgType(WxConsts.CUSTOM_MSG_TEXT);
message1.setToUser(configStorage.getUserId());
message1.setContent("欢迎欢迎,热烈欢迎\n换行测试\n超链接:<a href=\"http://www.baidu.com\">Hello World</a>");
wxService.messageSend(message1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@ public void prepare(boolean async, StringBuffer sb, WxCpMessageRouter router) {
router
.rule()
.async(async)
.msgType(WxCpConsts.XML_MSG_TEXT).event(WxCpConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1")
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1").content("CONTENT_1")
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_4"))
.end()
.rule()
.async(async)
.msgType(WxCpConsts.XML_MSG_TEXT).event(WxCpConsts.EVT_CLICK).eventKey("KEY_1")
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK).eventKey("KEY_1")
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_3"))
.end()
.rule()
.async(async)
.msgType(WxCpConsts.XML_MSG_TEXT).event(WxCpConsts.EVT_CLICK)
.msgType(WxConsts.XML_MSG_TEXT).event(WxConsts.EVT_CLICK)
.handler(new WxEchoCpMessageHandler(sb, "COMBINE_2"))
.end()
.rule().async(async).msgType(WxCpConsts.XML_MSG_TEXT).handler(new WxEchoCpMessageHandler(sb, WxCpConsts.XML_MSG_TEXT)).end()
.rule().async(async).event(WxCpConsts.EVT_CLICK).handler(new WxEchoCpMessageHandler(sb, WxCpConsts.EVT_CLICK)).end()
.rule().async(async).msgType(WxConsts.XML_MSG_TEXT).handler(new WxEchoCpMessageHandler(sb, WxConsts.XML_MSG_TEXT)).end()
.rule().async(async).event(WxConsts.EVT_CLICK).handler(new WxEchoCpMessageHandler(sb, WxConsts.EVT_CLICK)).end()
.rule().async(async).eventKey("KEY_1").handler(new WxEchoCpMessageHandler(sb, "KEY_1")).end()
.rule().async(async).content("CONTENT_1").handler(new WxEchoCpMessageHandler(sb, "CONTENT_1")).end()
.rule().async(async).rContent(".*bc.*").handler(new WxEchoCpMessageHandler(sb, "abcd")).end()
Expand Down Expand Up @@ -91,10 +91,10 @@ public void run() {
@DataProvider(name="messages-1")
public Object[][] messages2() {
WxCpXmlMessage message1 = new WxCpXmlMessage();
message1.setMsgType(WxCpConsts.XML_MSG_TEXT);
message1.setMsgType(WxConsts.XML_MSG_TEXT);

WxCpXmlMessage message2 = new WxCpXmlMessage();
message2.setEvent(WxCpConsts.EVT_CLICK);
message2.setEvent(WxConsts.EVT_CLICK);

WxCpXmlMessage message3 = new WxCpXmlMessage();
message3.setEventKey("KEY_1");
Expand All @@ -109,23 +109,23 @@ public Object[][] messages2() {
message6.setContent("abcd");

WxCpXmlMessage c2 = new WxCpXmlMessage();
c2.setMsgType(WxCpConsts.XML_MSG_TEXT);
c2.setEvent(WxCpConsts.EVT_CLICK);
c2.setMsgType(WxConsts.XML_MSG_TEXT);
c2.setEvent(WxConsts.EVT_CLICK);

WxCpXmlMessage c3 = new WxCpXmlMessage();
c3.setMsgType(WxCpConsts.XML_MSG_TEXT);
c3.setEvent(WxCpConsts.EVT_CLICK);
c3.setMsgType(WxConsts.XML_MSG_TEXT);
c3.setEvent(WxConsts.EVT_CLICK);
c3.setEventKey("KEY_1");

WxCpXmlMessage c4 = new WxCpXmlMessage();
c4.setMsgType(WxCpConsts.XML_MSG_TEXT);
c4.setEvent(WxCpConsts.EVT_CLICK);
c4.setMsgType(WxConsts.XML_MSG_TEXT);
c4.setEvent(WxConsts.EVT_CLICK);
c4.setEventKey("KEY_1");
c4.setContent("CONTENT_1");

return new Object[][] {
new Object[] { message1, WxCpConsts.XML_MSG_TEXT + "," },
new Object[] { message2, WxCpConsts.EVT_CLICK + "," },
new Object[] { message1, WxConsts.XML_MSG_TEXT + "," },
new Object[] { message2, WxConsts.EVT_CLICK + "," },
new Object[] { message3, "KEY_1," },
new Object[] { message4, "CONTENT_1," },
new Object[] { message5, "ALL," },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public void testDeleteMenu() throws WxErrorException {
public Object[][] getMenu() throws JAXBException {
WxMenu menu = new WxMenu();
WxMenuButton button1 = new WxMenuButton();
button1.setType(WxCpConsts.BUTTON_CLICK);
button1.setType(WxConsts.BUTTON_CLICK);
button1.setName("今日歌曲");
button1.setKey("V1001_TODAY_MUSIC");

WxMenuButton button2 = new WxMenuButton();
button2.setType(WxCpConsts.BUTTON_CLICK);
button2.setType(WxConsts.BUTTON_CLICK);
button2.setName("歌手简介");
button2.setKey("V1001_TODAY_SINGER");

Expand All @@ -61,17 +61,17 @@ public Object[][] getMenu() throws JAXBException {
menu.getButtons().add(button3);

WxMenuButton button31 = new WxMenuButton();
button31.setType(WxCpConsts.BUTTON_VIEW);
button31.setType(WxConsts.BUTTON_VIEW);
button31.setName("搜索");
button31.setUrl("http://www.soso.com/");

WxMenuButton button32 = new WxMenuButton();
button32.setType(WxCpConsts.BUTTON_VIEW);
button32.setType(WxConsts.BUTTON_VIEW);
button32.setName("视频");
button32.setUrl("http://v.qq.com/");

WxMenuButton button33 = new WxMenuButton();
button33.setType(WxCpConsts.BUTTON_CLICK);
button33.setType(WxConsts.BUTTON_CLICK);
button33.setName("赞一下我们");
button33.setKey("V1001_GOOD");

Expand Down
Loading

0 comments on commit c23293f

Please sign in to comment.