1 package com.foxinmy.weixin4j.qy.model;
2
3 import java.io.Serializable;
4 import java.util.Arrays;
5 import java.util.List;
6
7 import com.alibaba.fastjson.annotation.JSONField;
8 import com.foxinmy.weixin4j.qy.type.UserStatus;
9 import com.foxinmy.weixin4j.type.Gender;
10 import com.foxinmy.weixin4j.util.NameValue;
11
12
13
14
15
16
17
18
19
20 public class User implements Serializable {
21
22 private static final long serialVersionUID = 4747301605060801611L;
23
24
25
26 @JSONField(name = "userid")
27 private String userId;
28
29
30
31 private String name;
32
33
34
35 @JSONField(name = "department")
36 private List<Integer> partyIds;
37
38
39
40 private List<Long> order;
41
42
43
44 private String position;
45
46
47
48 private String mobile;
49
50
51
52 private Integer gender;
53
54
55
56 private String email;
57
58
59
60 private String avatar;
61
62
63
64 private Integer status;
65
66
67
68 private List<NameValue> extattr;
69
70
71
72
73 @JSONField(name = "english_name")
74 private String englishName;
75
76
77
78 private String telephone;
79
80
81
82 @JSONField(name = "isleader")
83 private Boolean isLeader;
84
85
86
87 private Boolean enable;
88
89 protected User() {
90 }
91
92 public User(String userId, String name) {
93 this.userId = userId;
94 this.name = name;
95 }
96
97 public String getUserId() {
98 return userId;
99 }
100
101 public String getName() {
102 return name;
103 }
104
105 public List<Integer> getPartyIds() {
106 return partyIds;
107 }
108
109 public void setPartyIds(Integer... partyIds) {
110 this.partyIds = Arrays.asList(partyIds);
111 }
112
113 public String getPosition() {
114 return position;
115 }
116
117 public String getMobile() {
118 return mobile;
119 }
120
121 public Integer getGender() {
122 return gender;
123 }
124
125 @JSONField(serialize = false)
126 public Gender getFormatGender() {
127 if (gender != null) {
128 if (gender.intValue() == 0) {
129 return Gender.male;
130 } else if (gender.intValue() == 1) {
131 return Gender.female;
132 } else {
133 return Gender.unknown;
134 }
135 }
136 return null;
137 }
138
139 public String getEmail() {
140 return email;
141 }
142
143 public String getAvatar() {
144 return avatar;
145 }
146
147 @JSONField(serialize = false)
148 public UserStatus getFormatStatus() {
149 if (status != null) {
150 for (UserStatus userStatus : UserStatus.values()) {
151 if (userStatus.getVal() == status) {
152 return userStatus;
153 }
154 }
155 }
156 return null;
157 }
158
159 public Integer getStatus() {
160 return status;
161 }
162
163 @JSONField(serialize = false)
164 public Boolean getFormatEnable() {
165 if (status != null) {
166 return status.intValue() != 2;
167 }
168 return Boolean.FALSE;
169 }
170
171 public void setEnable(boolean enable) {
172 this.status = enable ? 1 : 0;
173 }
174
175 public List<NameValue> getExtattr() {
176 return extattr;
177 }
178
179 public void setExtattr(List<NameValue> extattr) {
180 this.extattr = extattr;
181 }
182
183 public void setExtattr(NameValue... extattr) {
184 this.extattr = Arrays.asList(extattr);
185 }
186
187 public void pushExattr(String name, String value) {
188 extattr.add(new NameValue(name, value));
189 }
190
191
192
193 public void setUserId(String userId) {
194 this.userId = userId;
195 }
196
197 public void setName(String name) {
198 this.name = name;
199 }
200
201 public void setPartyIds(List<Integer> partyIds) {
202 this.partyIds = partyIds;
203 }
204
205 public void setPosition(String position) {
206 this.position = position;
207 }
208
209 public void setMobile(String mobile) {
210 this.mobile = mobile;
211 }
212
213 public void setGender(Integer gender) {
214 this.gender = gender;
215 }
216
217 public void setEmail(String email) {
218 this.email = email;
219 }
220
221 public void setAvatar(String avatar) {
222 this.avatar = avatar;
223 }
224
225 public void setStatus(Integer status) {
226 this.status = status;
227 }
228
229 public String getEnglishName() {
230 return englishName;
231 }
232
233 public void setEnglishName(String englishName) {
234 this.englishName = englishName;
235 }
236
237 public String getTelephone() {
238 return telephone;
239 }
240
241 public void setTelephone(String telephone) {
242 this.telephone = telephone;
243 }
244
245 public Boolean getIsLeader() {
246 return isLeader;
247 }
248
249 public void setIsLeader(Boolean isLeader) {
250 this.isLeader = isLeader;
251 }
252
253 public Boolean getEnable() {
254 return enable;
255 }
256
257 public void setEnable(Boolean enable) {
258 this.enable = enable;
259 }
260
261 public List<Long> getOrder() {
262 return order;
263 }
264
265 public void setOrder(List<Long> order) {
266 this.order = order;
267 }
268
269 @Override
270 public int hashCode() {
271 final int prime = 31;
272 int result = 1;
273 result = prime * result + ((userId == null) ? 0 : userId.hashCode());
274 return result;
275 }
276
277 @Override
278 public boolean equals(Object obj) {
279 if (this == obj)
280 return true;
281 if (obj == null)
282 return false;
283 if (getClass() != obj.getClass())
284 return false;
285 User other = (User) obj;
286 if (userId == null) {
287 if (other.userId != null)
288 return false;
289 } else if (!userId.equals(other.userId))
290 return false;
291 return true;
292 }
293
294 @Override
295 public String toString() {
296 return "User [userId=" + userId + ", name=" + name + ", partyIds=" + partyIds + ", position=" + position
297 + ", mobile=" + mobile + ", gender=" + gender + ", email=" + email + ", avatar=" + avatar + ", status="
298 + status + ", extattr=" + extattr + ", englishName=" + englishName + ", telephone=" + telephone
299 + ", isLeader=" + isLeader + ", enable=" + enable + ", order=" + order + "]";
300 }
301 }