WxCustomMessage.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package me.chanjar.weixin.enterprise.bean;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import me.chanjar.weixin.enterprise.api.WxConsts;
  5. import me.chanjar.weixin.enterprise.bean.custombuilder.ImageBuilder;
  6. import me.chanjar.weixin.enterprise.bean.custombuilder.MusicBuilder;
  7. import me.chanjar.weixin.enterprise.bean.custombuilder.NewsBuilder;
  8. import me.chanjar.weixin.enterprise.bean.custombuilder.TextBuilder;
  9. import me.chanjar.weixin.enterprise.bean.custombuilder.VideoBuilder;
  10. import me.chanjar.weixin.enterprise.bean.custombuilder.VoiceBuilder;
  11. import me.chanjar.weixin.enterprise.util.json.WxGsonBuilder;
  12. /**
  13. * 客服消息
  14. * @author Daniel Qian
  15. *
  16. */
  17. public class WxCustomMessage {
  18. private String toUser;
  19. private String msgType;
  20. private String content;
  21. private String mediaId;
  22. private String thumbMediaId;
  23. private String title;
  24. private String description;
  25. private String musicUrl;
  26. private String hqMusicUrl;
  27. private List<WxArticle> articles = new ArrayList<WxArticle>();
  28. public String getToUser() {
  29. return toUser;
  30. }
  31. public void setToUser(String toUser) {
  32. this.toUser = toUser;
  33. }
  34. public String getMsgType() {
  35. return msgType;
  36. }
  37. /**
  38. * <pre>
  39. * 请使用
  40. * {@link WxConsts#CUSTOM_MSG_TEXT}
  41. * {@link WxConsts#CUSTOM_MSG_IMAGE}
  42. * {@link WxConsts#CUSTOM_MSG_VOICE}
  43. * {@link WxConsts#CUSTOM_MSG_MUSIC}
  44. * {@link WxConsts#CUSTOM_MSG_VIDEO}
  45. * {@link WxConsts#CUSTOM_MSG_NEWS}
  46. * </pre>
  47. * @param msgType
  48. */
  49. public void setMsgType(String msgType) {
  50. this.msgType = msgType;
  51. }
  52. public String getContent() {
  53. return content;
  54. }
  55. public void setContent(String content) {
  56. this.content = content;
  57. }
  58. public String getMediaId() {
  59. return mediaId;
  60. }
  61. public void setMediaId(String mediaId) {
  62. this.mediaId = mediaId;
  63. }
  64. public String getThumbMediaId() {
  65. return thumbMediaId;
  66. }
  67. public void setThumbMediaId(String thumbMediaId) {
  68. this.thumbMediaId = thumbMediaId;
  69. }
  70. public String getTitle() {
  71. return title;
  72. }
  73. public void setTitle(String title) {
  74. this.title = title;
  75. }
  76. public String getDescription() {
  77. return description;
  78. }
  79. public void setDescription(String description) {
  80. this.description = description;
  81. }
  82. public String getMusicUrl() {
  83. return musicUrl;
  84. }
  85. public void setMusicUrl(String musicUrl) {
  86. this.musicUrl = musicUrl;
  87. }
  88. public String getHqMusicUrl() {
  89. return hqMusicUrl;
  90. }
  91. public void setHqMusicUrl(String hqMusicUrl) {
  92. this.hqMusicUrl = hqMusicUrl;
  93. }
  94. public List<WxArticle> getArticles() {
  95. return articles;
  96. }
  97. public void setArticles(List<WxArticle> articles) {
  98. this.articles = articles;
  99. }
  100. public String toJson() {
  101. return WxGsonBuilder.INSTANCE.create().toJson(this);
  102. }
  103. public static class WxArticle {
  104. private String title;
  105. private String description;
  106. private String url;
  107. private String picUrl;
  108. public String getTitle() {
  109. return title;
  110. }
  111. public void setTitle(String title) {
  112. this.title = title;
  113. }
  114. public String getDescription() {
  115. return description;
  116. }
  117. public void setDescription(String description) {
  118. this.description = description;
  119. }
  120. public String getUrl() {
  121. return url;
  122. }
  123. public void setUrl(String url) {
  124. this.url = url;
  125. }
  126. public String getPicUrl() {
  127. return picUrl;
  128. }
  129. public void setPicUrl(String picUrl) {
  130. this.picUrl = picUrl;
  131. }
  132. }
  133. /**
  134. * 获得文本消息builder
  135. * @return
  136. */
  137. public static TextBuilder TEXT() {
  138. return new TextBuilder();
  139. }
  140. /**
  141. * 获得图片消息builder
  142. * @return
  143. */
  144. public static ImageBuilder IMAGE() {
  145. return new ImageBuilder();
  146. }
  147. /**
  148. * 获得语音消息builder
  149. * @return
  150. */
  151. public static VoiceBuilder VOICE() {
  152. return new VoiceBuilder();
  153. }
  154. /**
  155. * 获得视频消息builder
  156. * @return
  157. */
  158. public static VideoBuilder VIDEO() {
  159. return new VideoBuilder();
  160. }
  161. /**
  162. * 获得音乐消息builder
  163. * @return
  164. */
  165. public static MusicBuilder MUSIC() {
  166. return new MusicBuilder();
  167. }
  168. /**
  169. * 获得图文消息builder
  170. * @return
  171. */
  172. public static NewsBuilder NEWS() {
  173. return new NewsBuilder();
  174. }
  175. }