WxCpMessage.java 4.4 KB

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