* 新增跳转型会员卡,用户提交资料的信息参数解析 * 修复通讯录变更事件ExtAttr解析报错,并补充Address属性master
| @@ -8,6 +8,7 @@ import java.util.ArrayList; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| import com.thoughtworks.xstream.annotations.XStreamImplicit; | |||||
| import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
| import com.thoughtworks.xstream.annotations.XStreamAlias; | import com.thoughtworks.xstream.annotations.XStreamAlias; | ||||
| @@ -247,6 +248,13 @@ public class WxCpXmlMessage implements Serializable { | |||||
| @XStreamConverter(value = XStreamCDataConverter.class) | @XStreamConverter(value = XStreamCDataConverter.class) | ||||
| private String telephone; | private String telephone; | ||||
| /** | |||||
| * 地址. | |||||
| */ | |||||
| @XStreamAlias("Address") | |||||
| @XStreamConverter(value = XStreamCDataConverter.class) | |||||
| private String address; | |||||
| /** | /** | ||||
| * 扩展属性. | * 扩展属性. | ||||
| */ | */ | ||||
| @@ -327,17 +335,20 @@ public class WxCpXmlMessage implements Serializable { | |||||
| */ | */ | ||||
| @XStreamAlias("TotalCount") | @XStreamAlias("TotalCount") | ||||
| private Integer totalCount; | private Integer totalCount; | ||||
| /** | /** | ||||
| * 过滤. | * 过滤. | ||||
| * (过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,filterCount = sentCount + errorCount | * (过滤是指特定地区、性别的过滤、用户设置拒收的过滤,用户接收已超4条的过滤)后,准备发送的粉丝数,原则上,filterCount = sentCount + errorCount | ||||
| */ | */ | ||||
| @XStreamAlias("FilterCount") | @XStreamAlias("FilterCount") | ||||
| private Integer filterCount; | private Integer filterCount; | ||||
| /** | /** | ||||
| * 发送成功的粉丝数. | * 发送成功的粉丝数. | ||||
| */ | */ | ||||
| @XStreamAlias("SentCount") | @XStreamAlias("SentCount") | ||||
| private Integer sentCount; | private Integer sentCount; | ||||
| /** | /** | ||||
| * 发送失败的粉丝数. | * 发送失败的粉丝数. | ||||
| */ | */ | ||||
| @@ -411,9 +422,11 @@ public class WxCpXmlMessage implements Serializable { | |||||
| @Data | @Data | ||||
| public static class ExtAttr { | public static class ExtAttr { | ||||
| @XStreamAlias("Item") | |||||
| @XStreamImplicit(itemFieldName = "Item") | |||||
| protected final List<Item> items = new ArrayList<>(); | protected final List<Item> items = new ArrayList<>(); | ||||
| @XStreamAlias("Item") | |||||
| @Data | @Data | ||||
| public static class Item { | public static class Item { | ||||
| @XStreamAlias("Name") | @XStreamAlias("Name") | ||||
| @@ -117,4 +117,36 @@ public class WxCpXmlMessageTest { | |||||
| assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "aef52ae501537e552725c5d7f99c1741"); | assertEquals(wxMessage.getSendPicsInfo().getPicList().get(0).getPicMd5Sum(), "aef52ae501537e552725c5d7f99c1741"); | ||||
| assertEquals(wxMessage.getSendPicsInfo().getPicList().get(1).getPicMd5Sum(), "c4564632a4fab91378c39bea6aad6f9e"); | assertEquals(wxMessage.getSendPicsInfo().getPicList().get(1).getPicMd5Sum(), "c4564632a4fab91378c39bea6aad6f9e"); | ||||
| } | } | ||||
| public void testExtAttr() { | |||||
| String xml = "<xml>" + | |||||
| " <ToUserName><![CDATA[w56c9fe3d50ad1ea2]]></ToUserName>" + | |||||
| " <FromUserName><![CDATA[sys]]></FromUserName>" + | |||||
| " <CreateTime>1557241961</CreateTime>" + | |||||
| " <MsgType><![CDATA[event]]></MsgType>" + | |||||
| " <Event><![CDATA[change_contact]]></Event>" + | |||||
| " <ChangeType><![CDATA[update_user]]></ChangeType>" + | |||||
| " <UserID><![CDATA[zhangsan]]></UserID>" + | |||||
| " <ExtAttr>" + | |||||
| " <Item><Name><![CDATA[爱好]]></Name><Value><![CDATA[111]]></Value><Text><Value><![CDATA[111]]></Value></Text></Item>" + | |||||
| " <Item><Name><![CDATA[入职时间]]></Name><Value><![CDATA[11111]]></Value><Text><Value><![CDATA[11111]]></Value></Text></Item>" + | |||||
| " <Item><Name><![CDATA[城市]]></Name><Value><![CDATA[11111]]></Value><Text><Value><![CDATA[11111]]></Value></Text></Item>" + | |||||
| " </ExtAttr>" + | |||||
| " <Address><![CDATA[11111]]></Address>" + | |||||
| "</xml>"; | |||||
| WxCpXmlMessage wxMessage = WxCpXmlMessage.fromXml(xml); | |||||
| assertEquals(wxMessage.getToUserName(), "w56c9fe3d50ad1ea2"); | |||||
| assertEquals(wxMessage.getFromUserName(), "sys"); | |||||
| assertEquals(wxMessage.getCreateTime(), new Long(1557241961)); | |||||
| assertEquals(wxMessage.getMsgType(), WxConsts.XmlMsgType.EVENT); | |||||
| assertEquals(wxMessage.getEvent(), "change_contact"); | |||||
| assertEquals(wxMessage.getChangeType(), "update_user"); | |||||
| assertEquals(wxMessage.getUserId(), "zhangsan"); | |||||
| assertNotNull(wxMessage.getExtAttrs()); | |||||
| assertNotNull(wxMessage.getExtAttrs().getItems()); | |||||
| assertEquals(wxMessage.getExtAttrs().getItems().size(), 3); | |||||
| assertEquals(wxMessage.getExtAttrs().getItems().get(0).getName(), "爱好"); | |||||
| } | |||||
| } | } | ||||