5 changed files with 173 additions and 4 deletions
@ -0,0 +1,84 @@ |
|||||
|
package com.ccsens.opensource.wxconfigurer.bean.vo; |
||||
|
|
||||
|
import com.ccsens.opensource.wxconfigurer.util.JacksonUtil; |
||||
|
import com.ccsens.opensource.wxconfigurer.util.WxGzhUtil; |
||||
|
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; |
||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; |
||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @description: 微信被动回复用户消息--图文消息 |
||||
|
* @author: whj |
||||
|
* @time: 2020/12/22 16:08 |
||||
|
*/ |
||||
|
|
||||
|
@Data |
||||
|
@JacksonXmlRootElement(localName = "xml") |
||||
|
public class WxReplyNewsVo extends WxReplyVo { |
||||
|
|
||||
|
/** |
||||
|
* 图文消息个数;当用户发送文本、图片、语音、视频、图文、地理位置这六种消息时,开发者只能回复1条图文消息;其余场景最多可回复8条图文消息 |
||||
|
*/ |
||||
|
@JacksonXmlProperty(localName = "ArticleCount") |
||||
|
private Integer articleCount; |
||||
|
@JacksonXmlProperty(localName = "item") |
||||
|
@JacksonXmlElementWrapper(localName="Articles") |
||||
|
private List<Item> articles = new ArrayList<>(); |
||||
|
/** |
||||
|
* 图文消息信息,注意,如果图文数超过限制,则将只发限制内的条数 |
||||
|
*/ |
||||
|
@Data |
||||
|
public static class Item { |
||||
|
/** |
||||
|
* 图文消息标题 |
||||
|
*/ |
||||
|
@JacksonXmlProperty(localName = "Title") |
||||
|
private String title; |
||||
|
/** |
||||
|
* 图文消息描述 |
||||
|
*/ |
||||
|
@JacksonXmlProperty(localName = "Description") |
||||
|
private String description; |
||||
|
/** |
||||
|
* 图片链接,支持JPG、PNG格式,较好的效果为大图360*200,小图200*200 |
||||
|
*/ |
||||
|
@JacksonXmlProperty(localName = "PicUrl") |
||||
|
private String picUrl; |
||||
|
/** |
||||
|
* 点击图文消息跳转链接 |
||||
|
*/ |
||||
|
@JacksonXmlProperty(localName = "Url") |
||||
|
private String url; |
||||
|
|
||||
|
public Item(String title, String description, String picUrl, String url) { |
||||
|
this.title = title; |
||||
|
this.description = description; |
||||
|
this.picUrl = picUrl; |
||||
|
this.url = url; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public WxReplyNewsVo(){ |
||||
|
this.msgType = "news"; |
||||
|
} |
||||
|
|
||||
|
public WxReplyNewsVo(String gzhId, String openId){ |
||||
|
this(); |
||||
|
this.gzhId = gzhId; |
||||
|
this.openId = openId; |
||||
|
} |
||||
|
|
||||
|
public static void main(String[] args) throws JsonProcessingException { |
||||
|
WxReplyNewsVo vo = new WxReplyNewsVo(); |
||||
|
vo.getArticles().add(WxGzhUtil.Reply.news.get("平车")); |
||||
|
System.out.println(JacksonUtil.beanToXml(vo)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.ccsens.opensource.wxconfigurer.bean.vo; |
||||
|
|
||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; |
||||
|
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @description: 微信被动回复用户消息 |
||||
|
* @author: whj |
||||
|
* @time: 2020/12/22 16:02 |
||||
|
*/ |
||||
|
@Data |
||||
|
@JacksonXmlRootElement(localName = "xml") |
||||
|
public class WxReplyVo { |
||||
|
|
||||
|
|
||||
|
@JacksonXmlProperty(localName = "FromUserName") |
||||
|
protected String gzhId; |
||||
|
@JacksonXmlProperty(localName = "ToUserName") |
||||
|
protected String openId; |
||||
|
@JacksonXmlProperty(localName = "CreateTime") |
||||
|
protected Long createTime = System.currentTimeMillis(); |
||||
|
@JacksonXmlProperty(localName = "MsgType") |
||||
|
protected String msgType; |
||||
|
|
||||
|
} |
Loading…
Reference in new issue