WeixinMessage.java 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package com.example.getweather.util;
  2. import com.alibaba.fastjson.JSONObject;
  3. import lombok.Data;
  4. @Data
  5. public class WeixinMessage {
  6. private String toUser;
  7. private String msgType;
  8. private String content;
  9. private String markdown;
  10. private int agentid;
  11. public String getToUser() {
  12. return toUser;
  13. }
  14. public void setToUser(String toUser) {
  15. this.toUser = toUser;
  16. }
  17. public String getMsgType() {
  18. return msgType;
  19. }
  20. public void setMsgType(String msgType) {
  21. this.msgType = msgType;
  22. }
  23. public String getContent() {
  24. return content;
  25. }
  26. public void setContent(String content) {
  27. this.content = content;
  28. }
  29. public int getAgentid() {
  30. return agentid;
  31. }
  32. public void setAgentid(int agentid) {
  33. this.agentid = agentid;
  34. }
  35. public String toJson() {
  36. JSONObject jsonObject = new JSONObject();
  37. jsonObject.put("touser", toUser);
  38. jsonObject.put("msgtype", msgType);
  39. jsonObject.put("agentid", agentid);
  40. JSONObject textObject = new JSONObject();
  41. textObject.put("content", content);
  42. jsonObject.put("text", textObject);
  43. return jsonObject.toJSONString();
  44. }
  45. }