|
| 1 | +package me.chanjar.weixin.mp.bean.message; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData; |
| 4 | +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; |
| 5 | +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; |
| 6 | +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; |
| 7 | +import com.thoughtworks.xstream.annotations.XStreamAlias; |
| 8 | +import com.thoughtworks.xstream.annotations.XStreamConverter; |
| 9 | +import com.thoughtworks.xstream.annotations.XStreamImplicit; |
| 10 | +import lombok.Data; |
| 11 | +import me.chanjar.weixin.common.util.xml.XStreamCDataConverter; |
| 12 | + |
| 13 | +import java.io.Serializable; |
| 14 | +import java.util.LinkedList; |
| 15 | +import java.util.List; |
| 16 | + |
| 17 | +/** |
| 18 | + * WxMpSubscribeMsgEvent class |
| 19 | + * 订阅通知事件推送,与小程序一致 |
| 20 | + * @author liuxy |
| 21 | + * created on 2022/12/30 |
| 22 | + */ |
| 23 | +public class WxMpSubscribeMsgEvent { |
| 24 | + /** |
| 25 | + * https://developers.weixin.qq.com/doc/offiaccount/Subscription_Messages/api.html |
| 26 | + * */ |
| 27 | + @Data |
| 28 | + @XStreamAlias("SubscribeMsgPopupEvent") |
| 29 | + @JacksonXmlRootElement(localName = "SubscribeMsgPopupEvent") |
| 30 | + public static class SubscribeMsgPopupEvent implements Serializable { |
| 31 | + private static final long serialVersionUID = 6329723189257161326L; |
| 32 | + @XStreamImplicit(itemFieldName = "List") |
| 33 | + @JacksonXmlElementWrapper(useWrapping = false) |
| 34 | + @JacksonXmlProperty(localName = "List") |
| 35 | + private List<PopupEvent> list = new LinkedList<>(); |
| 36 | + } |
| 37 | + |
| 38 | + @Data |
| 39 | + @XStreamAlias("SubscribeMsgChangeEvent") |
| 40 | + @JacksonXmlRootElement(localName = "SubscribeMsgChangeEvent") |
| 41 | + public static class SubscribeMsgChangeEvent implements Serializable { |
| 42 | + private static final long serialVersionUID = 7205686111539437751L; |
| 43 | + @XStreamImplicit(itemFieldName = "List") |
| 44 | + @JacksonXmlElementWrapper(useWrapping = false) |
| 45 | + @JacksonXmlProperty(localName = "List") |
| 46 | + private List<ChangeEvent> list = new LinkedList<>(); |
| 47 | + } |
| 48 | + |
| 49 | + @Data |
| 50 | + @XStreamAlias("SubscribeMsgSentEvent") |
| 51 | + @JacksonXmlRootElement(localName = "SubscribeMsgSentEvent") |
| 52 | + public static class SubscribeMsgSentEvent implements Serializable { |
| 53 | + private static final long serialVersionUID = 7305686111539437752L; |
| 54 | + @XStreamImplicit(itemFieldName = "List") |
| 55 | + @JacksonXmlElementWrapper(useWrapping = false) |
| 56 | + @JacksonXmlProperty(localName = "List") |
| 57 | + private List<SentEvent> list = new LinkedList<>(); |
| 58 | + } |
| 59 | + |
| 60 | + |
| 61 | + @Data |
| 62 | + public static class PopupEvent implements Serializable { |
| 63 | + private static final long serialVersionUID = 4934029303242387226L; |
| 64 | + /** |
| 65 | + * 模板id |
| 66 | + */ |
| 67 | + @XStreamAlias("TemplateId") |
| 68 | + @XStreamConverter(value = XStreamCDataConverter.class) |
| 69 | + @JacksonXmlProperty(localName = "TemplateId") |
| 70 | + @JacksonXmlCData |
| 71 | + private String templateId; |
| 72 | + /** |
| 73 | + * 订阅结果(accept接收;reject拒收) |
| 74 | + */ |
| 75 | + @XStreamAlias("SubscribeStatusString") |
| 76 | + @XStreamConverter(value = XStreamCDataConverter.class) |
| 77 | + @JacksonXmlProperty(localName = "SubscribeStatusString") |
| 78 | + @JacksonXmlCData |
| 79 | + private String subscribeStatusString; |
| 80 | + /** |
| 81 | + * 弹框场景,1代表弹窗来自 H5 页面, 2代表弹窗来自图文消息 |
| 82 | + */ |
| 83 | + @XStreamAlias("PopupScene") |
| 84 | + @JacksonXmlProperty(localName = "PopupScene") |
| 85 | + private String popupScene; |
| 86 | + } |
| 87 | + |
| 88 | + @Data |
| 89 | + public static class ChangeEvent implements Serializable { |
| 90 | + private static final long serialVersionUID = 3523634146232757624L; |
| 91 | + /** |
| 92 | + * 模板id |
| 93 | + */ |
| 94 | + @XStreamAlias("TemplateId") |
| 95 | + @XStreamConverter(value = XStreamCDataConverter.class) |
| 96 | + @JacksonXmlProperty(localName = "TemplateId") |
| 97 | + @JacksonXmlCData |
| 98 | + private String templateId; |
| 99 | + /** |
| 100 | + * 订阅结果(accept接收;reject拒收) |
| 101 | + */ |
| 102 | + @XStreamAlias("SubscribeStatusString") |
| 103 | + @XStreamConverter(value = XStreamCDataConverter.class) |
| 104 | + @JacksonXmlProperty(localName = "SubscribeStatusString") |
| 105 | + @JacksonXmlCData |
| 106 | + private String subscribeStatusString; |
| 107 | + } |
| 108 | + |
| 109 | + @Data |
| 110 | + public static class SentEvent implements Serializable { |
| 111 | + private static final long serialVersionUID = 1734478345463177940L; |
| 112 | + /** |
| 113 | + * 模板id |
| 114 | + */ |
| 115 | + @XStreamAlias("TemplateId") |
| 116 | + @XStreamConverter(value = XStreamCDataConverter.class) |
| 117 | + @JacksonXmlProperty(localName = "TemplateId") |
| 118 | + @JacksonXmlCData |
| 119 | + private String templateId; |
| 120 | + |
| 121 | + /** |
| 122 | + * 消息id |
| 123 | + */ |
| 124 | + @XStreamAlias("MsgID") |
| 125 | + @JacksonXmlProperty(localName = "MsgID") |
| 126 | + private String msgId; |
| 127 | + |
| 128 | + /** |
| 129 | + * 推送结果状态码(0表示成功) |
| 130 | + */ |
| 131 | + @XStreamAlias("ErrorCode") |
| 132 | + @JacksonXmlProperty(localName = "ErrorCode") |
| 133 | + private String errorCode; |
| 134 | + |
| 135 | + /** |
| 136 | + * 推送结果状态码文字含义 |
| 137 | + */ |
| 138 | + @XStreamAlias("ErrorStatus") |
| 139 | + @XStreamConverter(value = XStreamCDataConverter.class) |
| 140 | + @JacksonXmlProperty(localName = "ErrorStatus") |
| 141 | + @JacksonXmlCData |
| 142 | + private String errorStatus; |
| 143 | + } |
| 144 | +} |
0 commit comments