1 package com.foxinmy.weixin4j.qy.chat;
2
3 import java.io.Serializable;
4 import java.util.Arrays;
5 import java.util.Date;
6 import java.util.List;
7
8 import javax.xml.bind.annotation.XmlElement;
9 import javax.xml.bind.annotation.XmlTransient;
10
11 import com.foxinmy.weixin4j.type.MessageType;
12
13
14
15
16
17
18
19
20
21
22 public class ChatItem implements Serializable {
23
24 private static final long serialVersionUID = -5921235260175596270L;
25
26 private final String LIST_SEPARATOR = "\\|";
27
28
29
30
31 @XmlElement(name = "FromUserName")
32 private String operatorId;
33
34
35
36 @XmlElement(name = "CreateTime")
37 private long createTime;
38
39
40
41
42 @XmlElement(name = "MsgType")
43 private String msgType;
44
45
46
47 @XmlElement(name = "Event")
48 private String eventType;
49
50
51
52 @XmlElement(name = "ChatId")
53 private String chatId;
54
55
56
57 @XmlElement(name = "Name")
58 private String chatName;
59
60
61
62 @XmlElement(name = "Owner")
63 private String ownerId;
64
65
66
67 @XmlElement(name = "UserList")
68 private String members;
69
70
71
72 @XmlElement(name = "AddUserList")
73 private String addMembers;
74
75
76
77 @XmlElement(name = "DelUserList")
78 private String deleteMembers;
79
80
81
82 @XmlElement(name = "MsgId")
83 private long msgId;
84
85
86
87 @XmlElement(name = "Receiver")
88 private ChatReceiver receiver;
89
90
91
92 @XmlElement(name = "Content")
93 private String content;
94
95
96
97 @XmlElement(name = "PicUrl")
98 private String picUrl;
99
100
101
102 @XmlElement(name = "Title")
103 private String title;
104
105
106
107 @XmlElement(name = "Description")
108 private String description;
109
110
111
112 @XmlElement(name = "Url")
113 private String url;
114
115
116
117 @XmlElement(name = "MediaId")
118 private String mediaId;
119
120 public String getOperatorId() {
121 return operatorId;
122 }
123
124 public long getCreateTime() {
125 return createTime;
126 }
127
128 @XmlTransient
129 public Date getFormatCreateTime() {
130 return createTime > 0l ? new Date(createTime * 1000l) : null;
131 }
132
133 public String getMsgType() {
134 return msgType;
135 }
136
137 @XmlTransient
138 public MessageType getFormatMsgType() {
139 return msgType != null ? MessageType.valueOf(msgType) : null;
140 }
141
142 public String getEventType() {
143 return eventType;
144 }
145
146 @XmlTransient
147 public ChatEventType getFormatEventType() {
148 return eventType != null ? ChatEventType.valueOf(eventType) : null;
149 }
150
151 public String getChatId() {
152 return chatId;
153 }
154
155 public String getChatName() {
156 return chatName;
157 }
158
159 public String getOwnerId() {
160 return ownerId;
161 }
162
163 public String getMembers() {
164 return members;
165 }
166
167 @XmlTransient
168 public List<String> getFormatMembers() {
169 return members != null ? Arrays.asList(members.split(LIST_SEPARATOR))
170 : null;
171 }
172
173 public String getAddMembers() {
174 return addMembers;
175 }
176
177 @XmlTransient
178 public List<String> getFormatAddMembers() {
179 return addMembers != null ? Arrays.asList(addMembers
180 .split(LIST_SEPARATOR)) : null;
181 }
182
183 public String getDeleteMembers() {
184 return deleteMembers;
185 }
186
187 @XmlTransient
188 public List<String> getFormatDeleteMembers() {
189 return deleteMembers != null ? Arrays.asList(deleteMembers
190 .split(LIST_SEPARATOR)) : null;
191 }
192
193 public long getMsgId() {
194 return msgId;
195 }
196
197 public ChatReceiver getReceiver() {
198 return receiver;
199 }
200
201 public String getContent() {
202 return content;
203 }
204
205 public String getPicUrl() {
206 return picUrl;
207 }
208
209 public String getMediaId() {
210 return mediaId;
211 }
212
213 public static long getSerialversionuid() {
214 return serialVersionUID;
215 }
216
217 public String getTitle() {
218 return title;
219 }
220
221 public String getDescription() {
222 return description;
223 }
224
225 public String getUrl() {
226 return url;
227 }
228
229 @Override
230 public String toString() {
231 return "ChatItem [operatorId=" + operatorId + ", createTime="
232 + createTime + ", msgType=" + msgType + ", eventType="
233 + eventType + ", chatId=" + chatId + ", chatName=" + chatName
234 + ", ownerId=" + ownerId + ", members=" + members
235 + ", addMembers=" + addMembers + ", deleteMembers="
236 + deleteMembers + ", msgId=" + msgId + ", receiver=" + receiver
237 + ", content=" + content + ", picUrl=" + picUrl + ", title="
238 + title + ", description=" + description + ", url=" + url
239 + ", mediaId=" + mediaId + "]";
240 }
241 }